Search in sources :

Example 1 with NewDictionaryEntity

use of io.gravitee.rest.api.model.configuration.dictionary.NewDictionaryEntity in project gravitee-management-rest-api by gravitee-io.

the class DictionariesResourceTest method shouldNotCreateDictionary_emptyName.

@Test
public void shouldNotCreateDictionary_emptyName() {
    reset(dictionaryService);
    final NewDictionaryEntity newDictionaryEntity = new NewDictionaryEntity();
    newDictionaryEntity.setName(null);
    newDictionaryEntity.setType(DictionaryType.MANUAL);
    DictionaryEntity returnedDictionary = new DictionaryEntity();
    returnedDictionary.setId("my-dictionary");
    doReturn(returnedDictionary).when(dictionaryService).create(any());
    final Response response = envTarget().request().post(Entity.json(new NewDictionaryEntity()));
    assertEquals(HttpStatusCode.BAD_REQUEST_400, response.getStatus());
}
Also used : Response(javax.ws.rs.core.Response) NewDictionaryEntity(io.gravitee.rest.api.model.configuration.dictionary.NewDictionaryEntity) DictionaryEntity(io.gravitee.rest.api.model.configuration.dictionary.DictionaryEntity) NewDictionaryEntity(io.gravitee.rest.api.model.configuration.dictionary.NewDictionaryEntity) Test(org.junit.Test)

Example 2 with NewDictionaryEntity

use of io.gravitee.rest.api.model.configuration.dictionary.NewDictionaryEntity in project gravitee-management-rest-api by gravitee-io.

the class DictionariesResourceTest method shouldCreateApi.

@Test
public void shouldCreateApi() {
    reset(dictionaryService);
    final NewDictionaryEntity newDictionaryEntity = new NewDictionaryEntity();
    newDictionaryEntity.setDescription("description");
    newDictionaryEntity.setName("my-dictionary-name");
    newDictionaryEntity.setType(DictionaryType.MANUAL);
    DictionaryEntity returnedDictionary = new DictionaryEntity();
    returnedDictionary.setId("my-dictionary");
    doReturn(returnedDictionary).when(dictionaryService).create(any());
    final Response response = envTarget().request().post(Entity.json(newDictionaryEntity));
    assertEquals(HttpStatusCode.CREATED_201, response.getStatus());
    assertEquals(envTarget().path("my-dictionary").getUri().toString(), response.getHeaders().getFirst(HttpHeaders.LOCATION));
}
Also used : Response(javax.ws.rs.core.Response) NewDictionaryEntity(io.gravitee.rest.api.model.configuration.dictionary.NewDictionaryEntity) DictionaryEntity(io.gravitee.rest.api.model.configuration.dictionary.DictionaryEntity) NewDictionaryEntity(io.gravitee.rest.api.model.configuration.dictionary.NewDictionaryEntity) Test(org.junit.Test)

Aggregations

DictionaryEntity (io.gravitee.rest.api.model.configuration.dictionary.DictionaryEntity)2 NewDictionaryEntity (io.gravitee.rest.api.model.configuration.dictionary.NewDictionaryEntity)2 Response (javax.ws.rs.core.Response)2 Test (org.junit.Test)2