Search in sources :

Example 66 with WebCertUser

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

the class WebCertUserServiceTest method setupUserMottagningAccessTest.

private WebCertUser setupUserMottagningAccessTest() {
    WebCertUser user = createWebCertUser(true);
    ((Vardenhet) user.getValdVardenhet()).getMottagningar().add(buildMottagning1());
    ((Vardenhet) user.getValdVardenhet()).getMottagningar().add(buildMottagning2());
    applyUserToThreadLocalCtx(user);
    return user;
}
Also used : WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser)

Example 67 with WebCertUser

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

the class WebCertUserServiceTest method testStoreExistingUserMetadata.

@Test
public void testStoreExistingUserMetadata() {
    WebCertUser user = createWebCertUser(false);
    applyUserToThreadLocalCtx(user);
    when(anvandarPreferenceRepository.findByHsaIdAndKey("HSA-id", "key1")).thenReturn(new AnvandarPreference("HSA-id", "key1", "value1"));
    webcertUserService.storeUserPreference("key1", "value1");
    assertEquals("value1", user.getAnvandarPreference().get("key1"));
    verify(anvandarPreferenceRepository, times(1)).findByHsaIdAndKey("HSA-id", "key1");
    verify(anvandarPreferenceRepository, times(1)).save(any(AnvandarPreference.class));
}
Also used : AnvandarPreference(se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 68 with WebCertUser

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

the class WebCertUserServiceTest method testDeleteUnknownAnvandarPreference.

@Test
public void testDeleteUnknownAnvandarPreference() {
    WebCertUser user = createWebCertUser(false);
    applyUserToThreadLocalCtx(user);
    when(anvandarPreferenceRepository.findByHsaIdAndKey(user.getHsaId(), "key1")).thenReturn(null);
    webcertUserService.deleteUserPreference("key1");
    verify(anvandarPreferenceRepository, times(1)).findByHsaIdAndKey("HSA-id", "key1");
    verify(anvandarPreferenceRepository, times(0)).delete(any(AnvandarPreference.class));
}
Also used : AnvandarPreference(se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 69 with WebCertUser

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

the class WebCertUserServiceTest method testGetMiuOk.

@Test
public void testGetMiuOk() {
    WebCertUser user = createWebCertUser(false);
    assertEquals("Mitt uppdrag", user.getSelectedMedarbetarUppdragNamn());
}
Also used : WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 70 with WebCertUser

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

the class WebCertUserServiceTest method testDeleteStoredAnvandarPreference.

@Test
public void testDeleteStoredAnvandarPreference() {
    AnvandarPreference anvandarPreference = new AnvandarPreference("HSA-id", "key1", "value1");
    WebCertUser user = createWebCertUser(false);
    applyUserToThreadLocalCtx(user);
    when(anvandarPreferenceRepository.findByHsaIdAndKey(user.getHsaId(), "key1")).thenReturn(anvandarPreference);
    webcertUserService.deleteUserPreference("key1");
    verify(anvandarPreferenceRepository, times(1)).findByHsaIdAndKey("HSA-id", "key1");
    verify(anvandarPreferenceRepository, times(1)).delete(anvandarPreference);
}
Also used : AnvandarPreference(se.inera.intyg.webcert.persistence.anvandarmetadata.model.AnvandarPreference) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

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