use of se.inera.intyg.webcert.web.web.controller.api.dto.Relations in project webcert by sklintyg.
the class IntygRelationHelperImplTest method testGetRelationsForIntygOneInITAndTwoFromWebcert.
@Test
public void testGetRelationsForIntygOneInITAndTwoFromWebcert() {
when(listRelationsForCertificateResponderInterface.listRelationsForCertificate(isNull(), any(ListRelationsForCertificateType.class))).thenReturn(buildResponse());
when(certificateRelationService.getRelations(INTYG_ID)).thenReturn(buildWebcertRelations());
Relations relationsForIntyg = testee.getRelationsForIntyg(INTYG_ID);
assertNotNull(relationsForIntyg);
assertFrontendRelationsIntygsIds(relationsForIntyg.getLatestChildRelations(), OTHER_INTYG_ID_3, null, OTHER_INTYG_ID, OTHER_INTYG_ID_2);
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.Relations in project webcert by sklintyg.
the class UtkastModuleApiControllerTest method getDraftShouldNotPatchIfNewAddressIsIncomplete.
@Test
public void getDraftShouldNotPatchIfNewAddressIsIncomplete() throws Exception {
// Given
String intygsTyp = "gdsnpinaii-intygsTyp";
String intygsId = "gdsnpinaii-intygsId";
setupUser(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, intygsTyp, false, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
when(utkastService.getDraft(CERTIFICATE_ID, intygsTyp)).thenReturn(buildUtkast(intygsTyp, intygsId));
when(certificateRelationService.getRelations(eq(intygsId))).thenReturn(new Relations());
String postadress = "gdsnpinaii-postadress";
String postort = "";
String postnummer = "gdsnpinaii-postnummer";
Patient patientWithIncompleteAddress = buildPatient();
patientWithIncompleteAddress.setPostadress(postadress);
patientWithIncompleteAddress.setPostort(postort);
patientWithIncompleteAddress.setPostnummer(postnummer);
when(patientDetailsResolver.resolvePatient(any(Personnummer.class), anyString())).thenReturn(patientWithIncompleteAddress);
// When
Response response = moduleApiController.getDraft(intygsTyp, CERTIFICATE_ID, request);
// Then
ArgumentCaptor<Patient> argumentCaptor = ArgumentCaptor.forClass(Patient.class);
verify(moduleApi).updateBeforeSave(anyString(), argumentCaptor.capture());
assertNotEquals(postadress, argumentCaptor.getValue().getPostadress());
assertNotEquals(postnummer, argumentCaptor.getValue().getPostnummer());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.Relations in project webcert by sklintyg.
the class UtkastModuleApiControllerTest method getDraftShouldPatchIfNewAddressExist.
@Test
public void getDraftShouldPatchIfNewAddressExist() throws Exception {
// Given
String intygsTyp = "gdspinae-intygsTyp";
String intygsId = "gdspinae-intygsId";
setupUser(AuthoritiesConstants.PRIVILEGE_SKRIVA_INTYG, intygsTyp, false, AuthoritiesConstants.FEATURE_HANTERA_INTYGSUTKAST);
when(utkastService.getDraft(CERTIFICATE_ID, intygsTyp)).thenReturn(buildUtkast(intygsTyp, intygsId));
when(certificateRelationService.getRelations(eq(intygsId))).thenReturn(new Relations());
String postadress = "gdspinae-postadress";
String postort = "gdspinae-postort";
String postnummer = "gdspinae-postnummer";
Patient patientWithIncompleteAddress = buildPatient();
patientWithIncompleteAddress.setPostadress(postadress);
patientWithIncompleteAddress.setPostort(postort);
patientWithIncompleteAddress.setPostnummer(postnummer);
when(patientDetailsResolver.resolvePatient(any(Personnummer.class), anyString())).thenReturn(patientWithIncompleteAddress);
// When
Response response = moduleApiController.getDraft(intygsTyp, CERTIFICATE_ID, request);
// Then
ArgumentCaptor<Patient> argumentCaptor = ArgumentCaptor.forClass(Patient.class);
verify(moduleApi).updateBeforeSave(anyString(), argumentCaptor.capture());
assertEquals(postadress, argumentCaptor.getValue().getPostadress());
assertEquals(postort, argumentCaptor.getValue().getPostort());
assertEquals(postnummer, argumentCaptor.getValue().getPostnummer());
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.Relations in project webcert by sklintyg.
the class CertificateRelationServiceImplTest method testGetWithParentRelation.
@Test
public void testGetWithParentRelation() {
when(utkastRepositoryCustom.findParentRelation(anyString())).thenReturn(buildParentRelations());
Relations relations = testee.getRelations(INTYG_ID);
assertEquals(OTHER_INTYG_ID, relations.getParent().getIntygsId());
assertFrontendRelations(relations.getLatestChildRelations(), null, null, null, null);
}
use of se.inera.intyg.webcert.web.web.controller.api.dto.Relations in project webcert by sklintyg.
the class CertificateRelationServiceImplTest method testGetWithNoRelations.
@Test
public void testGetWithNoRelations() {
Relations relations = testee.getRelations(INTYG_ID);
assertNull(relations.getParent());
assertFrontendRelations(relations.getLatestChildRelations(), null, null, null, null);
}
Aggregations