use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiResourceNotAdminTest method shouldGetApi.
@Test
public void shouldGetApi() {
final Response response = envTarget(API).request().get();
assertEquals(OK_200, response.getStatus());
final ApiEntity responseApi = response.readEntity(ApiEntity.class);
assertNotNull(responseApi);
assertEquals(API, responseApi.getName());
}
use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApisResourceTest method shouldImportApiFromGraviteeIODefinitionV1.
@Test
public void shouldImportApiFromGraviteeIODefinitionV1() {
reset(apiService, swaggerService);
String apiDefinition = "{}";
ApiEntity createdApi = new ApiEntity();
createdApi.setGraviteeDefinitionVersion("1.0.0");
createdApi.setId("my-beautiful-api");
doReturn(createdApi).when(apiDuplicatorService).createWithImportedDefinition(any(), any(), eq(GraviteeContext.getCurrentOrganization()), eq(GraviteeContext.getCurrentEnvironment()));
final Response response = envTarget().path("import").request().post(Entity.json(apiDefinition));
assertEquals(HttpStatusCode.OK_200, response.getStatus());
verify(apiService, times(0)).migrate(any());
}
use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApisResourceTest method shouldNotCreateApi_withoutPath.
@Test
public void shouldNotCreateApi_withoutPath() {
final NewApiEntity apiEntity = new NewApiEntity();
apiEntity.setName("My beautiful api");
apiEntity.setVersion("v1");
apiEntity.setDescription("my description");
ApiEntity returnedApi = new ApiEntity();
returnedApi.setId("my-beautiful-api");
doReturn(returnedApi).when(apiService).create(Mockito.any(NewApiEntity.class), Mockito.eq(USER_NAME));
final Response response = envTarget().request().post(Entity.json(apiEntity));
assertEquals(HttpStatusCode.BAD_REQUEST_400, response.getStatus());
}
use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApisResourceTest method shouldImportApiWithoutMigrationFromGraviteeIODefinitionIfAlreadyV2.
@Test
public void shouldImportApiWithoutMigrationFromGraviteeIODefinitionIfAlreadyV2() {
reset(apiService, swaggerService);
String apiDefinition = "{}";
ApiEntity createdApi = new ApiEntity();
createdApi.setGraviteeDefinitionVersion("2.0.0");
createdApi.setId("my-beautiful-api");
doReturn(createdApi).when(apiDuplicatorService).createWithImportedDefinition(any(), any(), eq(GraviteeContext.getCurrentOrganization()), eq(GraviteeContext.getCurrentEnvironment()));
final Response response = envTarget().path("import").queryParam("definitionVersion", "2.0.0").request().post(Entity.json(apiDefinition));
assertEquals(HttpStatusCode.OK_200, response.getStatus());
verify(apiService, times(0)).migrate(any());
}
use of io.gravitee.rest.api.model.api.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApisResourceTest method shouldCreateApi.
@Test
public void shouldCreateApi() {
final NewApiEntity apiEntity = new NewApiEntity();
apiEntity.setName("My beautiful api");
apiEntity.setVersion("v1");
apiEntity.setDescription("my description");
apiEntity.setContextPath("/myapi");
apiEntity.setEndpoint("http://localhost:9099/");
ApiEntity returnedApi = new ApiEntity();
returnedApi.setId("my-beautiful-api");
doReturn(returnedApi).when(apiService).create(Mockito.any(NewApiEntity.class), Mockito.eq(USER_NAME));
final Response response = envTarget().request().post(Entity.json(apiEntity));
assertEquals(HttpStatusCode.CREATED_201, response.getStatus());
assertEquals(envTarget().path("my-beautiful-api").getUri().toString(), response.getHeaders().getFirst(HttpHeaders.LOCATION));
}
Aggregations