Search in sources :

Example 26 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class AuthoritiesValidatorTest method testMustNotHavePrevilegeIntygsTyp.

@Test
public void testMustNotHavePrevilegeIntygsTyp() {
    WebCertUser user = createDefaultUser();
    validator.given(user, "fk7263").notPrivilege("p3");
}
Also used : WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 27 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class AuthoritiesValidatorTest method createUser.

private WebCertUser createUser(String roleName, Privilege p, Map<String, Feature> features, String origin) {
    WebCertUser user = new WebCertUser();
    HashMap<String, Privilege> pMap = new HashMap<>();
    pMap.put(p.getName(), p);
    user.setAuthorities(pMap);
    user.setOrigin(origin);
    user.setFeatures(features);
    HashMap<String, Role> rMap = new HashMap<>();
    Role role = new Role();
    role.setName(roleName);
    rMap.put(roleName, role);
    user.setRoles(rMap);
    return user;
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) HashMap(java.util.HashMap) Privilege(se.inera.intyg.infra.security.common.model.Privilege) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 28 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class RoleConverterTest method testConvert.

@Test
public void testConvert() {
    String role = "user role";
    WebCertUser user = new WebCertUser();
    user.setRoles(ImmutableMap.of(role, new Role()));
    Authentication authentication = mock(Authentication.class);
    when(authentication.getPrincipal()).thenReturn(user);
    SecurityContextHolder.getContext().setAuthentication(authentication);
    ILoggingEvent event = mock(ILoggingEvent.class);
    String res = converter.convert(event);
    assertEquals(role, res);
}
Also used : Role(se.inera.intyg.infra.security.common.model.Role) Authentication(org.springframework.security.core.Authentication) ILoggingEvent(ch.qos.logback.classic.spi.ILoggingEvent) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 29 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class IntygConverterUtilTest method testBuildHosPersonalFromWebCertUserWithVardenhet.

@Test
public void testBuildHosPersonalFromWebCertUserWithVardenhet() {
    final String forskrivarkod = "forskrivarkod";
    final String hsaId = "hsaid";
    final String namn = "namn";
    final String arbetsplatskod = "arbetsplatskod";
    final String epost = "epost";
    final String enhetsId = "enhetsId";
    final String enhetsnamn = "enhetsnamn";
    final String postadress = "postadress";
    final String postnummer = "postnummer";
    final String postort = "postort";
    final String telefonnummer = "telefonnummer";
    final String vardgivarId = "vardgivarId";
    final String vardgivarnamn = "vardgivarnamn";
    se.inera.intyg.common.support.model.common.internal.Vardgivare vardgivare = new se.inera.intyg.common.support.model.common.internal.Vardgivare();
    vardgivare.setVardgivarid(vardgivarId);
    vardgivare.setVardgivarnamn(vardgivarnamn);
    se.inera.intyg.common.support.model.common.internal.Vardenhet vardenhet = new se.inera.intyg.common.support.model.common.internal.Vardenhet();
    vardenhet.setArbetsplatsKod(arbetsplatskod);
    vardenhet.setEpost(epost);
    vardenhet.setEnhetsid(enhetsId);
    vardenhet.setEnhetsnamn(enhetsnamn);
    vardenhet.setPostadress(postadress);
    vardenhet.setPostnummer(postnummer);
    vardenhet.setPostort(postort);
    vardenhet.setTelefonnummer(telefonnummer);
    vardenhet.setVardgivare(vardgivare);
    WebCertUser user = new WebCertUser();
    user.setForskrivarkod(forskrivarkod);
    user.setHsaId(hsaId);
    user.setNamn(namn);
    HoSPersonal result = IntygConverterUtil.buildHosPersonalFromWebCertUser(user, vardenhet);
    assertEquals(forskrivarkod, result.getForskrivarKod());
    assertEquals(hsaId, result.getPersonId());
    assertEquals(namn, result.getFullstandigtNamn());
    assertEquals(arbetsplatskod, result.getVardenhet().getArbetsplatsKod());
    assertEquals(epost, result.getVardenhet().getEpost());
    assertEquals(enhetsId, result.getVardenhet().getEnhetsid());
    assertEquals(enhetsnamn, result.getVardenhet().getEnhetsnamn());
    assertEquals(postadress, result.getVardenhet().getPostadress());
    assertEquals(postnummer, result.getVardenhet().getPostnummer());
    assertEquals(postort, result.getVardenhet().getPostort());
    assertEquals(telefonnummer, result.getVardenhet().getTelefonnummer());
    assertEquals(vardgivarId, result.getVardenhet().getVardgivare().getVardgivarid());
    assertEquals(vardgivarnamn, result.getVardenhet().getVardgivare().getVardgivarnamn());
}
Also used : Vardgivare(se.inera.intyg.infra.integration.hsa.model.Vardgivare) Vardenhet(se.inera.intyg.infra.integration.hsa.model.Vardenhet) HoSPersonal(se.inera.intyg.common.support.model.common.internal.HoSPersonal) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 30 with WebCertUser

