use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.
the class VsReqeustServiceTest method changeUidTest.
@Test
public void changeUidTest() {
SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
IdmIdentityDto userOne = helper.createIdentity(USER_ONE_NAME);
identityService.save(userOne);
this.assignRoleSystem(system, userOne, ROLE_ONE_NAME);
// Find created requests
VsRequestFilter requestFilter = new VsRequestFilter();
requestFilter.setSystemId(system.getId());
requestFilter.setUid(USER_ONE_NAME);
requestFilter.setState(VsRequestState.IN_PROGRESS);
List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(1, requests.size());
VsRequestDto createRequest = requests.get(0);
Assert.assertEquals(USER_ONE_NAME, createRequest.getUid());
Assert.assertEquals(VsOperationType.CREATE, createRequest.getOperationType());
Assert.assertEquals(VsRequestState.IN_PROGRESS, createRequest.getState());
VsConnectorObjectDto wish = requestService.getWishConnectorObject(createRequest);
boolean findAttributeWithouChange = wish.getAttributes().stream().filter(attribute -> !attribute.isChanged()).findFirst().isPresent();
Assert.assertTrue(!findAttributeWithouChange);
// Change username attributes
userOne.setUsername(USER_ONE_CHANGED_NAME);
// Invoke provisioning
identityService.save(userOne);
requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(2, requests.size());
// We realize the create request
super.logout();
loginService.login(new LoginDto(USER_IMPLEMENTER_NAME, new GuardedString("password")));
requestService.realize(createRequest);
requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(1, requests.size());
// get wish
wish = requestService.getWishConnectorObject(requests.get(0));
Assert.assertEquals(1, wish.getAttributes().stream().filter(attr -> attr.isChanged()).count());
// Find change for firstName value
boolean findCorrectChangedUserName = wish.getAttributes().stream().filter(attr -> attr.getValue().getValue().equals(USER_ONE_CHANGED_NAME) && attr.getValue().getOldValue().equals(USER_ONE_NAME) && VsValueChangeType.UPDATED == attr.getValue().getChange()).findFirst().isPresent();
Assert.assertTrue(findCorrectChangedUserName);
SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
systemEntityFilter.setSystemId(system.getId());
systemEntityFilter.setUid(USER_ONE_NAME);
boolean oldUserNameExist = !systemEntityService.find(systemEntityFilter, null).getContent().isEmpty();
Assert.assertTrue(oldUserNameExist);
// Realize change username
requestService.realize(requests.get(0));
// We expects change UID in SystemEntity.UID
oldUserNameExist = !systemEntityService.find(systemEntityFilter, null).getContent().isEmpty();
Assert.assertTrue(!oldUserNameExist);
systemEntityFilter.setUid(USER_ONE_CHANGED_NAME);
boolean changedUserNameExist = !systemEntityService.find(systemEntityFilter, null).getContent().isEmpty();
Assert.assertTrue(changedUserNameExist);
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.
the class DefaultSynchronizationService method findSystemEntity.
private SysSystemEntityDto findSystemEntity(String uid, SysSystemDto system, SystemEntityType entityType) {
SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
systemEntityFilter.setEntityType(entityType);
systemEntityFilter.setSystemId(system.getId());
systemEntityFilter.setUid(uid);
List<SysSystemEntityDto> systemEntities = systemEntityService.find(systemEntityFilter, null).getContent();
SysSystemEntityDto systemEntity = null;
if (systemEntities.size() == 1) {
systemEntity = systemEntities.get(0);
} else if (systemEntities.size() > 1) {
throw new ProvisioningException(AccResultCode.SYNCHRONIZATION_TO_MANY_SYSTEM_ENTITY, uid);
}
return systemEntity;
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemEntityServiceFilterTest method testFindByText.
@Test
public void testFindByText() {
SysSystemDto system = helper.createTestResourceSystem(false);
SysSystemEntityDto entityOne = createEntitySystem(getHelper().createName(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
createEntitySystem(getHelper().createName(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
createEntitySystem(getHelper().createName(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
//
SysSystemEntityFilter testFilter = new SysSystemEntityFilter();
testFilter.setText(entityOne.getUid());
List<SysSystemEntityDto> results = entityService.find(testFilter, null).getContent();
Assert.assertEquals(1, results.size());
Assert.assertEquals(entityOne.getId(), results.get(0).getId());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.
the class DefaultSysSystemEntityServiceFilterTest method testUid.
@Test
public void testUid() {
SysSystemDto system = helper.createTestResourceSystem(false);
SysSystemEntityDto entity1 = createEntitySystem("test1-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
createEntitySystem("test2-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
createEntitySystem("test3-" + System.currentTimeMillis(), SystemEntityType.CONTRACT, system.getId(), UUID.randomUUID());
//
SysSystemEntityFilter testFilter = new SysSystemEntityFilter();
testFilter.setUid(entity1.getUid());
Page<SysSystemEntityDto> pages = entityService.find(testFilter, null);
assertEquals(1, pages.getTotalElements());
assertEquals(entity1.getId(), pages.getContent().get(0).getId());
}
use of eu.bcvsolutions.idm.acc.dto.filter.SysSystemEntityFilter in project CzechIdMng by bcvsolutions.
the class DefaultVsRequestServiceIntegrationTest method changeUidTest.
@Test
public void changeUidTest() {
SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
IdmIdentityDto userOne = helper.createIdentity(USER_ONE_NAME);
identityService.save(userOne);
this.assignRoleSystem(system, userOne, ROLE_ONE_NAME);
// Find created requests
VsRequestFilter requestFilter = new VsRequestFilter();
requestFilter.setSystemId(system.getId());
requestFilter.setUid(USER_ONE_NAME);
requestFilter.setState(VsRequestState.IN_PROGRESS);
List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(1, requests.size());
VsRequestDto createRequest = requests.get(0);
Assert.assertEquals(USER_ONE_NAME, createRequest.getUid());
Assert.assertEquals(VsOperationType.CREATE, createRequest.getOperationType());
Assert.assertEquals(VsRequestState.IN_PROGRESS, createRequest.getState());
VsConnectorObjectDto wish = requestService.getWishConnectorObject(createRequest);
boolean findAttributeWithouChange = wish.getAttributes().stream().filter(attribute -> !attribute.isChanged()).findFirst().isPresent();
Assert.assertTrue(!findAttributeWithouChange);
// Change username attributes
userOne.setUsername(USER_ONE_CHANGED_NAME);
// Invoke provisioning
identityService.save(userOne);
requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(2, requests.size());
// We realize the create request
super.logout();
loginService.login(new LoginDto(USER_IMPLEMENTER_NAME, new GuardedString("password")));
requestService.realize(createRequest);
requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(1, requests.size());
// get wish
wish = requestService.getWishConnectorObject(requests.get(0));
Assert.assertEquals(1, wish.getAttributes().stream().filter(attr -> attr.isChanged()).count());
// Find change for firstName value
boolean findCorrectChangedUserName = wish.getAttributes().stream().filter(attr -> attr.getValue().getValue().equals(USER_ONE_CHANGED_NAME) && attr.getValue().getOldValue().equals(USER_ONE_NAME) && SysValueChangeType.UPDATED == attr.getValue().getChange()).findFirst().isPresent();
Assert.assertTrue(findCorrectChangedUserName);
SysSystemEntityFilter systemEntityFilter = new SysSystemEntityFilter();
systemEntityFilter.setSystemId(system.getId());
systemEntityFilter.setUid(USER_ONE_NAME);
boolean oldUserNameExist = !systemEntityService.find(systemEntityFilter, null).getContent().isEmpty();
Assert.assertTrue(oldUserNameExist);
// Realize change username
requestService.realize(requests.get(0));
// We expects change UID in SystemEntity.UID
oldUserNameExist = !systemEntityService.find(systemEntityFilter, null).getContent().isEmpty();
Assert.assertTrue(!oldUserNameExist);
systemEntityFilter.setUid(USER_ONE_CHANGED_NAME);
boolean changedUserNameExist = !systemEntityService.find(systemEntityFilter, null).getContent().isEmpty();
Assert.assertTrue(changedUserNameExist);
}
Aggregations