Search in sources :

Example 1 with SwaggerApiEntity

use of io.gravitee.rest.api.model.api.SwaggerApiEntity in project gravitee-management-rest-api by gravitee-io.

the class SwaggerService_CreateAPIV2Test method validateRules.

@Override
protected void validateRules(SwaggerApiEntity api, String path, int expectedRuleSize, List<HttpMethod> firstRuleMethods, String firstRuleDescription) {
    List<Flow> flows = api.getFlows().stream().filter(flow1 -> flow1.getPath().equals(path)).collect(Collectors.toList());
    // assertEquals(1, flows.size());
    assertEquals(expectedRuleSize, flows.get(0).getPre().size());
    assertTrue(flows.get(0).getMethods().containsAll(firstRuleMethods));
    Step step = flows.get(0).getPre().get(0);
    assertNotNull(step);
    assertEquals(firstRuleDescription, step.getDescription());
}
Also used : Step(io.gravitee.definition.model.flow.Step) java.util(java.util) Flow(io.gravitee.definition.model.flow.Flow) RunWith(org.junit.runner.RunWith) IOException(java.io.IOException) Test(org.junit.Test) io.gravitee.definition.model(io.gravitee.definition.model) Collectors(java.util.stream.Collectors) HttpMethod(io.gravitee.common.http.HttpMethod) Arrays.asList(java.util.Arrays.asList) SwaggerApiEntity(io.gravitee.rest.api.model.api.SwaggerApiEntity) io.gravitee.rest.api.model(io.gravitee.rest.api.model) Assert(org.junit.Assert) MockitoJUnitRunner(org.mockito.junit.MockitoJUnitRunner) Step(io.gravitee.definition.model.flow.Step) Flow(io.gravitee.definition.model.flow.Flow)

Example 2 with SwaggerApiEntity

use of io.gravitee.rest.api.model.api.SwaggerApiEntity in project gravitee-management-rest-api by gravitee-io.

the class SwaggerService_CreateAPITest method shouldPrepareAPIFromSwaggerV2_URL_yaml_extensions.

@Test
public void shouldPrepareAPIFromSwaggerV2_URL_yaml_extensions() throws IOException {
    final SwaggerApiEntity swaggerApiEntity = prepareUrl("io/gravitee/rest/api/management/service/swagger-withExtensions-v2.yaml");
    validate(swaggerApiEntity);
    validateExtensions(swaggerApiEntity);
}
Also used : SwaggerApiEntity(io.gravitee.rest.api.model.api.SwaggerApiEntity) Test(org.junit.Test)

Example 3 with SwaggerApiEntity

use of io.gravitee.rest.api.model.api.SwaggerApiEntity in project gravitee-management-rest-api by gravitee-io.

the class SwaggerService_CreateAPITest method shouldPrepareAPIFromSwaggerV3_URL_json_extensions.

@Test
public void shouldPrepareAPIFromSwaggerV3_URL_json_extensions() throws IOException {
    final SwaggerApiEntity swaggerApiEntity = prepareUrl("io/gravitee/rest/api/management/service/openapi-withExtensions.json");
    validate(swaggerApiEntity);
    validateExtensions(swaggerApiEntity);
}
Also used : SwaggerApiEntity(io.gravitee.rest.api.model.api.SwaggerApiEntity) Test(org.junit.Test)

Example 4 with SwaggerApiEntity

use of io.gravitee.rest.api.model.api.SwaggerApiEntity in project gravitee-management-rest-api by gravitee-io.

the class SwaggerService_CreateAPITest method shouldPrepareAPIFromSwaggerV3WithPetstore.

@Test
public void shouldPrepareAPIFromSwaggerV3WithPetstore() throws IOException {
    final SwaggerApiEntity api = prepareInline("io/gravitee/rest/api/management/service/mock/petstore.yaml", true, true);
    assertEquals("1.0.0", api.getVersion());
    assertEquals("/v1", api.getProxy().getVirtualHosts().get(0).getPath());
    assertEquals("Swagger Petstore", api.getName());
    assertEquals("http://petstore.swagger.io/v1", api.getProxy().getGroups().iterator().next().getEndpoints().iterator().next().getTarget());
    validatePolicies(api, 2, 3, asList("/pets", "/pets/:petId"));
}
Also used : SwaggerApiEntity(io.gravitee.rest.api.model.api.SwaggerApiEntity) Test(org.junit.Test)

Example 5 with SwaggerApiEntity

use of io.gravitee.rest.api.model.api.SwaggerApiEntity in project gravitee-management-rest-api by gravitee-io.

the class SwaggerService_CreateAPITest method shouldPrepareAPIFromSwaggerV3_URL_yaml_extensions.

@Test
public void shouldPrepareAPIFromSwaggerV3_URL_yaml_extensions() throws IOException {
    final SwaggerApiEntity swaggerApiEntity = prepareUrl("io/gravitee/rest/api/management/service/openapi-withExtensions.yaml");
    validate(swaggerApiEntity);
    validateExtensions(swaggerApiEntity);
}
Also used : SwaggerApiEntity(io.gravitee.rest.api.model.api.SwaggerApiEntity) Test(org.junit.Test)

Aggregations

SwaggerApiEntity (io.gravitee.rest.api.model.api.SwaggerApiEntity)19 Test (org.junit.Test)17 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)6 HttpMethod (io.gravitee.common.http.HttpMethod)3 java.util (java.util)3 Collectors (java.util.stream.Collectors)3 io.gravitee.definition.model (io.gravitee.definition.model)2 Flow (io.gravitee.definition.model.flow.Flow)2 Step (io.gravitee.definition.model.flow.Step)2 Policy (io.gravitee.policy.api.swagger.Policy)2 io.gravitee.rest.api.model (io.gravitee.rest.api.model)2 GroupService (io.gravitee.rest.api.service.GroupService)2 TagService (io.gravitee.rest.api.service.TagService)2 PolicyOperationVisitorManager (io.gravitee.rest.api.service.impl.swagger.policy.PolicyOperationVisitorManager)2 OAIOperationVisitor (io.gravitee.rest.api.service.impl.swagger.visitor.v3.OAIOperationVisitor)2 PolicyHelper.clearNullValues (io.gravitee.rest.api.service.validator.PolicyHelper.clearNullValues)2 OpenAPI (io.swagger.v3.oas.models.OpenAPI)2 Operation (io.swagger.v3.oas.models.Operation)2 PathItem (io.swagger.v3.oas.models.PathItem)2 Collections.singleton (java.util.Collections.singleton)2