Search in sources :

Example 16 with ApiEntity

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());
}
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 17 with ApiEntity

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

Example 18 with ApiEntity

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());
}
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 19 with ApiEntity

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

Example 20 with ApiEntity

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