Search in sources :

Example 66 with SysSyncLogDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncLogDto in project CzechIdMng by bcvsolutions.

the class ContractSliceSyncTest method createContractBySliceTest.

@Test
public void createContractBySliceTest() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
    Assert.assertTrue(config instanceof SysSyncContractConfigDto);
    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");
    Assert.assertEquals(1, contractSliceService.find(contractSliceFilter, null).getTotalElements());
    contractSliceFilter.setValue("2");
    List<IdmContractSliceDto> slicesTwo = contractSliceService.find(contractSliceFilter, null).getContent();
    Assert.assertEquals(1, slicesTwo.size());
    contractSliceFilter.setValue("3");
    List<IdmContractSliceDto> contractsThree = contractSliceService.find(contractSliceFilter, null).getContent();
    Assert.assertEquals(1, contractsThree.size());
    Assert.assertEquals(null, contractsThree.get(0).getState());
    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
    Assert.assertEquals(1, contracts.stream().filter(c -> c.getPosition().equals("2") && c.isValid()).count());
    Assert.assertTrue(slicesTwo.get(0).isUsingAsContract());
    // Delete log
    syncLogService.delete(log);
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmContractSliceFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmContractSliceFilter) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) IdmContractSliceDto(eu.bcvsolutions.idm.core.api.dto.IdmContractSliceDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 67 with SysSyncLogDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncLogDto in project CzechIdMng by bcvsolutions.

the class IdentityContractSyncTest method checkContractDisableTest.

@Test
public void checkContractDisableTest() {
    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);
    IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
    contractFilter.setProperty(IdmIdentityContract_.position.getName());
    contractFilter.setValue("1");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    contractFilter.setValue("2");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    // Change resources (set state on disable) .. must be call in
    // transaction
    this.getBean().initContractCheckDisableTest();
    helper.startSynchronization(config);
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    contractFilter.setValue("1");
    List<IdmIdentityContractDto> contractsOne = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsOne.size());
    Assert.assertEquals(ContractState.DISABLED, contractsOne.get(0).getState());
    contractFilter.setValue("2");
    List<IdmIdentityContractDto> contractsTwo = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsTwo.size());
    Assert.assertEquals(null, contractsTwo.get(0).getState());
    contractFilter.setValue("3");
    List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsThree.size());
    Assert.assertEquals(ContractState.DISABLED, contractsThree.get(0).getState());
    // Delete log
    syncLogService.delete(log);
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 68 with SysSyncLogDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncLogDto in project CzechIdMng by bcvsolutions.

the class IdentityContractSyncTest method createContractTest.

@Test
public void createContractTest() {
    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);
    IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
    contractFilter.setProperty(IdmIdentityContract_.position.getName());
    contractFilter.setValue("1");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    contractFilter.setValue("2");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    helper.startSynchronization(config);
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    contractFilter.setValue("1");
    Assert.assertEquals(1, contractService.find(contractFilter, null).getTotalElements());
    contractFilter.setValue("2");
    List<IdmIdentityContractDto> contractsTwo = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsTwo.size());
    contractFilter.setValue("3");
    List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsThree.size());
    Assert.assertEquals(null, contractsThree.get(0).getState());
    // Delete log
    syncLogService.delete(log);
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 69 with SysSyncLogDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncLogDto in project CzechIdMng by bcvsolutions.

the class IdentityContractSyncTest method checkContractInvalidWithStartHrProcessesTest.

@Test
public /**
 * HR process are not executed during sync, but after sync end.
 */
