use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto in project CzechIdMng by bcvsolutions.
the class DefaultCodeListManager method delete.
@Override
@Transactional
public void delete(Serializable codeListIdentifier, BasePermission... permission) {
IdmCodeListDto codeList = get(codeListIdentifier);
if (codeList == null) {
return;
}
//
codeListService.delete(codeList, permission);
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto in project CzechIdMng by bcvsolutions.
the class DefaultCodeListManagerIntegrationTest method testCodeListItemCRUD.
@Test
public void testCodeListItemCRUD() {
String code = getHelper().createName();
IdmCodeListDto codeList = manager.create(code);
//
String itemCode = getHelper().createName();
String itemName = getHelper().createName();
IdmCodeListItemDto item = manager.createItem(codeList, itemCode, itemName);
//
Assert.assertEquals(itemCode, item.getCode());
Assert.assertEquals(itemName, item.getName());
//
String itemCodeUpdate = getHelper().createName();
String itemNameUpdate = getHelper().createName();
item.setCode(itemCodeUpdate);
item.setName(itemNameUpdate);
item = manager.saveItem(item);
//
Assert.assertEquals(itemCodeUpdate, item.getCode());
Assert.assertEquals(itemNameUpdate, item.getName());
//
Assert.assertNotNull(manager.getItem(codeList, itemCodeUpdate));
Assert.assertEquals(item.getId(), manager.getItem(codeList, itemCodeUpdate).getId());
//
List<IdmCodeListItemDto> items = manager.getItems(codeList, null);
Assert.assertEquals(1, items.size());
Assert.assertTrue(items.stream().anyMatch(i -> i.getCode().equals(itemCodeUpdate)));
//
manager.deleteItem(codeList, itemCodeUpdate);
//
Assert.assertNull(manager.getItem(codeList, itemCodeUpdate));
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto in project CzechIdMng by bcvsolutions.
the class DefaultCodeListManagerIntegrationTest method testCodeListCRUD.
@Test
public void testCodeListCRUD() {
String code = getHelper().createName();
IdmCodeListDto codeList = manager.create(code);
codeList = manager.get(code);
//
Assert.assertEquals(code, codeList.getCode());
Assert.assertEquals(code, codeList.getName());
Assert.assertNotNull(codeList.getFormDefinition());
IdmFormDefinitionDto formDefinition = codeList.getFormDefinition();
Assert.assertEquals(code, formDefinition.getCode());
Assert.assertEquals(code, formDefinition.getName());
Assert.assertEquals(formService.getDefaultDefinitionType(IdmCodeListItemDto.class), formDefinition.getType());
//
String codeUpdate = getHelper().createName();
String codeNameUpdate = getHelper().createName();
codeList.setCode(codeUpdate);
codeList.setName(codeNameUpdate);
//
manager.save(codeList);
codeList = manager.get(codeList.getId());
//
Assert.assertEquals(codeUpdate, codeList.getCode());
Assert.assertEquals(codeNameUpdate, codeList.getName());
Assert.assertNotNull(codeList.getFormDefinition());
formDefinition = codeList.getFormDefinition();
Assert.assertEquals(codeUpdate, formDefinition.getCode());
Assert.assertEquals(codeNameUpdate, formDefinition.getName());
//
manager.delete(codeList);
//
Assert.assertNull(manager.get(codeList.getId()));
formService.getDefinition(formDefinition.getId());
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto in project CzechIdMng by bcvsolutions.
the class DefaultCodeListManagerIntegrationTest method testSetFormDefintion.
@Test(expected = ResultCodeException.class)
public void testSetFormDefintion() {
IdmCodeListDto codeList = new IdmCodeListDto();
codeList.setCode(getHelper().createName());
codeList.setName(getHelper().createName());
codeList.setFormDefinition(formService.createDefinition(IdmCodeListItemDto.class, getHelper().createName(), null));
//
manager.save(codeList);
}
use of eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto in project CzechIdMng by bcvsolutions.
the class IdmCodeListItemControllerRestTest method prepareDto.
@Override
protected IdmCodeListItemDto prepareDto() {
IdmCodeListDto codeList = new IdmCodeListDto();
codeList.setName(getHelper().createName());
codeList.setCode(getHelper().createName());
codeList = getHelper().getService(IdmCodeListService.class).save(codeList);
//
IdmCodeListItemDto dto = new IdmCodeListItemDto();
dto.setName(getHelper().createName());
dto.setCode(getHelper().createName());
dto.setCodeList(codeList.getId());
//
return dto;
}
Aggregations