Search in sources :

Example 1 with NewApiEntity

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

Example 2 with NewApiEntity

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

Example 3 with NewApiEntity

use of io.gravitee.rest.api.model.api.NewApiEntity in project gravitee-management-rest-api by gravitee-io.

the class ApisResourceTest method shouldNotCreateApi_emptyName.

@Test
public void shouldNotCreateApi_emptyName() {
    final NewApiEntity apiEntity = new NewApiEntity();
    apiEntity.setName("");
    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());
}
Also used : Response(javax.ws.rs.core.Response) ApiEntity(io.gravitee.rest.api.model.api.ApiEntity) NewApiEntity(io.gravitee.rest.api.model.api.NewApiEntity) NewApiEntity(io.gravitee.rest.api.model.api.NewApiEntity) Test(org.junit.Test)

Aggregations

ApiEntity (io.gravitee.rest.api.model.api.ApiEntity)3 NewApiEntity (io.gravitee.rest.api.model.api.NewApiEntity)3 Response (javax.ws.rs.core.Response)3 Test (org.junit.Test)3