Search in sources :

Example 1 with ToStringStyle

use of org.apache.commons.lang3.builder.ToStringStyle in project cloudstack by apache.

the class ReflectionToStringBuilderUtilsTest method validateReflectOnlySelectedFieldsObjectIsNotACollectionMustReflectObject.

@Test
public void validateReflectOnlySelectedFieldsObjectIsNotACollectionMustReflectObject() throws Exception {
    String expectedResult = "test";
    PowerMockito.spy(ReflectionToStringBuilderUtils.class);
    PowerMockito.when(ReflectionToStringBuilderUtils.getNonSelectedFields(Mockito.any(), Mockito.any())).thenReturn(classToReflectFieldsNamesArray);
    PowerMockito.when(ReflectionToStringBuilderUtils.reflectCollection(Mockito.any(), Mockito.any(), Mockito.anyString(), Mockito.any())).thenReturn(null);
    for (ToStringStyle style : TO_STRING_STYLES) {
        PowerMockito.doReturn(expectedResult).when(ReflectionToStringBuilderUtils.class, "getReflectedObject", Mockito.any(), Mockito.any(), Mockito.any());
        String result = ReflectionToStringBuilderUtils.reflectOnlySelectedFields(expectedResult, style, "-", classToReflectFieldsNamesArray);
        Assert.assertEquals(expectedResult, result);
    }
}
Also used : ToStringStyle(org.apache.commons.lang3.builder.ToStringStyle) Test(org.junit.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Aggregations

ToStringStyle (org.apache.commons.lang3.builder.ToStringStyle)1 Test (org.junit.Test)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1