use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmAutomaticRoleRequestServiceIntegrationTest method testCreateTreeAutomaticRoleWithApproval.
@Test
public void testCreateTreeAutomaticRoleWithApproval() {
IdmRoleDto role = prepareRole();
IdmTreeNodeDto nodeOne = helper.createTreeNode();
IdmIdentityDto guaranteeIdentity = helper.createIdentity();
IdmRoleGuaranteeDto guarantee = new IdmRoleGuaranteeDto();
guarantee.setRole(role.getId());
guarantee.setGuarantee(guaranteeIdentity.getId());
role.getGuarantees().add(guarantee);
role = roleService.save(role);
IdmRoleTreeNodeDto automaticRole = new IdmRoleTreeNodeDto();
automaticRole.setRole(role.getId());
automaticRole.setName(role.getName());
automaticRole.setTreeNode(nodeOne.getId());
// Create automatic role via manager
try {
automaticRole = automaticRoleManager.createAutomaticRoleByTree(automaticRole, false);
} catch (AcceptedException ex) {
// The request is in approval
Assert.assertNotNull(ex.getIdentifier());
UUID requestId = UUID.fromString(ex.getIdentifier());
loginAsNoAdmin(guaranteeIdentity.getUsername());
try {
completeTasksFromUsers(guaranteeIdentity.getUsername(), "approve");
} catch (ResultCodeException e) {
fail("User has permission to approve task. Error message: " + e.getLocalizedMessage());
} catch (Exception e) {
fail("Some problem: " + e.getLocalizedMessage());
}
IdmAutomaticRoleRequestDto request = roleRequestService.get(requestId);
Assert.assertEquals(RequestState.EXECUTED, request.getState());
Assert.assertNotNull(request.getAutomaticRole());
IdmRoleTreeNodeDto treeAutomaticRole = roleTreeNodeService.get(request.getAutomaticRole());
Assert.assertNotNull(treeAutomaticRole);
Assert.assertEquals(nodeOne.getId(), treeAutomaticRole.getTreeNode());
Assert.assertEquals(role.getId(), treeAutomaticRole.getRole());
return;
}
fail("Automatic role request have to be approving by gurantee!");
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method externeFilterTest.
@Test
public void externeFilterTest() {
IdmIdentityDto identity = helper.createIdentity();
IdmIdentityDto identity2 = helper.createIdentity();
IdmTreeNodeDto node = helper.createTreeNode();
IdmTreeNodeDto node2 = helper.createTreeNode();
IdmIdentityContractDto contract = helper.createIdentityContact(identity, node);
IdmIdentityContractDto contract2 = helper.createIdentityContact(identity2, node2);
contract.setExterne(true);
service.save(contract);
contract2.setExterne(false);
service.save(contract2);
IdmIdentityContractFilter filter = new IdmIdentityContractFilter();
filter.setExterne(true);
Page<IdmIdentityContractDto> result = service.find(filter, null);
assertTrue(result.getContent().contains(contract));
assertFalse(result.getContent().contains(contract2));
filter.setExterne(false);
result = service.find(filter, null);
assertTrue(result.getContent().contains(contract2));
assertFalse(result.getContent().contains(contract));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method datesValidFilterTest.
@Test
public void datesValidFilterTest() {
IdmIdentityDto identity = helper.createIdentity();
IdmIdentityDto identity2 = helper.createIdentity();
IdmIdentityDto identity3 = helper.createIdentity();
IdmIdentityDto identity4 = helper.createIdentity();
IdmTreeNodeDto node = helper.createTreeNode();
IdmTreeNodeDto node2 = helper.createTreeNode();
IdmTreeNodeDto node3 = helper.createTreeNode();
IdmTreeNodeDto node4 = helper.createTreeNode();
IdmIdentityContractDto contract = helper.createIdentityContact(identity, node, org.joda.time.LocalDate.now(), org.joda.time.LocalDate.parse("2021-06-05"));
IdmIdentityContractDto contract2 = helper.createIdentityContact(identity2, node2, org.joda.time.LocalDate.now(), org.joda.time.LocalDate.parse("2020-05-05"));
IdmIdentityContractDto contract3 = helper.createIdentityContact(identity3, node3, org.joda.time.LocalDate.now(), org.joda.time.LocalDate.parse("2016-05-05"));
IdmIdentityContractDto contract4 = helper.createIdentityContact(identity4, node4, org.joda.time.LocalDate.parse("2018-05-05"), org.joda.time.LocalDate.parse("2025-05-05"));
IdmIdentityContractFilter filter = new IdmIdentityContractFilter();
filter.setValidFrom(contract.getValidFrom());
Page<IdmIdentityContractDto> result = service.find(filter, null);
assertTrue(result.getContent().contains(contract));
filter.setValidFrom(null);
filter.setValidTill(contract2.getValidTill());
result = service.find(filter, null);
assertTrue(result.getContent().contains(contract2));
filter.setValidTill(null);
filter.setValid(true);
result = service.find(filter, null);
assertTrue(result.getContent().contains(contract));
assertTrue(result.getContent().contains(contract2));
assertFalse(result.getContent().contains(contract3));
filter.setValid(null);
filter.setValidNowOrInFuture(true);
result = service.find(filter, null);
assertTrue(result.getContent().contains(contract4));
filter.setValidNowOrInFuture(false);
result = service.find(filter, null);
assertTrue(result.getContent().contains(contract3));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method testReferentialIntegrityOnTreeNode.
@Test
public void testReferentialIntegrityOnTreeNode() {
helper.setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, false);
try {
// prepare data
IdmRoleDto role = helper.createRole();
IdmTreeNodeDto treeNode = helper.createTreeNode();
// automatic role
IdmRoleTreeNodeDto roleTreeNode = helper.createRoleTreeNode(role, treeNode, false);
//
assertNotNull(roleTreeNode.getId());
assertEquals(roleTreeNode.getId(), roleTreeNodeService.get(roleTreeNode.getId()).getId());
//
helper.deleteTreeNode(treeNode.getId());
//
assertNull(roleTreeNodeService.get(roleTreeNode.getId()));
} finally {
helper.setConfigurationValue(SchedulerConfiguration.PROPERTY_TASK_ASYNCHRONOUS_ENABLED, true);
}
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultIdmIdentityContractServiceIntegrationTest method textFilterTest.
@Test
public void textFilterTest() {
IdmIdentityDto identity = helper.createIdentity();
IdmIdentityDto identity2 = helper.createIdentity();
IdmIdentityDto identity3 = helper.createIdentity();
IdmIdentityDto identity4 = helper.createIdentity();
IdmTreeNodeDto node = helper.createTreeNode();
node.setName("Position105");
treeNodeService.save(node);
IdmTreeNodeDto node2 = helper.createTreeNode();
node2.setName("Position006");
treeNodeService.save(node2);
IdmTreeNodeDto node3 = helper.createTreeNode();
node3.setCode("Position007");
treeNodeService.save(node3);
IdmTreeNodeDto node4 = helper.createTreeNode();
node4.setCode("Position108");
treeNodeService.save(node4);
IdmIdentityContractDto contract = helper.createIdentityContact(identity, node);
IdmIdentityContractDto contract2 = helper.createIdentityContact(identity2, node2);
IdmIdentityContractDto contract3 = helper.createIdentityContact(identity3, node3);
IdmIdentityContractDto contract4 = helper.createIdentityContact(identity4, node4);
contract.setPosition("Position001");
contract = service.save(contract);
contract2.setPosition("Position102");
service.save(contract2);
contract3.setPosition("Position103");
service.save(contract3);
contract4.setPosition("Position104");
service.save(contract4);
IdmIdentityContractFilter filter = new IdmIdentityContractFilter();
filter.setText("Position00");
Page<IdmIdentityContractDto> result = service.find(filter, null);
assertEquals("Wrong Text", 3, result.getTotalElements());
assertTrue(result.getContent().contains(contract));
assertTrue(result.getContent().contains(contract2));
assertTrue(result.getContent().contains(contract3));
}
Aggregations