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);
}
}
Aggregations