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