use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class TreeNodeCodeGeneratorTest method testAllCombination.
@Test
public void testAllCombination() {
IdmTreeTypeDto type = getHelper().createTreeType();
IdmTreeNodeDto node = new IdmTreeNodeDto();
node.setTreeType(type.getId());
node.setName("ABCDa bc dř Ř ř");
IdmGenerateValueDto generator = this.createGenerator(getDtoType(), getGeneratorType(), null, 1, null);
IdmTreeNodeDto generated = valueGeneratorManager.generate(node);
assertNotNull(generated.getCode());
assertEquals("abcdabcdrrr", generated.getCode());
generatedAttributeService.delete(generator);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class TreeNodeCodeGeneratorTest method testUpperCase.
@Test
public void testUpperCase() {
IdmTreeTypeDto type = getHelper().createTreeType();
IdmTreeNodeDto node = new IdmTreeNodeDto();
node.setTreeType(type.getId());
node.setName("NODE-" + System.currentTimeMillis());
node.setTreeType(type.getId());
IdmGenerateValueDto generator = this.createGenerator(getDtoType(), getGeneratorType(), null, 1, null);
IdmTreeNodeDto generated = valueGeneratorManager.generate(node);
assertNotNull(generated.getCode());
assertEquals(node.getName().toLowerCase(), generated.getCode());
generatedAttributeService.delete(generator);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class TreeNodeCodeGeneratorTest method testGreenLine.
@Test
public void testGreenLine() {
IdmTreeTypeDto type = getHelper().createTreeType();
IdmTreeNodeDto node = new IdmTreeNodeDto();
node.setName("node-" + System.currentTimeMillis());
node.setTreeType(type.getId());
IdmGenerateValueDto generator = this.createGenerator(getDtoType(), getGeneratorType(), null, 1, null);
IdmTreeNodeDto generated = valueGeneratorManager.generate(node);
assertNotNull(generated.getCode());
assertEquals(node.getName(), generated.getCode());
generatedAttributeService.delete(generator);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class DefaultContractByManagerFilterIntegrationTest method testFindSubordinateContractsByTree.
@Test
public void testFindSubordinateContractsByTree() {
// prepare data - one identity two contract but one manager
IdmIdentityDto subordinate = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto managerOne = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto managerTwo = getHelper().createIdentity((GuardedString) null);
// other contracts
IdmIdentityContractDto contractOther = getHelper().getPrimeContract(subordinate);
getHelper().createContractGuarantee(contractOther.getId(), managerOne.getId());
//
IdmTreeTypeDto structure = getHelper().createTreeType();
IdmTreeNodeDto managerOnePosition = getHelper().createTreeNode(structure, null);
getHelper().createContract(managerOne, managerOnePosition);
IdmTreeNodeDto managerTwoPosition = getHelper().createTreeNode(structure, null);
getHelper().createContract(managerTwo, managerTwoPosition);
//
IdmTreeNodeDto subordinateOnePositionOne = getHelper().createTreeNode(structure, managerOnePosition);
IdmTreeNodeDto subordinateOnePositionTwo = getHelper().createTreeNode(structure, managerTwoPosition);
IdmIdentityContractDto contractOne = getHelper().createContract(subordinate, subordinateOnePositionOne);
IdmIdentityContractDto contractTwo = getHelper().createContract(subordinate, subordinateOnePositionTwo);
//
IdmIdentityContractFilter filter = new IdmIdentityContractFilter();
filter.setIncludeGuarantees(false);
filter.setSubordinatesFor(managerOne.getId());
List<IdmIdentityContract> managedContracts = builder.find(filter, null).getContent();
Assert.assertEquals(1, managedContracts.size());
Assert.assertEquals(contractOne.getId(), managedContracts.get(0).getId());
//
filter.setSubordinatesFor(managerTwo.getId());
managedContracts = builder.find(filter, null).getContent();
Assert.assertEquals(1, managedContracts.size());
Assert.assertEquals(contractTwo.getId(), managedContracts.get(0).getId());
//
filter.setIncludeGuarantees(true);
filter.setSubordinatesFor(managerOne.getId());
managedContracts = builder.find(filter, null).getContent();
Assert.assertEquals(2, managedContracts.size());
Assert.assertTrue(managedContracts.stream().anyMatch(c -> c.getId().equals(contractOther.getId())));
Assert.assertTrue(managedContracts.stream().anyMatch(c -> c.getId().equals(contractOne.getId())));
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeTypeDto in project CzechIdMng by bcvsolutions.
the class IdmTreeNodeControllerRestTest method testFindByDefaultTreeType.
@Test
@Transactional
public void testFindByDefaultTreeType() {
String code = getHelper().createName();
IdmTreeNodeDto nodeDefault;
try {
getHelper().loginAdmin();
//
IdmTreeTypeDto defaultTreeType = getHelper().getDefaultTreeType();
IdmTreeTypeDto treeTypeTwo = getHelper().createTreeType();
//
nodeDefault = getHelper().createTreeNode(defaultTreeType, code, null);
// other
getHelper().createTreeNode(treeTypeTwo, code, null);
} finally {
getHelper().logout();
}
IdmTreeNodeFilter filter = new IdmTreeNodeFilter();
filter.setDefaultTreeType(true);
filter.setCode(code);
List<IdmTreeNodeDto> results = find(filter);
//
Assert.assertEquals(1, results.size());
Assert.assertEquals(nodeDefault, results.get(0));
}
Aggregations