Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gb-cic committed Dec 19, 2023
1 parent cfacb71 commit 9600005
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ void whenEdsFails_anErrorShouldBeReturned() {

mockIniClient(HttpStatus.OK, true);
mockEdsClient(HttpStatus.INTERNAL_SERVER_ERROR);
assertThrows(HttpServerErrorException.InternalServerError.class, () -> callDelete(idDocument));
assertThrows(BusinessException.class, () -> callDelete(idDocument));
}

void mockIniClient(final HttpStatus status, boolean esito) {
Expand Down Expand Up @@ -174,7 +174,7 @@ void mockEdsClient(final HttpStatus status) {
.exchange(anyString(), eq(HttpMethod.DELETE), eq(null), ArgumentMatchers.eq(EdsResponseDTO.class));
} else {
Mockito.doThrow(new BusinessException("")).when(restTemplate)
.exchange(anyString(), eq(HttpMethod.DELETE), eq(null), ArgumentMatchers.eq(EdsResponseDTO.class));
.exchange(anyString(), eq(HttpMethod.DELETE), any(), ArgumentMatchers.eq(EdsResponseDTO.class));
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -376,33 +376,6 @@ void testPublicationDateError() {
assertEquals(RestExecutionResultEnum.OK.getType(), resPublicationOk.getType());
}

@Test
void publicationForcedTest() {

//given(client.callConvertCdaInBundle(any(FhirResourceDTO.class))).willReturn(new TransformResDTO("", "{\"json\" : \"json\"}"));
doReturn(new ResponseEntity<>(new TransformResDTO("", Document.parse("{\"json\" : \"json\"}")), HttpStatus.OK))
.when(restTemplate).exchange(anyString(), eq(HttpMethod.POST), any(HttpEntity.class), eq(TransformResDTO.class));

final byte[] file = FileUtility.getFileFromInternalResources("Files" + File.separator + "attachment" + File.separator + "SIGNED_LDO1.pdf");
final String jwtToken = generateJwt(file, true, EventTypeEnum.PUBLICATION);

final ValidationCDAReqDTO validationRB = validateDataPreparation();

// Mocking validator
final ValidationInfoDTO info = new ValidationInfoDTO(RawValidationEnum.OK, new ArrayList<>(), "", "");
given(validatorClient.validate(anyString(),anyString(), any())).willReturn(info);

final ResponseEntity<ValidationResDTO> validationResponse = callPlainValidation(jwtToken, file, validationRB);
assumeFalse(validationResponse == null);

final PublicationCreationReqDTO publicationRB = publicationDataPreparation();

final ResponseEntity<PublicationResDTO> publicationResponse = callPlainPublication(jwtToken, file, publicationRB);
assertNotNull(publicationResponse);
assertEquals(HttpStatus.CREATED.value(), publicationResponse.getStatusCode().value());

}

@Test
@DisplayName("error fhir creation")
void errorFhirResourceCreationTest() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,5 @@
public class TestConstants {
private TestConstants() {}
public static final String documentId = "030702.TSTSMN63A01F205H.20220325112426.OQlvTq1J";
public static final String mockRequest = "{\"workflowInstanceId\":\"wfid\",\"healthDataFormat\":\"CDA\",\"mode\":\"ATTACHMENT\",\"tipologiaStruttura\":\"Ospedale\",\"attiCliniciRegoleAccesso\":[\"P99\"],\"identificativoDoc\":\"030702.TSTSMN63A01F205H.20220325112426.OQlvTq1J\",\"identificativoRep\":\"string\",\"tipoDocumentoLivAlto\":\"WOR\",\"assettoOrganizzativo\":\"AD_PSC001\",\"conservazioneANorma\":\"string\",\"tipoAttivitaClinica\":\"PHR\",\"identificativoSottomissione\":\"string\",\"forcePublish\":false,\"priorita\":true}";
public static final String mockRequest = "{\"workflowInstanceId\":\"wfid\",\"healthDataFormat\":\"CDA\",\"mode\":\"ATTACHMENT\",\"tipologiaStruttura\":\"Ospedale\",\"attiCliniciRegoleAccesso\":[\"P99\"],\"identificativoDoc\":\"030702.TSTSMN63A01F205H.20220325112426.OQlvTq1J\",\"identificativoRep\":\"string\",\"tipoDocumentoLivAlto\":\"WOR\",\"assettoOrganizzativo\":\"AD_PSC001\",\"conservazioneANorma\":\"string\",\"tipoAttivitaClinica\":\"PHR\",\"identificativoSottomissione\":\"string\",\"priorita\":true}";
}

0 comments on commit 9600005

Please sign in to comment.