Merge pull request #2704 from hapifhir/2703-@RequiresDocker-annotation-check-fails

Fix DockerRequiredCondition check.
This commit is contained in:
jmarchionatto 2021-06-03 15:58:38 -04:00 committed by GitHub
commit d574c4625b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 12 additions and 3 deletions

View File

@ -17,6 +17,7 @@ import ca.uhn.fhir.rest.param.ReferenceParam;
import ca.uhn.fhir.rest.param.TokenAndListParam; import ca.uhn.fhir.rest.param.TokenAndListParam;
import ca.uhn.fhir.rest.param.TokenOrListParam; import ca.uhn.fhir.rest.param.TokenOrListParam;
import ca.uhn.fhir.rest.param.TokenParam; 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.annotation.JsonInclude;
import com.fasterxml.jackson.core.JsonGenerator; import com.fasterxml.jackson.core.JsonGenerator;
import com.fasterxml.jackson.databind.ObjectMapper; 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; import static org.junit.jupiter.api.Assertions.assertTrue;
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@RequiresDocker
@Testcontainers @Testcontainers
public class LastNElasticsearchSvcSingleObservationIT { public class LastNElasticsearchSvcSingleObservationIT {
@ -323,3 +325,4 @@ public class LastNElasticsearchSvcSingleObservationIT {
} }
} }

View File

@ -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.api.server.storage.ResourcePersistentId;
import ca.uhn.fhir.rest.server.exceptions.InternalErrorException; import ca.uhn.fhir.rest.server.exceptions.InternalErrorException;
import ca.uhn.fhir.rest.server.servlet.ServletRequestDetails; 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.instance.model.api.IIdType;
import org.hl7.fhir.r4.model.CodeSystem; import org.hl7.fhir.r4.model.CodeSystem;
import org.hl7.fhir.r4.model.CodeableConcept; import org.hl7.fhir.r4.model.CodeableConcept;
@ -50,6 +51,7 @@ import static org.mockito.Mockito.when;
@ExtendWith(SpringExtension.class) @ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {TestR4ConfigWithElasticSearch.class}) @ContextConfiguration(classes = {TestR4ConfigWithElasticSearch.class})
@RequiresDocker
public class ValueSetExpansionR4ElasticsearchIT extends BaseJpaTest { public class ValueSetExpansionR4ElasticsearchIT extends BaseJpaTest {
protected static final String CS_URL = "http://example.com/my_code_system"; protected static final String CS_URL = "http://example.com/my_code_system";

View File

@ -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 * 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 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 @Override
public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext theExtensionContext) { public ConditionEvaluationResult evaluateExecutionCondition(ExtensionContext theExtensionContext) {
try { try {
DockerClientFactory.instance().isDockerAvailable(); boolean isDockerAvailable = DockerClientFactory.instance().isDockerAvailable();
return ConditionEvaluationResult.enabled("Docker is installed so we can run these tests!"); return isDockerAvailable
? ConditionEvaluationResult.enabled(AVAILABLE_MSG)
: ConditionEvaluationResult.disabled(UNAVAILABLE_MSG);
} catch (Exception e) { } catch (Exception e) {
return ConditionEvaluationResult.disabled("It appears as though docker is not installed on the host machine!"); return ConditionEvaluationResult.disabled(UNAVAILABLE_MSG);
} }
} }
} }