use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class DefaultFormServiceIntegrationTest method testFindTreeNodesByNullTextAttributeValue.
@Test
public void testFindTreeNodesByNullTextAttributeValue() {
IdmTreeNodeDto owner = getHelper().createTreeNode();
//
IdmFormAttributeDto attribute = new IdmFormAttributeDto();
attribute.setCode(getHelper().createName());
attribute.setName(attribute.getCode());
attribute.setPersistentType(PersistentType.TEXT);
IdmFormDefinitionDto formDefinitionOne = formService.createDefinition(IdmTreeNode.class.getCanonicalName(), getHelper().createName(), Lists.newArrayList(attribute));
attribute = formDefinitionOne.getMappedAttributeByCode(attribute.getCode());
// save values
formService.saveValues(owner.getId(), IdmTreeNode.class, attribute, Lists.newArrayList(FORM_VALUE_ONE));
//
Page<? extends Identifiable> owners = formService.findOwners(IdmTreeNode.class, attribute, FORM_VALUE_ONE, null);
//
assertEquals(1, owners.getTotalElements());
assertEquals(owner.getId(), owners.getContent().get(0).getId());
//
owners = formService.findOwners(IdmTreeNode.class, attribute, null, null);
assertEquals(0, owners.getTotalElements());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdmContractPositionControllerRestTest method testFilterByWorkPosition.
@Test
public void testFilterByWorkPosition() {
IdmIdentityDto identity = getHelper().createIdentity();
IdmIdentityContractDto primeContract = getHelper().getPrimeContract(identity);
//
IdmTreeNodeDto treeNodeOne = getHelper().createTreeNode();
IdmContractPositionDto dtoOne = createDto(new IdmContractPositionDto(primeContract.getId(), treeNodeOne.getId()));
// other
createDto(new IdmContractPositionDto(primeContract.getId(), getHelper().createTreeNode().getId()));
//
IdmContractPositionFilter filter = new IdmContractPositionFilter();
filter.setWorkPosition(treeNodeOne.getId());
//
List<IdmContractPositionDto> results = find(filter);
//
Assert.assertEquals(1, results.size());
Assert.assertEquals(dtoOne.getId(), results.get(0).getId());
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class TreeNodeAndTypeRestTest method testCreateRootNodeTwice.
@Test
public void testCreateRootNodeTwice() {
IdmTreeTypeDto type = getHelper().createTreeType();
IdmTreeNodeDto root = new IdmTreeNodeDto();
root.setCode(getHelper().createName());
root.setName(getHelper().createName());
root.setTreeType(type.getId());
// save first root
Exception ex = null;
try {
treeNodeService.save(root);
} catch (Exception e) {
ex = e;
}
assertNull(ex);
// save second root, same type
Map<String, String> body = new HashMap<>();
body.put("code", getHelper().createName());
body.put("name", getHelper().createName());
body.put("treeType", type.getId().toString());
String jsonContent = toJson(body);
ex = null;
int status = 0;
try {
status = getMockMvc().perform(post(BaseDtoController.BASE_PATH + "/tree-nodes").with(authentication(getAdminAuthentication())).content(jsonContent).contentType(MediaType.APPLICATION_JSON)).andReturn().getResponse().getStatus();
} catch (Exception e) {
ex = e;
}
assertNull(ex);
assertEquals(201, status);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class ChangesOnSystemReportIntegrationTest method testProvisioningOperationReportWithChanges.
@Test
public void testProvisioningOperationReportWithChanges() throws IOException {
IdmIdentityDto identityOne = getHelper().createIdentity((GuardedString) null);
IdmIdentityDto identityTwo = getHelper().createIdentity((GuardedString) null);
IdmTreeNodeDto position = getHelper().createTreeNode();
getHelper().createContract(identityTwo, position);
SysSystemDto system = createSystemWithOperation();
SysSystemMappingDto defaultMapping = getHelper().getDefaultMapping(system);
IdmRoleDto role = getHelper().createRole();
getHelper().createRoleSystem(role, system);
getHelper().createIdentityRole(identityTwo, role);
//
AccAccountFilter accountFilter = new AccAccountFilter();
accountFilter.setIdentityId(identityTwo.getId());
accountFilter.setSystemId(system.getId());
accountFilter.setEntityType(SystemEntityType.IDENTITY);
List<AccAccountDto> accounts = accountService.find(accountFilter, null).getContent();
Assert.assertEquals(1, accounts.size());
//
// change => readonly system
system.setDisabledProvisioning(true);
system.setReadonly(true);
system = systemService.save(system);
identityTwo.setLastName(getHelper().createName());
identityTwo = identityService.save(identityTwo);
system.setDisabledProvisioning(false);
system.setReadonly(false);
system = systemService.save(system);
//
// prepare report filter
RptReportDto report = new RptReportDto(UUID.randomUUID());
report.setExecutorName(reportExecutor.getName());
IdmFormDto filter = new IdmFormDto();
IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
IdmFormValueDto filterValue = new IdmFormValueDto(definition.getMappedAttributeByCode(ChangesOnSystemReportExecutor.PARAMETER_MAPPING_ATTRIBUTES));
// TODO: create json java POJO representation
filterValue.setStringValue("{ \"system\": \"" + system.getId() + "\", \"systemMapping\": \"" + defaultMapping.getId() + "\", \"mappingAttributes\": [ ] }");
filter.getValues().add(filterValue);
IdmFormValueDto filterIdentitites = new IdmFormValueDto(definition.getMappedAttributeByCode(ChangesOnSystemReportExecutor.PARAMETER_ONLY_IDENTITY));
filterIdentitites.setUuidValue(identityOne.getId());
filter.getValues().add(filterIdentitites);
IdmFormValueDto filterTreeNode = new IdmFormValueDto(definition.getMappedAttributeByCode(ChangesOnSystemReportExecutor.PARAMETER_TREE_NODE));
filterTreeNode.setUuidValue(position.getId());
filter.getValues().add(filterTreeNode);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
//
// generate report
report = reportExecutor.generate(report);
Assert.assertNotNull(report.getData());
//
// test renderer
Assert.assertNotNull(xlsxRenderer.render(report));
//
attachmentManager.deleteAttachments(report);
}
use of eu.bcvsolutions.idm.core.api.dto.IdmTreeNodeDto in project CzechIdMng by bcvsolutions.
the class IdentityRoleByIdentityDeduplicationExecutorTest method testExecuteReportOneContractMoreRolesWithValidity.
@Test
public void testExecuteReportOneContractMoreRolesWithValidity() throws JsonParseException, JsonMappingException, IOException {
String roleCode = "test-" + System.currentTimeMillis();
IdmTreeNodeDto treeNode = getHelper().createTreeNode();
IdmIdentityDto identity = getHelper().createIdentity(new GuardedString());
IdmIdentityContractDto contact = getHelper().createContract(identity, treeNode);
IdmRoleDto role = getHelper().createRole(roleCode);
getHelper().createIdentityRole(contact, role, LocalDate.now().minusDays(40), LocalDate.now().plusDays(40));
getHelper().createIdentityRole(contact, role, LocalDate.now().minusDays(30), LocalDate.now().plusDays(30));
getHelper().createIdentityRole(contact, role, LocalDate.now().minusDays(20), LocalDate.now().plusDays(20));
getHelper().createIdentityRole(contact, role, LocalDate.now().minusDays(10), LocalDate.now().plusDays(10));
RptReportDto report = new RptReportDto(UUID.randomUUID());
report.setExecutorName(reportExecutor.getName());
IdmFormDto filter = new IdmFormDto();
IdmFormDefinitionDto definition = reportExecutor.getFormDefinition();
IdmFormValueDto treeNodeParameter = new IdmFormValueDto(definition.getMappedAttributeByCode(IdentityRoleByIdentityDeduplicationExecutor.PARAMETER_TREE_NODE));
treeNodeParameter.setValue(treeNode.getId());
filter.getValues().add(treeNodeParameter);
filter.setFormDefinition(definition.getId());
report.setFilter(filter);
report = reportExecutor.generate(report);
Assert.assertNotNull(report.getData());
List<RptIdentityRoleByRoleDeduplicationDto> reportItems = mapper.readValue(attachmentManager.getAttachmentData(report.getData()), new TypeReference<List<RptIdentityRoleByRoleDeduplicationDto>>() {
});
assertEquals(1, reportItems.size());
RptIdentityRoleByRoleDeduplicationDto item = reportItems.get(0);
List<RptIdentityRoleByRoleDeduplicationDuplicityDto> duplicities = item.getDuplicity();
assertEquals(3, duplicities.size());
for (RptIdentityRoleByRoleDeduplicationDuplicityDto duplicity : duplicities) {
assertEquals(role.getId(), duplicity.getRole().getId());
if (duplicity.getValidTill().isEqual(duplicity.getValidFrom())) {
fail();
}
if (!duplicity.getValidTill().isBefore(LocalDate.now().plusDays(35))) {
fail();
}
if (!duplicity.getValidFrom().isAfter(LocalDate.now().minusDays(35))) {
fail();
}
}
attachmentManager.deleteAttachments(report);
}
Aggregations