Search in sources :

Example 11 with ArrayProperty

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");
}
Also used : ArrayProperty(io.swagger.models.properties.ArrayProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) Property(io.swagger.models.properties.Property) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 12 with ArrayProperty

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");
}
Also used : ArrayProperty(io.swagger.models.properties.ArrayProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) Property(io.swagger.models.properties.Property) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 13 with ArrayProperty

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");
}
Also used : ArrayProperty(io.swagger.models.properties.ArrayProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) Property(io.swagger.models.properties.Property) Test(org.testng.annotations.Test) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest)

Example 14 with ArrayProperty

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());
}
Also used : ArrayProperty(io.swagger.models.properties.ArrayProperty) Test(org.testng.annotations.Test)

Example 15 with ArrayProperty

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");
}
Also used : BaseIntegerProperty(io.swagger.models.properties.BaseIntegerProperty) IntegerProperty(io.swagger.models.properties.IntegerProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) AbstractModelWithApiModel(io.swagger.models.composition.AbstractModelWithApiModel) Model(io.swagger.models.Model) ModelWithApiModel(io.swagger.models.ModelWithApiModel) EmptyModel(io.swagger.models.EmptyModel) JodaDateTimeModel(io.swagger.models.JodaDateTimeModel) JacksonReadonlyModel(io.swagger.models.JacksonReadonlyModel) StringProperty(io.swagger.models.properties.StringProperty) ModelImpl(io.swagger.models.ModelImpl) StringProperty(io.swagger.models.properties.StringProperty) ArrayProperty(io.swagger.models.properties.ArrayProperty) LongProperty(io.swagger.models.properties.LongProperty) DecimalProperty(io.swagger.models.properties.DecimalProperty) Property(io.swagger.models.properties.Property) DoubleProperty(io.swagger.models.properties.DoubleProperty) MapProperty(io.swagger.models.properties.MapProperty) ApiModelProperty(io.swagger.annotations.ApiModelProperty) BaseIntegerProperty(io.swagger.models.properties.BaseIntegerProperty) ModelWithUrlProperty(io.swagger.models.composition.ModelWithUrlProperty) RefProperty(io.swagger.models.properties.RefProperty) FloatProperty(io.swagger.models.properties.FloatProperty) IntegerProperty(io.swagger.models.properties.IntegerProperty) RefProperty(io.swagger.models.properties.RefProperty) Test(org.testng.annotations.Test)

Aggregations

ArrayProperty (io.swagger.models.properties.ArrayProperty)43 Property (io.swagger.models.properties.Property)30 Test (org.testng.annotations.Test)30 StringProperty (io.swagger.models.properties.StringProperty)23 Model (io.swagger.models.Model)14 MapProperty (io.swagger.models.properties.MapProperty)14 IntegerProperty (io.swagger.models.properties.IntegerProperty)12 RefProperty (io.swagger.models.properties.RefProperty)12 ModelImpl (io.swagger.models.ModelImpl)8 DoubleProperty (io.swagger.models.properties.DoubleProperty)7 LongProperty (io.swagger.models.properties.LongProperty)7 Operation (io.swagger.models.Operation)6 ByteArrayProperty (io.swagger.models.properties.ByteArrayProperty)6 FloatProperty (io.swagger.models.properties.FloatProperty)5 ApiModelProperty (io.swagger.annotations.ApiModelProperty)4 AbstractNumericProperty (io.swagger.models.properties.AbstractNumericProperty)4 BaseIntegerProperty (io.swagger.models.properties.BaseIntegerProperty)4 BooleanProperty (io.swagger.models.properties.BooleanProperty)4 DecimalProperty (io.swagger.models.properties.DecimalProperty)4 Annotation (java.lang.annotation.Annotation)4