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