void checkContractInvalidWithStartHrProcessesTest() {
    SysSystemDto system = initData();
    Assert.assertNotNull(system);
    AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
    Assert.assertTrue(config instanceof SysSyncContractConfigDto);
    ((SysSyncContractConfigDto) config).setStartOfHrProcesses(true);
    syncConfigService.save(config);
    Task task = findTask(HrEnableContractProcess.class);
    IdmScheduledTaskDto scheduledTask = null;
    if (scheduledService.findByQuartzTaskName(task.getId()) == null) {
        scheduledTask = new IdmScheduledTaskDto();
        scheduledTask.setQuartzTaskName(task.getId());
        scheduledService.save(scheduledTask);
    }
    task = findTask(HrEndContractProcess.class);
    if (scheduledService.findByQuartzTaskName(task.getId()) == null) {
        scheduledTask = new IdmScheduledTaskDto();
        scheduledTask.setQuartzTaskName(task.getId());
        scheduledService.save(scheduledTask);
    }
    task = findTask(HrContractExclusionProcess.class);
    if (scheduledService.findByQuartzTaskName(task.getId()) == null) {
        scheduledTask = new IdmScheduledTaskDto();
        scheduledTask.setQuartzTaskName(task.getId());
        scheduledService.save(scheduledTask);
    }
    IdmIdentityDto ownerOne = helper.createIdentity(CONTRACT_OWNER_ONE);
    IdmIdentityDto ownerTwo = helper.createIdentity(CONTRACT_OWNER_TWO);
    helper.createIdentity(CONTRACT_LEADER_ONE);
    contractService.findAllByIdentity(ownerOne.getId()).forEach(contract -> {
        IdentityContractEvent event = new IdentityContractEvent(IdentityContractEventType.DELETE, contract);
        event.getProperties().put(IdmIdentityContractService.SKIP_HR_PROCESSES, Boolean.TRUE);
        contractService.publish(event);
    });
    contractService.findAllByIdentity(ownerTwo.getId()).forEach(contract -> {
        IdentityContractEvent event = new IdentityContractEvent(IdentityContractEventType.DELETE, contract);
        event.getProperties().put(IdmIdentityContractService.SKIP_HR_PROCESSES, Boolean.TRUE);
        contractService.publish(event);
    });
    IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
    contractFilter.setProperty(IdmIdentityContract_.position.getName());
    contractFilter.setValue("1");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    contractFilter.setValue("2");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    // Change resources (set to invalid) .. must be call in transaction
    this.getBean().initContractCheckInvalidTest();
    helper.startSynchronization(config);
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 2);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    contractFilter.setValue("1");
    List<IdmIdentityContractDto> contractsOne = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsOne.size());
    Assert.assertFalse(contractsOne.get(0).isValid());
    contractFilter.setValue("3");
    List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsThree.size());
    Assert.assertTrue(contractsThree.get(0).isValid());
    // HR processes was started, identity have to be in "correct" state
    ownerOne = identityService.getByUsername(CONTRACT_OWNER_ONE);
    Assert.assertTrue(ownerOne.isDisabled());
    ownerTwo = identityService.getByUsername(CONTRACT_OWNER_TWO);
    Assert.assertFalse(ownerTwo.isDisabled());
    // Delete log
    syncLogService.delete(log);
}
Also used : Task(eu.bcvsolutions.idm.core.scheduler.api.dto.Task) HrEndContractProcess(eu.bcvsolutions.idm.core.scheduler.task.impl.hr.HrEndContractProcess) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmScheduledTaskDto(eu.bcvsolutions.idm.core.scheduler.api.dto.IdmScheduledTaskDto) HrContractExclusionProcess(eu.bcvsolutions.idm.core.scheduler.task.impl.hr.HrContractExclusionProcess) IdentityContractEvent(eu.bcvsolutions.idm.core.model.event.IdentityContractEvent) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Example 70 with SysSyncLogDto

use of eu.bcvsolutions.idm.acc.dto.SysSyncLogDto in project CzechIdMng by bcvsolutions.

the class IdentityContractSyncTest method checkContractExcludeTest.

@Test
public void checkContractExcludeTest() {
    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);
    IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
    contractFilter.setProperty(IdmIdentityContract_.position.getName());
    contractFilter.setValue("1");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    contractFilter.setValue("2");
    Assert.assertEquals(0, contractService.find(contractFilter, null).getTotalElements());
    // Change resources (set state on exclude) .. must be call in
    // transaction
    this.getBean().initContractCheckExcludeTest();
    helper.startSynchronization(config);
    SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 3);
    Assert.assertFalse(log.isRunning());
    Assert.assertFalse(log.isContainsError());
    contractFilter.setValue("1");
    Assert.assertEquals(1, contractService.find(contractFilter, null).getTotalElements());
    contractFilter.setValue("2");
    List<IdmIdentityContractDto> contractsTwo = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsTwo.size());
    Assert.assertEquals(null, contractsTwo.get(0).getState());
    contractFilter.setValue("3");
    List<IdmIdentityContractDto> contractsThree = contractService.find(contractFilter, null).getContent();
    Assert.assertEquals(1, contractsThree.size());
    Assert.assertEquals(ContractState.EXCLUDED, contractsThree.get(0).getState());
    // Delete log
    syncLogService.delete(log);
}
Also used : AbstractSysSyncConfigDto(eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto) SysSyncContractConfigDto(eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto) IdmIdentityContractFilter(eu.bcvsolutions.idm.core.api.dto.filter.IdmIdentityContractFilter) IdmIdentityContractDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto) SysSystemDto(eu.bcvsolutions.idm.acc.dto.SysSystemDto) SysSyncLogDto(eu.bcvsolutions.idm.acc.dto.SysSyncLogDto) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

SysSyncLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncLogDto)170 Test (org.junit.Test)141 SysSystemDto (eu.bcvsolutions.idm.acc.dto.SysSystemDto)129 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)129 AbstractSysSyncConfigDto (eu.bcvsolutions.idm.acc.dto.AbstractSysSyncConfigDto)98 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)83 SysSyncIdentityConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncIdentityConfigDto)55 IdmRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmRoleDto)54 SysSyncActionLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncActionLogDto)53 DefaultSynchronizationServiceTest (eu.bcvsolutions.idm.acc.service.impl.DefaultSynchronizationServiceTest)50 SysSyncLogFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncLogFilter)48 IdmIdentityContractDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityContractDto)45 SysSyncItemLogDto (eu.bcvsolutions.idm.acc.dto.SysSyncItemLogDto)44 SysSystemMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemMappingDto)40 SysSyncConfigFilter (eu.bcvsolutions.idm.acc.dto.filter.SysSyncConfigFilter)40 SysSystemAttributeMappingDto (eu.bcvsolutions.idm.acc.dto.SysSystemAttributeMappingDto)39 IdmIdentityRoleDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityRoleDto)36 SysSyncContractConfigDto (eu.bcvsolutions.idm.acc.dto.SysSyncContractConfigDto)34 GuardedString (eu.bcvsolutions.idm.core.security.api.domain.GuardedString)33 UUID (java.util.UUID)33