Skip to content

Commit

Permalink
issue #2436 - validate the metadata response in e2e tests (#2467)
Browse files Browse the repository at this point in the history
For both the CapabilityStatement and the TerminologyStatement.

Signed-off-by: Lee Surprenant <lmsurpre@us.ibm.com>
  • Loading branch information
lmsurpre authored Jun 4, 2021
1 parent 4c74d8d commit c185a79
Showing 1 changed file with 26 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
package com.ibm.fhir.server.test;

import static com.ibm.fhir.model.type.String.string;
import static org.testng.Assert.assertFalse;
import static org.testng.AssertJUnit.assertEquals;
import static org.testng.AssertJUnit.assertNotNull;
import static org.testng.AssertJUnit.assertTrue;
Expand All @@ -18,6 +19,7 @@
import java.util.Collections;
import java.util.Iterator;
import java.util.List;
import java.util.stream.Collectors;

import javax.ws.rs.client.Entity;
import javax.ws.rs.client.WebTarget;
Expand All @@ -34,6 +36,7 @@
import com.ibm.fhir.model.resource.Immunization;
import com.ibm.fhir.model.resource.Observation;
import com.ibm.fhir.model.resource.OperationOutcome;
import com.ibm.fhir.model.resource.OperationOutcome.Issue;
import com.ibm.fhir.model.resource.Patient;
import com.ibm.fhir.model.resource.Resource;
import com.ibm.fhir.model.resource.TerminologyCapabilities;
Expand All @@ -49,6 +52,9 @@
import com.ibm.fhir.path.evaluator.FHIRPathEvaluator;
import com.ibm.fhir.path.evaluator.FHIRPathEvaluator.EvaluationContext;
import com.ibm.fhir.path.exception.FHIRPathException;
import com.ibm.fhir.validation.FHIRValidator;
import com.ibm.fhir.validation.exception.FHIRValidationException;
import com.ibm.fhir.validation.util.FHIRValidationUtil;

import jakarta.json.JsonObject;

Expand All @@ -63,7 +69,7 @@ public class BasicServerTest extends FHIRServerTestBase {
* Verify the 'metadata' API.
*/
@Test(groups = { "server-basic" })
public void testMetadataAPI() throws FHIRPathException {
public void testMetadataAPI() throws FHIRPathException, FHIRValidationException {
WebTarget target = getWebTarget();
Response response = target.path("metadata").request().get();
assertResponse(response, Response.Status.OK.getStatusCode());
Expand All @@ -85,10 +91,19 @@ public void testMetadataAPI() throws FHIRPathException {
instance = node._boolean();
}
assertTrue(instance);

List<Issue> issues = FHIRValidator.validator().validate(conf);
assertFalse(FHIRValidationUtil.hasErrors(issues));
if (FHIRValidationUtil.hasWarnings(issues)) {
System.out.println("CapabilityStatement warnings: \n" +
FHIRValidationUtil.getWarnings(issues).stream()
.map(i -> i.getDetails().getText().getValue())
.collect(Collectors.joining("\n")));
}
}

@Test(groups = { "server-basic" })
public void testMetadataAPITerminology() throws FHIRPathException {
public void testMetadataAPITerminology() throws FHIRPathException, FHIRValidationException {
WebTarget target = getWebTarget();
Response response = target.path("metadata").queryParam("mode", "terminology").request().get();
assertResponse(response, Response.Status.OK.getStatusCode());
Expand All @@ -108,6 +123,15 @@ public void testMetadataAPITerminology() throws FHIRPathException {
instance = node._boolean();
}
assertTrue(instance);

List<Issue> issues = FHIRValidator.validator().validate(conf);
assertFalse(FHIRValidationUtil.hasErrors(issues));
if (FHIRValidationUtil.hasWarnings(issues)) {
System.out.println("TerminologyStatement warnings: \n" +
FHIRValidationUtil.getWarnings(issues).stream()
.map(i -> i.getDetails().getText().getValue())
.collect(Collectors.joining("\n")));
}
}

/**
Expand Down

0 comments on commit c185a79

Please sign in to comment.