Search in sources :

Example 11 with QueryFragaSvarParameter

use of se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarParameter in project webcert by sklintyg.

the class ArendeServiceTest method testFilterArendeWithNoEnhetsIdAsParam.

@Test
public void testFilterArendeWithNoEnhetsIdAsParam() {
    when(webcertUserService.getUser()).thenReturn(createUser());
    List<Arende> queryResults = new ArrayList<>();
    queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now(), null));
    queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now().plusDays(1), null));
    when(arendeRepository.filterArende(any(Filter.class))).thenReturn(queryResults);
    QueryFragaSvarResponse fsResponse = new QueryFragaSvarResponse();
    fsResponse.setResults(new ArrayList<>());
    fsResponse.setTotalCount(0);
    when(fragaSvarService.filterFragaSvar(any(Filter.class))).thenReturn(fsResponse);
    QueryFragaSvarParameter params = new QueryFragaSvarParameter();
    QueryFragaSvarResponse response = service.filterArende(params);
    verify(webcertUserService).getUser();
    verify(arendeRepository).filterArende(any(Filter.class));
    // verify(arendeRepository).filterArendeCount(any(Filter.class));
    verify(fragaSvarService).filterFragaSvar(any(Filter.class));
    assertEquals(2, response.getResults().size());
// assertEquals(3, response.getTotalCount());
}
Also used : Filter(se.inera.intyg.webcert.persistence.model.Filter) QueryFragaSvarParameter(se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarParameter) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) QueryFragaSvarResponse(se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarResponse) Test(org.junit.Test)

Example 12 with QueryFragaSvarParameter

use of se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarParameter in project webcert by sklintyg.

the class ArendeServiceTest method testFilterArendeWithEnhetsIdAsParam.

@Test
public void testFilterArendeWithEnhetsIdAsParam() {
    WebCertUser webCertUser = createUser();
    when(webcertUserService.getUser()).thenReturn(webCertUser);
    when(webcertUserService.isAuthorizedForUnit(any(String.class), eq(true))).thenReturn(true);
    List<Arende> queryResults = new ArrayList<>();
    queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now(), null));
    queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now().minusDays(1), null));
    when(arendeRepository.filterArende(any(Filter.class))).thenReturn(queryResults);
    QueryFragaSvarResponse fsResponse = new QueryFragaSvarResponse();
    fsResponse.setResults(new ArrayList<>());
    fsResponse.setTotalCount(0);
    when(fragaSvarService.filterFragaSvar(any(Filter.class))).thenReturn(fsResponse);
    QueryFragaSvarParameter params = new QueryFragaSvarParameter();
    params.setEnhetId(webCertUser.getValdVardenhet().getId());
    QueryFragaSvarResponse response = service.filterArende(params);
    verify(webcertUserService).isAuthorizedForUnit(anyString(), eq(true));
    verify(arendeRepository).filterArende(any(Filter.class));
    // verify(arendeRepository).filterArendeCount(any(Filter.class));
    verify(fragaSvarService).filterFragaSvar(any(Filter.class));
    assertEquals(2, response.getResults().size());
// assertEquals(3, response.getTotalCount());
}
Also used : Filter(se.inera.intyg.webcert.persistence.model.Filter) QueryFragaSvarParameter(se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarParameter) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) Matchers.anyString(org.mockito.Matchers.anyString) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) QueryFragaSvarResponse(se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarResponse) Test(org.junit.Test)

Example 13 with QueryFragaSvarParameter

use of se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarParameter in project webcert by sklintyg.

the class ArendeServiceTest method testFilterArendeMergesFragaSvar.

@Test
public void testFilterArendeMergesFragaSvar() {
    when(webcertUserService.getUser()).thenReturn(createUser());
    List<Arende> queryResults = new ArrayList<>();
    queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now(), null));
    queryResults.add(buildArende(UUID.randomUUID().toString(), LocalDateTime.now().plusDays(1), null));
    when(arendeRepository.filterArende(any(Filter.class))).thenReturn(queryResults);
    QueryFragaSvarResponse fsResponse = new QueryFragaSvarResponse();
    fsResponse.setResults(new ArrayList<>());
    fsResponse.getResults().add(buildArendeListItem("intyg1", LocalDateTime.now().minusDays(1)));
    fsResponse.setTotalCount(1);
    when(fragaSvarService.filterFragaSvar(any(Filter.class))).thenReturn(fsResponse);
    QueryFragaSvarParameter params = new QueryFragaSvarParameter();
    QueryFragaSvarResponse response = service.filterArende(params);
    verify(webcertUserService).getUser();
    verify(arendeRepository).filterArende(any(Filter.class));
    // verify(arendeRepository).filterArendeCount(any(Filter.class));
    verify(fragaSvarService).filterFragaSvar(any(Filter.class));
    assertEquals(3, response.getResults().size());
// assertEquals(4, response.getTotalCount());
}
Also used : Filter(se.inera.intyg.webcert.persistence.model.Filter) QueryFragaSvarParameter(se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarParameter) MedicinsktArende(se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende) Arende(se.inera.intyg.webcert.persistence.arende.model.Arende) QueryFragaSvarResponse(se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarResponse) Test(org.junit.Test)

Aggregations

QueryFragaSvarParameter (se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarParameter)13 Test (org.junit.Test)11 Filter (se.inera.intyg.webcert.persistence.model.Filter)11 Arende (se.inera.intyg.webcert.persistence.arende.model.Arende)8 MedicinsktArende (se.inera.intyg.webcert.persistence.arende.model.MedicinsktArende)8 QueryFragaSvarResponse (se.inera.intyg.webcert.web.service.fragasvar.dto.QueryFragaSvarResponse)8 WebCertUser (se.inera.intyg.webcert.web.service.user.dto.WebCertUser)4 LocalDateTime (java.time.LocalDateTime)2 Matchers.anyString (org.mockito.Matchers.anyString)2 Personnummer (se.inera.intyg.schemas.contract.Personnummer)2 VisibleForTesting (com.google.common.annotations.VisibleForTesting)1 Preconditions (com.google.common.base.Preconditions)1 Strings (com.google.common.base.Strings)1 Clock (java.time.Clock)1 LocalDate (java.time.LocalDate)1 ArrayList (java.util.ArrayList)1 Arrays (java.util.Arrays)1 Comparator (java.util.Comparator)1 HashMap (java.util.HashMap)1 List (java.util.List)1