Can Anyone help me to write unit test cases for this method?
@Override
public Property resolveProperty(Type type, ModelConverterContext context, Annotation[] annotations, Iterator<ModelConverter> chain) {
final JavaType jType = Json.mapper().constructType(type);
if (jType != null) {
final Class<?> cls = jType.getRawClass();
if (Date.class.isAssignableFrom(cls)) {
//DateTimeProperty property =
// (DateTimeProperty) chain.next().resolveProperty(type, context, annotations, chain);
return new LongProperty();
}
}
return chain.hasNext() ?
chain.next().resolveProperty(type, context, annotations, chain)
: null;
}
I have tried like this but its not working, dont know what i am missing
@Test
public void testResolveProperty() {
Type type1 = SwaggerDateTimeConverter.class;
type1=Mockito.mock(Type.class);
javaType = Mockito.mock(JavaType.class);
//javaType = Json.mapper().constructType(type1);
Class<?> cls = javaType.getRawClass();
// cls=Mockito.mock(Class.class);
Mockito.when(json.mapper().constructType(type1)).thenReturn(javaType);
assertNotNull(javaType);
assertSame(JavaType.class,javaType.getRawClass());
assertTrue(Date.class.isAssignableFrom(cls));
assertSame(longProperty,swaggerDateTimeConverter.resolveProperty(type1,context, type1.getAnnotations(), chain));
}