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());
}
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));
}
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());
}
Aggregations