use of io.gravitee.management.model.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiResourceTest method shouldNotDeleteApiBecausePermissionDenied.
@Test
public void shouldNotDeleteApiBecausePermissionDenied() {
final ApiEntity mockApi = new ApiEntity();
mockApi.setName(API_NAME);
doReturn(Optional.of(mockApi)).when(apiService).findById(API_NAME);
final Response response = target(API_NAME).request().delete();
assertEquals(FORBIDDEN_403, response.getStatus());
}
use of io.gravitee.management.model.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiResourceTest method shouldUpdateApi.
@Test
public void shouldUpdateApi() {
final UpdateApiEntity mockApi = new UpdateApiEntity();
mockApi.setVersion("v1");
mockApi.setDescription("Description of my API");
mockApi.setProxy(new Proxy());
doReturn(new ApiEntity()).when(apiService).update(API_NAME, mockApi);
final Response response = target(API_NAME).request().put(Entity.json(mockApi));
assertEquals(NO_CONTENT_204, response.getStatus());
}
use of io.gravitee.management.model.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiResourceTest method shouldNotStopApiBecauseNotFound.
@Test
public void shouldNotStopApiBecauseNotFound() {
final ApiEntity mockApi = new ApiEntity();
mockApi.setName(API_NAME);
doReturn(Optional.empty()).when(apiService).findById(API_NAME);
final Response response = target(API_NAME).queryParam("action", LifecycleActionParam.LifecycleAction.STOP).request().post(null);
assertEquals(NOT_FOUND_404, response.getStatus());
}
use of io.gravitee.management.model.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 = target().request().post(Entity.json(apiEntity));
assertEquals(HttpStatusCode.BAD_REQUEST_400, response.getStatus());
}
use of io.gravitee.management.model.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 = target().request().post(Entity.json(apiEntity));
assertEquals(HttpStatusCode.CREATED_201, response.getStatus());
}
Aggregations