use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class UsernameIdentityFilterIntegrationTest method testFilteringFound.
@Test
public void testFilteringFound() {
String username = getHelper().createName();
IdmIdentityDto identityOne = getHelper().createIdentity(username);
IdmIdentityDto identityTwo = getHelper().createIdentity(getHelper().createName() + username + getHelper().createName());
IdmIdentityDto identityThree = getHelper().createIdentity(getHelper().createName() + username + getHelper().createName());
IdmIdentityFilter filter = new IdmIdentityFilter();
filter.setUsername(username);
List<IdmIdentity> identities = usernameIdentityFilter.find(filter, null).getContent();
assertEquals(3, identities.size());
IdmIdentity identity = identities.stream().filter(ident -> ident.getId().equals(identityOne.getId())).findFirst().get();
assertNotNull(identity);
identity = identities.stream().filter(ident -> ident.getId().equals(identityTwo.getId())).findFirst().get();
assertNotNull(identity);
identity = identities.stream().filter(ident -> ident.getId().equals(identityThree.getId())).findFirst().get();
assertNotNull(identity);
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class UsernameIdentityFilterIntegrationTest method testFilteringNotFound.
@Test
public void testFilteringNotFound() {
String username = "usernameValue" + System.currentTimeMillis();
getHelper().createIdentity(username);
getHelper().createIdentity("123" + username + getHelper().createName());
getHelper().createIdentity(getHelper().createName() + username + getHelper().createName());
IdmIdentityFilter filter = new IdmIdentityFilter();
// value is different than variable username
filter.setUsername("username1Value");
List<IdmIdentity> identities = usernameIdentityFilter.find(filter, null).getContent();
assertEquals(0, identities.size());
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class IdmIdentityController method findRevision.
@ResponseBody
@RequestMapping(value = "/{backendId}/revisions/{revId}", method = RequestMethod.GET)
@PreAuthorize("hasAuthority('" + CoreGroupPermission.IDENTITY_READ + "')")
@ApiOperation(value = "Identity audit - read revision detail", nickname = "getIdentityRevision", tags = { IdmIdentityController.TAG }, authorizations = { @Authorization(value = SwaggerConfig.AUTHENTICATION_BASIC, scopes = { @AuthorizationScope(scope = CoreGroupPermission.IDENTITY_READ, description = "") }), @Authorization(value = SwaggerConfig.AUTHENTICATION_CIDMST, scopes = { @AuthorizationScope(scope = CoreGroupPermission.IDENTITY_READ, description = "") }) })
public ResponseEntity<?> findRevision(@ApiParam(value = "Identity's uuid identifier or username.", required = true) @PathVariable("backendId") String backendId, @ApiParam(value = "Revision identifier.", required = true) @PathVariable("revId") Long revId) {
IdmIdentityDto originalEntity = getDto(backendId);
if (originalEntity == null) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("entity", backendId));
}
//
IdmIdentity revisionIdentity;
try {
revisionIdentity = this.auditService.findRevision(IdmIdentity.class, originalEntity.getId(), revId);
} catch (RevisionDoesNotExistException ex) {
throw new ResultCodeException(CoreResultCode.NOT_FOUND, ImmutableMap.of("revision", revId), ex);
}
// FIXME: to dto
return new ResponseEntity<>(revisionIdentity, HttpStatus.OK);
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class OptimisticLockIntegrationTest method testOptimisticLockException.
@Transactional
@Test(expected = ObjectOptimisticLockingFailureException.class)
public void testOptimisticLockException() {
IdmIdentity identityOne = identityRepository.findOneByUsername(InitTestDataProcessor.TEST_USER_1);
entityManager.detach(identityOne);
IdmIdentity identityTwo = identityRepository.findOneByUsername(InitTestDataProcessor.TEST_USER_1);
entityManager.detach(identityTwo);
assertNull(identityOne.getTitleAfter());
assertNull(identityOne.getTitleBefore());
assertNull(identityTwo.getTitleAfter());
assertNull(identityTwo.getTitleBefore());
identityOne.setTitleAfter("after");
identityTwo.setTitleBefore("before");
assertEquals("after", identityOne.getTitleAfter());
assertNull(identityOne.getTitleBefore());
assertNull(identityTwo.getTitleAfter());
assertEquals("before", identityTwo.getTitleBefore());
saveInNewTransaction(identityOne);
entityManager.detach(identityOne);
entityManager.flush();
assertEquals("after", identityOne.getTitleAfter());
assertNull(identityOne.getTitleBefore());
assertNull(identityTwo.getTitleAfter());
assertEquals("before", identityTwo.getTitleBefore());
saveInNewTransaction(identityTwo);
}
use of eu.bcvsolutions.idm.core.model.entity.IdmIdentity in project CzechIdMng by bcvsolutions.
the class DefaultEntityEventManagerUnitTest method testPropagatePropertiesOnNotifyIntoChildren.
@Test
public void testPropagatePropertiesOnNotifyIntoChildren() {
IdmIdentity identity = new IdmIdentity(UUID.randomUUID());
when(lookupService.getOwnerId(any())).thenReturn(identity.getId());
//
Map<String, Serializable> props = new HashMap<>();
props.put("one", "valueOne");
//
IdmEntityEventDto entityEvent = manager.prepareEvent(identity, new CoreEvent<>(CoreEventType.CREATE, identity, props));
//
Assert.assertEquals(props.get("one"), entityEvent.getProperties().get("one"));
}
Aggregations