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