use of io.swagger.models.properties.DoubleProperty in project swagger-core by swagger-api.
the class HibernateBeanValidationsTest method readHibernateValidations.
@Test(description = "it should read hibernate validations")
public void readHibernateValidations() {
final Map<String, Model> schemas = ModelConverters.getInstance().readAll(HibernateBeanValidationsModel.class);
final Map<String, Property> properties = schemas.get("HibernateBeanValidationsModel").getProperties();
final IntegerProperty age = (IntegerProperty) properties.get("age");
assertEquals(age.getMinimum().doubleValue(), 13.0, 0.01);
assertEquals(age.getMaximum().doubleValue(), 99.0, 0.01);
final StringProperty password = (StringProperty) properties.get("password");
assertEquals((int) password.getMinLength(), 6);
assertEquals((int) password.getMaxLength(), 20);
assertTrue(((DoubleProperty) properties.get("minBalance")).getExclusiveMinimum());
assertTrue(((DoubleProperty) properties.get("maxBalance")).getExclusiveMaximum());
}
use of io.swagger.models.properties.DoubleProperty in project swagger-core by swagger-api.
the class PropertySerializationTest method serializeDoubleProperty.
@Test(description = "it should serialize a DoubleProperty")
public void serializeDoubleProperty() throws IOException {
final DoubleProperty p = new DoubleProperty()._default(3.14159);
final String json = "{\"type\":\"number\",\"format\":\"double\",\"default\":3.14159}";
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.models.properties.DoubleProperty in project swagger-core by swagger-api.
the class PropertySerializationTest method deserializeDoubleProperty.
@Test(description = "it should deserialize a DoubleProperty")
public void deserializeDoubleProperty() throws IOException {
final String json = "{\"type\":\"number\",\"format\":\"double\"}";
final Property p = m.readValue(json, Property.class);
assertEquals(p.getType(), "number");
assertEquals(p.getFormat(), "double");
assertEquals(p.getClass(), DoubleProperty.class);
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.models.properties.DoubleProperty in project swagger-core by swagger-api.
the class AbstractSerializableParameter method setProperty.
public void setProperty(Property property) {
setType(property.getType());
this.format = property.getFormat();
if (property instanceof StringProperty) {
final StringProperty string = (StringProperty) property;
setEnum(string.getEnum());
} else if (property instanceof IntegerProperty) {
setEnumValue(((IntegerProperty) property).getEnum());
} else if (property instanceof LongProperty) {
setEnumValue(((LongProperty) property).getEnum());
} else if (property instanceof FloatProperty) {
setEnumValue(((FloatProperty) property).getEnum());
} else if (property instanceof DoubleProperty) {
setEnumValue(((DoubleProperty) property).getEnum());
} else if (property instanceof ArrayProperty) {
final ArrayProperty array = (ArrayProperty) property;
setItems(array.getItems());
}
}
use of io.swagger.models.properties.DoubleProperty in project swagger-core by swagger-api.
the class DoublePropertyTest method testEquals.
@Test
public void testEquals() {
final DoubleProperty prop1 = new DoubleProperty();
prop1.setName(PROP_1);
prop1.setRequired(true);
final DoubleProperty prop2 = new DoubleProperty();
prop2.setName(PROP_2);
assertNotEquals(prop1, prop2);
prop2.setName(PROP_1);
prop2.setRequired(true);
assertEquals(prop1, prop2);
}
Aggregations