diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcSingleObservationIT.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcSingleObservationIT.java index 3313c1ee111..a8447121486 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcSingleObservationIT.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/search/lastn/LastNElasticsearchSvcSingleObservationIT.java @@ -17,6 +17,7 @@ import ca.uhn.fhir.rest.param.ReferenceParam; import ca.uhn.fhir.rest.param.TokenAndListParam; import ca.uhn.fhir.rest.param.TokenOrListParam; import ca.uhn.fhir.rest.param.TokenParam; +import ca.uhn.fhir.test.utilities.docker.RequiresDocker; import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.databind.ObjectMapper; @@ -47,6 +48,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertTrue; @ExtendWith(SpringExtension.class) +@RequiresDocker @Testcontainers public class LastNElasticsearchSvcSingleObservationIT { @@ -323,3 +325,4 @@ public class LastNElasticsearchSvcSingleObservationIT { } } + diff --git a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4ElasticsearchIT.java b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4ElasticsearchIT.java index 66ac0d415cb..80411d14ad0 100644 --- a/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4ElasticsearchIT.java +++ b/hapi-fhir-jpaserver-base/src/test/java/ca/uhn/fhir/jpa/term/ValueSetExpansionR4ElasticsearchIT.java @@ -23,6 +23,7 @@ import ca.uhn.fhir.jpa.term.custom.CustomTerminologySet; import ca.uhn.fhir.rest.api.server.storage.ResourcePersistentId; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; +import ca.uhn.fhir.test.utilities.docker.RequiresDocker; import org.hl7.fhir.instance.model.api.IIdType; import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeableConcept; @@ -50,6 +51,7 @@ import static org.mockito.Mockito.when; @ExtendWith(SpringExtension.class) @ContextConfiguration(classes = {TestR4ConfigWithElasticSearch.class}) +@RequiresDocker public class ValueSetExpansionR4ElasticsearchIT extends BaseJpaTest { protected static final String CS_URL = "http://example.com/my_code_system"; diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/docker/DockerRequiredCondition.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/docker/DockerRequiredCondition.java index 1d849814d81..7b264aad70b 100644 --- a/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/docker/DockerRequiredCondition.java +++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/fhir/test/utilities/docker/DockerRequiredCondition.java @@ -30,14 +30,18 @@ import org.testcontainers.DockerClientFactory; * Execution condition which will skip test classes that require docker if it is not present on the host machine */ public class DockerRequiredCondition implements ExecutionCondition { + public static final String AVAILABLE_MSG = "Docker is installed so we can run these tests!"; + public static final String UNAVAILABLE_MSG = "It appears as though docker is not installed on the host machine!"; @Override public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext theExtensionContext) { try { - DockerClientFactory.instance().isDockerAvailable(); - return ConditionEvaluationResult.enabled("Docker is installed so we can run these tests!"); + boolean isDockerAvailable = DockerClientFactory.instance().isDockerAvailable(); + return isDockerAvailable + ? ConditionEvaluationResult.enabled(AVAILABLE_MSG) + : ConditionEvaluationResult.disabled(UNAVAILABLE_MSG); } catch (Exception e) { - return ConditionEvaluationResult.disabled("It appears as though docker is not installed on the host machine!"); + return ConditionEvaluationResult.disabled(UNAVAILABLE_MSG); } } }