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());
}
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());
}
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());
}
Aggregations