Search in sources :

Example 1 with TestObject

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

the class ConventionsTests method set.

@Test
void set() {
    assertThat(Conventions.getVariableName(Collections.singleton(new TestObject()))).as("Incorrect plural Set form").isEqualTo("testObjectList");
    assertThat(Conventions.getVariableNameForParameter(getMethodParameter(Set.class))).as("Incorrect plural Set form").isEqualTo("testObjectList");
    assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(Set.class))).as("Incorrect plural Set form").isEqualTo("testObjectList");
}
Also used : TestObject(org.springframework.tests.sample.objects.TestObject) Test(org.junit.jupiter.api.Test)

Example 2 with TestObject

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

the class ConventionsTests method list.

@Test
void list() {
    assertThat(Conventions.getVariableName(Collections.singletonList(new TestObject()))).as("Incorrect plural List form").isEqualTo("testObjectList");
    assertThat(Conventions.getVariableNameForParameter(getMethodParameter(List.class))).as("Incorrect plural List form").isEqualTo("testObjectList");
    assertThat(Conventions.getVariableNameForReturnType(getMethodForReturnType(List.class))).as("Incorrect plural List form").isEqualTo("testObjectList");
}
Also used : TestObject(org.springframework.tests.sample.objects.TestObject) Test(org.junit.jupiter.api.Test)

Example 3 with TestObject

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

the class ConventionsTests method array.

@Test
void array() {
    Object actual = Conventions.getVariableName(new TestObject[0]);
    assertThat(actual).as("Incorrect plural array form").isEqualTo("testObjectList");
}
Also used : TestObject(org.springframework.tests.sample.objects.TestObject) Test(org.junit.jupiter.api.Test)

Example 4 with TestObject

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

the class ReflectionUtilsTests method copySrcToDestinationOfIncorrectClass.

@Test
void copySrcToDestinationOfIncorrectClass() {
    TestObject src = new TestObject();
    String dest = new String();
    assertThatIllegalArgumentException().isThrownBy(() -> ReflectionUtils.shallowCopyFieldState(src, dest));
}
Also used : TestObject(org.springframework.tests.sample.objects.TestObject) Test(org.junit.jupiter.api.Test)

Example 5 with TestObject

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

the class ReflectionUtilsTests method validCopyToSubType.

@Test
void validCopyToSubType() {
    TestObject src = new TestObject();
    TestObjectSubclassWithNewField dest = new TestObjectSubclassWithNewField();
    dest.magic = 11;
    testValidCopy(src, dest);
    // Should have left this one alone
    assertThat(dest.magic).isEqualTo(11);
}
Also used : TestObject(org.springframework.tests.sample.objects.TestObject) Test(org.junit.jupiter.api.Test)

Aggregations

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