use of com.github.victools.jsonschema.generator.FieldScope in project jsonschema-generator by victools.
the class SwaggerModuleTest method testDescriptionResolver.
@Test
@Parameters
public void testDescriptionResolver(String fieldName, boolean asContainerItem, String expectedMemberDescription, String expectedTypeDescription) {
new SwaggerModule().applyToConfigBuilder(this.configBuilder);
TestType testType = new TestType(TestClassForDescription.class);
FieldScope field = testType.getMemberField(fieldName);
if (asContainerItem) {
field = field.asFakeContainerItemScope();
}
ArgumentCaptor<ConfigFunction<FieldScope, String>> memberCaptor = ArgumentCaptor.forClass(ConfigFunction.class);
Mockito.verify(this.fieldConfigPart).withDescriptionResolver(memberCaptor.capture());
String memberDescription = memberCaptor.getValue().apply(field);
Assert.assertEquals(expectedMemberDescription, memberDescription);
ArgumentCaptor<ConfigFunction<TypeScope, String>> typeCaptor = ArgumentCaptor.forClass(ConfigFunction.class);
Mockito.verify(this.typesInGeneralConfigPart).withDescriptionResolver(typeCaptor.capture());
TypeScope scope = Mockito.mock(TypeScope.class);
Mockito.when(scope.getType()).thenReturn(field.getType());
String typeDescription = typeCaptor.getValue().apply(scope);
Assert.assertEquals(expectedTypeDescription, typeDescription);
}
Aggregations