use of io.gravitee.management.model.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiResourceTest method shouldGetApi.
@Test
public void shouldGetApi() {
final ApiEntity mockApi = new ApiEntity();
mockApi.setName(API_NAME);
doReturn(mockApi).when(apiService).findById(API_NAME);
final Response response = target().request().get();
assertEquals(OK_200, response.getStatus());
final ApiEntity responseApi = response.readEntity(ApiEntity.class);
assertNotNull(responseApi);
assertEquals(API_NAME, responseApi.getName());
}
use of io.gravitee.management.model.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiResourceTest method shouldStartApi.
@Test
public void shouldStartApi() {
final ApiEntity mockApi = new ApiEntity();
mockApi.setName(API_NAME);
doReturn(Optional.of(mockApi)).when(apiService).findById(API_NAME);
final Response response = target(API_NAME).queryParam("action", LifecycleActionParam.LifecycleAction.START).request().post(null);
assertEquals(NO_CONTENT_204, response.getStatus());
verify(apiService).start(API_NAME, "admin");
}
use of io.gravitee.management.model.ApiEntity in project gravitee-management-rest-api by gravitee-io.
the class ApiResourceTest method shouldStopApi.
@Test
public void shouldStopApi() {
final ApiEntity mockApi = new ApiEntity();
mockApi.setName(API_NAME);
doReturn(Optional.of(mockApi)).when(apiService).findById(API_NAME);
final Response response = target(API_NAME).queryParam("action", LifecycleActionParam.LifecycleAction.STOP).request().post(null);
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 shouldNotStopApiBecausePermissionDenied.
@Test
public void shouldNotStopApiBecausePermissionDenied() {
final ApiEntity mockApi = new ApiEntity();
mockApi.setName(API_NAME);
doReturn(Optional.of(mockApi)).when(apiService).findById(API_NAME);
final Response response = target(API_NAME).queryParam("action", LifecycleActionParam.LifecycleAction.STOP).request().post(null);
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 shouldNotGetApiBecauseNotFound.
@Test
public void shouldNotGetApiBecauseNotFound() {
final ApiEntity mockApi = new ApiEntity();
mockApi.setName(API_NAME);
doReturn(Optional.empty()).when(apiService).findById(API_NAME);
final Response response = target(API_NAME).request().get();
assertEquals(NOT_FOUND_404, response.getStatus());
}
Aggregations