Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
revinclude integration tests
Browse files Browse the repository at this point in the history
  • Loading branch information
hhund committed Feb 10, 2020
1 parent 69b5367 commit 4fd7fc8
Show file tree
Hide file tree
Showing 3 changed files with 97 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
package org.highmed.dsf.fhir.integration;

import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.util.Collections;
import java.util.Map;

import org.hl7.fhir.r4.model.Bundle;
import org.hl7.fhir.r4.model.Bundle.BundleEntryComponent;
import org.hl7.fhir.r4.model.Bundle.SearchEntryMode;
import org.hl7.fhir.r4.model.Endpoint;
import org.hl7.fhir.r4.model.Organization;
import org.junit.Test;

public class EndpointIntegrationTest extends AbstractIntegrationTest
{
@Test
public void testSearchAll() throws Exception
{
Bundle searchBundle = getWebserviceClient().search(Endpoint.class, Collections.emptyMap());
assertNotNull(searchBundle);
assertEquals(1, searchBundle.getTotal());
assertTrue(searchBundle.getEntryFirstRep().getResource() instanceof Endpoint);
}

@Test
public void testSearchEndpointIncludeOrganization() throws Exception
{
Bundle searchBundle = getWebserviceClient().search(Endpoint.class,
Map.of("_include", Collections.singletonList("Endpoint:organization")));
assertNotNull(searchBundle);
assertEquals(1, searchBundle.getTotal());
assertEquals(2, searchBundle.getEntry().size());

BundleEntryComponent eptEntry = searchBundle.getEntry().get(0);
assertNotNull(eptEntry);
assertEquals(SearchEntryMode.MATCH, eptEntry.getSearch().getMode());
assertNotNull(eptEntry.getResource());
assertTrue(eptEntry.getResource() instanceof Endpoint);

BundleEntryComponent orgEntry = searchBundle.getEntry().get(1);
assertNotNull(orgEntry);
assertEquals(SearchEntryMode.INCLUDE, orgEntry.getSearch().getMode());
assertNotNull(orgEntry.getResource());
assertTrue(orgEntry.getResource() instanceof Organization);
}

@Test
public void testSearchEndpointRevIncludeOrganization() throws Exception
{
Bundle searchBundle = getWebserviceClient().search(Endpoint.class,
Map.of("_revinclude", Collections.singletonList("Organization:endpoint")));
assertNotNull(searchBundle);
assertEquals(1, searchBundle.getTotal());
assertEquals(2, searchBundle.getEntry().size());

BundleEntryComponent orgEntry = searchBundle.getEntry().get(0);
assertNotNull(orgEntry);
assertEquals(SearchEntryMode.MATCH, orgEntry.getSearch().getMode());
assertNotNull(orgEntry.getResource());
assertTrue(orgEntry.getResource() instanceof Endpoint);

BundleEntryComponent eptEntry = searchBundle.getEntry().get(1);
assertNotNull(eptEntry);
assertEquals(SearchEntryMode.INCLUDE, eptEntry.getSearch().getMode());
assertNotNull(eptEntry.getResource());
assertTrue(eptEntry.getResource() instanceof Organization);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ public void testSearchAll() throws Exception
Bundle searchBundle = getWebserviceClient().search(Organization.class, Collections.emptyMap());
assertNotNull(searchBundle);
assertEquals(1, searchBundle.getTotal());
assertTrue(searchBundle.getEntryFirstRep().getResource() instanceof Organization);
}

@Test
Expand All @@ -45,4 +46,26 @@ public void testSearchOrganizationIncludeEndpoint() throws Exception
assertNotNull(eptEntry.getResource());
assertTrue(eptEntry.getResource() instanceof Endpoint);
}

@Test
public void testSearchOrganizationRevIncludeEndpoint() throws Exception
{
Bundle searchBundle = getWebserviceClient().search(Organization.class,
Map.of("_revinclude", Collections.singletonList("Endpoint:organization")));
assertNotNull(searchBundle);
assertEquals(1, searchBundle.getTotal());
assertEquals(2, searchBundle.getEntry().size());

BundleEntryComponent orgEntry = searchBundle.getEntry().get(0);
assertNotNull(orgEntry);
assertEquals(SearchEntryMode.MATCH, orgEntry.getSearch().getMode());
assertNotNull(orgEntry.getResource());
assertTrue(orgEntry.getResource() instanceof Organization);

BundleEntryComponent eptEntry = searchBundle.getEntry().get(1);
assertNotNull(eptEntry);
assertEquals(SearchEntryMode.INCLUDE, eptEntry.getSearch().getMode());
assertNotNull(eptEntry.getResource());
assertTrue(eptEntry.getResource() instanceof Endpoint);
}
}
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package org.highmed.dsf.fhir.test;

import org.highmed.dsf.fhir.integration.BinaryIntegrationTest;
import org.highmed.dsf.fhir.integration.EndpointIntegrationTest;
import org.highmed.dsf.fhir.integration.OrganizationIntegrationTest;
import org.highmed.dsf.fhir.integration.TaskIntegrationTest;
import org.junit.ClassRule;
Expand All @@ -9,7 +10,8 @@
import org.junit.runners.Suite.SuiteClasses;

@RunWith(Suite.class)
@SuiteClasses({ BinaryIntegrationTest.class, OrganizationIntegrationTest.class, TaskIntegrationTest.class })
@SuiteClasses({ BinaryIntegrationTest.class, EndpointIntegrationTest.class, OrganizationIntegrationTest.class,
TaskIntegrationTest.class })
public class TestSuiteIntegrationTests
{
@ClassRule
Expand Down

0 comments on commit 4fd7fc8

Please sign in to comment.