@Test(description = "should mark a parameter as to allow empty value") public void testAllowEmptyValueParameter() throws Exception { final Parameter qp = new QueryParameter().allowEmptyValue(true); final String json = "{\"in\":\"query\",\"allowEmptyValue\":true}"; SerializationMatchers.assertEqualsToJson(qp, json); } }
@Test(description = "it should serialize a QueryParameter") public void serializeQueryParameter() { final Parameter p = new QueryParameter() .schema(new StringSchema()); final String json = "{\"in\":\"query\",\"schema\":{\"type\":\"string\"}}"; SerializationMatchers.assertEqualsToJson(p, json); }
@Test(description = "should serialize float value") public void testFloatValue() { final QueryParameter param = new QueryParameter(); param.setSchema(new NumberSchema()._default(new BigDecimal("12.34")).format("float")); final String json = "{\"in\":\"query\",\"schema\":{\"type\":\"number\",\"format\":\"float\",\"default\":12.34}}"; SerializationMatchers.assertEqualsToJson(param, json); }
@Test(description = "should serialize double value") public void testDoubleValue() { final QueryParameter param = new QueryParameter(); param.setSchema(new NumberSchema()._default(new BigDecimal("12.34")).format("double")); final String json = "{\"in\":\"query\",\"schema\":{\"type\":\"number\",\"format\":\"double\",\"default\":12.34}}"; SerializationMatchers.assertEqualsToJson(param, json); }
@Test(description = "should mark a parameter as readOnly") public void testReadOnlyParameter() throws Exception { final QueryParameter qp = new QueryParameter(); qp.setSchema(new StringSchema().readOnly(true)); final String json = "{" + " \"in\":\"query\"," + " \"schema\":{" + " \"type\":\"string\"," + " \"readOnly\":true" + " }" + "}"; SerializationMatchers.assertEqualsToJson(qp, json); }
@Test(description = "it should serialize a QueryParameter with array") public void serializeArrayQueryParameter() { final Parameter p = new QueryParameter() .schema(new ArraySchema() .items(new StringSchema())); final String json = "{" + " \"in\":\"query\"," + " \"schema\":{" + " \"type\":\"array\"," + " \"items\":{" + " \"type\":\"string\"" + " }}" + "}"; SerializationMatchers.assertEqualsToJson(p, json); }
@Test(description = "should not serialize incorrect double value") public void testIncorrectDouble() { final QueryParameter param = (QueryParameter) new QueryParameter().required(false); Schema schema = new NumberSchema().format("double"); schema.setDefault("test"); param.setSchema(schema); final String json = "{" + " \"in\":\"query\"," + " \"required\":false," + " \"schema\":{" + " \"type\":\"number\"," + " \"format\":\"double\"" + " }" + "}"; SerializationMatchers.assertEqualsToJson(param, json); }
@Test(description = "should serialize string value") public void testStringValue() { final QueryParameter param = (QueryParameter) new QueryParameter().required(false); Schema schema = new Schema() .type("string"); schema.setDefault("false"); param.setSchema(schema); final String json = "{" + " \"in\":\"query\"," + " \"required\":false," + " \"schema\":{" + " \"type\":\"string\"," + " \"default\":\"false\"" + " }" + "}"; SerializationMatchers.assertEqualsToJson(param, json); }
@Test(description = "should not serialize incorrect long value") public void testIncorrectLong() { final QueryParameter param = (QueryParameter) new QueryParameter().required(false); Schema schema = new IntegerSchema().format("int64"); schema.setDefault("test"); param.setSchema(schema); final String json = "{" + " \"in\":\"query\"," + " \"required\":false," + " \"schema\":{" + " \"type\":\"integer\"," + " \"format\":\"int64\"" + " }" + "}"; SerializationMatchers.assertEqualsToJson(param, json); }
@Test(description = "should serialize boolean value") public void testBooleanValue() { final QueryParameter param = (QueryParameter) new QueryParameter().required(false); Schema schema = new Schema() .type("boolean"); schema.setDefault("false"); param.setSchema(schema); final String json = "{" + " \"in\":\"query\"," + " \"required\":false," + " \"schema\":{" + " \"type\":\"boolean\"," + " \"default\":\"false\"" + " }" + "}"; SerializationMatchers.assertEqualsToJson(param, json); }
@Test(description = "should serialize incorrect boolean value as string") public void testIncorrectBoolean() { final QueryParameter param = (QueryParameter) new QueryParameter().required(false); Schema schema = new Schema() .type("boolean"); schema.setDefault("test"); param.setSchema(schema); final String json = "{" + " \"in\":\"query\"," + " \"required\":false," + " \"schema\":{" + " \"type\":\"boolean\"," + " \"default\":\"test\"" + " }" + "}"; SerializationMatchers.assertEqualsToJson(param, json); }
@Test(description = "should serialize long value") public void testLongValue() { final QueryParameter param = (QueryParameter) new QueryParameter().required(false); Schema schema = new IntegerSchema().format("int64"); schema.setDefault("1234"); param.setSchema(schema); final String json = "{" + " \"in\":\"query\"," + " \"required\":false," + " \"schema\":{" + " \"type\":\"integer\"," + " \"default\":1234," + " \"format\":\"int64\"" + " }" + "}"; SerializationMatchers.assertEqualsToJson(param, json); }
final QueryParameter parameter = (QueryParameter) new QueryParameter() .name("id") .description("a common get parameter")
parameter = new QueryParameter(); } else if (HEADER_PARAMETER.equals(value)) { parameter = new HeaderParameter();
parameter = new QueryParameter(); } else if (HEADER_PARAMETER.equals(value)) { parameter = new HeaderParameter();
parameter = new QueryParameter(); } else if (HEADER_PARAMETER.equals(value)) { parameter = new HeaderParameter();