Search in sources :

Example 1 with CertificateMetaData

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

the class AbstractIntygServiceTest method buildCertificateMetaData.

protected CertificateMetaData buildCertificateMetaData() {
    CertificateMetaData metaData = new CertificateMetaData();
    metaData.setStatus(new ArrayList<>());
    Status statusSigned = new Status(CertificateState.RECEIVED, "FKASSA", LocalDateTime.now());
    metaData.getStatus().add(statusSigned);
    metaData.setSignDate(LocalDateTime.now());
    return metaData;
}
Also used : Status(se.inera.intyg.common.support.model.Status) CertificateMetaData(se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData)

Example 2 with CertificateMetaData

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

the class IntygServiceSendTest method testSendIntygFailsForRevokedCertificate.

@Test(expected = WebCertServiceException.class)
public void testSendIntygFailsForRevokedCertificate() throws Exception {
    when(intygRepository.findOne(INTYG_ID)).thenReturn(getUtkast(INTYG_ID));
    CertificateMetaData metaData = new CertificateMetaData();
    metaData.setStatus(new ArrayList<>());
    when(moduleFacade.getUtlatandeFromInternalModel(isNull(), anyString())).thenReturn(utlatande);
    intygService.sendIntyg(INTYG_ID, INTYG_TYP_FK, "FKASSA", false);
    verifyZeroInteractions(logService);
}
Also used : CertificateMetaData(se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData) Test(org.junit.Test)

Example 3 with CertificateMetaData

use of se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData 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 4 with CertificateMetaData

use of se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData 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 5 with CertificateMetaData

use of se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData 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)

Aggregations

CertificateMetaData (se.inera.intyg.common.support.modules.support.api.dto.CertificateMetaData)9 CertificateResponse (se.inera.intyg.common.support.modules.support.api.dto.CertificateResponse)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 Test (org.junit.Test)3 Status (se.inera.intyg.common.support.model.Status)2 Patient (se.inera.intyg.common.support.model.common.internal.Patient)2 Personnummer (se.inera.intyg.schemas.contract.Personnummer)2 Relations (se.inera.intyg.webcert.web.web.controller.api.dto.Relations)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 ArgumentMatchers.anyList (org.mockito.ArgumentMatchers.anyList)1 RelationKod (se.inera.intyg.common.support.common.enumerations.RelationKod)1 Relation (se.inera.intyg.common.support.model.common.internal.Relation)1 Utlatande (se.inera.intyg.common.support.model.common.internal.Utlatande)1 UtkastStatus (se.inera.intyg.webcert.common.model.UtkastStatus)1 WebcertCertificateRelation (se.inera.intyg.webcert.common.model.WebcertCertificateRelation)1 VardpersonReferens (se.inera.intyg.webcert.persistence.utkast.model.VardpersonReferens)1