use of eu.bcvsolutions.idm.core.api.dto.filter.IdmContractPositionFilter in project CzechIdMng by bcvsolutions.
the class IdmContractPositionControllerRestTest method testFilterByContract.
@Test
public void testFilterByContract() {
IdmIdentityDto identity = getHelper().createIdentity();
IdmIdentityContractDto primeContract = getHelper().getPrimeContract(identity);
IdmIdentityContractDto otherContract = getHelper().createContract(identity);
//
IdmContractPositionDto dtoOne = createDto(new IdmContractPositionDto(primeContract.getId(), null));
// other
createDto(new IdmContractPositionDto(otherContract.getId(), null));
//
IdmContractPositionFilter filter = new IdmContractPositionFilter();
filter.setIdentityContractId(primeContract.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.filter.IdmContractPositionFilter 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.filter.IdmContractPositionFilter in project CzechIdMng by bcvsolutions.
the class DefaultIdmContractPositionService method findAllByWorkPosition.
@Override
@Transactional(readOnly = true)
public List<IdmContractPositionDto> findAllByWorkPosition(UUID workPositionId, RecursionType recursionType) {
Assert.notNull(workPositionId, "Work position is required to get related contracts.");
//
IdmContractPositionFilter filter = new IdmContractPositionFilter();
filter.setWorkPosition(workPositionId);
filter.setRecursionType(recursionType);
//
return find(filter, null).getContent();
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmContractPositionFilter in project CzechIdMng by bcvsolutions.
the class IdentityContractSyncTest method testContractPositions.
@Test
public void testContractPositions() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
Assert.assertTrue(config instanceof SysSyncContractConfigDto);
helper.createIdentity(CONTRACT_OWNER_THREE);
// 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());
config = syncConfigService.save(configContract);
IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
contractFilter.setProperty(IdmIdentityContract_.position.getName());
// Set work positions to resources
this.getBean().initContractPositionTest();
// Start sync again (we want to see some work positions)
helper.startSynchronization(config);
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 1);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
// For contract One must be found workposition (one)
contractFilter.setValue("1");
IdmIdentityContractDto contractOne = contractService.find(contractFilter, null).getContent().get(0);
Assert.assertNotNull(contractOne);
//
IdmContractPositionFilter positionFitler = new IdmContractPositionFilter();
positionFitler.setIdentityContractId(contractOne.getId());
List<IdmContractPositionDto> positions = contractPositionService.find(positionFitler, null).getContent();
Assert.assertEquals(1, positions.size());
Assert.assertEquals("one", DtoUtils.getEmbedded(positions.get(0), IdmContractPosition_.workPosition, IdmTreeNodeDto.class).getCode());
// Delete log
syncLogService.delete(log);
}
use of eu.bcvsolutions.idm.core.api.dto.filter.IdmContractPositionFilter in project CzechIdMng by bcvsolutions.
the class IdentityContractSyncTest method testDifferentSyncChangePositions.
@Test
public void testDifferentSyncChangePositions() {
SysSystemDto system = initData();
Assert.assertNotNull(system);
AbstractSysSyncConfigDto config = doCreateSyncConfig(system);
Assert.assertTrue(config instanceof SysSyncContractConfigDto);
helper.createIdentity(CONTRACT_OWNER_THREE);
// 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());
config = syncConfigService.save(configContract);
IdmIdentityContractFilter contractFilter = new IdmIdentityContractFilter();
contractFilter.setProperty(IdmIdentityContract_.position.getName());
// Set work positions to resources
this.getBean().initContractPositionTest();
helper.startSynchronization(config);
SysSyncLogDto log = checkSyncLog(config, SynchronizationActionType.CREATE_ENTITY, 1);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
// For contract One must be found workposition (one)
contractFilter.setValue("1");
IdmIdentityContractDto contractOne = contractService.find(contractFilter, null).getContent().get(0);
Assert.assertNotNull(contractOne);
IdmContractPositionFilter positionFitler = new IdmContractPositionFilter();
positionFitler.setIdentityContractId(contractOne.getId());
List<IdmContractPositionDto> positions = contractPositionService.find(positionFitler, null).getContent();
Assert.assertEquals(1, positions.size());
Assert.assertEquals("one", DtoUtils.getEmbedded(positions.get(0), IdmContractPosition_.workPosition, IdmTreeNodeDto.class).getCode());
// Enable different sync.
config.setDifferentialSync(true);
config = syncConfigService.save(config);
Assert.assertTrue(config.isDifferentialSync());
// Start sync with enable different sync - no change was made on so only ignore update should be made.
helper.startSynchronization(config);
log = helper.checkSyncLog(config, SynchronizationActionType.UPDATE_ENTITY, 1, OperationResultType.IGNORE);
Assert.assertFalse(log.isRunning());
Assert.assertFalse(log.isContainsError());
// Delete position name
contractPositionService.delete(positions.get(0));
// Start sync with enable different sync - position name was changed, standard 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());
// For contract One must be found workposition (one)
contractFilter.setValue("1");
contractOne = contractService.find(contractFilter, null).getContent().get(0);
Assert.assertNotNull(contractOne);
positionFitler = new IdmContractPositionFilter();
positionFitler.setIdentityContractId(contractOne.getId());
positions = contractPositionService.find(positionFitler, null).getContent();
Assert.assertEquals(1, positions.size());
Assert.assertEquals("one", DtoUtils.getEmbedded(positions.get(0), IdmContractPosition_.workPosition, IdmTreeNodeDto.class).getCode());
// Delete log
syncLogService.delete(log);
}
Aggregations