From e3f64c23a28edb367f228b5ad658e60d2ae1a3f4 Mon Sep 17 00:00:00 2001 From: VK-SMILECDR <88211153+VK-SMILECDR@users.noreply.github.com> Date: Tue, 9 Jul 2024 16:06:06 -0400 Subject: [PATCH] logback test extention assert (#6087) * initial check-in * HAPI logback test extension cleanup * bump version * revert mistake change * changes based on review --- hapi-deployable-pom/pom.xml | 2 +- hapi-fhir-android/pom.xml | 2 +- hapi-fhir-base/pom.xml | 2 +- hapi-fhir-bom/pom.xml | 4 +- hapi-fhir-checkstyle/pom.xml | 2 +- hapi-fhir-cli/hapi-fhir-cli-api/pom.xml | 2 +- .../cli/ReindexTerminologyCommandTest.java | 16 +-- hapi-fhir-cli/hapi-fhir-cli-app/pom.xml | 2 +- hapi-fhir-cli/pom.xml | 2 +- hapi-fhir-client-okhttp/pom.xml | 2 +- hapi-fhir-client/pom.xml | 2 +- hapi-fhir-converter/pom.xml | 2 +- hapi-fhir-dist/pom.xml | 2 +- hapi-fhir-docs/pom.xml | 2 +- hapi-fhir-jacoco/pom.xml | 2 +- hapi-fhir-jaxrsserver-base/pom.xml | 2 +- hapi-fhir-jpa/pom.xml | 2 +- hapi-fhir-jpaserver-base/pom.xml | 2 +- .../pom.xml | 2 +- ...esourceDaoR4SearchWithElasticSearchIT.java | 18 +-- hapi-fhir-jpaserver-hfql/pom.xml | 2 +- hapi-fhir-jpaserver-ips/pom.xml | 2 +- hapi-fhir-jpaserver-mdm/pom.xml | 2 +- hapi-fhir-jpaserver-model/pom.xml | 2 +- hapi-fhir-jpaserver-searchparam/pom.xml | 2 +- hapi-fhir-jpaserver-subscription/pom.xml | 2 +- .../registry/SubscriptionLoaderTest.java | 11 +- hapi-fhir-jpaserver-test-dstu2/pom.xml | 2 +- hapi-fhir-jpaserver-test-dstu3/pom.xml | 2 +- hapi-fhir-jpaserver-test-r4/pom.xml | 2 +- .../dao/r4/FhirResourceDaoR4ValidateTest.java | 14 +-- hapi-fhir-jpaserver-test-r4b/pom.xml | 2 +- hapi-fhir-jpaserver-test-r5/pom.xml | 2 +- hapi-fhir-jpaserver-test-utilities/pom.xml | 2 +- .../fhir/jpa/auth/FhirQueryRuleImplTest.java | 9 +- hapi-fhir-jpaserver-uhnfhirtest/pom.xml | 2 +- hapi-fhir-server-cds-hooks/pom.xml | 2 +- .../cdshooks/svc/CdsServiceCacheTest.java | 6 +- hapi-fhir-server-mdm/pom.xml | 2 +- hapi-fhir-server-openapi/pom.xml | 2 +- hapi-fhir-server/pom.xml | 2 +- .../hapi-fhir-caching-api/pom.xml | 2 +- .../hapi-fhir-caching-caffeine/pom.xml | 4 +- .../hapi-fhir-caching-guava/pom.xml | 2 +- .../hapi-fhir-caching-testing/pom.xml | 2 +- hapi-fhir-serviceloaders/pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../hapi-fhir-spring-boot-samples/pom.xml | 2 +- .../hapi-fhir-spring-boot-starter/pom.xml | 2 +- hapi-fhir-spring-boot/pom.xml | 2 +- hapi-fhir-sql-migrate/pom.xml | 2 +- hapi-fhir-storage-batch2-jobs/pom.xml | 2 +- .../pom.xml | 2 +- hapi-fhir-storage-batch2/pom.xml | 2 +- hapi-fhir-storage-cr/pom.xml | 2 +- hapi-fhir-storage-mdm/pom.xml | 2 +- hapi-fhir-storage-test-utilities/pom.xml | 2 +- hapi-fhir-storage/pom.xml | 2 +- hapi-fhir-structures-dstu2.1/pom.xml | 2 +- hapi-fhir-structures-dstu2/pom.xml | 2 +- .../provider/ObservableSupplierSetTest.java | 3 +- hapi-fhir-structures-dstu3/pom.xml | 2 +- hapi-fhir-structures-hl7org-dstu2/pom.xml | 2 +- hapi-fhir-structures-r4/pom.xml | 2 +- hapi-fhir-structures-r4b/pom.xml | 2 +- hapi-fhir-structures-r5/pom.xml | 2 +- hapi-fhir-test-utilities/pom.xml | 2 +- .../java/ca/uhn/test/util/LogEventAssert.java | 30 ----- .../uhn/test/util/LogEventIterableAssert.java | 119 ------------------ .../ca/uhn/test/util/LogbackEventAssert.java | 75 ----------- .../uhn/test/util/LogbackTestExtension.java | 39 ++---- .../test/util/LogbackTestExtensionAssert.java | 110 ++++++++++++++-- .../uhn/test/util/LoggingEventPredicates.java | 58 +++++++++ .../test/util/StaticLogbackTestExtension.java | 15 +-- hapi-fhir-testpage-overlay/pom.xml | 2 +- .../pom.xml | 2 +- hapi-fhir-validation-resources-dstu2/pom.xml | 2 +- hapi-fhir-validation-resources-dstu3/pom.xml | 2 +- hapi-fhir-validation-resources-r4/pom.xml | 2 +- hapi-fhir-validation-resources-r4b/pom.xml | 2 +- hapi-fhir-validation-resources-r5/pom.xml | 2 +- hapi-fhir-validation/pom.xml | 2 +- hapi-tinder-plugin/pom.xml | 2 +- hapi-tinder-test/pom.xml | 2 +- pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- .../pom.xml | 2 +- 91 files changed, 276 insertions(+), 405 deletions(-) delete mode 100644 hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogEventAssert.java delete mode 100644 hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogEventIterableAssert.java delete mode 100644 hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogbackEventAssert.java create mode 100644 hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LoggingEventPredicates.java diff --git a/hapi-deployable-pom/pom.xml b/hapi-deployable-pom/pom.xml index 201e445a4a9..51c5425eca6 100644 --- a/hapi-deployable-pom/pom.xml +++ b/hapi-deployable-pom/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-android/pom.xml b/hapi-fhir-android/pom.xml index 13909dbc16a..feaca8b7da1 100644 --- a/hapi-fhir-android/pom.xml +++ b/hapi-fhir-android/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-base/pom.xml b/hapi-fhir-base/pom.xml index 088a0759e7f..2fde11f09f1 100644 --- a/hapi-fhir-base/pom.xml +++ b/hapi-fhir-base/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-bom/pom.xml b/hapi-fhir-bom/pom.xml index 91eb20984d7..bf725a7f316 100644 --- a/hapi-fhir-bom/pom.xml +++ b/hapi-fhir-bom/pom.xml @@ -4,7 +4,7 @@ 4.0.0 ca.uhn.hapi.fhir hapi-fhir-bom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT pom HAPI FHIR BOM @@ -12,7 +12,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-checkstyle/pom.xml b/hapi-fhir-checkstyle/pom.xml index 1d5ac23a286..3697c4a748b 100644 --- a/hapi-fhir-checkstyle/pom.xml +++ b/hapi-fhir-checkstyle/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml index 84d516e1c15..7c64eb14bdc 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-api/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ReindexTerminologyCommandTest.java b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ReindexTerminologyCommandTest.java index 81c0a079f7a..53f39fdf7a6 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ReindexTerminologyCommandTest.java +++ b/hapi-fhir-cli/hapi-fhir-cli-api/src/test/java/ca/uhn/fhir/cli/ReindexTerminologyCommandTest.java @@ -6,8 +6,8 @@ import ca.uhn.fhir.system.HapiSystemProperties; import ca.uhn.fhir.test.utilities.RestServerR4Helper; import ca.uhn.fhir.test.utilities.TlsAuthenticationTestHelper; import ca.uhn.fhir.util.ParametersUtil; -import ca.uhn.test.util.LogEventIterableAssert; import ca.uhn.test.util.LogbackTestExtension; +import ca.uhn.test.util.LogbackTestExtensionAssert; import ch.qos.logback.classic.Logger; import org.hl7.fhir.instance.model.api.IBaseParameters; import org.junit.jupiter.api.BeforeEach; @@ -30,6 +30,7 @@ import static org.mockito.Mockito.spy; @ExtendWith(MockitoExtension.class) class ReindexTerminologyCommandTest { + private static final String FAILURE_MESSAGE = "FAILURE"; private final FhirContext myContext = FhirContext.forR4(); @Spy @@ -68,10 +69,9 @@ class ReindexTerminologyCommandTest { ); runAppWithStartupHook(args, getLoggingStartupHook()); - LogEventIterableAssert.assertThat(myAppLogCapture.getLogEvents()).hasNoFailureMessages(); + LogbackTestExtensionAssert.assertThat(myAppLogCapture).doesNotHaveMessage(FAILURE_MESSAGE); } - @ParameterizedTest @ValueSource(booleans = {true, false}) public void testNoVersionThrows(boolean theIncludeTls) { @@ -131,8 +131,9 @@ class ReindexTerminologyCommandTest { ); runAppWithStartupHook(args, getLoggingStartupHook()); - LogEventIterableAssert.assertThat(myAppLogCapture.getLogEvents()).hasAtLeastOneFailureMessage(); - LogEventIterableAssert.assertThat(myAppLogCapture.getLogEvents()).hasAtLeastOneEventWithMessage("Internal error. Command result unknown. Check system logs for details"); + LogbackTestExtensionAssert.assertThat(myAppLogCapture) + .hasMessage(FAILURE_MESSAGE) + .hasMessage("Internal error. Command result unknown. Check system logs for details"); } @ParameterizedTest @@ -155,8 +156,9 @@ class ReindexTerminologyCommandTest { ); runAppWithStartupHook(args, getLoggingStartupHook()); - LogEventIterableAssert.assertThat(myAppLogCapture.getLogEvents()).hasAtLeastOneFailureMessage(); - LogEventIterableAssert.assertThat(myAppLogCapture.getLogEvents()).hasAtLeastOneEventWithMessage("Freetext service is not configured. Operation didn't run."); + LogbackTestExtensionAssert.assertThat(myAppLogCapture) + .hasMessage(FAILURE_MESSAGE) + .hasMessage("Freetext service is not configured. Operation didn't run."); } static void runAppWithStartupHook(String[] args, Consumer startupHook) { diff --git a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml index f8ad950f61a..8e941cb0a0e 100644 --- a/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml +++ b/hapi-fhir-cli/hapi-fhir-cli-app/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-fhir-cli - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-cli/pom.xml b/hapi-fhir-cli/pom.xml index 3e5e320ae33..21639b13dbd 100644 --- a/hapi-fhir-cli/pom.xml +++ b/hapi-fhir-cli/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-client-okhttp/pom.xml b/hapi-fhir-client-okhttp/pom.xml index 7e51b799115..c1830ea0cd6 100644 --- a/hapi-fhir-client-okhttp/pom.xml +++ b/hapi-fhir-client-okhttp/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-client/pom.xml b/hapi-fhir-client/pom.xml index 50c73354381..0af38c9fe65 100644 --- a/hapi-fhir-client/pom.xml +++ b/hapi-fhir-client/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-converter/pom.xml b/hapi-fhir-converter/pom.xml index eddec160b6d..2654c2950d2 100644 --- a/hapi-fhir-converter/pom.xml +++ b/hapi-fhir-converter/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-dist/pom.xml b/hapi-fhir-dist/pom.xml index ac9a6e400cb..b99f36c00ba 100644 --- a/hapi-fhir-dist/pom.xml +++ b/hapi-fhir-dist/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-docs/pom.xml b/hapi-fhir-docs/pom.xml index 7799c4a2bee..6e055f475f0 100644 --- a/hapi-fhir-docs/pom.xml +++ b/hapi-fhir-docs/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jacoco/pom.xml b/hapi-fhir-jacoco/pom.xml index 82a2c6633b5..ebbf76b2a9e 100644 --- a/hapi-fhir-jacoco/pom.xml +++ b/hapi-fhir-jacoco/pom.xml @@ -11,7 +11,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jaxrsserver-base/pom.xml b/hapi-fhir-jaxrsserver-base/pom.xml index 69bffab63ad..e03ab0b9c8e 100644 --- a/hapi-fhir-jaxrsserver-base/pom.xml +++ b/hapi-fhir-jaxrsserver-base/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpa/pom.xml b/hapi-fhir-jpa/pom.xml index d49ec2ac0f9..dd240799546 100644 --- a/hapi-fhir-jpa/pom.xml +++ b/hapi-fhir-jpa/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-base/pom.xml b/hapi-fhir-jpaserver-base/pom.xml index 2a9f0b2cdf8..794bb2dc7fc 100644 --- a/hapi-fhir-jpaserver-base/pom.xml +++ b/hapi-fhir-jpaserver-base/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml b/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml index ca2c9dcea70..702c664e8be 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml +++ b/hapi-fhir-jpaserver-elastic-test-utilities/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java index bf0b3b9b45d..3ee1dd89aaf 100644 --- a/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java +++ b/hapi-fhir-jpaserver-elastic-test-utilities/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4SearchWithElasticSearchIT.java @@ -27,9 +27,7 @@ import ca.uhn.fhir.jpa.search.BaseSourceSearchParameterTestCases; import ca.uhn.fhir.jpa.search.CompositeSearchParameterTestCases; import ca.uhn.fhir.jpa.search.QuantitySearchParameterTestCases; import ca.uhn.fhir.jpa.search.builder.SearchBuilder; -import ca.uhn.fhir.jpa.search.lastn.ElasticsearchRestClientFactory; import ca.uhn.fhir.jpa.search.lastn.ElasticsearchSvcImpl; -import ca.uhn.fhir.jpa.search.lastn.json.ObservationJson; import ca.uhn.fhir.jpa.search.reindex.IResourceReindexingSvc; import ca.uhn.fhir.jpa.searchparam.SearchParameterMap; import ca.uhn.fhir.jpa.sp.ISearchParamPresenceSvc; @@ -60,17 +58,11 @@ import ca.uhn.fhir.test.utilities.docker.RequiresDocker; import ca.uhn.fhir.validation.FhirValidator; import ca.uhn.fhir.validation.ValidationResult; import ca.uhn.test.util.LogbackTestExtension; +import ca.uhn.test.util.LogbackTestExtensionAssert; import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.spi.ILoggingEvent; -import co.elastic.clients.elasticsearch.ElasticsearchClient; -import co.elastic.clients.elasticsearch.core.SearchRequest; -import co.elastic.clients.elasticsearch.core.SearchResponse; -import com.fasterxml.jackson.databind.node.ObjectNode; import jakarta.annotation.Nonnull; -import jakarta.json.JsonValue; import jakarta.persistence.EntityManager; import org.apache.commons.lang3.RandomStringUtils; -import org.elasticsearch.client.RequestOptions; import org.hl7.fhir.instance.model.api.IBaseCoding; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; @@ -282,7 +274,7 @@ public class FhirResourceDaoR4SearchWithElasticSearchIT extends BaseJpaTest impl class ElasticPerformanceTracingInterceptor { - private List messages = new ArrayList<>(); + private final List messages = new ArrayList<>(); @Hook(Pointcut.JPA_PERFTRACE_INFO) public void logPerformance(StorageProcessingMessage theMessage) { @@ -955,9 +947,7 @@ public class FhirResourceDaoR4SearchWithElasticSearchIT extends BaseJpaTest impl assertThat(result).hasSize(1); assertEquals(((Observation) result.get(0)).getIdElement().getIdPart(), id1.getIdPart()); - List events = myLogbackTestExtension.filterLoggingEventsWithPredicate(e -> e.getLevel() == Level.WARN); - assertFalse(events.isEmpty()); - assertTrue(events.stream().anyMatch(e -> e.getFormattedMessage().contains("Some resources were not found in index. Make sure all resources were indexed. Resorting to database search."))); + LogbackTestExtensionAssert.assertThat(myLogbackTestExtension).hasWarnMessage("Some resources were not found in index. Make sure all resources were indexed. Resorting to database search."); // restore changed property JpaStorageSettings defaultConfig = new JpaStorageSettings(); @@ -1766,7 +1756,7 @@ public class FhirResourceDaoR4SearchWithElasticSearchIT extends BaseJpaTest impl public class LastUpdatedTests { private String myOldObsId, myNewObsId; - private String myOldLastUpdatedDateTime = "2017-03-24T03:21:47"; + private final String myOldLastUpdatedDateTime = "2017-03-24T03:21:47"; @BeforeEach public void enableResourceStorage() { diff --git a/hapi-fhir-jpaserver-hfql/pom.xml b/hapi-fhir-jpaserver-hfql/pom.xml index 9583fdb476e..3eff499cc70 100644 --- a/hapi-fhir-jpaserver-hfql/pom.xml +++ b/hapi-fhir-jpaserver-hfql/pom.xml @@ -3,7 +3,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-ips/pom.xml b/hapi-fhir-jpaserver-ips/pom.xml index 4f67baddc2a..cfbd59eb7b9 100644 --- a/hapi-fhir-jpaserver-ips/pom.xml +++ b/hapi-fhir-jpaserver-ips/pom.xml @@ -3,7 +3,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-mdm/pom.xml b/hapi-fhir-jpaserver-mdm/pom.xml index 9597e5a5336..ab4e4387aeb 100644 --- a/hapi-fhir-jpaserver-mdm/pom.xml +++ b/hapi-fhir-jpaserver-mdm/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-model/pom.xml b/hapi-fhir-jpaserver-model/pom.xml index 8aac2c78684..54a5a4d85a5 100644 --- a/hapi-fhir-jpaserver-model/pom.xml +++ b/hapi-fhir-jpaserver-model/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-searchparam/pom.xml b/hapi-fhir-jpaserver-searchparam/pom.xml index e80a8be7df3..17e2ad77faa 100755 --- a/hapi-fhir-jpaserver-searchparam/pom.xml +++ b/hapi-fhir-jpaserver-searchparam/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-subscription/pom.xml b/hapi-fhir-jpaserver-subscription/pom.xml index ce7be44c49c..a05e3b6e060 100644 --- a/hapi-fhir-jpaserver-subscription/pom.xml +++ b/hapi-fhir-jpaserver-subscription/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/registry/SubscriptionLoaderTest.java b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/registry/SubscriptionLoaderTest.java index 3661691d583..b386603f203 100644 --- a/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/registry/SubscriptionLoaderTest.java +++ b/hapi-fhir-jpaserver-subscription/src/test/java/ca/uhn/fhir/jpa/subscription/match/registry/SubscriptionLoaderTest.java @@ -13,9 +13,8 @@ import ca.uhn.fhir.rest.api.server.SystemRequestDetails; import ca.uhn.fhir.rest.server.SimpleBundleProvider; import ca.uhn.fhir.rest.server.util.ISearchParamRegistry; import ca.uhn.fhir.subscription.SubscriptionConstants; -import ca.uhn.test.util.LogEventIterableAssert; import ca.uhn.test.util.LogbackTestExtension; -import ch.qos.logback.classic.Level; +import ca.uhn.test.util.LogbackTestExtensionAssert; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.r4.model.Subscription; import org.junit.jupiter.api.BeforeEach; @@ -125,10 +124,8 @@ public class SubscriptionLoaderTest { verify(mySubscriptionDao) .searchForResources(any(SearchParameterMap.class), any(SystemRequestDetails.class)); - String expected = "Subscription " - + subscription.getIdElement().getIdPart() - + " could not be activated."; - LogEventIterableAssert.assertThat(myLogCapture.getLogEvents()).hasEventWithLevelAndMessageContains(Level.ERROR, expected); - LogEventIterableAssert.assertThat(myLogCapture.getLogEvents()).hasAtLeastOneEventWithMessage(subscription.getError()); + LogbackTestExtensionAssert.assertThat(myLogCapture).hasErrorMessage( + "Subscription " + subscription.getIdElement().getIdPart() + " could not be activated."); + LogbackTestExtensionAssert.assertThat(myLogCapture).hasMessage(subscription.getError()); } } diff --git a/hapi-fhir-jpaserver-test-dstu2/pom.xml b/hapi-fhir-jpaserver-test-dstu2/pom.xml index 0481251547f..f376488440b 100644 --- a/hapi-fhir-jpaserver-test-dstu2/pom.xml +++ b/hapi-fhir-jpaserver-test-dstu2/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-dstu3/pom.xml b/hapi-fhir-jpaserver-test-dstu3/pom.xml index 24cd5461796..f58a0362a48 100644 --- a/hapi-fhir-jpaserver-test-dstu3/pom.xml +++ b/hapi-fhir-jpaserver-test-dstu3/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-r4/pom.xml b/hapi-fhir-jpaserver-test-r4/pom.xml index ff76c82b8e4..47298899f9a 100644 --- a/hapi-fhir-jpaserver-test-r4/pom.xml +++ b/hapi-fhir-jpaserver-test-r4/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValidateTest.java b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValidateTest.java index 1597b816bea..65eb5737e2b 100644 --- a/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValidateTest.java +++ b/hapi-fhir-jpaserver-test-r4/src/test/java/ca/uhn/fhir/jpa/dao/r4/FhirResourceDaoR4ValidateTest.java @@ -32,8 +32,8 @@ import ca.uhn.fhir.rest.server.exceptions.UnprocessableEntityException; import ca.uhn.fhir.util.OperationOutcomeUtil; import ca.uhn.fhir.util.StopWatch; import ca.uhn.fhir.validation.IValidatorModule; +import ca.uhn.test.util.LogbackTestExtensionAssert; import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.spi.ILoggingEvent; import org.apache.commons.io.IOUtils; import org.hl7.fhir.common.hapi.validation.support.InMemoryTerminologyServerValidationSupport; import org.hl7.fhir.common.hapi.validation.support.UnknownCodeSystemWarningValidationSupport; @@ -103,6 +103,7 @@ import static org.hl7.fhir.common.hapi.validation.support.CommonCodeSystemsTermi import static org.hl7.fhir.common.hapi.validation.support.ValidationConstants.LOINC_LOW; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertInstanceOf; import static org.junit.jupiter.api.Assertions.assertNotNull; import static org.junit.jupiter.api.Assertions.assertTrue; import static org.junit.jupiter.api.Assertions.fail; @@ -1514,7 +1515,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { // validator assertNotNull(outcome); - assertTrue(outcome.getOperationOutcome() instanceof OperationOutcome); + assertInstanceOf(OperationOutcome.class, outcome.getOperationOutcome()); List issues = ((OperationOutcome) outcome.getOperationOutcome()).getIssue(); assertFalse(issues.isEmpty()); List errors = issues.stream() @@ -1523,12 +1524,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { // we have errors assertFalse(errors.isEmpty()); - List events = myLogbackTestExtension.filterLoggingEventsWithPredicate(e -> { - return e.getLevel() == Level.WARN; - }); - // and we have warning logs - assertFalse(events.isEmpty()); - assertTrue(events.stream().anyMatch(e -> e.getFormattedMessage().contains("Unrecognized profile uri"))); + LogbackTestExtensionAssert.assertThat(myLogbackTestExtension).hasWarnMessage("Unrecognized profile uri"); } @Test @@ -1654,7 +1650,7 @@ public class FhirResourceDaoR4ValidateTest extends BaseJpaR4Test { // verify assertNotNull(outcome); - assertTrue(outcome.getOperationOutcome() instanceof OperationOutcome); + assertInstanceOf(OperationOutcome.class, outcome.getOperationOutcome()); List issues = ((OperationOutcome) outcome.getOperationOutcome()).getIssue(); assertFalse(issues.isEmpty()); List errors = issues.stream() diff --git a/hapi-fhir-jpaserver-test-r4b/pom.xml b/hapi-fhir-jpaserver-test-r4b/pom.xml index 8a7495daaf1..818c701136f 100644 --- a/hapi-fhir-jpaserver-test-r4b/pom.xml +++ b/hapi-fhir-jpaserver-test-r4b/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-r5/pom.xml b/hapi-fhir-jpaserver-test-r5/pom.xml index 259a6493649..608fdd50554 100644 --- a/hapi-fhir-jpaserver-test-r5/pom.xml +++ b/hapi-fhir-jpaserver-test-r5/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-utilities/pom.xml b/hapi-fhir-jpaserver-test-utilities/pom.xml index db997edc3df..c2ec846dc4a 100644 --- a/hapi-fhir-jpaserver-test-utilities/pom.xml +++ b/hapi-fhir-jpaserver-test-utilities/pom.xml @@ -6,7 +6,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/auth/FhirQueryRuleImplTest.java b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/auth/FhirQueryRuleImplTest.java index e88b6fcb645..3f3188baa85 100644 --- a/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/auth/FhirQueryRuleImplTest.java +++ b/hapi-fhir-jpaserver-test-utilities/src/test/java/ca/uhn/fhir/jpa/auth/FhirQueryRuleImplTest.java @@ -12,9 +12,8 @@ import ca.uhn.fhir.rest.server.interceptor.auth.IAuthorizationSearchParamMatcher import ca.uhn.fhir.rest.server.interceptor.auth.PolicyEnum; import ca.uhn.fhir.rest.server.interceptor.auth.RuleBuilder; import ca.uhn.fhir.test.utilities.ITestDataBuilder; -import ca.uhn.test.util.LogEventIterableAssert; import ca.uhn.test.util.LogbackTestExtension; -import ch.qos.logback.classic.Level; +import ca.uhn.test.util.LogbackTestExtensionAssert; import jakarta.annotation.Nullable; import org.hl7.fhir.instance.model.api.IBaseResource; import org.hl7.fhir.instance.model.api.IIdType; @@ -272,7 +271,7 @@ class FhirQueryRuleImplTest implements ITestDataBuilder { // then assertNull(verdict); - LogEventIterableAssert.assertThat(myLogCapture.getLogEvents()).hasEventWithLevelAndMessageContains(Level.WARN, "unsupported chain XXX"); + LogbackTestExtensionAssert.assertThat(myLogCapture).hasWarnMessage("unsupported chain XXX"); } @Test @@ -287,7 +286,7 @@ class FhirQueryRuleImplTest implements ITestDataBuilder { // then assertEquals(PolicyEnum.DENY, verdict.getDecision()); - LogEventIterableAssert.assertThat(myLogCapture.getLogEvents()).hasEventWithLevelAndMessageContains(Level.WARN, "unsupported chain XXX"); + LogbackTestExtensionAssert.assertThat(myLogCapture).hasWarnMessage("unsupported chain XXX"); } /** @@ -306,7 +305,7 @@ class FhirQueryRuleImplTest implements ITestDataBuilder { // then assertNull(verdict); - LogEventIterableAssert.assertThat(myLogCapture.getLogEvents()).hasEventWithLevelAndMessageContains(Level.WARN, "No matcher provided"); + LogbackTestExtensionAssert.assertThat(myLogCapture).hasWarnMessage("No matcher provided"); } } diff --git a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml index 71d88524097..2bf177376a4 100644 --- a/hapi-fhir-jpaserver-uhnfhirtest/pom.xml +++ b/hapi-fhir-jpaserver-uhnfhirtest/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-server-cds-hooks/pom.xml b/hapi-fhir-server-cds-hooks/pom.xml index 7f61bbb7962..580d759866a 100644 --- a/hapi-fhir-server-cds-hooks/pom.xml +++ b/hapi-fhir-server-cds-hooks/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsServiceCacheTest.java b/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsServiceCacheTest.java index a42e4c186ba..a9cdbcfb82b 100644 --- a/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsServiceCacheTest.java +++ b/hapi-fhir-server-cds-hooks/src/test/java/ca/uhn/hapi/fhir/cdshooks/svc/CdsServiceCacheTest.java @@ -5,8 +5,8 @@ import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceRequestJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceResponseCardJson; import ca.uhn.hapi.fhir.cdshooks.api.json.CdsServiceResponseJson; -import ca.uhn.test.util.LogEventIterableAssert; import ca.uhn.test.util.LogbackTestExtension; +import ca.uhn.test.util.LogbackTestExtensionAssert; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.Logger; import jakarta.annotation.Nonnull; @@ -68,7 +68,7 @@ class CdsServiceCacheTest { assertTrue(cdsMethod.isAllowAutoFhirClientPrefetch()); assertThat(myFixture.myCdsServiceJson.getServices()).hasSize(1); assertEquals(cdsServiceJson, myFixture.myCdsServiceJson.getServices().get(0)); - LogEventIterableAssert.assertThat(myLogCapture.getLogEvents()).hasEventWithLevelAndMessageContains(Level.ERROR, expectedLogMessage); + LogbackTestExtensionAssert.assertThat(myLogCapture).hasErrorMessage(expectedLogMessage); } @@ -96,7 +96,7 @@ class CdsServiceCacheTest { final ICdsMethod actual = myFixture.unregisterServiceMethod(TEST_KEY, MODULE_ID); // validate assertNull(actual); - LogEventIterableAssert.assertThat(myLogCapture.getLogEvents()).hasEventWithLevelAndMessageContains(Level.ERROR, expectedLogMessage); + LogbackTestExtensionAssert.assertThat(myLogCapture).hasErrorMessage(expectedLogMessage); } @Nonnull diff --git a/hapi-fhir-server-mdm/pom.xml b/hapi-fhir-server-mdm/pom.xml index 80b9e0ed656..8933befbe65 100644 --- a/hapi-fhir-server-mdm/pom.xml +++ b/hapi-fhir-server-mdm/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server-openapi/pom.xml b/hapi-fhir-server-openapi/pom.xml index 24024f4d4e2..39bf63f2e15 100644 --- a/hapi-fhir-server-openapi/pom.xml +++ b/hapi-fhir-server-openapi/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-server/pom.xml b/hapi-fhir-server/pom.xml index a34c76f9c43..2960b6c699b 100644 --- a/hapi-fhir-server/pom.xml +++ b/hapi-fhir-server/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml index cad1eb5cb20..4ad27d29228 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-api/pom.xml @@ -7,7 +7,7 @@ hapi-fhir-serviceloaders ca.uhn.hapi.fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml index 64375e7cb85..4ccbb5543e1 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-caffeine/pom.xml @@ -7,7 +7,7 @@ hapi-fhir-serviceloaders ca.uhn.hapi.fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../pom.xml @@ -21,7 +21,7 @@ ca.uhn.hapi.fhir hapi-fhir-caching-api - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml index 70f721728a7..2fced0308fa 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-guava/pom.xml @@ -7,7 +7,7 @@ hapi-fhir-serviceloaders ca.uhn.hapi.fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml b/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml index 896cade4e24..9b85a596aa1 100644 --- a/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml +++ b/hapi-fhir-serviceloaders/hapi-fhir-caching-testing/pom.xml @@ -7,7 +7,7 @@ hapi-fhir ca.uhn.hapi.fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../../pom.xml diff --git a/hapi-fhir-serviceloaders/pom.xml b/hapi-fhir-serviceloaders/pom.xml index a36e8af164b..b0750d335d2 100644 --- a/hapi-fhir-serviceloaders/pom.xml +++ b/hapi-fhir-serviceloaders/pom.xml @@ -5,7 +5,7 @@ hapi-deployable-pom ca.uhn.hapi.fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml index eba034a3f1a..df157679965 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-autoconfigure/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml index f56394509da..6affbba2e14 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-apache/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT hapi-fhir-spring-boot-sample-client-apache diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml index a9a5f761a80..d6eb50c50a8 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-client-okhttp/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml index 65949540425..1ccc2bfd27e 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/hapi-fhir-spring-boot-sample-server-jersey/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot-samples - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml index 91a9520acc4..92edf4d9b14 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-samples/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir-spring-boot - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT diff --git a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml index 74ecebfb13a..b869d30105b 100644 --- a/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml +++ b/hapi-fhir-spring-boot/hapi-fhir-spring-boot-starter/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-spring-boot/pom.xml b/hapi-fhir-spring-boot/pom.xml index 7549eb1eb83..7380b3e795e 100644 --- a/hapi-fhir-spring-boot/pom.xml +++ b/hapi-fhir-spring-boot/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-sql-migrate/pom.xml b/hapi-fhir-sql-migrate/pom.xml index 7df21c64a59..db4594ee68f 100644 --- a/hapi-fhir-sql-migrate/pom.xml +++ b/hapi-fhir-sql-migrate/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-batch2-jobs/pom.xml b/hapi-fhir-storage-batch2-jobs/pom.xml index 56b010918f4..6c0307fb1b8 100644 --- a/hapi-fhir-storage-batch2-jobs/pom.xml +++ b/hapi-fhir-storage-batch2-jobs/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-batch2-test-utilities/pom.xml b/hapi-fhir-storage-batch2-test-utilities/pom.xml index 93ea4cf7b13..9d33165b068 100644 --- a/hapi-fhir-storage-batch2-test-utilities/pom.xml +++ b/hapi-fhir-storage-batch2-test-utilities/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-batch2/pom.xml b/hapi-fhir-storage-batch2/pom.xml index eb6613d9a1a..db6a81ee6a0 100644 --- a/hapi-fhir-storage-batch2/pom.xml +++ b/hapi-fhir-storage-batch2/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-cr/pom.xml b/hapi-fhir-storage-cr/pom.xml index 9b14b5502d7..291bae09144 100644 --- a/hapi-fhir-storage-cr/pom.xml +++ b/hapi-fhir-storage-cr/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-mdm/pom.xml b/hapi-fhir-storage-mdm/pom.xml index 6bb66053175..d07296717fe 100644 --- a/hapi-fhir-storage-mdm/pom.xml +++ b/hapi-fhir-storage-mdm/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage-test-utilities/pom.xml b/hapi-fhir-storage-test-utilities/pom.xml index 661e8891445..b6ec7f3a55c 100644 --- a/hapi-fhir-storage-test-utilities/pom.xml +++ b/hapi-fhir-storage-test-utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-storage/pom.xml b/hapi-fhir-storage/pom.xml index e34bca707bb..fd25eed90a9 100644 --- a/hapi-fhir-storage/pom.xml +++ b/hapi-fhir-storage/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu2.1/pom.xml b/hapi-fhir-structures-dstu2.1/pom.xml index 770444fa1a1..fc267dcddf4 100644 --- a/hapi-fhir-structures-dstu2.1/pom.xml +++ b/hapi-fhir-structures-dstu2.1/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu2/pom.xml b/hapi-fhir-structures-dstu2/pom.xml index 0c8a4fb8302..57b6e8045bb 100644 --- a/hapi-fhir-structures-dstu2/pom.xml +++ b/hapi-fhir-structures-dstu2/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/provider/ObservableSupplierSetTest.java b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/provider/ObservableSupplierSetTest.java index 45b78682a9f..d39609a9bda 100644 --- a/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/provider/ObservableSupplierSetTest.java +++ b/hapi-fhir-structures-dstu2/src/test/java/ca/uhn/fhir/rest/server/provider/ObservableSupplierSetTest.java @@ -13,6 +13,7 @@ import java.util.List; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Supplier; +import static ca.uhn.test.util.LoggingEventPredicates.makeMessageContains; import static org.assertj.core.api.AssertionsForInterfaceTypes.assertThat; import static org.junit.jupiter.api.Assertions.assertEquals; @@ -56,7 +57,7 @@ class ObservableSupplierSetTest { myObservableSupplierSet.removeSupplier(myCounter::incrementAndGet); myObserver.assertCalls(1, 0); assertThat(myObservableSupplierSet.getSupplierResults()).hasSize(1); - List events = myLogger.filterLoggingEventsWithMessageContaining("Failed to remove supplier"); + List events = myLogger.getLogEvents(makeMessageContains("Failed to remove supplier")); assertThat(events).hasSize(1); assertEquals(Level.WARN, events.get(0).getLevel()); } diff --git a/hapi-fhir-structures-dstu3/pom.xml b/hapi-fhir-structures-dstu3/pom.xml index 9037e3bc704..a24986cae09 100644 --- a/hapi-fhir-structures-dstu3/pom.xml +++ b/hapi-fhir-structures-dstu3/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-hl7org-dstu2/pom.xml b/hapi-fhir-structures-hl7org-dstu2/pom.xml index 0d01ca0e479..461133b9324 100644 --- a/hapi-fhir-structures-hl7org-dstu2/pom.xml +++ b/hapi-fhir-structures-hl7org-dstu2/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r4/pom.xml b/hapi-fhir-structures-r4/pom.xml index 06498f45903..add2380e321 100644 --- a/hapi-fhir-structures-r4/pom.xml +++ b/hapi-fhir-structures-r4/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r4b/pom.xml b/hapi-fhir-structures-r4b/pom.xml index bb63b81f956..ff544d60169 100644 --- a/hapi-fhir-structures-r4b/pom.xml +++ b/hapi-fhir-structures-r4b/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-structures-r5/pom.xml b/hapi-fhir-structures-r5/pom.xml index 8c2d6347171..7aafb2d11ae 100644 --- a/hapi-fhir-structures-r5/pom.xml +++ b/hapi-fhir-structures-r5/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-test-utilities/pom.xml b/hapi-fhir-test-utilities/pom.xml index 1faf8ccee8a..c9cedb6ead8 100644 --- a/hapi-fhir-test-utilities/pom.xml +++ b/hapi-fhir-test-utilities/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogEventAssert.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogEventAssert.java deleted file mode 100644 index 6dd8bdfce7c..00000000000 --- a/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogEventAssert.java +++ /dev/null @@ -1,30 +0,0 @@ -/*- - * #%L - * HAPI FHIR Test Utilities - * %% - * Copyright (C) 2014 - 2024 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ -package ca.uhn.test.util; - -import ch.qos.logback.classic.spi.ILoggingEvent; -import org.assertj.core.api.AbstractAssert; - -public class LogEventAssert extends AbstractAssert { - - protected LogEventAssert(ILoggingEvent actual) { - super(actual, LogEventAssert.class); - } -} diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogEventIterableAssert.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogEventIterableAssert.java deleted file mode 100644 index 40a3ecacfbd..00000000000 --- a/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogEventIterableAssert.java +++ /dev/null @@ -1,119 +0,0 @@ -/*- - * #%L - * HAPI FHIR Test Utilities - * %% - * Copyright (C) 2014 - 2024 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ -package ca.uhn.test.util; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.spi.ILoggingEvent; -import jakarta.annotation.Nonnull; -import org.assertj.core.api.AbstractIterableAssert; - -import java.util.Collection; - -public class LogEventIterableAssert extends AbstractIterableAssert, ILoggingEvent, LogEventAssert> { - - protected LogEventIterableAssert(Collection actual) { - super(actual, LogEventIterableAssert.class); - } - - public static LogEventIterableAssert assertThat(Collection actual) { - return new LogEventIterableAssert(actual); - } - - public LogEventIterableAssert hasNoFailureMessages() { - isNotNull(); - - matches(logEvents -> logEvents.stream() - .map(ILoggingEvent::getMessage) - .noneMatch(message -> message.contains("FAILURE")), - "LogEvents should not contain messages with 'FAILURE'"); - return this; - } - - public LogEventIterableAssert hasEventWithLevelAndMessageContains(@Nonnull Level theLevel, @Nonnull String thePartialMessage) { - isNotNull(); - matches(logEvents -> logEvents.stream() - .anyMatch(event-> event.getFormattedMessage().contains(thePartialMessage) && - event.getLevel().isGreaterOrEqual(theLevel)), - "Log Events should have at least one message with `"+theLevel.levelStr+"` in it."); - return this; - } - public LogEventIterableAssert hasAtLeastOneFailureMessage() { - isNotNull(); - - matches(logEvents -> logEvents.stream() - .map(ILoggingEvent::getMessage) - .anyMatch(message -> message.contains("FAILURE")), - "Log Events should have at least one message with `FAILURE` in it."); - return this; - } - - public LogEventIterableAssert hasAtLeastOneEventWithMessage(String thePartial) { - isNotNull(); - - matches(logEvents -> logEvents.stream() - .map(ILoggingEvent::getFormattedMessage) - .anyMatch(message -> message.contains(thePartial)), - "Log Events should have at least one message with "+ thePartial + " in it."); - return this; - } - - @Override - protected LogEventAssert toAssert(ILoggingEvent value, String description) { - return new LogEventAssert(value).as(description); - } - - @Override - protected LogEventIterableAssert newAbstractIterableAssert(Iterable iterable) { - return new LogEventIterableAssert((Collection) iterable); - } - - public LogEventIterableAssert doesNotHaveEventWithMessage(String thePartial) { - isNotNull(); - - matches(logEvents -> logEvents.stream() - .map(ILoggingEvent::getFormattedMessage) - .noneMatch(message -> message.contains(thePartial)), - "Log Events should have no message with "+ thePartial + " in it."); - return this; - } - - public LogEventIterableAssert hasEventWithLevelAndMessageAndThrew(Level theLevel, String thePartial, String theExceptionMessage) { - isNotNull(); - - matches(logEvents -> logEvents.stream() - .filter(message -> message.getMessage().contains(thePartial)) - .filter(message -> message.getLevel() == theLevel) - .anyMatch(message -> message.getThrowableProxy().getMessage().contains(theExceptionMessage)), - "Log Events should have at least one message with "+ thePartial + " in it."); - - return this; - } - - public LogEventIterableAssert doesNotHaveEventWithLevelAndMessage(Level theLevel, String thePartial) { - isNotNull(); - - matches(logEvents -> logEvents.stream() - .filter(e -> e.getLevel() == theLevel) - .map(ILoggingEvent::getFormattedMessage) - .noneMatch(message -> message.contains(thePartial)), - "Log Events should have no " + theLevel.toString() + " message with "+ thePartial + " in it."); - return this; - } -} diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogbackEventAssert.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogbackEventAssert.java deleted file mode 100644 index e91ce2e0189..00000000000 --- a/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogbackEventAssert.java +++ /dev/null @@ -1,75 +0,0 @@ -/*- - * #%L - * HAPI FHIR Test Utilities - * %% - * Copyright (C) 2014 - 2024 Smile CDR, Inc. - * %% - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * #L% - */ -package ca.uhn.test.util; - -import ch.qos.logback.classic.Level; -import ch.qos.logback.classic.spi.ILoggingEvent; -import jakarta.annotation.Nullable; -import org.assertj.core.api.AbstractAssert; - -/** - * An assertj matcher for junit assertions. - * Matches on level, partial message, and/or a portion of the message contained by a throwable, if present. - */ -public class LogbackEventAssert extends AbstractAssert { - @Nullable - private final Level myLevel; - @Nullable - private final String myLogMessage; - @Nullable - private final String myThrownMessage; - - public LogbackEventAssert(@Nullable Level theLevel, @Nullable String thePartialString) { - this(theLevel, thePartialString, null); - } - - public LogbackEventAssert(@Nullable Level theLevel, @Nullable String thePartialString, @Nullable String theThrownMessage) { - super(null, LogbackEventAssert.class); - myLevel = theLevel; - myLogMessage = thePartialString; - myThrownMessage = theThrownMessage; - } - - public static LogbackEventAssert assertThat(@Nullable Level theLevel, @Nullable String thePartialString) { - return new LogbackEventAssert(theLevel, thePartialString); - } - - public static LogbackEventAssert assertThat(@Nullable Level theLevel, @Nullable String thePartialString, @Nullable String theThrownMessage) { - return new LogbackEventAssert(theLevel, thePartialString, theThrownMessage); - } - - public LogbackEventAssert matches(ILoggingEvent item) { - isNotNull(); - - if (myLevel != null && !item.getLevel().isGreaterOrEqual(myLevel)) { - failWithMessage("Expected level to be at least <%s> but was <%s>", myLevel, item.getLevel()); - } - - if (myLogMessage != null && !item.getFormattedMessage().contains(myLogMessage)) { - failWithMessage("Expected log message to contain <%s> but was <%s>", myLogMessage, item.getFormattedMessage()); - } - - if (myThrownMessage != null && (item.getThrowableProxy() == null || !item.getThrowableProxy().getMessage().contains(myThrownMessage))) { - failWithMessage("Expected throwable message to contain <%s> but was <%s>", myThrownMessage, item.getThrowableProxy() != null ? item.getThrowableProxy().getMessage() : "null"); - } - - return this; - } -} diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogbackTestExtension.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogbackTestExtension.java index 6afd1362e0d..40ae0c21d6a 100644 --- a/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogbackTestExtension.java +++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogbackTestExtension.java @@ -32,9 +32,6 @@ import org.slf4j.LoggerFactory; import java.util.ArrayList; import java.util.List; import java.util.function.Predicate; -import java.util.stream.Collectors; - -import static org.assertj.core.api.Assertions.assertThat; /** * Test helper to collect logback lines. @@ -80,7 +77,11 @@ public class LogbackTestExtension implements BeforeEachCallback, AfterEachCallba this((Logger) theLogger); } - public java.util.List getLogEvents() { + /** + * Returns a copy to avoid concurrent modification errors. + * @return A copy of the log events so far. + */ + public List getLogEvents() { return new ArrayList<>(myListAppender.list); } @@ -120,37 +121,13 @@ public class LogbackTestExtension implements BeforeEachCallback, AfterEachCallba } } - public List filterLoggingEventsWithMessageEqualTo(String theMessageText) { - return filterLoggingEventsWithPredicate(loggingEvent -> loggingEvent.getFormattedMessage().equals(theMessageText)); - } - - public List filterLoggingEventsWithMessageContaining(String theMessageText) { - return filterLoggingEventsWithPredicate(loggingEvent -> loggingEvent.getFormattedMessage().contains(theMessageText)); - } - - public List filterLoggingEventsWithPredicate(Predicate theLoggingEventPredicate) { - return getLogEvents().stream().filter(theLoggingEventPredicate).collect(Collectors.toList()); + public List getLogEvents(Predicate thePredicate) { + return getLogEvents().stream().filter(thePredicate).toList(); } @Nonnull public List getLogMessages() { - return getLogEvents().stream().map(ILoggingEvent::getMessage).collect(Collectors.toList()); + return getLogEvents().stream().map(ILoggingEvent::getMessage).toList(); } - public static void assertEventWithLevelAndMessageContains(List events, @Nonnull Level theLevel, @Nonnull String thePartialMessage) { - assertThat(events).anySatisfy(event -> LogbackEventAssert.assertThat(theLevel, thePartialMessage).matches(event)); - } - - public static void assertEventWithLevel(List events, @Nonnull Level theLevel) { - assertThat(events).anySatisfy(event -> LogbackEventAssert.assertThat(theLevel, null).matches(event)); - } - - public static void assertEventWithMessageContains(List events, @Nonnull String thePartialMessage) { - assertThat(events).anySatisfy(event -> LogbackEventAssert.assertThat(null, thePartialMessage).matches(event)); - } - - public static void assertEventWithLevelAndMessageAndThrew(List events, @Nonnull Level theLevel, - @Nonnull String thePartialMessage, @Nonnull String theThrown) { - assertThat(events).anySatisfy(event -> LogbackEventAssert.assertThat(theLevel, thePartialMessage, theThrown).matches(event)); - } } diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogbackTestExtensionAssert.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogbackTestExtensionAssert.java index ef18a3200b7..0c4162265c7 100644 --- a/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogbackTestExtensionAssert.java +++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LogbackTestExtensionAssert.java @@ -19,7 +19,16 @@ import org.assertj.core.api.Condition; import java.util.List; import java.util.function.Predicate; +import static ca.uhn.test.util.LoggingEventPredicates.makeAnyMatch; +import static ca.uhn.test.util.LoggingEventPredicates.makeLevelEquals; +import static ca.uhn.test.util.LoggingEventPredicates.makeMessageContains; + + public class LogbackTestExtensionAssert extends AbstractAssert { + + private static final String HAS_ERROR_MSG_1 = "has logging message with message containing %s"; + private static final String HAS_ERROR_MSG_2 = "has logging message with level %s and message containing %s"; + @Nonnull public static LogbackTestExtensionAssert assertThat(@Nonnull LogbackTestExtension theLogbackTestExtension) { return new LogbackTestExtensionAssert(theLogbackTestExtension, LogbackTestExtensionAssert.class); @@ -29,21 +38,93 @@ public class LogbackTestExtensionAssert extends AbstractAssert predicate = makeMessageContains(theMessage); + final Condition> condition = + new Condition<>(makeAnyMatch(predicate), HAS_ERROR_MSG_1, theMessage); + Assertions.assertThat(actual.getLogEvents()).has(condition); + return this; + } + + public LogbackTestExtensionAssert doesNotHaveMessage(@Nonnull String theMessage) { + isNotNull(); + final Predicate predicate = makeMessageContains(theMessage); + final Condition> condition = + new Condition<>(makeAnyMatch(predicate), HAS_ERROR_MSG_1, theMessage); + Assertions.assertThat(actual.getLogEvents()).doesNotHave(condition); return this; } @Nonnull - public LogbackTestExtensionAssert hasDebug(@Nonnull String theMessage) { - Assertions.assertThat(actual.getLogEvents()).has(eventWithLevelAndMessageContains(Level.DEBUG, theMessage)); + public LogbackTestExtensionAssert hasErrorMessage(@Nonnull String theMessage) { + isNotNull(); + final Predicate predicate = makeLevelEquals(Level.ERROR) + .and(makeMessageContains(theMessage)); + final Condition> condition = + new Condition<>(makeAnyMatch(predicate), HAS_ERROR_MSG_2, Level.ERROR, theMessage); + Assertions.assertThat(actual.getLogEvents()).has(condition); + return this; + } + + @Nonnull + public LogbackTestExtensionAssert hasInfoMessage(@Nonnull String theMessage) { + isNotNull(); + final Predicate predicate = makeLevelEquals(Level.INFO) + .and(makeMessageContains(theMessage)); + final Condition> condition = + new Condition<>(makeAnyMatch(predicate), HAS_ERROR_MSG_2, Level.INFO, theMessage); + Assertions.assertThat(actual.getLogEvents()).has(condition); + return this; + } + + @Nonnull + public LogbackTestExtensionAssert doesNotHaveInfoMessage(@Nonnull String theMessage) { + isNotNull(); + final Predicate predicate = makeLevelEquals(Level.INFO).and(makeMessageContains(theMessage)); + final Condition> condition = + new Condition<>(makeAnyMatch(predicate), HAS_ERROR_MSG_2, Level.INFO, theMessage); + Assertions.assertThat(actual.getLogEvents()).doesNotHave(condition); + return this; + } + + @Nonnull + public LogbackTestExtensionAssert hasWarnMessage(@Nonnull String theMessage) { + isNotNull(); + final Predicate predicate = makeLevelEquals(Level.WARN) + .and(makeMessageContains(theMessage)); + final Condition> condition = + new Condition<>(makeAnyMatch(predicate), HAS_ERROR_MSG_2, Level.WARN, theMessage); + Assertions.assertThat(actual.getLogEvents()).has(condition); + return this; + } + + @Nonnull + public LogbackTestExtensionAssert hasDebugMessage(@Nonnull String theMessage) { + isNotNull(); + final Predicate predicate = makeLevelEquals(Level.DEBUG) + .and(makeMessageContains(theMessage)); + final Condition> condition = + new Condition<>(makeAnyMatch(predicate), HAS_ERROR_MSG_2, Level.DEBUG, theMessage); + Assertions.assertThat(actual.getLogEvents()).has(condition); + return this; + } + + @Nonnull + public LogbackTestExtensionAssert anyMatch(@Nonnull Predicate thePredicate) { + isNotNull(); + Assertions.assertThat(actual.getLogEvents()).anyMatch(thePredicate); return this; } @@ -54,12 +135,17 @@ public class LogbackTestExtensionAssert extends AbstractAssert> eventWithLevelAndMessageContains(@Nonnull Level theLevel, @Nonnull String theExpected) { - final Predicate loggingEvent = theLoggingEvent -> - theLoggingEvent.getLevel().equals(theLevel) && theLoggingEvent.getFormattedMessage().contains(theExpected); - final Predicate> loggingEvents = theLoggingEvents -> - theLoggingEvents.stream().anyMatch(loggingEvent); - return new Condition<>(loggingEvents, "has error logging message with level %s and message containing %s", theLevel, theExpected); + public LogbackTestExtensionAssert isNotEmpty() { + isNotNull(); + Assertions.assertThat(actual.getLogEvents()).isNotEmpty(); + return this; + } + + @Nonnull + public LogbackTestExtensionAssert hasSize(int theExpected) { + isNotNull(); + Assertions.assertThat(actual.getLogEvents()).hasSize(theExpected); + return this; } } diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LoggingEventPredicates.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LoggingEventPredicates.java new file mode 100644 index 00000000000..a5e742b7a49 --- /dev/null +++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/LoggingEventPredicates.java @@ -0,0 +1,58 @@ +/*- + * #%L + * HAPI FHIR Test Utilities + * %% + * Copyright (C) 2014 - 2024 Smile CDR, Inc. + * %% + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * #L% + */ +package ca.uhn.test.util; + +import ch.qos.logback.classic.Level; +import ch.qos.logback.classic.spi.ILoggingEvent; +import jakarta.annotation.Nonnull; + +import java.util.List; +import java.util.function.Predicate; + +public final class LoggingEventPredicates { + private LoggingEventPredicates() { + } + + @Nonnull + public static Predicate makeLevelEquals(@Nonnull Level theLevel) { + return loggingEvent -> loggingEvent.getLevel().equals(theLevel); + } + + @Nonnull + public static Predicate makeMessageEquals(@Nonnull String theMessage) { + return loggingEvent -> loggingEvent.getFormattedMessage().equals(theMessage); + } + + @Nonnull + public static Predicate makeMessageContains(@Nonnull String theMessage) { + return loggingEvent -> loggingEvent.getFormattedMessage().contains(theMessage); + } + + @Nonnull + public static Predicate makeExceptionMessageContains(@Nonnull String theExceptionMessage) { + return loggingEvent -> loggingEvent.getThrowableProxy().getMessage().contains(theExceptionMessage); + } + + @Nonnull + public static Predicate> makeAnyMatch(@Nonnull Predicate thePredicate) { + return loggingEvents -> loggingEvents.stream().anyMatch(thePredicate); + } + +} diff --git a/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/StaticLogbackTestExtension.java b/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/StaticLogbackTestExtension.java index 32dec261ab1..cc6b4b6f255 100644 --- a/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/StaticLogbackTestExtension.java +++ b/hapi-fhir-test-utilities/src/main/java/ca/uhn/test/util/StaticLogbackTestExtension.java @@ -21,13 +21,10 @@ package ca.uhn.test.util; import ch.qos.logback.classic.Level; import ch.qos.logback.classic.filter.ThresholdFilter; -import ch.qos.logback.classic.spi.ILoggingEvent; import org.junit.jupiter.api.extension.AfterAllCallback; import org.junit.jupiter.api.extension.BeforeAllCallback; import org.junit.jupiter.api.extension.ExtensionContext; -import java.util.List; - /** * This is a static wrapper around LogbackTestExtension for use in IT tests when you need to assert on App * startup log entries @@ -64,16 +61,8 @@ public class StaticLogbackTestExtension implements BeforeAllCallback, AfterAllCa myLogbackTestExtension.afterEach(theExtensionContext); } - public List filterLoggingEventsWithMessageEqualTo(String theMessageText) { - return myLogbackTestExtension.filterLoggingEventsWithMessageEqualTo(theMessageText); - } - - /** - * Returns a copy to avoid concurrent modification errors. - * @return A copy of the log events so far. - */ - public java.util.List getLogEvents() { - return myLogbackTestExtension.getLogEvents(); + public LogbackTestExtension getLogbackTestExtension() { + return myLogbackTestExtension; } } diff --git a/hapi-fhir-testpage-overlay/pom.xml b/hapi-fhir-testpage-overlay/pom.xml index d418eebfb6e..85a1d7c1ffd 100644 --- a/hapi-fhir-testpage-overlay/pom.xml +++ b/hapi-fhir-testpage-overlay/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../pom.xml diff --git a/hapi-fhir-validation-resources-dstu2.1/pom.xml b/hapi-fhir-validation-resources-dstu2.1/pom.xml index a24a770c6ea..896b3ba3120 100644 --- a/hapi-fhir-validation-resources-dstu2.1/pom.xml +++ b/hapi-fhir-validation-resources-dstu2.1/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-dstu2/pom.xml b/hapi-fhir-validation-resources-dstu2/pom.xml index d34eca32021..9dfdc4d5267 100644 --- a/hapi-fhir-validation-resources-dstu2/pom.xml +++ b/hapi-fhir-validation-resources-dstu2/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-dstu3/pom.xml b/hapi-fhir-validation-resources-dstu3/pom.xml index 0a241fe1a29..8c6ec9700c8 100644 --- a/hapi-fhir-validation-resources-dstu3/pom.xml +++ b/hapi-fhir-validation-resources-dstu3/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r4/pom.xml b/hapi-fhir-validation-resources-r4/pom.xml index d3c570146be..f7df57a5ee5 100644 --- a/hapi-fhir-validation-resources-r4/pom.xml +++ b/hapi-fhir-validation-resources-r4/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r4b/pom.xml b/hapi-fhir-validation-resources-r4b/pom.xml index 03975dc2910..ba31ac3cb2f 100644 --- a/hapi-fhir-validation-resources-r4b/pom.xml +++ b/hapi-fhir-validation-resources-r4b/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation-resources-r5/pom.xml b/hapi-fhir-validation-resources-r5/pom.xml index 3d300b34a53..a9b999429c3 100644 --- a/hapi-fhir-validation-resources-r5/pom.xml +++ b/hapi-fhir-validation-resources-r5/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-fhir-validation/pom.xml b/hapi-fhir-validation/pom.xml index a97d18b99bf..ce3c5c602a5 100644 --- a/hapi-fhir-validation/pom.xml +++ b/hapi-fhir-validation/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-deployable-pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../hapi-deployable-pom/pom.xml diff --git a/hapi-tinder-plugin/pom.xml b/hapi-tinder-plugin/pom.xml index 9ce3b68a313..865612ed58f 100644 --- a/hapi-tinder-plugin/pom.xml +++ b/hapi-tinder-plugin/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../pom.xml diff --git a/hapi-tinder-test/pom.xml b/hapi-tinder-test/pom.xml index f9ba636c8fe..45474c6cc0b 100644 --- a/hapi-tinder-test/pom.xml +++ b/hapi-tinder-test/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../pom.xml diff --git a/pom.xml b/pom.xml index 9b95f512121..cd9aa43df9b 100644 --- a/pom.xml +++ b/pom.xml @@ -8,7 +8,7 @@ ca.uhn.hapi.fhir hapi-fhir pom - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT HAPI-FHIR An open-source implementation of the FHIR specification in Java. diff --git a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml index e87614ddff1..abe1288dc88 100644 --- a/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml +++ b/tests/hapi-fhir-base-test-jaxrsserver-kotlin/pom.xml @@ -7,7 +7,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../../pom.xml diff --git a/tests/hapi-fhir-base-test-mindeps-client/pom.xml b/tests/hapi-fhir-base-test-mindeps-client/pom.xml index 984f0c2d7f5..ac4d0cff4a8 100644 --- a/tests/hapi-fhir-base-test-mindeps-client/pom.xml +++ b/tests/hapi-fhir-base-test-mindeps-client/pom.xml @@ -4,7 +4,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../../pom.xml diff --git a/tests/hapi-fhir-base-test-mindeps-server/pom.xml b/tests/hapi-fhir-base-test-mindeps-server/pom.xml index c222aa683e1..968330bb439 100644 --- a/tests/hapi-fhir-base-test-mindeps-server/pom.xml +++ b/tests/hapi-fhir-base-test-mindeps-server/pom.xml @@ -5,7 +5,7 @@ ca.uhn.hapi.fhir hapi-fhir - 7.3.9-SNAPSHOT + 7.3.10-SNAPSHOT ../../pom.xml