use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class SimpleReaderTest method scanResourceWithApiOperationTags.
@Test(description = "scan a resource with tags in test 841")
public void scanResourceWithApiOperationTags() {
Swagger swagger = getSwagger(Resource841.class);
assertEquals(swagger.getTags().size(), 3);
List<String> rootTags = getGet(swagger, "/fun").getTags();
assertEquals(rootTags.size(), 2);
assertEquals(rootTags, Arrays.asList("tag1", "tag2"));
List<String> thisTags = getGet(swagger, "/fun/this").getTags();
assertEquals(thisTags.size(), 1);
assertEquals(thisTags, Arrays.asList("tag1"));
List<String> thatTags = getGet(swagger, "/fun/that").getTags();
assertEquals(thatTags.size(), 1);
assertEquals(thatTags, Arrays.asList("tag2"));
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class SwaggerContextServiceTest method initializeAndGetConfigWithoutServletConfig.
@Test(description = "should add SwaggerConfig to SwaggerConfigLocator map with key CONFIG_ID_DEFAULT")
public void initializeAndGetConfigWithoutServletConfig() {
new SwaggerContextService().initConfig();
new SwaggerContextService().initConfig();
verify(servletConfig1, never()).getInitParameter(eq(CONFIG_ID_KEY));
verify(servletConfig2, never()).getInitParameter(eq(CONFIG_ID_KEY));
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class SwaggerScannerLocatorTest method putConfigSecondTime.
@Test(description = "shouldn't add given scanner to map because already set")
public void putConfigSecondTime() {
putScannerFirstTime();
Scanner scanner = new Scanner() {
@Override
public Set<Class<?>> classes() {
return null;
}
@Override
public boolean getPrettyPrint() {
return false;
}
@Override
public void setPrettyPrint(boolean shouldPrettyPrint) {
}
};
SwaggerScannerLocator.getInstance().putScanner(id, scanner);
assertNotEquals(SwaggerScannerLocator.getInstance().getScanner(id), scanner);
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class SwaggerScannerLocatorTest method putScannerFirstTime.
@Test(description = "should add given scanner to map ")
public void putScannerFirstTime() {
Scanner scanner = new Scanner() {
@Override
public Set<Class<?>> classes() {
return null;
}
@Override
public boolean getPrettyPrint() {
return false;
}
@Override
public void setPrettyPrint(boolean shouldPrettyPrint) {
}
};
SwaggerScannerLocator.getInstance().putScanner(id, scanner);
assertEquals(SwaggerScannerLocator.getInstance().getScanner(id), scanner);
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class SimpleReaderTest method scanClassWithImplicitExampleQuery.
@Test(description = "scan a resource with implicit operation query example")
public void scanClassWithImplicitExampleQuery() {
Swagger swagger = getSwagger(ClassWithExamplePost.class);
Parameter param = swagger.getPaths().get("/external/info2").getGet().getParameters().get(0);
QueryParameter bp = (QueryParameter) param;
assertNotNull(bp.getExample());
Object value = bp.getExample();
assertEquals("77", value);
}
Aggregations