Search in sources :

Example 1 with HibernateBeanValidationsModel

use of io.swagger.models.HibernateBeanValidationsModel 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());
}
Also used : IntegerProperty(io.swagger.models.properties.IntegerProperty) HibernateBeanValidationsModel(io.swagger.models.HibernateBeanValidationsModel) Model(io.swagger.models.Model) StringProperty(io.swagger.models.properties.StringProperty) IntegerProperty(io.swagger.models.properties.IntegerProperty) DoubleProperty(io.swagger.models.properties.DoubleProperty) StringProperty(io.swagger.models.properties.StringProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) Property(io.swagger.models.properties.Property) Test(org.testng.annotations.Test)

Example 2 with HibernateBeanValidationsModel

use of io.swagger.models.HibernateBeanValidationsModel in project swagger-core by swagger-api.

the class HibernateBeanValidationsTest method shouldUnderstandNotEmpty.

@Test
public void shouldUnderstandNotEmpty() {
    final Map<String, Model> schemas = ModelConverters.getInstance().readAll(HibernateBeanValidationsModel.class);
    final Map<String, Property> properties = schemas.get("HibernateBeanValidationsModel").getProperties();
    final StringProperty notEmptyString = (StringProperty) properties.get("notEmptyString");
    assertEquals((int) notEmptyString.getMinLength(), 1);
    final ArrayProperty notEmptyArray = (ArrayProperty) properties.get("notEmptyArray");
    assertEquals((int) notEmptyArray.getMinItems(), 1);
}
Also used : ArrayProperty(io.swagger.models.properties.ArrayProperty) HibernateBeanValidationsModel(io.swagger.models.HibernateBeanValidationsModel) Model(io.swagger.models.Model) StringProperty(io.swagger.models.properties.StringProperty) IntegerProperty(io.swagger.models.properties.IntegerProperty) DoubleProperty(io.swagger.models.properties.DoubleProperty) StringProperty(io.swagger.models.properties.StringProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) Property(io.swagger.models.properties.Property) Test(org.testng.annotations.Test)

Aggregations

HibernateBeanValidationsModel (io.swagger.models.HibernateBeanValidationsModel)2 Model (io.swagger.models.Model)2 ArrayProperty (io.swagger.models.properties.ArrayProperty)2 DoubleProperty (io.swagger.models.properties.DoubleProperty)2 IntegerProperty (io.swagger.models.properties.IntegerProperty)2 Property (io.swagger.models.properties.Property)2 StringProperty (io.swagger.models.properties.StringProperty)2 Test (org.testng.annotations.Test)2