Search in sources :

Example 26 with Issue

use of com.b2international.snowowl.fhir.core.model.Issue 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 27 with Issue

use of com.b2international.snowowl.fhir.core.model.Issue in project snow-owl by b2ihealthcare.

the class IssueTest method build.

@Test
public void build() throws Exception {
    Issue issue = Issue.builder().severity(IssueSeverity.ERROR).code(IssueType.REQUIRED).addExpression("Issue expression").addLocation("Issue location").details(CodeableConcept.builder().addCoding(Coding.builder().code("A").display("A display").build()).text("Text").build()).build();
    assertEquals(IssueSeverity.ERROR.getCode(), issue.getSeverity());
    assertEquals(IssueType.REQUIRED.getCode(), issue.getCode());
    assertThat(issue.getExpressions(), hasItems("Issue expression"));
    assertThat(issue.getLocations(), hasItems("Issue location"));
    CodeableConcept details = issue.getDetails();
    assertEquals(1, details.getCodings().size());
    assertEquals("Text", details.getText());
    Coding coding = details.getCodings().iterator().next();
    assertEquals("A", coding.getCode().getCodeValue());
    assertEquals("A display", coding.getDisplay());
}
Also used : Issue(com.b2international.snowowl.fhir.core.model.Issue) Coding(com.b2international.snowowl.fhir.core.model.dt.Coding) CodeableConcept(com.b2international.snowowl.fhir.core.model.dt.CodeableConcept) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 28 with Issue

use of com.b2international.snowowl.fhir.core.model.Issue in project snow-owl by b2ihealthcare.

the class OperationOutcomeTest method buildWithMissingIssue.

@Test
public void buildWithMissingIssue() throws Exception {
    Issue expectedIssue = validationErrorIssueBuilder.addLocation("OperationOutcome.issues").detailsWithDisplay(OperationOutcomeCode.MSG_PARAM_INVALID, "Parameter 'issues' content is invalid [null]. Violation: may not be empty.").build();
    exception.expect(ValidationException.class);
    exception.expectMessage("1 validation error");
    exception.expect(FhirExceptionIssueMatcher.issue(expectedIssue));
    OperationOutcome.builder().build();
}
Also used : Issue(com.b2international.snowowl.fhir.core.model.Issue) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 29 with Issue

use of com.b2international.snowowl.fhir.core.model.Issue in project snow-owl by b2ihealthcare.

the class OperationOutcomeTest method build.

@Test
public void build() throws Exception {
    OperationOutcome operationOutcome = OperationOutcome.builder().addIssue(Issue.builder().severity(IssueSeverity.ERROR).code(IssueType.REQUIRED).build()).build();
    assertEquals(1, operationOutcome.getIssues().size());
    Issue issue = operationOutcome.getIssues().iterator().next();
    assertEquals(IssueSeverity.ERROR.getCode(), issue.getSeverity());
    assertEquals(IssueType.REQUIRED.getCode(), issue.getCode());
}
Also used : Issue(com.b2international.snowowl.fhir.core.model.Issue) OperationOutcome(com.b2international.snowowl.fhir.core.model.OperationOutcome) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Example 30 with Issue

use of com.b2international.snowowl.fhir.core.model.Issue in project snow-owl by b2ihealthcare.

the class OperationOutcomeTest method deserialize.

@Test
public void deserialize() throws Exception {
    OperationOutcome operationOutcome = OperationOutcome.builder().addIssue(Issue.builder().severity(IssueSeverity.ERROR).code(IssueType.REQUIRED).build()).build();
    OperationOutcome readOperationOutcome = objectMapper.readValue(objectMapper.writeValueAsString(operationOutcome), OperationOutcome.class);
    assertEquals(1, readOperationOutcome.getIssues().size());
    Issue issue = readOperationOutcome.getIssues().iterator().next();
    assertEquals(IssueSeverity.ERROR.getCode(), issue.getSeverity());
    assertEquals(IssueType.REQUIRED.getCode(), issue.getCode());
}
Also used : Issue(com.b2international.snowowl.fhir.core.model.Issue) OperationOutcome(com.b2international.snowowl.fhir.core.model.OperationOutcome) FhirTest(com.b2international.snowowl.fhir.tests.FhirTest) Test(org.junit.Test)

Aggregations

Issue (com.b2international.snowowl.fhir.core.model.Issue)47 Test (org.junit.Test)44 FhirTest (com.b2international.snowowl.fhir.tests.FhirTest)42 Builder (com.b2international.snowowl.fhir.core.model.Issue.Builder)18 Coding (com.b2international.snowowl.fhir.core.model.dt.Coding)6 ValidationException (com.b2international.snowowl.fhir.core.exceptions.ValidationException)5 OperationOutcomeCode (com.b2international.snowowl.fhir.core.codesystems.OperationOutcomeCode)4 OperationOutcome (com.b2international.snowowl.fhir.core.model.OperationOutcome)4 CodeableConcept (com.b2international.snowowl.fhir.core.model.dt.CodeableConcept)4 Fhir (com.b2international.snowowl.fhir.core.model.dt.Parameters.Fhir)4 Json (com.b2international.snowowl.fhir.core.model.dt.Parameters.Json)4 IssueSeverity (com.b2international.snowowl.fhir.core.codesystems.IssueSeverity)3 IssueType (com.b2international.snowowl.fhir.core.codesystems.IssueType)3 Parameters (com.b2international.snowowl.fhir.core.model.dt.Parameters)3 FhirExceptionIssueMatcher (com.b2international.snowowl.fhir.tests.FhirExceptionIssueMatcher)3 Optional (java.util.Optional)3 Assert.assertTrue (org.junit.Assert.assertTrue)3 BadRequestException (com.b2international.snowowl.fhir.core.exceptions.BadRequestException)2 LookupRequest (com.b2international.snowowl.fhir.core.model.codesystem.LookupRequest)2 Parameter (com.b2international.snowowl.fhir.core.model.dt.Parameter)2