Search in sources :

Example 1 with TransformException

use of gov.cms.qpp.conversion.model.error.TransformException in project qpp-conversion-tool by CMSgov.

the class ExceptionHandlerControllerV1Test method testTransformExceptionBody.

@Test
void testTransformExceptionBody() {
    TransformException exception = new TransformException("test transform exception", new NullPointerException(), report);
    ResponseEntity<AllErrors> responseEntity = objectUnderTest.handleTransformException(exception);
    assertThat(responseEntity.getBody()).isEqualTo(allErrors);
}
Also used : AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) TransformException(gov.cms.qpp.conversion.model.error.TransformException) Test(org.junit.jupiter.api.Test)

Example 2 with TransformException

use of gov.cms.qpp.conversion.model.error.TransformException in project qpp-conversion-tool by CMSgov.

the class ExceptionHandlerControllerV1Test method testTransformExceptionHeaderContentType.

@Test
void testTransformExceptionHeaderContentType() {
    TransformException exception = new TransformException("test transform exception", new NullPointerException(), report);
    ResponseEntity<AllErrors> responseEntity = objectUnderTest.handleTransformException(exception);
    assertThat(responseEntity.getHeaders().getContentType()).isEquivalentAccordingToCompareTo(MediaType.APPLICATION_JSON_UTF8);
}
Also used : AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) TransformException(gov.cms.qpp.conversion.model.error.TransformException) Test(org.junit.jupiter.api.Test)

Example 3 with TransformException

use of gov.cms.qpp.conversion.model.error.TransformException in project qpp-conversion-tool by CMSgov.

the class QrdaControllerV1Test method testFailedQppValidation.

@Test
void testFailedQppValidation() {
    String transformationErrorMessage = "Test failed QPP validation";
    when(qrdaService.convertQrda3ToQpp(any(Source.class))).thenReturn(null);
    Mockito.doThrow(new TransformException(transformationErrorMessage, null, null)).when(validationService).validateQpp(isNull());
    try {
        ResponseEntity qppResponse = objectUnderTest.uploadQrdaFile(multipartFile, null);
        Assertions.fail("An exception should have occurred. Instead was " + qppResponse);
    } catch (TransformException exception) {
        assertThat(exception.getMessage()).isEqualTo(transformationErrorMessage);
    } catch (Exception exception) {
        Assertions.fail("The wrong exception occurred.");
    }
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) TransformException(gov.cms.qpp.conversion.model.error.TransformException) Source(gov.cms.qpp.conversion.Source) TransformException(gov.cms.qpp.conversion.model.error.TransformException) IOException(java.io.IOException) UncheckedIOException(java.io.UncheckedIOException) Test(org.junit.jupiter.api.Test)

Example 4 with TransformException

use of gov.cms.qpp.conversion.model.error.TransformException in project qpp-conversion-tool by CMSgov.

the class ClinicalDocumentValidatorTest method testClinicalDocumentValidationParsesMultipleErrors.

@Test
void testClinicalDocumentValidationParsesMultipleErrors() {
    // setup
    Path path = Paths.get("src/test/resources/negative/angerClinicalDocumentValidations.xml");
    // execute
    Context context = new Context();
    context.setDoDefaults(true);
    Converter converter = new Converter(new PathSource(path), context);
    AllErrors allErrors = new AllErrors();
    try {
        converter.transform();
    } catch (TransformException exception) {
        allErrors = exception.getDetails();
    }
    List<Detail> errors = getErrors(allErrors);
    assertWithMessage("Must have 4 errors").that(errors).hasSize(4);
    assertWithMessage("Must contain the correct errors").that(errors).comparingElementsUsing(DetailsErrorEquals.INSTANCE).containsAllOf(ErrorCode.CLINICAL_DOCUMENT_MISSING_PROGRAM_NAME, ErrorCode.REPORTING_PARAMETERS_MUST_CONTAIN_SINGLE_PERFORMANCE_START);
}
Also used : Path(java.nio.file.Path) Context(gov.cms.qpp.conversion.Context) AllErrors(gov.cms.qpp.conversion.model.error.AllErrors) PathSource(gov.cms.qpp.conversion.PathSource) TransformException(gov.cms.qpp.conversion.model.error.TransformException) Converter(gov.cms.qpp.conversion.Converter) Detail(gov.cms.qpp.conversion.model.error.Detail) Test(org.junit.jupiter.api.Test)

Example 5 with TransformException

use of gov.cms.qpp.conversion.model.error.TransformException in project qpp-conversion-tool by CMSgov.

the class ConverterTest method testInvalidXml.

@Test
public void testInvalidXml() {
    Path path = Paths.get("src/test/resources/non-xml-file.xml");
    Converter converter = new Converter(new PathSource(path));
    try {
        converter.transform();
        fail();
    } catch (TransformException exception) {
        checkup(exception, ErrorCode.NOT_VALID_XML_DOCUMENT);
    }
}
Also used : Path(java.nio.file.Path) TransformException(gov.cms.qpp.conversion.model.error.TransformException) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

TransformException (gov.cms.qpp.conversion.model.error.TransformException)27 AllErrors (gov.cms.qpp.conversion.model.error.AllErrors)21 Test (org.junit.jupiter.api.Test)17 Converter (gov.cms.qpp.conversion.Converter)16 PathSource (gov.cms.qpp.conversion.PathSource)13 Path (java.nio.file.Path)10 Detail (gov.cms.qpp.conversion.model.error.Detail)9 ArrayList (java.util.ArrayList)6 Test (org.junit.Test)4 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)4 Context (gov.cms.qpp.conversion.Context)2 InputStreamSupplierSource (gov.cms.qpp.conversion.InputStreamSupplierSource)2 LocalizedError (gov.cms.qpp.conversion.model.error.LocalizedError)2 InputStream (java.io.InputStream)2 List (java.util.List)2 ParameterizedTest (org.junit.jupiter.params.ParameterizedTest)2 MethodSource (org.junit.jupiter.params.provider.MethodSource)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 ObjectWriter (com.fasterxml.jackson.databind.ObjectWriter)1 ConversionReport (gov.cms.qpp.conversion.ConversionReport)1