Search in sources :

Example 11 with TestObject

use of org.springframework.tests.sample.objects.TestObject in project spring-framework by spring-projects.

the class AutoPopulatingListTests method doTestWithClass.

private void doTestWithClass(AutoPopulatingList<Object> list) {
    Object lastElement = null;
    for (int x = 0; x < 10; x++) {
        Object element = list.get(x);
        assertThat(list.get(x)).as("Element is null").isNotNull();
        boolean condition = element instanceof TestObject;
        assertThat(condition).as("Element is incorrect type").isTrue();
        assertThat(element).isNotSameAs(lastElement);
        lastElement = element;
    }
    String helloWorld = "Hello World!";
    list.add(10, null);
    list.add(11, helloWorld);
    assertThat(list.get(11)).isEqualTo(helloWorld);
    boolean condition3 = list.get(10) instanceof TestObject;
    assertThat(condition3).isTrue();
    boolean condition2 = list.get(12) instanceof TestObject;
    assertThat(condition2).isTrue();
    boolean condition1 = list.get(13) instanceof TestObject;
    assertThat(condition1).isTrue();
    boolean condition = list.get(20) instanceof TestObject;
    assertThat(condition).isTrue();
}
Also used : TestObject(org.springframework.tests.sample.objects.TestObject) TestObject(org.springframework.tests.sample.objects.TestObject)

Aggregations

TestObject (org.springframework.tests.sample.objects.TestObject)11 Test (org.junit.jupiter.api.Test)9 Method (java.lang.reflect.Method)1