use of io.swagger.models.properties.ArrayProperty in project swagger-core by swagger-api.
the class ModelImplTest method testAddProperty.
@Test
public void testAddProperty() {
// given
String badKey = "badKey";
String key = "key";
Property property = new ArrayProperty();
instance.property(key, property);
// when
instance.addProperty(badKey, null);
// then
assertNull(instance.getProperties().get(badKey), "The bad key must not be added to the properties");
// given
instance.setRequired(Arrays.asList(key));
// when
instance.addProperty(key, property);
assertEquals(instance.getProperties().get(key), property, "Must be able to retrieve the set value from the map");
}
use of io.swagger.models.properties.ArrayProperty in project swagger-core by swagger-api.
the class ModelImplTest method testSetRequired.
@Test
public void testSetRequired() {
// given
String required = "required";
Property property = new ArrayProperty();
instance.property(required, property);
// when
instance.setRequired(Arrays.asList(required));
// then
assertTrue(instance.getRequired().contains(required), "The set key must be contained in the required list");
}
use of io.swagger.models.properties.ArrayProperty in project swagger-core by swagger-api.
the class ModelImplTest method testProperty.
@Test
public void testProperty() {
// given
String key = "key";
Property property = new ArrayProperty();
// when
instance.property(key, property);
// then
assertEquals(instance.getProperties().get(key), property, "Must be able to retrieve the set value from the map");
assertTrue(instance.required(key).getRequired().contains(key), "The set key must be contained in the required list");
}
use of io.swagger.models.properties.ArrayProperty in project swagger-core by swagger-api.
the class ArrayPropertyTest method testSetNullUniqueItems.
@Test
public void testSetNullUniqueItems() {
final ArrayProperty prop = new ArrayProperty();
prop.setUniqueItems(null);
assertNull(prop.getUniqueItems());
}
use of io.swagger.models.properties.ArrayProperty 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");
}
Aggregations