Skip to content

Commit

Permalink
Merge branch 'develop' into release/v2024.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Joshua Curtis committed Jul 25, 2024
2 parents 19db3dc + 72cdf48 commit c473693
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 7 deletions.
6 changes: 6 additions & 0 deletions converter/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@
<scope>test</scope>
</dependency>

<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<scope>test</scope>
</dependency>

<dependency>
<groupId>gov.cms.qpp.conversion</groupId>
<artifactId>test-commons</artifactId>
Expand Down
35 changes: 35 additions & 0 deletions converter/src/test/java/gov/cms/qpp/CacheBuilder.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
package gov.cms.qpp;

import com.github.benmanes.caffeine.cache.Cache;
import com.github.benmanes.caffeine.cache.Caffeine;
import gov.cms.qpp.conversion.model.validation.ApmEntityIds;
import gov.cms.qpp.model.CacheType;

import java.util.concurrent.TimeUnit;

public class CacheBuilder {
private static Cache<CacheType, ApmEntityIds> entityIdsCache;

CacheBuilder() {}

public static void buildEntityIdsCache() {
entityIdsCache = Caffeine.newBuilder()
.expireAfterWrite(5, TimeUnit.MINUTES)
.maximumSize(100)
.build();
}

public static ApmEntityIds getEntityIds(CacheType value) {
if (entityIdsCache == null) buildEntityIdsCache();
if (entityIdsCache.getIfPresent(value) == null) {
ApmEntityIds entityData = null;
switch(value) {
case ApmEntityId -> entityData = new ApmEntityIds("test_apm_entity_ids.json");
case ApmEntityIds -> entityData = new ApmEntityIds("test_apm_entity_ids.json","test_apm_entity_ids.json");
case ApmPcfEntityIds -> entityData = new ApmEntityIds("test_apm_entity_ids.json","test_pcf_apm_entity_ids.json");
}
entityIdsCache.put(value, entityData);
}
return entityIdsCache.getIfPresent(value);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package gov.cms.qpp.acceptance;

import gov.cms.qpp.CacheBuilder;
import gov.cms.qpp.model.CacheType;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.Assertions;
Expand Down Expand Up @@ -64,7 +66,7 @@ void invalidMessage() throws IOException {
}

private JsonWrapper convert(Path location) throws IOException {
ApmEntityIds apmEntityIds = new ApmEntityIds("test_apm_entity_ids.json", "test_apm_entity_ids.json");
ApmEntityIds apmEntityIds = CacheBuilder.getEntityIds(CacheType.ApmEntityIds);
Converter converter = new Converter(new PathSource(location), new Context(apmEntityIds));
return converter.transform();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package gov.cms.qpp.acceptance;

import gov.cms.qpp.CacheBuilder;
import gov.cms.qpp.model.CacheType;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -43,7 +45,7 @@ public class NegativePcfRoundTripTest {

@BeforeEach
void setup() {
apmEntityIds = new ApmEntityIds("test_apm_entity_ids.json", "test_apm_entity_ids.json");
apmEntityIds = CacheBuilder.getEntityIds(CacheType.ApmEntityIds);
}

@AfterEach
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@

import static com.google.common.truth.Truth.assertThat;
import static gov.cms.qpp.acceptance.Util.getXml;
import gov.cms.qpp.CacheBuilder;
import gov.cms.qpp.model.CacheType;

public class Pcf2024AcceptanceTest {
private static final Path BASE = Paths.get("src/test/resources/pcf/acceptance2024");
private static final Path SUCCESS = BASE.resolve("success");
private static final Path SUCCESS_WARNING = BASE.resolve("warning");
private static final Path FAILURE = BASE.resolve("failure");
private final ApmEntityIds apmEntityIds = new ApmEntityIds("test_apm_entity_ids.json","test_apm_entity_ids.json");
private static final ApmEntityIds apmEntityIds = CacheBuilder.getEntityIds(CacheType.ApmEntityIds);

static Stream<Path> successData() {
return getXml(SUCCESS);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gov.cms.qpp.acceptance;

import com.fasterxml.jackson.databind.ObjectMapper;
import gov.cms.qpp.CacheBuilder;
import gov.cms.qpp.model.CacheType;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -36,7 +38,7 @@ public class PcfRoundTripTest {
@SuppressWarnings("unchecked")
@BeforeAll
static void setup() throws URISyntaxException, IOException {
ApmEntityIds apmEntityIds = new ApmEntityIds("test_apm_entity_ids.json", "test_pcf_apm_entity_ids.json");
ApmEntityIds apmEntityIds = CacheBuilder.getEntityIds(CacheType.ApmPcfEntityIds);
URL sample = PcfRoundTripTest.class.getClassLoader()
.getResource("pcf/success/PCF_Sample_QRDA-III.xml");
Path path = Paths.get(sample.toURI());
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package gov.cms.qpp.acceptance;

import com.jayway.jsonpath.TypeRef;
import gov.cms.qpp.CacheBuilder;
import gov.cms.qpp.model.CacheType;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -51,7 +53,7 @@ class QualityMeasureIdRoundTripTest {

@BeforeEach
void setup() {
apmEntityIds = new ApmEntityIds("test_apm_entity_ids.json", "test_apm_entity_ids.json");
apmEntityIds = CacheBuilder.getEntityIds(CacheType.ApmEntityIds);
MeasureConfigs.initMeasureConfigs(MeasureConfigs.TEST_MEASURE_DATA);
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package gov.cms.qpp.conversion.model.validation;

import gov.cms.qpp.CacheBuilder;
import gov.cms.qpp.model.CacheType;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;

Expand All @@ -15,7 +17,7 @@ class ApmEntityIdsTest {

@BeforeEach
void setUp() {
apmEntityIds = new ApmEntityIds("test_apm_entity_ids.json");
apmEntityIds = CacheBuilder.getEntityIds(CacheType.ApmEntityId);
}

@Test
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package gov.cms.qpp.conversion.validate;

import gov.cms.qpp.CacheBuilder;
import gov.cms.qpp.model.CacheType;
import org.junit.jupiter.api.AfterEach;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand All @@ -24,7 +26,7 @@ public class PcfClinicalDocumentValidatorTest {

@BeforeEach
void setUp() {
apmEntityIds = new ApmEntityIds("test_apm_entity_ids.json", "test_apm_entity_ids.json");
apmEntityIds = CacheBuilder.getEntityIds(CacheType.ApmEntityIds);
validator = new PcfClinicalDocumentValidator(new Context(apmEntityIds));
}

Expand Down
7 changes: 7 additions & 0 deletions converter/src/test/java/gov/cms/qpp/model/CacheType.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package gov.cms.qpp.model;

public enum CacheType {
ApmEntityId,
ApmEntityIds,
ApmPcfEntityIds;
}
6 changes: 6 additions & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@
<version>32.1.1-jre</version>
</dependency>

<dependency>
<groupId>com.github.ben-manes.caffeine</groupId>
<artifactId>caffeine</artifactId>
<version>3.1.8</version>
</dependency>

<dependency>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
Expand Down

0 comments on commit c473693

Please sign in to comment.