use of io.swagger.models.BeanValidationsModel in project swagger-core by swagger-api.
the class BeanValidatorTest method readBeanValidatorTest.
@Test(description = "read bean validations")
public void readBeanValidatorTest() {
final Map<String, Model> schemas = ModelConverters.getInstance().readAll(BeanValidationsModel.class);
final Model model = schemas.get("BeanValidationsModel");
final Map<String, Property> properties = model.getProperties();
final IntegerProperty age = (IntegerProperty) properties.get("age");
Assert.assertEquals(age.getMinimum(), new BigDecimal(13.0));
Assert.assertEquals(age.getMaximum(), new BigDecimal(99.0));
final StringProperty password = (StringProperty) properties.get("password");
Assert.assertEquals((int) password.getMinLength(), 6);
Assert.assertEquals((int) password.getMaxLength(), 20);
final StringProperty email = (StringProperty) properties.get("email");
Assert.assertEquals((String) email.getPattern(), "(.+?)@(.+?)");
final DoubleProperty minBalance = (DoubleProperty) properties.get("minBalance");
Assert.assertTrue(minBalance.getExclusiveMinimum());
final DoubleProperty maxBalance = (DoubleProperty) properties.get("maxBalance");
Assert.assertTrue(maxBalance.getExclusiveMaximum());
final ArrayProperty items = (ArrayProperty) properties.get("items");
Assert.assertEquals((int) items.getMinItems(), 2);
Assert.assertEquals((int) items.getMaxItems(), 10);
}
Aggregations