Search in sources :

Example 76 with LinkedMultiValueMap

use of org.springframework.util.LinkedMultiValueMap in project CzechIdMng by bcvsolutions.

the class DefaultAuditServiceTest method editAndEditOneTrasaction.

@Test
public void editAndEditOneTrasaction() {
    String username = "test_user_" + System.currentTimeMillis();
    IdmIdentityDto identity = new IdmIdentityDto();
    identity.setUsername(username);
    identity.setFirstName(username);
    identity.setLastName(username);
    identityService.save(identity);
    IdmIdentityDto newIdentity = getTransactionTemplate().execute(new TransactionCallback<IdmIdentityDto>() {

        public IdmIdentityDto doInTransaction(TransactionStatus transactionStatus) {
            IdmIdentityDto identity = identityService.getByCode(username);
            identity.setFirstName(username + "--edit");
            identityService.save(identity);
            // 
            identity.setEmail("example@example.tld");
            identity.setLastName(username + "edit");
            return identityService.save(identity);
        }
    });
    assertEquals(newIdentity.getUsername(), username);
    MultiValueMap<String, Object> parameters = new LinkedMultiValueMap<>();
    parameters.put("username", ImmutableList.of(username));
    List<IdmAuditDto> audits = auditService.findEntityWithRelation(IdmIdentity.class, parameters, null).getContent();
    assertEquals(3, audits.size());
}
Also used : LinkedMultiValueMap(org.springframework.util.LinkedMultiValueMap) IdmAuditDto(eu.bcvsolutions.idm.core.api.audit.dto.IdmAuditDto) TransactionStatus(org.springframework.transaction.TransactionStatus) IdmIdentityDto(eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto) IdmIdentity(eu.bcvsolutions.idm.core.model.entity.IdmIdentity) AbstractIntegrationTest(eu.bcvsolutions.idm.test.api.AbstractIntegrationTest) Test(org.junit.Test)

Aggregations

LinkedMultiValueMap (org.springframework.util.LinkedMultiValueMap)76 Test (org.junit.Test)40 HttpHeaders (org.springframework.http.HttpHeaders)20 MultiValueMap (org.springframework.util.MultiValueMap)19 Map (java.util.Map)9 HttpEntity (org.springframework.http.HttpEntity)9 RestTemplate (org.springframework.web.client.RestTemplate)9 ClassPathResource (org.springframework.core.io.ClassPathResource)8 MediaType (org.springframework.http.MediaType)7 URI (java.net.URI)6 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)6 Resource (org.springframework.core.io.Resource)5 HashMap (java.util.HashMap)4 FileItem (org.apache.commons.fileupload.FileItem)4 Credential (org.apereo.cas.authentication.Credential)4 IdmAuditDto (eu.bcvsolutions.idm.core.api.audit.dto.IdmAuditDto)3 IdmIdentityDto (eu.bcvsolutions.idm.core.api.dto.IdmIdentityDto)3 IdmIdentity (eu.bcvsolutions.idm.core.model.entity.IdmIdentity)3 AbstractIntegrationTest (eu.bcvsolutions.idm.test.api.AbstractIntegrationTest)3 X509CertificateCredential (org.apereo.cas.adaptors.x509.authentication.principal.X509CertificateCredential)3