use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ReaderTest method scanBeanValidation.
@Test(description = "it should scan parameters with Swagger and JSR-303 bean validation annotations")
public void scanBeanValidation() {
Swagger swagger = getSwagger(ResourceWithValidation.class);
assertNotNull(swagger);
QueryParameter par = (QueryParameter) swagger.getPaths().get("/303").getOperations().get(0).getParameters().get(0);
assertTrue(par.getRequired());
assertEquals(par.getMinimum(), new BigDecimal(10));
par = (QueryParameter) swagger.getPaths().get("/swagger-and-303").getOperations().get(0).getParameters().get(0);
assertTrue(par.getRequired());
assertEquals(par.getMinimum(), new BigDecimal(7));
par = (QueryParameter) swagger.getPaths().get("/swagger").getOperations().get(0).getParameters().get(0);
assertTrue(par.getRequired());
assertEquals(par.getMinimum(), new BigDecimal(7));
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ResourceTest1343 method scanResource1343.
@Test(description = "scan resource 1343")
public void scanResource1343() {
Swagger swagger = getSwagger(Resource1343.class);
assertNotNull(swagger);
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ResourceWithSchemeTest method scanResourceWithSubresources.
@Test(description = "scan another resource with subresources")
public void scanResourceWithSubresources() {
Swagger swagger = getSwagger(ResourceWithScheme.class);
assertEquals(loadSchemes(swagger, "/test/status"), Arrays.asList(Scheme.HTTPS));
assertEquals(loadSchemes(swagger, "/test/value"), Arrays.asList(Scheme.WS, Scheme.WSS));
assertEquals(loadSchemes(swagger, "/test/notes"), Arrays.asList(Scheme.HTTP));
assertEquals(loadSchemes(swagger, "/test/description"), Arrays.asList(Scheme.HTTP));
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class SimpleReaderTest method scanClassWithExamplePostClass.
@Test(description = "scan a resource with operation post example (dataTypeClass)")
public void scanClassWithExamplePostClass() {
Swagger swagger = getSwagger(ClassWithExamplePostClass.class);
Parameter param = swagger.getPaths().get("/external/info").getPost().getParameters().get(0);
BodyParameter bp = (BodyParameter) param;
assertNotNull(bp.getExamples());
assertTrue(bp.getExamples().size() == 1);
String value = bp.getExamples().get("application/json");
assertEquals("[\"a\",\"b\"]", value);
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class SimpleReaderTest method scanResourceWithMapReturnType.
@Test(description = "scan a resource with map return type")
public void scanResourceWithMapReturnType() {
Swagger swagger = getSwagger(ResourceWithMapReturnValue.class);
Operation get = getGet(swagger, "/{id}");
assertNotNull(get);
assertNotNull(get.getResponses());
Response response = get.getResponses().get("200");
assertNotNull(response);
Property schema = response.getSchema();
assertEquals(schema.getClass(), MapProperty.class);
}
Aggregations