use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ModelConverterTest method maintainPropertyNames.
@Test(description = "it should maintain property names")
public void maintainPropertyNames() {
final Map<String, Model> schemas = readAll(ModelPropertyName.class);
assertEquals(schemas.size(), 1);
final String modelName = schemas.keySet().iterator().next();
assertEquals(modelName, "ModelPropertyName");
final Model model = schemas.get(modelName);
final Iterator<String> itr = new TreeSet(model.getProperties().keySet()).iterator();
assertEquals(itr.next(), "gettersAndHaters");
assertEquals(itr.next(), "is_persistent");
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ModelConverterTest method checkStringTypesHandling.
@Test(description = "it should check handling of string types")
public void checkStringTypesHandling() {
for (Class<?> cls : Arrays.asList(URI.class, URL.class, UUID.class)) {
final Map<String, Model> schemas = readAll(cls);
assertEquals(schemas.size(), 0);
final Property property = ModelConverters.getInstance().readAsProperty(cls);
assertNotNull(property);
assertEquals(property.getType(), "string");
}
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ModelConverterTest method checkHandlingClassType.
@Test(description = "it should check handling of the Class<?> type")
public void checkHandlingClassType() throws Exception {
final Type type = getGenericType(null);
assertFalse(type instanceof Class<?>);
final Map<String, Model> schemas = readAll(type);
assertEquals(schemas.size(), 0);
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ModelConverterTest method serializeParameterizedType.
@Test(description = "it should serialize a parameterized type per 606")
public void serializeParameterizedType() {
final Map<String, Model> schemas = readAll(Employee.class);
final ModelImpl employee = (ModelImpl) schemas.get("employee");
final Map<String, Property> props = employee.getProperties();
final Iterator<String> et = props.keySet().iterator();
final Property id = props.get(et.next());
assertTrue(id instanceof IntegerProperty);
final Property firstName = props.get(et.next());
assertTrue(firstName instanceof StringProperty);
final Property lastName = props.get(et.next());
assertTrue(lastName instanceof StringProperty);
final Property department = props.get(et.next());
assertTrue(department instanceof RefProperty);
final Property manager = props.get(et.next());
assertTrue(manager instanceof RefProperty);
final Property team = props.get(et.next());
assertTrue(team instanceof ArrayProperty);
final ArrayProperty ap = (ArrayProperty) team;
assertTrue(ap.getUniqueItems());
assertNotNull(employee.getXml());
assertEquals(employee.getXml().getName(), "employee");
}
use of org.testng.annotations.Test in project swagger-core by swagger-api.
the class ModelExampleTest method createModel.
@Test(description = "it should create a model")
public void createModel() {
ModelImpl model = new ModelImpl().property("name", new StringProperty().example("Tony")).property("id", new LongProperty().example(123L));
assertNotNull(model);
}
Aggregations