use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class IdentityByTreeNodeEvaluatorIntegrationTest method testMoreTreeTypeStructure.
@Test
public void testMoreTreeTypeStructure() {
IdmTreeTypeDto typeOne = getHelper().createTreeType();
IdmTreeTypeDto typeTwo = getHelper().createTreeType();
IdmTreeNodeDto parent = getHelper().createTreeNode(typeOne, null);
IdmTreeNodeDto subParent = getHelper().createTreeNode(typeOne, getHelper().createName(), parent);
IdmTreeNodeDto position = getHelper().createTreeNode(typeOne, getHelper().createName(), subParent);
IdmTreeNodeDto parentTwo = getHelper().createTreeNode(typeTwo, null);
IdmTreeNodeDto subParentTwo = getHelper().createTreeNode(typeTwo, getHelper().createName(), parentTwo);
IdmTreeNodeDto positionTwo = getHelper().createTreeNode(typeTwo, getHelper().createName(), subParentTwo);
// Evaluator is on parentTwo
IdmRoleDto role = prepareRoleWithEvaluator(parent);
// Position is sub child
IdmIdentityDto identity = prepareIdentityOnWorkPosition(position);
// New position on another tree type
IdmIdentityDto identityTwo = prepareIdentityOnWorkPosition(positionTwo);
IdmIdentityDto administrator = getHelper().createIdentity();
try {
getHelper().login(administrator);
List<IdmIdentityDto> users = identityService.find(null, IdmBasePermission.READ).getContent();
// only myself
assertEquals(0, users.size());
checkIdentityInList(identity, users, false);
checkIdentityInList(identityTwo, users, false);
} finally {
getHelper().logout();
}
getHelper().assignRoles(getHelper().getPrimeContract(administrator), role);
try {
getHelper().login(administrator);
List<IdmIdentityDto> users = identityService.find(null, IdmBasePermission.READ).getContent();
assertEquals(1, users.size());
checkIdentityInList(identity, users, true);
checkIdentityInList(identityTwo, users, false);
} finally {
getHelper().logout();
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class IdentityContractSyncTest method defaultWorkPositionTest.
@Test
public void defaultWorkPositionTest() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
Assert.assertTrue(config instanceof SysSyncContractConfigDto);
helper.createIdentity(CONTRACT_OWNER_ONE);
helper.createIdentity(CONTRACT_OWNER_TWO);
helper.createIdentity(CONTRACT_LEADER_ONE);
helper.createIdentity(CONTRACT_LEADER_TWO);
// Set default tree type to sync configuration
IdmTreeTypeDto treeType = treeTypeService.getByCode(InitApplicationData.DEFAULT_TREE_TYPE);
Assert.assertNotNull(treeType);
SysSyncContractConfigDto configContract = (SysSyncContractConfigDto) config;
configContract.setDefaultTreeType(treeType.getId());
// Set default tree node to sync configuration
IdmTreeNodeFilter nodeFilter = new IdmTreeNodeFilter();
nodeFilter.setCode("one");
nodeFilter.setTreeTypeId(treeType.getId());
List<IdmTreeNodeDto> nodes = treeNodeService.find(nodeFilter, null).getContent();
Assert.assertEquals(1, nodes.size());
IdmTreeNodeDto defaultNode = nodes.get(0);
configContract.setDefaultTreeNode(defaultNode.getId());
config = syncConfigService.save(configContract);
IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
contractFilter.setProperty(IdmIdentityContract_.position.getName());
// Start sync
helper.startSynchronization(config);
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
// Default work positions must be set
contractFilter.setValue("1");
List<IdmIdentityContractDto> contractsOne = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsOne.size());
Assert.assertEquals(defaultNode.getId(), contractsOne.get(0).getWorkPosition());
contractFilter.setValue("2");
List<IdmIdentityContractDto> contractsTwo = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsTwo.size());
Assert.assertEquals(defaultNode.getId(), contractsTwo.get(0).getWorkPosition());
contractFilter.setValue("3");
List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsThree.size());
Assert.assertEquals(defaultNode.getId(), contractsThree.get(0).getWorkPosition());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class ContractSliceSyncTest method createContractSlicesTest.
@Test
public void createContractSlicesTest() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
Assert.assertTrue(config instanceof SysSyncContractConfigDto);
helper.createIdentity(CONTRACT_OWNER_ONE);
helper.createIdentity(CONTRACT_OWNER_TWO);
helper.createIdentity(CONTRACT_LEADER_ONE);
IdmTreeTypeDto treeType = helper.createTreeType();
IdmTreeNodeDto defaultNode = helper.createTreeNode(treeType, null);
((SysSyncContractConfigDto) config).setDefaultTreeType(treeType.getId());
((SysSyncContractConfigDto) config).setDefaultTreeNode(defaultNode.getId());
config = syncConfigService.save(config);
IdmContractSliceFilter contractFilter = new IdmContractSliceFilter();
contractFilter.setProperty(IdmIdentityContract_.position.getName());
contractFilter.setValue("1");
Assert.assertEquals(0, contractSliceService.find(contractFilter, null).getTotalElements());
contractFilter.setValue("2");
Assert.assertEquals(0, contractSliceService.find(contractFilter, null).getTotalElements());
helper.startSynchronization(config);
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 4);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
contractFilter.setValue("1");
Assert.assertEquals(1, contractSliceService.find(contractFilter, null).getTotalElements());
// Find slice guarantees
Assert.assertEquals(1, contractSliceManager.findSliceGuarantees(contractSliceService.find(contractFilter, null).getContent().get(0).getId()).size());
contractFilter.setValue("2");
Assert.assertEquals(1, contractSliceService.find(contractFilter, null).getTotalElements());
contractFilter.setValue("3");
List<IdmContractSliceDto> contractsThree = contractSliceService.find(contractFilter, null).getContent();
Assert.assertEquals(1, contractsThree.size());
Assert.assertEquals(null, contractsThree.get(0).getState());
// Find slice guarantees
Assert.assertEquals(0, contractSliceManager.findSliceGuarantees(contractsThree.get(0).getId()).size());
contractFilter.setValue("4");
Assert.assertEquals(1, contractSliceService.find(contractFilter, null).getTotalElements());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class ContractSliceSyncTest method sliceWithDefaultPositionTest.
@Test
public void sliceWithDefaultPositionTest() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
Assert.assertTrue(config instanceof SysSyncContractConfigDto);
IdmTreeTypeDto treeType = helper.createTreeType();
IdmTreeNodeDto defaultNode = helper.createTreeNode(treeType, null);
IdmTreeNodeDto workPositionOneNode = helper.createTreeNode(treeType, ContractSliceSyncTest.WORK_POSITION_CODE, null);
((SysSyncContractConfigDto) config).setDefaultTreeType(treeType.getId());
((SysSyncContractConfigDto) config).setDefaultTreeNode(defaultNode.getId());
config = syncConfigService.save(config);
IdmIdentityDto owner = helper.createIdentity(CONTRACT_OWNER_ONE);
helper.createIdentity(CONTRACT_LEADER_ONE);
IdmContractSliceFilter contractSliceFilter = new IdmContractSliceFilter();
contractSliceFilter.setProperty(IdmIdentityContract_.position.getName());
contractSliceFilter.setValue("1");
Assert.assertEquals(0, contractSliceService.find(contractSliceFilter, null).getTotalElements());
contractSliceFilter.setValue("2");
Assert.assertEquals(0, contractSliceService.find(contractSliceFilter, null).getTotalElements());
helper.startSynchronization(config);
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 4);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
contractSliceFilter.setValue("1");
List<IdmContractSliceDto> slicesOne = contractSliceService.find(contractSliceFilter, null).getContent();
Assert.assertEquals(1, slicesOne.size());
// Must have sets ContractSliceSyncTest.WORK_POSITION_CODE work position
Assert.assertEquals(workPositionOneNode.getId(), slicesOne.get(0).getWorkPosition());
contractSliceFilter.setValue("2");
List<IdmContractSliceDto> slicesTwo = contractSliceService.find(contractSliceFilter, null).getContent();
Assert.assertEquals(1, slicesTwo.size());
// Must have sets default work position
Assert.assertEquals(defaultNode.getId(), slicesTwo.get(0).getWorkPosition());
contractSliceFilter.setValue("3");
List<IdmContractSliceDto> contractsThree = contractSliceService.find(contractSliceFilter, null).getContent();
Assert.assertEquals(1, contractsThree.size());
Assert.assertEquals(null, contractsThree.get(0).getState());
// Must have sets default work position
Assert.assertEquals(defaultNode.getId(), contractsThree.get(0).getWorkPosition());
contractSliceFilter.setValue("4");
Assert.assertEquals(1, contractSliceService.find(contractSliceFilter, null).getTotalElements());
// Find created contract
IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
contractFilter.setIdentity(owner.getId());
List<IdmIdentityContractDto> contracts = contractService.find(contractFilter, null).getContent();
Assert.assertEquals(3, contracts.size());
// Slice with id "2" should be current using and must have work position sets to
// default node
Assert.assertEquals(1, contracts.stream().filter(c -> c.getPosition().equals("2") && c.isValid() && c.getWorkPosition().equals(defaultNode.getId())).count());
Assert.assertTrue(slicesTwo.get(0).isUsingAsContract());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class ContractSliceSyncTest method createContractSlicesEavTest.
/**
* Contract slices EAV use definition from the contracts
*/
@Test
public void createContractSlicesEavTest() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
Assert.assertTrue(config instanceof SysSyncContractConfigDto);
helper.createIdentity(CONTRACT_OWNER_ONE);
helper.createIdentity(CONTRACT_OWNER_TWO);
helper.createIdentity(CONTRACT_LEADER_ONE);
IdmTreeTypeDto treeType = helper.createTreeType();
IdmTreeNodeDto defaultNode = helper.createTreeNode(treeType, null);
helper.createTreeNode(treeType, ContractSliceSyncTest.WORK_POSITION_CODE, null);
((SysSyncContractConfigDto) config).setDefaultTreeType(treeType.getId());
((SysSyncContractConfigDto) config).setDefaultTreeNode(defaultNode.getId());
config = syncConfigService.save(config);
IdmContractSliceFilter contractFilter = new IdmContractSliceFilter();
contractFilter.setProperty(IdmIdentityContract_.position.getName());
contractFilter.setValue("1");
Assert.assertEquals(0, contractSliceService.find(contractFilter, null).getTotalElements());
contractFilter.setValue("2");
Assert.assertEquals(0, contractSliceService.find(contractFilter, null).getTotalElements());
helper.startSynchronization(config);
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 4);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
contractFilter.setValue("1");
List<IdmContractSliceDto> slices = contractSliceService.find(contractFilter, null).getContent();
Assert.assertEquals(1, slices.size());
IdmContractSliceDto slice = slices.get(0);
// Contract slices use EAV definition from the contracts
IdmFormDefinitionDto formDefinition = formService.getDefinition(IdmIdentityContract.class, FormService.DEFAULT_DEFINITION_CODE);
List<IdmFormValueDto> values = formService.getValues(slice, formDefinition, EXTENDED_ATTRIBUTE);
Assert.assertEquals(1, values.size());
Assert.assertEquals(slice.getPosition(), values.get(0).getValue());
// Enable different sync.
config.setDifferentialSync(true);
config = syncConfigService.save(config);
Assert.assertTrue(config.isDifferentialSync());
// Start sync with enable different sync - no change was made, so only ignore update should be made.
helper.startSynchronization(config);
// Three ignored updates
log = helper.checkSyncLog(config, SynchronizationActionType.UPDATE_ENTITY, 4, OperationResultType.IGNORE);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
// Change EAV slice value
formService.saveValues(slice, formDefinition, EXTENDED_ATTRIBUTE, Lists.newArrayList(getHelper().createName()));
// Start sync with enable different sync - EAV value changed, so standard ignore update should be made.
helper.startSynchronization(config);
log = helper.checkSyncLog(config, SynchronizationActionType.UPDATE_ENTITY, 1, OperationResultType.SUCCESS);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
// Delete log
syncLogService.delete(log);
}
Aggregations