Skip to content

Comments

в Pairs тесте вылетает ошибка хз почему#3

Open
VynnykVV wants to merge 1 commit intoChangeRequest:masterfrom
VynnykVV:master
Open

в Pairs тесте вылетает ошибка хз почему#3
VynnykVV wants to merge 1 commit intoChangeRequest:masterfrom
VynnykVV:master

Conversation

@VynnykVV
Copy link

@VynnykVV VynnykVV commented Jan 3, 2017

java.lang.NoClassDefFoundError:

@xSAVIKx xSAVIKx self-assigned this Jan 4, 2017
Copy link
Member

@xSAVIKx xSAVIKx left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please, review comments below and fix all problems, I'm sure, that your problem with test will be fixed, if you'll implement everything as it should be.

* Created by User on 02.01.2017.
*/
public class Container <T> {
ArrayList<T> container= new ArrayList<T>();
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Use: List<T> container = new ArrayList<T>(); - in this way you'll use more generic type - List and if you'll need to change implementation to any other type, that implements List interface - it'll be easy for you. (It's common practice to use the most generic type you could.

*/
public class Container <T> {
ArrayList<T> container= new ArrayList<T>();
public Container (){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you don't make any initialization in default constructor - remove it from code - it'll be generated automatically.

ArrayList<T> container= new ArrayList<T>();
public Container (){
}
public int size(Container e){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Method size should return size of your underlying implementation (in your case size of variable container, but not some container that you receive).

if(e==null)throw new NullPointerException();
return container.size();
}
public void clear(Container e){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for clear as for size

/**
* Created by User on 02.01.2017.
*/
public class Container <T> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You must not use Collections API in your Container implementation. Reuse your implementation from OOP homework:

Create class container the same as for https://github.com/ChangeRequest/oop.hw1 but instead of Integer it should work with elements of any type.

/**
* Created by User on 03.01.2017.
*/
public class DoubleGeneratorTestUnit {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is no need to point that it's Unit test in class name, it should be just: DoubleGeneratorTest

/**
* Created by User on 03.01.2017.
*/
public class IntegerGeneratorTestUnit {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for class name

Assert.assertEquals(expected,result);
}
@org.junit.Test
public void testWhatTypeOfNumberGeneratesShouldBeInteger(){
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the better method name will be: shouldGenerateNumberOfIntegerType

/**
* Created by User on 03.01.2017.
*/
public class TestTest {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For sure it should be renamed.

/**
* Created by User on 03.01.2017.
*/
public class pairUtils {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Class names should start from Uppercase letter.
Also, all tests should end with Test suffix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants