use of io.gravitee.rest.api.model.ImportSwaggerDescriptorEntity in project gravitee-management-rest-api by gravitee-io.
the class ApisResourceTest method shouldImportApiFromSwager.
@Test
public void shouldImportApiFromSwager() {
reset(apiService, swaggerService);
ImportSwaggerDescriptorEntity swaggerDescriptor = new ImportSwaggerDescriptorEntity();
swaggerDescriptor.setPayload("my-payload");
ApiEntity createdApi = new ApiEntity();
createdApi.setId("my-beautiful-api");
doReturn(createdApi).when(apiService).createFromSwagger(any(), any(), any());
final Response response = envTarget().path("import").path("swagger").request().post(Entity.json(swaggerDescriptor));
assertEquals(HttpStatusCode.CREATED_201, response.getStatus());
assertEquals(envTarget().path("my-beautiful-api").getUri().toString(), response.getHeaders().getFirst(HttpHeaders.LOCATION));
verify(swaggerService).createAPI(argThat(argument -> argument.getPayload().equalsIgnoreCase(swaggerDescriptor.getPayload())), eq(DefinitionVersion.valueOfLabel("1.0.0")));
}
Aggregations