Search in sources :

Example 36 with Test

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

the class ReaderTest method scanConsumesProducesValuesWithRsClassLevelAnnotations.

@Test(description = "scan consumes and produces values with rs class level annotations")
public void scanConsumesProducesValuesWithRsClassLevelAnnotations() {
    Swagger swagger = getSwagger(RsConsumesProducesResource.class);
    assertEquals(getGet(swagger, "/{id}").getConsumes().get(0), "application/yaml");
    assertEquals(getGet(swagger, "/{id}").getProduces().get(0), APPLICATION_XML);
    assertEquals(getGet(swagger, "/{id}/value").getConsumes().get(0), APPLICATION_XML);
    assertEquals(getGet(swagger, "/{id}/value").getProduces().get(0), TEXT_PLAIN);
    assertEquals(getPut(swagger, "/{id}").getConsumes().get(0), MediaType.APPLICATION_JSON);
    assertEquals(getPut(swagger, "/{id}").getProduces().get(0), TEXT_PLAIN);
    assertEquals(getPut(swagger, "/{id}/value").getConsumes().get(0), APPLICATION_XML);
    assertEquals(getPut(swagger, "/{id}/value").getProduces().get(0), TEXT_PLAIN);
    assertEquals(getPut(swagger, "/split").getProduces(), Arrays.asList("image/jpeg", "image/gif", "image/png"));
    assertEquals(getPut(swagger, "/split").getConsumes(), Arrays.asList("image/jpeg", "image/gif", "image/png"));
}
Also used : Swagger(io.swagger.models.Swagger) Test(org.testng.annotations.Test)

Example 37 with Test

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

the class ReaderTest method scanConsumesProducesValuesWithBothClassLevelAnnotations.

@Test(description = "scan consumes and produces values with both class level annotations")
public void scanConsumesProducesValuesWithBothClassLevelAnnotations() {
    Swagger swagger = getSwagger(BothConsumesProducesResource.class);
    assertEquals(getGet(swagger, "/{id}").getConsumes().get(0), MediaType.APPLICATION_XHTML_XML);
    assertEquals(getGet(swagger, "/{id}").getProduces().get(0), MediaType.APPLICATION_ATOM_XML);
    assertEquals(getGet(swagger, "/{id}/value").getConsumes().get(0), APPLICATION_XML);
    assertEquals(getGet(swagger, "/{id}/value").getProduces().get(0), TEXT_PLAIN);
    assertEquals(getGet(swagger, "/{id}/{name}/value").getConsumes().get(0), MediaType.APPLICATION_JSON);
    assertEquals(getGet(swagger, "/{id}/{name}/value").getProduces().get(0), TEXT_PLAIN);
    assertEquals(getGet(swagger, "/{id}/{type}/value").getConsumes().get(0), APPLICATION_XML);
    assertEquals(getGet(swagger, "/{id}/{type}/value").getProduces().get(0), TEXT_HTML);
    assertEquals(getPut(swagger, "/{id}").getConsumes().get(0), MediaType.APPLICATION_JSON);
    assertEquals(getPut(swagger, "/{id}").getProduces().get(0), TEXT_PLAIN);
    assertEquals(getPut(swagger, "/{id}/value").getConsumes().get(0), APPLICATION_XML);
    assertEquals(getPut(swagger, "/{id}/value").getProduces().get(0), TEXT_PLAIN);
}
Also used : Swagger(io.swagger.models.Swagger) Test(org.testng.annotations.Test)

Example 38 with Test

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

the class ReaderTest method scanDeclaredExceptionsAndCombineWithMethodResponses.

@Test(description = "scan resource with annotated exception")
public void scanDeclaredExceptionsAndCombineWithMethodResponses() {
    Swagger swagger = getSwagger(ResourceWithCustomException.class);
    assertNotNull(swagger);
    Operation operation = getPut(swagger, "/{id}");
    assertEquals(operation.getResponses().size(), 4);
    assertTrue(operation.getResponses().containsKey("200"));
    assertTrue(operation.getResponses().containsKey("400"));
    assertTrue(operation.getResponses().containsKey("404"));
    assertTrue(operation.getResponses().containsKey("409"));
}
Also used : Swagger(io.swagger.models.Swagger) Operation(io.swagger.models.Operation) Test(org.testng.annotations.Test)

Example 39 with Test

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

the class ReaderTest method scanInterfaceTest.

@Test(description = "scan annotation from interface, issue#1427")
public void scanInterfaceTest() {
    final Swagger swagger = new Reader(new Swagger()).read(AnnotatedInterfaceImpl.class);
    assertNotNull(swagger);
    assertNotNull(swagger.getPath("/v1/users/{id}").getGet());
}
Also used : Swagger(io.swagger.models.Swagger) Reader(io.swagger.jaxrs.Reader) Test(org.testng.annotations.Test)

Example 40 with Test

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

the class ReaderTest method scanImplicitWithFile.

@Test(description = "scan implicit params with file objct")
public void scanImplicitWithFile() {
    Swagger swagger = getSwagger(ResourceWithImplicitFileParam.class);
    Parameter param = swagger.getPath("/testString").getPost().getParameters().get(0);
    assertTrue(param instanceof FormParameter);
    FormParameter fp = (FormParameter) param;
    assertEquals("file", fp.getType());
}
Also used : Swagger(io.swagger.models.Swagger) FormParameter(io.swagger.models.parameters.FormParameter) PathParameter(io.swagger.models.parameters.PathParameter) Parameter(io.swagger.models.parameters.Parameter) QueryParameter(io.swagger.models.parameters.QueryParameter) HeaderParameter(io.swagger.models.parameters.HeaderParameter) BodyParameter(io.swagger.models.parameters.BodyParameter) FormParameter(io.swagger.models.parameters.FormParameter) Test(org.testng.annotations.Test)

Aggregations

Test (org.testng.annotations.Test)25872 OperationResult (com.evolveum.midpoint.schema.result.OperationResult)2438 Task (com.evolveum.midpoint.task.api.Task)2069 File (java.io.File)1464 ArrayList (java.util.ArrayList)1408 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)1188 HashMap (java.util.HashMap)1089 UserType (com.evolveum.midpoint.xml.ns._public.common.common_3.UserType)1078 Issue (io.qameta.allure.Issue)857 BeforeTest (org.testng.annotations.BeforeTest)819 CommandLineProgramTest (org.broadinstitute.hellbender.CommandLineProgramTest)814 List (java.util.List)734 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)676 ODocument (com.orientechnologies.orient.core.record.impl.ODocument)651 BigDecimal (java.math.BigDecimal)627 Parameters (org.testng.annotations.Parameters)608 BaseTest (org.xdi.oxauth.BaseTest)582 HashSet (java.util.HashSet)568