use of io.swagger.models.apideclaration.ModelProperty in project swagger-parser by swagger-api.
the class ModelPropertyConverterTest method convertStringModelPropertyWithEnum.
@Test
public void convertStringModelPropertyWithEnum() throws Exception {
ModelProperty property = new ModelProperty();
property.setType("string");
property.setDescription("a simple string");
List<String> enumValues = new ArrayList<String>();
enumValues.add("cat");
enumValues.add("dog");
property.setEnumValues(enumValues);
Property converted = converter.convertProperty(property);
assertEquals(converted.getClass(), StringProperty.class);
assertEquals(converted.getType(), "string");
assertEquals(converted.getDescription(), property.getDescription());
StringProperty prop = (StringProperty) converted;
assertNotNull(prop.getEnum());
assertTrue(prop.getEnum().size() == 2);
}
use of io.swagger.models.apideclaration.ModelProperty in project swagger-parser by swagger-api.
the class ModelPropertyConverterTest method convertLongModelProperty.
@Test
public void convertLongModelProperty() throws Exception {
ModelProperty property = new ModelProperty();
property.setType("integer");
property.setFormat(Format.INT64);
property.setDescription("a simple int64 property");
property.setMinimum("1");
property.setMaximum("4");
Property converted = converter.convertProperty(property);
assertEquals(converted.getClass(), LongProperty.class);
assertEquals(converted.getType(), "integer");
assertEquals(converted.getFormat(), "int64");
LongProperty prop = (LongProperty) converted;
assertEquals(prop.getMinimum(), new BigDecimal("1"));
assertEquals(prop.getMaximum(), new BigDecimal("4"));
}
use of io.swagger.models.apideclaration.ModelProperty in project swagger-parser by swagger-api.
the class ModelPropertyConverterTest method convertFloatModelProperty.
@Test
public void convertFloatModelProperty() throws Exception {
ModelProperty property = new ModelProperty();
property.setType("number");
property.setFormat(Format.FLOAT);
property.setDescription("a simple float property");
property.setMinimum("1.23");
property.setMaximum("4.56");
Property converted = converter.convertProperty(property);
assertEquals(converted.getClass(), FloatProperty.class);
assertEquals(converted.getType(), "number");
assertEquals(converted.getFormat(), "float");
FloatProperty prop = (FloatProperty) converted;
assertEquals(prop.getMinimum(), new BigDecimal("1.23"));
assertEquals(prop.getMaximum(), new BigDecimal("4.56"));
}
use of io.swagger.models.apideclaration.ModelProperty in project swagger-parser by swagger-api.
the class ModelPropertyConverterTest method convertDoubleModelProperty.
@Test
public void convertDoubleModelProperty() throws Exception {
ModelProperty property = new ModelProperty();
property.setType("number");
property.setFormat(Format.DOUBLE);
property.setDescription("a simple double property");
property.setMinimum("1.23");
property.setMaximum("4.56");
Property converted = converter.convertProperty(property);
assertEquals(converted.getClass(), DoubleProperty.class);
assertEquals(converted.getType(), "number");
assertEquals(converted.getFormat(), "double");
DoubleProperty prop = (DoubleProperty) converted;
assertEquals(prop.getMinimum(), new BigDecimal("1.23"));
assertEquals(prop.getMaximum(), new BigDecimal("4.56"));
}
Aggregations