use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView in project webcert by sklintyg.
the class ArendeServiceTest method answerKompltQuestionClosesAllCompletionsAsHandled.
@Test
public void answerKompltQuestionClosesAllCompletionsAsHandled() throws CertificateSenderException {
final String svarPaMeddelandeId = "svarPaMeddelandeId";
Arende fraga = buildArende(svarPaMeddelandeId, ENHET_ID);
fraga.setStatus(Status.PENDING_INTERNAL_ACTION);
fraga.setAmne(ArendeAmne.KOMPLT);
fraga.setPatientPersonId(PERSON_ID);
Arende komplt1 = buildArende(UUID.randomUUID().toString(), ENHET_ID);
komplt1.setStatus(Status.PENDING_INTERNAL_ACTION);
komplt1.setAmne(ArendeAmne.KOMPLT);
komplt1.setPatientPersonId(PERSON_ID);
Arende komplt2 = buildArende(UUID.randomUUID().toString(), ENHET_ID);
komplt2.setStatus(Status.PENDING_INTERNAL_ACTION);
komplt2.setAmne(ArendeAmne.KOMPLT);
komplt2.setPatientPersonId(PERSON_ID);
Arende otherSubject = buildArende(UUID.randomUUID().toString(), ENHET_ID);
otherSubject.setStatus(Status.PENDING_INTERNAL_ACTION);
otherSubject.setAmne(ArendeAmne.AVSTMN);
otherSubject.setPatientPersonId(PERSON_ID);
when(arendeRepository.findByIntygsId(INTYG_ID)).thenReturn(Arrays.asList(fraga, komplt1, otherSubject, komplt2));
when(webcertUserService.isAuthorizedForUnit(anyString(), anyBoolean())).thenReturn(true);
WebCertUser webcertUser = createUser();
when(webcertUserService.getUser()).thenReturn(webcertUser);
List<ArendeConversationView> result = service.answerKomplettering(INTYG_ID, "svarstext");
verify(notificationService).sendNotificationForQAs(INTYG_ID, NotificationEvent.NEW_ANSWER_FROM_CARE);
verify(arendeRepository).findByIntygsId(INTYG_ID);
verify(arendeDraftService, times(3)).delete(eq(INTYG_ID), anyString());
assertTrue(result.stream().map(ArendeConversationView::getFraga).filter(f -> f.getAmne() == ArendeAmne.KOMPLT).allMatch(f -> f.getStatus() == Status.CLOSED));
assertNotNull(result.stream().map(ArendeConversationView::getSvar).filter(Objects::nonNull).map(ArendeView::getInternReferens).collect(MoreCollectors.onlyElement()));
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView in project webcert by sklintyg.
the class ArendeViewConverterTest method testConvertKompletteringWithoutInstans.
@SuppressWarnings("unchecked")
@Test
public void testConvertKompletteringWithoutInstans() throws ModuleNotFoundException {
Arende arende = buildArende("lisjp");
arende.setKomplettering(Arrays.asList(buildMedicinsktArende("1", null, "arende1")));
ArendeView result = converter.convertToDto(arende);
assertEquals(1, result.getKompletteringar().size());
assertEquals(RespConstants.GRUNDFORMEDICINSKTUNDERLAG_SVAR_JSON_ID_1, result.getKompletteringar().get(0).getJsonPropertyHandle());
assertEquals(new Integer(0), result.getKompletteringar().get(0).getPosition());
assertEquals(VARDAKTOR_NAMN, result.getVardaktorNamn());
assertEquals(ENHETS_NAMN, result.getEnhetsnamn());
assertEquals(VARDGIVARE_NAMN, result.getVardgivarnamn());
verify(moduleApi).getModuleSpecificArendeParameters(any(Utlatande.class), any(List.class));
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView in project webcert by sklintyg.
the class ArendeViewConverterTest method testConvertToArendeWithoutKomplettering.
@SuppressWarnings("unchecked")
@Test
public void testConvertToArendeWithoutKomplettering() throws ModuleNotFoundException {
ArendeView result = converter.convertToDto(buildArende("meddelandeId", LocalDateTime.now(), LocalDateTime.now()));
assertTrue(result.getKompletteringar().isEmpty());
assertEquals(VARDAKTOR_NAMN, result.getVardaktorNamn());
assertEquals(ENHETS_NAMN, result.getEnhetsnamn());
assertEquals(VARDGIVARE_NAMN, result.getVardgivarnamn());
verify(moduleApi, never()).getModuleSpecificArendeParameters(any(Utlatande.class), any(List.class));
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView in project webcert by sklintyg.
the class ArendeViewConverterTest method testConvertToArendeForLuse.
@SuppressWarnings("unchecked")
@Test
public void testConvertToArendeForLuse() throws ModuleNotFoundException {
ArendeView result = converter.convertToDto(buildArende("luse"));
assertNotNull(result.getKompletteringar().get(0).getJsonPropertyHandle());
assertEquals(RespConstants.KANNEDOM_SVAR_JSON_ID_2, result.getKompletteringar().get(1).getJsonPropertyHandle());
assertEquals(RespConstants.UNDERLAG_SVAR_JSON_ID_4, result.getKompletteringar().get(2).getJsonPropertyHandle());
assertEquals(new Integer(0), result.getKompletteringar().get(0).getPosition());
assertEquals(new Integer(0), result.getKompletteringar().get(1).getPosition());
assertEquals(new Integer(1), result.getKompletteringar().get(2).getPosition());
assertEquals(VARDAKTOR_NAMN, result.getVardaktorNamn());
assertEquals(ENHETS_NAMN, result.getEnhetsnamn());
assertEquals(VARDGIVARE_NAMN, result.getVardgivarnamn());
verify(moduleApi).getModuleSpecificArendeParameters(any(Utlatande.class), any(List.class));
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.ArendeView in project webcert by sklintyg.
the class ArendeViewConverterTest method differentMessageThreadsShouldBeSeparatedAndSortedOnSenasteHandelse.
@Test
public void differentMessageThreadsShouldBeSeparatedAndSortedOnSenasteHandelse() {
// Given
LocalDateTime startOfFirstThread = LocalDateTime.parse("2016-03-01T11:22:11");
Arende fraga1 = createValidArendeForLuse("fraga", startOfFirstThread, "fraga1-id", null);
Arende p11 = createValidArendeForLuse("paminnelse", startOfFirstThread.plusHours(2), "paminnelse-1.1-id", fraga1);
Arende p12 = createValidArendeForLuse("paminnelse", startOfFirstThread.plusDays(1), "paminnelse-1.2-id", fraga1);
Arende p13 = createValidArendeForLuse("paminnelse", startOfFirstThread.plusDays(3), "paminnelse-1.3-id", fraga1);
Arende svar1 = createValidArendeForLuse("svar", startOfFirstThread.plusDays(4), "svar-1-id", fraga1);
LocalDateTime startOfSecondThread = LocalDateTime.parse("2016-03-02T11:22:11");
Arende fraga2 = createValidArendeForLuse("fraga", startOfSecondThread, "fraga2-id", null);
Arende p21 = createValidArendeForLuse("paminnelse", startOfFirstThread.plusHours(2), "paminnelse-2.1-id", fraga2);
Arende p22 = createValidArendeForLuse("paminnelse", startOfFirstThread.plusDays(1), "paminnelse-2.2-id", fraga2);
Arende svar2 = createValidArendeForLuse("svar", startOfFirstThread.plusDays(4), "svar-2-id", fraga2);
List<Arende> mixedThreads = ImmutableList.of(fraga1, fraga2, p11, p21, p12, p22, p13, svar2, svar1);
// When
List<ArendeConversationView> createdList = converter.buildArendeConversations(intygsId, mixedThreads, Collections.emptyList(), Collections.emptyList());
// Then
List<ArendeView> expectedPaminnelser1Dtos = Stream.of(p13, p12, p11).map(converter::convertToDto).collect(Collectors.toList());
List<ArendeView> expectedPaminnelser2Dtos = Stream.of(p22, p21).map(converter::convertToDto).collect(Collectors.toList());
Assertions.assertThat(createdList).hasSize(2).extracting("fraga", "svar", "paminnelser").contains(tuple(converter.convertToDto(fraga1), converter.convertToDto(svar1), expectedPaminnelser1Dtos), tuple(converter.convertToDto(fraga2), converter.convertToDto(svar2), expectedPaminnelser2Dtos));
}
Aggregations