use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class AuthSerializationTest method testHeaderKeyToJson.
@Test(description = "it should convert serialize a header key model")
public void testHeaderKeyToJson() throws IOException {
final ApiKeyAuthDefinition auth = new ApiKeyAuthDefinition().name("api-key").in(In.HEADER);
final String json = "{\"type\":\"apiKey\",\"name\":\"api-key\",\"in\":\"header\"}";
SerializationMatchers.assertEqualsToJson(auth, json);
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class AuthSerializationTest method testImplicitAuth.
@Test(description = "it should convert serialize an oauth2 implicit flow model")
public void testImplicitAuth() throws IOException {
final OAuth2Definition auth = new OAuth2Definition().implicit("http://foo.com/authorization");
final String json = "{\"type\":\"oauth2\",\"authorizationUrl\":\"http://foo.com/authorization\",\"flow\":\"implicit\"}";
SerializationMatchers.assertEqualsToJson(auth, json);
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ModelConverterTest method ignoreHiddenFields.
@Test(description = "it should ignore hidden fields")
public void ignoreHiddenFields() {
final Map<String, Model> schemas = readAll(ClientOptInput.class);
final Model model = schemas.get("ClientOptInput");
assertEquals(model.getProperties().size(), 2);
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ModelConverterTest method scanEmptyModel.
@Test(description = "it should scan an empty model per 499")
public void scanEmptyModel() {
final Map<String, Model> schemas = readAll(EmptyModel.class);
final ModelImpl model = (ModelImpl) schemas.get("EmptyModel");
assertNull(model.getProperties());
assertEquals(model.getType(), "object");
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ModelConverterTest method formatDate.
@Test
public void formatDate() {
final Map<String, Model> models = ModelConverters.getInstance().read(DateModel.class);
final Model model = models.get("DateModel");
assertEquals(model.getProperties().size(), 5);
final String json = "{" + " \"type\":\"object\"," + " \"properties\":{" + " \"date\":{" + " \"type\":\"string\"," + " \"format\":\"date-time\"," + " \"position\":1" + " }," + " \"intValue\":{" + " \"type\":\"integer\"," + " \"format\":\"int32\"," + " \"position\":2" + " }," + " \"longValue\":{" + " \"type\":\"integer\"," + " \"format\":\"int64\"," + " \"position\":3" + " }," + " \"floatValue\":{" + " \"type\":\"number\"," + " \"format\":\"float\"," + " \"position\":4" + " }," + " \"doubleValue\":{" + " \"type\":\"number\"," + " \"format\":\"double\"," + " \"position\":5" + " }" + " }" + "}";
SerializationMatchers.assertEqualsToJson(model, json);
}
Aggregations