use of io.swagger.models.properties.DateProperty in project swagger-core by swagger-api.
the class JodaLocalDateConverterTest method testJodaLocalDate.
@Test
public void testJodaLocalDate() {
final Map<String, Model> models = ModelConverters.getInstance().read(ModelWithJodaLocalDate.class);
assertEquals(models.size(), 1);
final Model model = models.get("ModelWithJodaLocalDate");
final Property dateTimeProperty = model.getProperties().get("createdAt");
assertTrue(dateTimeProperty instanceof DateProperty);
assertEquals((int) dateTimeProperty.getPosition(), 1);
assertTrue(dateTimeProperty.getRequired());
assertEquals(dateTimeProperty.getDescription(), "creation localDate");
final Property nameProperty = model.getProperties().get("name");
assertTrue(nameProperty instanceof StringProperty);
assertEquals((int) nameProperty.getPosition(), 2);
assertEquals(nameProperty.getDescription(), "name of the model");
}
use of io.swagger.models.properties.DateProperty in project swagger-core by swagger-api.
the class ModelSerializerTest method convertModel.
@Test(description = "it should convert a model")
public void convertModel() throws JsonProcessingException {
final ModelImpl pet = new ModelImpl();
final HashMap<String, Property> props = new HashMap<String, Property>();
props.put("intValue", new IntegerProperty());
props.put("longValue", new LongProperty());
props.put("dateValue", new DateProperty());
props.put("dateTimeValue", new DateTimeProperty());
pet.setProperties(props);
pet.setRequired(Arrays.asList("intValue", "name"));
final String json = "{\n" + " \"required\":[\n" + " \"intValue\"\n" + " ],\n" + " \"properties\":{\n" + " \"dateValue\":{\n" + " \"type\":\"string\",\n" + " \"format\":\"date\"\n" + " },\n" + " \"longValue\":{\n" + " \"type\":\"integer\",\n" + " \"format\":\"int64\"\n" + " },\n" + " \"dateTimeValue\":{\n" + " \"type\":\"string\",\n" + " \"format\":\"date-time\"\n" + " },\n" + " \"intValue\":{\n" + " \"type\":\"integer\",\n" + " \"format\":\"int32\"\n" + " }\n" + " }\n" + "}";
SerializationMatchers.assertEqualsToJson(pet, json);
}
use of io.swagger.models.properties.DateProperty in project swagger-core by swagger-api.
the class PropertySerializationTest method serializeDateProperty.
@Test(description = "it should serialize a DateProperty")
public void serializeDateProperty() throws IOException {
final DateProperty p = new DateProperty();
final String json = "{\"type\":\"string\",\"format\":\"date\"}";
assertEquals(m.writeValueAsString(p), json);
}
use of io.swagger.models.properties.DateProperty in project swagger-core by swagger-api.
the class PropertySerializationTest method deserializeDateProperty.
@Test(description = "it should deserialize a DateProperty")
public void deserializeDateProperty() throws IOException {
final String json = "{\"type\":\"string\",\"format\":\"date\"}";
final Property p = m.readValue(json, Property.class);
assertEquals(p.getType(), "string");
assertEquals(p.getFormat(), "date");
assertEquals(p.getClass(), DateProperty.class);
assertEquals(m.writeValueAsString(p), json);
}
Aggregations