Search in sources :

Example 1 with ValidationException

use of com.b2international.snowowl.fhir.core.exceptions.ValidationException in project snow-owl by b2ihealthcare.

the class ExtensionTest method buildInvalid.

@Test
public void buildInvalid() {
    ValidationException exception = assertThrows(ValidationException.class, () -> {
        IntegerExtension.builder().url("ID").addExtension(IntegerExtension.builder().url("ID2").value(2).build()).value(1).build();
    });
    assertEquals("1 validation error", exception.getMessage());
    Issue expectedIssue = validationErrorIssueBuilder.addLocation("IntegerExtension.valid").detailsWithDisplay(OperationOutcomeCode.MSG_PARAM_INVALID, "Parameter 'valid' content is invalid [false]. " + "Violation: An extension SHALL have either a value (i.e. a value[x] element) or sub-extensions.").build();
    assertThat(exception, FhirExceptionIssueMatcher.issue(expectedIssue));
}
Also used : ValidationException(com.b2international.snowowl.fhir.core.exceptions.ValidationException) Issue(com.b2international.snowowl.fhir.core.model.Issue) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 2 with ValidationException

use of com.b2international.snowowl.fhir.core.exceptions.ValidationException in project snow-owl by b2ihealthcare.

the class IssueTest method buildInvalid.

@Test
public void buildInvalid() {
    ValidationException exception = assertThrows(ValidationException.class, () -> {
        Instant.builder().build();
    });
    assertEquals("1 validation error", exception.getMessage());
    Issue expectedIssue = validationErrorIssueBuilder.addLocation("Instant.instant").detailsWithDisplay(OperationOutcomeCode.MSG_PARAM_INVALID, "Parameter 'instant' content is invalid [null]. Violation: may not be null.").build();
    assertThat(exception, FhirExceptionIssueMatcher.issue(expectedIssue));
}
Also used : ValidationException(com.b2international.snowowl.fhir.core.exceptions.ValidationException) Issue(com.b2international.snowowl.fhir.core.model.Issue) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 3 with ValidationException

use of com.b2international.snowowl.fhir.core.exceptions.ValidationException in project snow-owl by b2ihealthcare.

the class BundleEntryTest method buildInvalidParametersEntry.

@Test
public void buildInvalidParametersEntry() {
    ValidationException exception = assertThrows(ValidationException.class, () -> {
        LookupRequest lookupRequest = LookupRequest.builder().code("23245-4").system("http://loinc.org").build();
        Json json1 = new Parameters.Json(lookupRequest);
        ParametersRequestEntry entry = ParametersRequestEntry.builder().request(BatchRequest.createGetRequest("CodeSystem/$lookup")).resource(new Parameters.Fhir(json1.parameters())).build();
    });
    Issue expectedIssue = validationErrorIssueBuilder.addLocation("ParametersRequestEntry.post").detailsWithDisplay(OperationOutcomeCode.MSG_PARAM_INVALID, "Parameter 'post' content is invalid [false]. Violation: Only POST requests can be parameter-based.").build();
    assertThat(exception, FhirExceptionIssueMatcher.issue(expectedIssue));
}
Also used : ValidationException(com.b2international.snowowl.fhir.core.exceptions.ValidationException) Json(com.b2international.snowowl.fhir.core.model.dt.Parameters.Json) LookupRequest(com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

ValidationException (com.b2international.snowowl.fhir.core.exceptions.ValidationException)3 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)3 Test (org.junit.Test)3 Issue (com.b2international.snowowl.fhir.core.model.Issue)2 LookupRequest (com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)1 Json (com.b2international.snowowl.fhir.core.model.dt.Parameters.Json)1