Search in sources :

Example 1 with CertificateResponse

use of se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse in project webcert by sklintyg.

the class IntygServiceSendTest method testSendIntygFailsForReplacedCertificate.

@Test(expected = WebCertServiceException.class)
public void testSendIntygFailsForReplacedCertificate() throws Exception {
    final String completionMeddelandeId = "meddelandeId";
    WebCertUser webCertUser = createUser();
    Utlatande completionUtlatande = utlatande;
    completionUtlatande.getGrundData().setRelation(new Relation());
    completionUtlatande.getGrundData().getRelation().setRelationKod(RelationKod.KOMPLT);
    completionUtlatande.getGrundData().getRelation().setMeddelandeId(completionMeddelandeId);
    when(webCertUserService.isAuthorizedForUnit(anyString(), anyString(), anyBoolean())).thenReturn(true);
    when(webCertUserService.getUser()).thenReturn(webCertUser);
    when(intygRepository.findOne(INTYG_ID)).thenReturn(getUtkast(INTYG_ID));
    WebcertCertificateRelation ersattRelation = new WebcertCertificateRelation(INTYG_ID, RelationKod.ERSATT, LocalDateTime.now(), UtkastStatus.SIGNED);
    when(certificateRelationService.getNewestRelationOfType(eq(INTYG_ID), eq(RelationKod.ERSATT), eq(Arrays.asList(UtkastStatus.SIGNED)))).thenReturn(Optional.of(ersattRelation));
    CertificateMetaData metaData = new CertificateMetaData();
    metaData.setStatus(new ArrayList<>());
    CertificateResponse revokedCertificateResponse = new CertificateResponse(json, utlatande, metaData, false);
    when(moduleFacade.getCertificate(any(String.class), any(String.class))).thenReturn(revokedCertificateResponse);
    when(moduleFacade.getUtlatandeFromInternalModel(any(), any())).thenReturn(utlatande);
    intygService.sendIntyg(INTYG_ID, INTYG_TYP_FK, "FKASSA", false);
    verifyZeroInteractions(logService);
}
Also used : Relation(se.inera.intyg.common.support.model.common.internal.Relation) WebcertCertificateRelation(se.inera.intyg.webcert.common.model.WebcertCertificateRelation) Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) Utlatande(se.inera.intyg.common.support.model.common.internal.Utlatande) WebcertCertificateRelation(se.inera.intyg.webcert.common.model.WebcertCertificateRelation) CertificateResponse(se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CertificateMetaData(se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData) WebCertUser(se.inera.intyg.webcert.web.service.user.dto.WebCertUser) Test(org.junit.Test)

Example 2 with CertificateResponse

use of se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse in project webcert by sklintyg.

the class IntygServiceStoreTest method setupMocks.

@Before
@Override
public void setupMocks() throws Exception {
    json = FileUtils.getStringFromFile(new ClassPathResource("IntygServiceTest/utlatande.json").getFile());
    utlatande = objectMapper.readValue(json, Fk7263Utlatande.class);
    CertificateMetaData metaData = buildCertificateMetaData();
    certificateResponse = new CertificateResponse(json, utlatande, metaData, false);
}
Also used : Fk7263Utlatande(se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande) CertificateResponse(se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse) ClassPathResource(org.springframework.core.io.ClassPathResource) CertificateMetaData(se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData) Before(org.junit.Before)

Example 3 with CertificateResponse

use of se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse in project webcert by sklintyg.

the class IntygModuleFacadeTest method testGetCertificate.

@Test
public void testGetCertificate() throws Exception {
    final String certificateId = "certificateId";
    final String logicalAddress = "logicalAddress";
    ReflectionTestUtils.setField(moduleFacade, "logicalAddress", logicalAddress);
    when(moduleApi.getCertificate(certificateId, logicalAddress, HSVARD_RECIPIENT_ID)).thenReturn(new CertificateResponse(INT_JSON, null, new CertificateMetaData(), false));
    CertificateResponse res = moduleFacade.getCertificate(certificateId, CERTIFICATE_TYPE);
    assertNotNull(res);
    verify(moduleApi).getCertificate(certificateId, logicalAddress, HSVARD_RECIPIENT_ID);
}
Also used : CertificateResponse(se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse) ArgumentMatchers.anyString(org.mockito.ArgumentMatchers.anyString) CertificateMetaData(se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData) Test(org.junit.Test)

Example 4 with CertificateResponse

use of se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse in project webcert by sklintyg.

the class UtkastIntygDecoratorTest method testRevokedIntygDoesNotAddAnyStatuses.

@Test
public void testRevokedIntygDoesNotAddAnyStatuses() {
    CertificateResponse response = buildCertificateResponse();
    CertificateResponse revokedResponse = new CertificateResponse(response.getInternalModel(), response.getUtlatande(), response.getMetaData(), true);
    testee.decorateWithUtkastStatus(revokedResponse);
    assertEquals(1, response.getMetaData().getStatus().size());
}
Also used : CertificateResponse(se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse) Test(org.junit.Test)

Example 5 with CertificateResponse

use of se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse in project webcert by sklintyg.

the class UtkastIntygDecoratorTest method testRevokedStatusIsAddedFromUtkast.

@Test
public void testRevokedStatusIsAddedFromUtkast() {
    signedUtkast.setSkickadTillMottagareDatum(LocalDateTime.now());
    signedUtkast.setAterkalladDatum(LocalDateTime.now());
    when(utkastRepository.findOne(isNull())).thenReturn(signedUtkast);
    CertificateResponse response = buildCertificateResponse();
    testee.decorateWithUtkastStatus(response);
    assertEquals(3, response.getMetaData().getStatus().size());
    assertEquals(CertificateState.RECEIVED, response.getMetaData().getStatus().get(0).getType());
    assertEquals(CertificateState.SENT, response.getMetaData().getStatus().get(1).getType());
    assertEquals(CertificateState.CANCELLED, response.getMetaData().getStatus().get(2).getType());
}
Also used : CertificateResponse(se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse) Test(org.junit.Test)

Aggregations

CertificateResponse (se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse)14 Test (org.junit.Test)9 CertificateMetaData (se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData)6 ArgumentMatchers.anyString (org.mockito.ArgumentMatchers.anyString)5 Fk7263Utlatande (se.inera.intyg.common.fk7263.model.internal.Fk7263Utlatande)5 Before (org.junit.Before)4 ClassPathResource (org.springframework.core.io.ClassPathResource)4 Status (se.inera.intyg.common.support.model.Status)3 Patient (se.inera.intyg.common.support.model.common.internal.Patient)3 Personnummer (se.inera.intyg.schemas.contract.Personnummer)3 UtkastStatus (se.inera.intyg.webcert.common.model.UtkastStatus)3 Relations (se.inera.intyg.webcert.web.web.controller.api.dto.Relations)3 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)2 IOException (java.io.IOException)1 LocalDateTime (java.time.LocalDateTime)1 ChronoLocalDateTime (java.time.chrono.ChronoLocalDateTime)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 WebServiceException (javax.xml.ws.WebServiceException)1 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)1