Search in sources :

Example 86 with Test

use of org.testng.annotations.Test in project swagger-core by swagger-api.

the class SnakeCaseConverterTest method testConvert.

@Test(description = "it should change naming style")
public void testConvert() {
    // add the custom converter
    final SnakeCaseConverter snakeCaseConverter = new SnakeCaseConverter();
    final ModelConverters converters = new ModelConverters();
    converters.addConverter(snakeCaseConverter);
    final Map<String, Model> models = converters.readAll(SnakeCaseModel.class);
    final String json = "{" + "   \"bar\":{" + "      \"type\":\"object\"," + "      \"properties\":{" + "         \"foo\":{" + "            \"type\":\"string\"" + "         }" + "      }" + "   }," + "   \"snake_case_model\":{" + "      \"type\":\"object\"," + "      \"properties\":{" + "         \"bar\":{" + "            \"$ref\":\"#/definitions/bar\"" + "         }," + "         \"title\":{" + "            \"type\":\"string\"" + "         }" + "      }," + "      \"xml\":{" + "         \"name\":\"snakeCaseModel\"" + "      }" + "   }" + "}";
    SerializationMatchers.assertEqualsToJson(models, json);
}
Also used : Model(io.swagger.models.Model) ModelConverters(io.swagger.converter.ModelConverters) Test(org.testng.annotations.Test)

Example 87 with Test

use of org.testng.annotations.Test in project swagger-core by swagger-api.

the class ParameterSerializationTest method serializeQueryParameter.

@Test(description = "it should serialize a QueryParameter")
public void serializeQueryParameter() {
    final QueryParameter p = new QueryParameter().property(new StringProperty());
    final String json = "{\"in\":\"query\",\"required\":false,\"type\":\"string\"}";
    SerializationMatchers.assertEqualsToJson(p, json);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) StringProperty(io.swagger.models.properties.StringProperty) Test(org.testng.annotations.Test)

Example 88 with Test

use of org.testng.annotations.Test in project swagger-core by swagger-api.

the class ParameterSerializationTest method testIssue1765.

@Test(description = "should serialize correctly typed numeric enums")
public void testIssue1765() throws Exception {
    String yaml = "swagger: '2.0'\n" + "paths:\n" + "  /test:\n" + "    get:\n" + "      parameters:\n" + "      - name: \"days\"\n" + "        in: \"path\"\n" + "        required: true\n" + "        type: \"integer\"\n" + "        format: \"int32\"\n" + "        enum:\n" + "        - 1\n" + "        - 2\n" + "        - 3\n" + "        - 4\n" + "        - 5\n" + "      responses:\n" + "        default:\n" + "          description: great";
    Swagger swagger = Yaml.mapper().readValue(yaml, Swagger.class);
    SerializationMatchers.assertEqualsToYaml(swagger, yaml);
}
Also used : Swagger(io.swagger.models.Swagger) Test(org.testng.annotations.Test)

Example 89 with Test

use of org.testng.annotations.Test in project swagger-core by swagger-api.

the class ParameterSerializationTest method deserializePathParameter.

@Test(description = "it should deserialize a PathParameter")
public void deserializePathParameter() throws IOException {
    final String json = "{\"in\":\"query\",\"required\":true,\"type\":\"string\"}";
    final Parameter p = m.readValue(json, Parameter.class);
    SerializationMatchers.assertEqualsToJson(p, json);
    assertTrue(p.getRequired());
}
Also used : BodyParameter(io.swagger.models.parameters.BodyParameter) PathParameter(io.swagger.models.parameters.PathParameter) Parameter(io.swagger.models.parameters.Parameter) QueryParameter(io.swagger.models.parameters.QueryParameter) HeaderParameter(io.swagger.models.parameters.HeaderParameter) Test(org.testng.annotations.Test)

Example 90 with Test

use of org.testng.annotations.Test in project swagger-core by swagger-api.

the class ParameterSerializationTest method testIncorrectLong.

@Test(description = "should serialize incorrect long value as string")
public void testIncorrectLong() {
    final QueryParameter param = new QueryParameter();
    param.setDefaultValue("test");
    param.setType("integer");
    param.setFormat("1nt64");
    final String json = "{\"in\":\"query\",\"required\":false,\"type\":\"integer\",\"default\":\"test\",\"format\":\"1nt64\"}";
    SerializationMatchers.assertEqualsToJson(param, json);
}
Also used : QueryParameter(io.swagger.models.parameters.QueryParameter) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)27231 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2438 Task (com.evolveum.midpoint.task.api.Task)2069 ArrayList (java.util.ArrayList)1583 File (java.io.File)1530 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)1188 HashMap (java.util.HashMap)1134 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1078 BeforeTest (org.testng.annotations.BeforeTest)870 Issue (io.qameta.allure.Issue)857 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)814 List (java.util.List)748 PolyString (com.evolveum.midpoint.prism.polystring.PolyString)692 ShadowType (com.evolveum.midpoint.xml.ns._public.common.common_3.ShadowType)690 Response (javax.ws.rs.core.Response)682 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)651 HashSet (java.util.HashSet)631 BigDecimal (java.math.BigDecimal)627 Parameters (org.testng.annotations.Parameters)608 BaseTest (org.xdi.oxauth.BaseTest)582