use of se.inera.intyg.webcert.web.service.user.dto.WebCertUser in project webcert by sklintyg.

the class SendMessageToRecipientTypeBuilderTest method buildWebCertUser.

private WebCertUser buildWebCertUser(boolean complete) {
    WebCertUser user = new WebCertUser();
    user.setHsaId(PERSONAL_HSA_ID);
    user.setNamn(USER_NAMN);
    user.setForskrivarkod(USER_FORSKRIVARKOD);
    Vardenhet valdVardenhet = new Vardenhet();
    valdVardenhet.setArbetsplatskod(ARBETSPLATSKOD);
    valdVardenhet.setId(VARDENHET_ENHET_ID);
    Vardgivare valdVardgivare = new Vardgivare();
    valdVardgivare.setId(VARDGIVARE_ID);
    if (complete) {
        valdVardenhet.setNamn(VARDENHET_NAMN);
        valdVardenhet.setPostadress(VARDENHET_POSTADRESS);
        valdVardenhet.setPostnummer(VARDENHET_POSTNUMMER);
        valdVardenhet.setPostort(VARDENHET_POSTORT);
        valdVardenhet.setTelefonnummer(VARDENHET_TELEFONNUMMER);
        valdVardenhet.setEpost(VARDENHET_EPOST);
        valdVardgivare.setNamn(VARDGIVARE_NAMN);
    }
    user.setValdVardenhet(valdVardenhet);
    user.setValdVardgivare(valdVardgivare);
    return user;
}
Also used : Vardenhet(se.inera.intyg.infra.integration.hsa.model.Vardenhet) Vardgivare(se.inera.intyg.infra.integration.hsa.model.Vardgivare) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Aggregations

WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)217 Test (org.junit.Test)123 IntegrationParameters (se.inera.intyg.webcert.web.web.controller.integration.dto.IntegrationParameters)32 Utkast (se.inera.intyg.webcert.persistence.utkast.model.Utkast)31 Personnummer (se.inera.intyg.schemas.contract.Personnummer)24 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)23 WebCertServiceException (se.inera.intyg.webcert.common.service.exception.WebCertServiceException)23 Role (se.inera.intyg.infra.security.common.model.Role)18 HoSPersonal (se.inera.intyg.common.support.model.common.internal.HoSPersonal)16 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)15 CopyIntygRequest (se.inera.intyg.webcert.web.web.controller.api.dto.CopyIntygRequest)15 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)14 Vardenhet (se.inera.intyg.infra.integration.hsa.model.Vardenhet)14 CopyUtkastBuilderResponse (se.inera.intyg.webcert.web.service.utkast.dto.CopyUtkastBuilderResponse)14 Vardgivare (se.inera.intyg.infra.integration.hsa.model.Vardgivare)13 Feature (se.inera.intyg.infra.security.common.model.Feature)13 HashMap (java.util.HashMap)12 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)12 Transactional (org.springframework.transaction.annotation.Transactional)11 Path (javax.ws.rs.Path)10