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