Search in sources :

Example 31 with ApiEntity

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());
}
Also used : Response(javax.ws.rs.core.Response) ApiEntity(io.gravitee.management.model.ApiEntity) UpdateApiEntity(io.gravitee.management.model.UpdateApiEntity) Test(org.junit.Test)

Example 32 with ApiEntity

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");
}
Also used : Response(javax.ws.rs.core.Response) ApiEntity(io.gravitee.management.model.ApiEntity) UpdateApiEntity(io.gravitee.management.model.UpdateApiEntity) Test(org.junit.Test)

Example 33 with ApiEntity

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());
}
Also used : Response(javax.ws.rs.core.Response) ApiEntity(io.gravitee.management.model.ApiEntity) UpdateApiEntity(io.gravitee.management.model.UpdateApiEntity) Test(org.junit.Test)

Example 34 with ApiEntity

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());
}
Also used : Response(javax.ws.rs.core.Response) ApiEntity(io.gravitee.management.model.ApiEntity) UpdateApiEntity(io.gravitee.management.model.UpdateApiEntity) Test(org.junit.Test)

Example 35 with ApiEntity

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());
}
Also used : Response(javax.ws.rs.core.Response) ApiEntity(io.gravitee.management.model.ApiEntity) UpdateApiEntity(io.gravitee.management.model.UpdateApiEntity) Test(org.junit.Test)

Aggregations

ApiEntity (io.gravitee.management.model.ApiEntity)50 Test (org.junit.Test)34 Response (javax.ws.rs.core.Response)19 UpdateApiEntity (io.gravitee.management.model.UpdateApiEntity)13 PageEntity (io.gravitee.management.model.PageEntity)5 NewApiEntity (io.gravitee.management.model.NewApiEntity)4 NewTopApiEntity (io.gravitee.management.model.NewTopApiEntity)3 TopApiEntity (io.gravitee.management.model.TopApiEntity)3 UpdateTopApiEntity (io.gravitee.management.model.UpdateTopApiEntity)3 Permission (io.gravitee.management.rest.security.Permission)3 HashMap (java.util.HashMap)3 Collectors (java.util.stream.Collectors)3 Proxy (io.gravitee.definition.model.Proxy)2 ApplicationEntity (io.gravitee.management.model.ApplicationEntity)2 MemberEntity (io.gravitee.management.model.MemberEntity)2 SubscriptionEntity (io.gravitee.management.model.SubscriptionEntity)2 UserEntity (io.gravitee.management.model.UserEntity)2 RolePermission (io.gravitee.management.model.permissions.RolePermission)2 RolePermissionAction (io.gravitee.management.model.permissions.RolePermissionAction)2 SubscriptionQuery (io.gravitee.management.model.subscription.SubscriptionQuery)2