Search in sources :

Example 16 with IdmCodeListDto

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);
}
Also used : IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto) Transactional(org.springframework.transaction.annotation.Transactional)

Example 17 with IdmCodeListDto

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));
}
Also used : IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto) Autowired(org.springframework.beans.factory.annotation.Autowired) Test(org.junit.Test) IdmCodeListItemDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto) FormService(eu.bcvsolutions.idm.core.eav.api.service.FormService) ApplicationContext(org.springframework.context.ApplicationContext) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) List(java.util.List) ResultCodeException(eu.bcvsolutions.idm.core.api.exception.ResultCodeException) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Assert(org.junit.Assert) Before(org.junit.Before) Transactional(org.springframework.transaction.annotation.Transactional) IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto) IdmCodeListItemDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 18 with IdmCodeListDto

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());
}
Also used : IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto) IdmFormDefinitionDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto) IdmCodeListItemDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 19 with IdmCodeListDto

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);
}
Also used : IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto) IdmCodeListItemDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto) Test(org.junit.Test) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)

Example 20 with IdmCodeListDto

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;
}
Also used : IdmCodeListDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto) IdmCodeListItemDto(eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto)

Aggregations

IdmCodeListDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListDto)20 IdmCodeListItemDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmCodeListItemDto)9 Test (org.junit.Test)8 Transactional (org.springframework.transaction.annotation.Transactional)7 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)5 List (java.util.List)4 Assert (org.junit.Assert)4 Autowired (org.springframework.beans.factory.annotation.Autowired)4 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)3 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)3 DefaultEventResult (eu.bcvsolutions.idm.core.api.event.DefaultEventResult)3 CodeListManager (eu.bcvsolutions.idm.core.eav.api.service.CodeListManager)3 CoreGroupPermission (eu.bcvsolutions.idm.core.model.domain.CoreGroupPermission)3 IdmBasePermission (eu.bcvsolutions.idm.core.security.api.domain.IdmBasePermission)3 AbstractEvaluatorIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractEvaluatorIntegrationTest)3 Set (java.util.Set)3 ResultCodeException (eu.bcvsolutions.idm.core.api.exception.ResultCodeException)2 IdmFormDefinitionDto (eu.bcvsolutions.idm.core.eav.api.dto.IdmFormDefinitionDto)2 FormService (eu.bcvsolutions.idm.core.eav.api.service.FormService)2 IdmCodeListItemService (eu.bcvsolutions.idm.core.eav.api.service.IdmCodeListItemService)2