use of eu.bcvsolutions.idm.vs.dto.VsRequestDto in project CzechIdMng by bcvsolutions.
the class DefaultVsRequestServiceIntegrationTest method filterByImplementersTest.
@Test
public void filterByImplementersTest() {
IdmIdentityDto implementerIdentity1 = helper.createIdentity(helper.createName());
IdmIdentityDto implementerIdentity2 = helper.createIdentity(helper.createName());
IdmRoleDto implementerRole = helper.createRole(helper.createName());
IdmIdentityDto userIdentity = helper.createIdentity(helper.createName());
IdmRoleDto userRole = helper.createRole(helper.createName());
// system with implementer by identity
VsSystemDto vsConfig1 = new VsSystemDto();
vsConfig1.setName(helper.createName());
vsConfig1.setImplementers(Arrays.asList(implementerIdentity1.getId()));
SysSystemDto system1 = helper.createVirtualSystem(vsConfig1);
helper.createRoleSystem(userRole, system1);
// system with implementer by role
VsSystemDto vsConfig2 = new VsSystemDto();
vsConfig2.setName(helper.createName());
vsConfig2.setImplementerRoles(Arrays.asList(implementerRole.getId()));
SysSystemDto system2 = helper.createVirtualSystem(vsConfig2);
helper.createRoleSystem(userRole, system2);
// assign user and implementer roles
helper.assignRoles(helper.getPrimeContract(implementerIdentity2.getId()), false, implementerRole);
helper.assignRoles(helper.getPrimeContract(userIdentity.getId()), false, userRole);
// no filter used, find all requests
VsRequestFilter requestFilter = new VsRequestFilter();
List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
Assert.assertTrue(requests.size() >= 2);
// find requests defined by implementer identity
requestFilter = new VsRequestFilter();
requestFilter.setImplementers(Arrays.asList(implementerIdentity1.getId()));
requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(1, requests.size());
Assert.assertEquals(requests.get(0).getSystem(), system1.getId());
// find requests defined by implementer role
requestFilter = new VsRequestFilter();
requestFilter.setImplementers(Arrays.asList(implementerIdentity2.getId()));
requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(1, requests.size());
Assert.assertEquals(requests.get(0).getSystem(), system2.getId());
// prove that no requests are found when identity is not an implementer
requestFilter = new VsRequestFilter();
requestFilter.setImplementers(Arrays.asList(userIdentity.getId()));
requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(0, requests.size());
}
use of eu.bcvsolutions.idm.vs.dto.VsRequestDto in project CzechIdMng by bcvsolutions.
the class DefaultVsRequestServiceIntegrationTest method createAndRealizeRequestWithNoteTest.
@Test
public void createAndRealizeRequestWithNoteTest() {
SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
this.assignRoleSystem(system, helper.createIdentity(USER_ONE_NAME), ROLE_ONE_NAME);
// Find created requests
VsRequestFilter requestFilter = new VsRequestFilter();
requestFilter.setSystemId(system.getId());
requestFilter.setUid(USER_ONE_NAME);
List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(1, requests.size());
VsRequestDto request = requests.get(0);
Assert.assertEquals(USER_ONE_NAME, request.getUid());
Assert.assertEquals(VsOperationType.CREATE, request.getOperationType());
Assert.assertEquals(VsRequestState.IN_PROGRESS, request.getState());
VsAccountDto account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
Assert.assertNull("Account must be null, because request was not realized yet!", account);
// We try realize the request
super.logout();
loginService.login(new LoginDto(USER_IMPLEMENTER_NAME, new GuardedString("password")));
String note = helper.createName();
request = requestService.realize(request, note);
Assert.assertEquals(VsRequestState.REALIZED, request.getState());
account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
Assert.assertNotNull("Account cannot be null, because request was realized!", account);
request = requestService.get(request.getId());
Assert.assertEquals(note, request.getReason());
}
use of eu.bcvsolutions.idm.vs.dto.VsRequestDto in project CzechIdMng by bcvsolutions.
the class DefaultVsRequestServiceIntegrationTest method createMoreRequestsTest.
@Test
public void createMoreRequestsTest() {
String changed = "changed";
SysSystemDto system = this.createVirtualSystem(USER_IMPLEMENTER_NAME, null);
this.assignRoleSystem(system, helper.createIdentity(USER_ONE_NAME), ROLE_ONE_NAME);
// Find created requests
VsRequestFilter requestFilter = new VsRequestFilter();
requestFilter.setSystemId(system.getId());
requestFilter.setUid(USER_ONE_NAME);
List<VsRequestDto> requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(1, requests.size());
VsRequestDto request = requests.get(0);
Assert.assertEquals(USER_ONE_NAME, request.getUid());
Assert.assertEquals(VsOperationType.CREATE, request.getOperationType());
Assert.assertEquals(VsRequestState.IN_PROGRESS, request.getState());
VsAccountDto account = accountService.findByUidSystem(USER_ONE_NAME, system.getId());
Assert.assertNull("Account must be null, because request was not realized yet!", account);
IdmIdentityDto userOne = identityService.getByUsername(USER_ONE_NAME);
userOne.setFirstName(changed);
userOne.setLastName(changed);
identityService.save(userOne);
// Duplicated save ... not invoke provisioning
identityService.save(userOne);
requests = requestService.find(requestFilter, null).getContent();
Assert.assertEquals(2, requests.size());
VsRequestDto changeRequest = requests.stream().filter(req -> VsRequestState.IN_PROGRESS == req.getState() && VsOperationType.UPDATE == req.getOperationType()).findFirst().orElse(null);
Assert.assertNotNull("Request with change not found!", changeRequest);
}
use of eu.bcvsolutions.idm.vs.dto.VsRequestDto in project CzechIdMng by bcvsolutions.
the class VsRequestController method getDto.
@Override
public VsRequestDto getDto(Serializable backendId) {
VsRequestDto requestDto = super.getDto(backendId);
// Request was not found
if (requestDto == null) {
return null;
}
// Add list of implementers
addImplementers(requestDto);
return requestDto;
}
use of eu.bcvsolutions.idm.vs.dto.VsRequestDto in project CzechIdMng by bcvsolutions.
the class DefaultVsRequestService method createRequest.
@Override
@Transactional
public VsRequestDto createRequest(VsRequestDto req) {
Assert.notNull(req, "Request cannot be null!");
// Save new request
req.setState(VsRequestState.CONCEPT);
VsRequestDto request = this.save(req);
return this.get(request.getId());
}
Aggregations