diff --git a/client-api/pom.xml b/client-api/pom.xml index 09f5c552..3ac127ed 100644 --- a/client-api/pom.xml +++ b/client-api/pom.xml @@ -22,12 +22,7 @@ - - junit - junit - 4.13.1 - test - + diff --git a/common/pom.xml b/common/pom.xml index bed5a3df..75af6f68 100644 --- a/common/pom.xml +++ b/common/pom.xml @@ -22,8 +22,8 @@ guava - org.codehaus.jackson - jackson-jaxrs + com.fasterxml.jackson.core + jackson-databind diff --git a/common/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/storage/FileBackedJsonIndexStorage.java b/common/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/storage/FileBackedJsonIndexStorage.java index f8f97c6f..affcf8fb 100644 --- a/common/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/storage/FileBackedJsonIndexStorage.java +++ b/common/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/storage/FileBackedJsonIndexStorage.java @@ -1,7 +1,7 @@ package edu.harvard.hms.dbmi.avillach.hpds.storage; -import org.codehaus.jackson.map.ObjectMapper; -import org.codehaus.jackson.type.TypeReference; +import com.fasterxml.jackson.core.type.TypeReference; +import com.fasterxml.jackson.databind.ObjectMapper; import java.io.*; import java.util.zip.GZIPInputStream; diff --git a/common/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/crypto/CryptoDefaultKeyTest.java b/common/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/crypto/CryptoDefaultKeyTest.java index 2a7f254f..8f93aeea 100644 --- a/common/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/crypto/CryptoDefaultKeyTest.java +++ b/common/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/crypto/CryptoDefaultKeyTest.java @@ -1,22 +1,22 @@ package edu.harvard.hms.dbmi.avillach.hpds.crypto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.test.context.event.annotation.BeforeTestClass; + +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.io.File; import java.lang.reflect.Field; import java.lang.reflect.Modifier; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; - -@Ignore // We should rewrite the crypto class to make it more testable, these tests don't work on certain JDKs +@Disabled // We should rewrite the crypto class to make it more testable, these tests don't work on certain JDKs public class CryptoDefaultKeyTest { String TEST_MESSAGE = "This is a test."; - @BeforeClass + @BeforeTestClass public static void overrideDefaultKeyLocation() throws IllegalArgumentException, IllegalAccessException { } diff --git a/common/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/crypto/CryptoNamedKeyTest.java b/common/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/crypto/CryptoNamedKeyTest.java index 115f9ba7..435b5150 100644 --- a/common/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/crypto/CryptoNamedKeyTest.java +++ b/common/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/crypto/CryptoNamedKeyTest.java @@ -1,20 +1,18 @@ package edu.harvard.hms.dbmi.avillach.hpds.crypto; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; -import static org.junit.Assert.fail; - import java.io.File; import java.lang.reflect.Field; import java.lang.reflect.Modifier; import javax.crypto.AEADBadTagException; -import org.junit.BeforeClass; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.springframework.test.context.event.annotation.BeforeTestClass; + +import static org.junit.jupiter.api.Assertions.*; -@Ignore // We should rewrite the crypto class to make it more testable, these tests don't work on certain JDKs +@Disabled // We should rewrite the crypto class to make it more testable, these tests don't work on certain JDKs public class CryptoNamedKeyTest { private static final String TEST_NAMED_ENCRYPTIOON_KEY_PATH = "src/test/resources/test_named_encryption_key"; @@ -23,7 +21,7 @@ public class CryptoNamedKeyTest { String TEST_NAMED_KEY = "TEST_NAMED_KEY"; - @BeforeClass + @BeforeTestClass public static void overrideDefaultKeyLocation() throws IllegalArgumentException, IllegalAccessException, NoSuchFieldException, SecurityException { Field field = Crypto.class.getDeclaredField("DEFAULT_ENCRYPTION_KEY_PATH"); field.setAccessible(true); @@ -45,29 +43,21 @@ public void testNamedKeyEncryptDecrypt() { @Test public void testNamedKeyEncryptNotUsingDefaultKey() { - Crypto.loadKey(TEST_NAMED_KEY, TEST_NAMED_ENCRYPTIOON_KEY_PATH); - byte[] ciphertext = Crypto.encryptData(TEST_NAMED_KEY, TEST_MESSAGE.getBytes()); - assertTrue(!new String(ciphertext).contentEquals(TEST_MESSAGE)); - try{ + assertThrows(AEADBadTagException.class, () -> { + Crypto.loadKey(TEST_NAMED_KEY, TEST_NAMED_ENCRYPTIOON_KEY_PATH); + byte[] ciphertext = Crypto.encryptData(TEST_NAMED_KEY, TEST_MESSAGE.getBytes()); + assertFalse(new String(ciphertext).contentEquals(TEST_MESSAGE)); Crypto.decryptData(ciphertext); - }catch(RuntimeException e) { - assertEquals(e.getCause().getClass(), AEADBadTagException.class); - return; - } - fail("Expected AEADBadTagException to be thrown"); + }); } @Test public void testNamedKeyDecryptNotUsingDefaultKey() { - Crypto.loadKey(TEST_NAMED_KEY, TEST_NAMED_ENCRYPTIOON_KEY_PATH); - byte[] ciphertext = Crypto.encryptData(TEST_MESSAGE.getBytes()); - assertTrue(!new String(ciphertext).contentEquals(TEST_MESSAGE)); - try{ + assertThrows(AEADBadTagException.class, () -> { + Crypto.loadKey(TEST_NAMED_KEY, TEST_NAMED_ENCRYPTIOON_KEY_PATH); + byte[] ciphertext = Crypto.encryptData(TEST_MESSAGE.getBytes()); + assertTrue(!new String(ciphertext).contentEquals(TEST_MESSAGE)); Crypto.decryptData(TEST_NAMED_KEY, ciphertext); - }catch(RuntimeException e) { - assertEquals(e.getCause().getClass(), AEADBadTagException.class); - return; - } - fail("Expected AEADBadTagException to be thrown"); + }); } } diff --git a/data/pom.xml b/data/pom.xml index 81366252..50e8c0bc 100644 --- a/data/pom.xml +++ b/data/pom.xml @@ -26,12 +26,8 @@ commons-csv - org.codehaus.jackson - jackson-core-asl - - - org.codehaus.jackson - jackson-mapper-asl + com.fasterxml.jackson.core + jackson-databind edu.harvard.hms.dbmi.avillach diff --git a/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/genotype/VariantMasks.java b/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/genotype/VariantMasks.java index a8e2b75d..abe9e04d 100644 --- a/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/genotype/VariantMasks.java +++ b/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/genotype/VariantMasks.java @@ -1,8 +1,9 @@ package edu.harvard.hms.dbmi.avillach.hpds.data.genotype; -import org.codehaus.jackson.annotate.JsonProperty; -import org.codehaus.jackson.map.annotate.JsonSerialize; -import org.codehaus.jackson.map.ser.ToStringSerializer; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.fasterxml.jackson.databind.ser.std.ToStringSerializer; import java.io.Serializable; import java.math.BigInteger; @@ -174,15 +175,19 @@ public VariantMasks() { } @JsonProperty("ho") - @JsonSerialize(using = ToStringSerializer.class, include=JsonSerialize.Inclusion.NON_NULL) + @JsonInclude(JsonInclude.Include.NON_NULL) + @JsonSerialize(using = ToStringSerializer.class) public BigInteger homozygousMask; @JsonProperty("he") - @JsonSerialize(using = ToStringSerializer.class, include=JsonSerialize.Inclusion.NON_NULL) + @JsonSerialize(using = ToStringSerializer.class) + @JsonInclude(JsonInclude.Include.NON_NULL) public BigInteger heterozygousMask; @JsonProperty("hon") - @JsonSerialize(using = ToStringSerializer.class, include=JsonSerialize.Inclusion.NON_NULL) + @JsonSerialize(using = ToStringSerializer.class) + @JsonInclude(JsonInclude.Include.NON_NULL) public BigInteger homozygousNoCallMask; @JsonProperty("hen") - @JsonSerialize(using = ToStringSerializer.class, include=JsonSerialize.Inclusion.NON_NULL) + @JsonSerialize(using = ToStringSerializer.class) + @JsonInclude(JsonInclude.Include.NON_NULL) public BigInteger heterozygousNoCallMask; } diff --git a/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/phenotype/ColumnMeta.java b/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/phenotype/ColumnMeta.java index 3831c31c..3243a9db 100644 --- a/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/phenotype/ColumnMeta.java +++ b/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/phenotype/ColumnMeta.java @@ -1,12 +1,14 @@ package edu.harvard.hms.dbmi.avillach.hpds.data.phenotype; +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonInclude; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; + import java.io.Serializable; import java.util.List; -import org.codehaus.jackson.annotate.JsonIgnore; -import org.codehaus.jackson.map.annotate.JsonSerialize; -@JsonSerialize(include=JsonSerialize.Inclusion.NON_NULL) +@JsonInclude(JsonInclude.Include.NON_NULL) public class ColumnMeta implements Serializable{ private static final long serialVersionUID = -124111104912063811L; diff --git a/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/storage/FileBackedStorageVariantIndexImpl.java b/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/storage/FileBackedStorageVariantIndexImpl.java index f2ec9e48..c29755de 100644 --- a/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/storage/FileBackedStorageVariantIndexImpl.java +++ b/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/storage/FileBackedStorageVariantIndexImpl.java @@ -1,7 +1,7 @@ package edu.harvard.hms.dbmi.avillach.hpds.data.storage; +import com.fasterxml.jackson.core.type.TypeReference; import edu.harvard.hms.dbmi.avillach.hpds.storage.FileBackedJsonIndexStorage; -import org.codehaus.jackson.type.TypeReference; import java.io.File; import java.io.FileNotFoundException; diff --git a/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/storage/FileBackedStorageVariantMasksImpl.java b/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/storage/FileBackedStorageVariantMasksImpl.java index 6d39d79a..9d326a8c 100644 --- a/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/storage/FileBackedStorageVariantMasksImpl.java +++ b/data/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/data/storage/FileBackedStorageVariantMasksImpl.java @@ -1,8 +1,8 @@ package edu.harvard.hms.dbmi.avillach.hpds.data.storage; +import com.fasterxml.jackson.core.type.TypeReference; import edu.harvard.hms.dbmi.avillach.hpds.data.genotype.VariantMasks; import edu.harvard.hms.dbmi.avillach.hpds.storage.FileBackedJsonIndexStorage; -import org.codehaus.jackson.type.TypeReference; import java.io.File; import java.io.FileNotFoundException; diff --git a/etl/pom.xml b/etl/pom.xml index ef755403..2d19f3f1 100644 --- a/etl/pom.xml +++ b/etl/pom.xml @@ -13,11 +13,6 @@ etl - - ch.qos.logback - logback-core - 1.2.9 - org.apache.commons commons-compress @@ -30,19 +25,8 @@ com.fasterxml.jackson.core - jackson-core - 2.10.5 + jackson-databind - - com.fasterxml.jackson.core - jackson-annotations - 2.10.5 - - - com.fasterxml.jackson.core - jackson-databind - 2.10.5.1 - edu.harvard.hms.dbmi.avillach.hpds data diff --git a/etl/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/etl/genotype/NewVCFLoader.java b/etl/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/etl/genotype/NewVCFLoader.java index 145667b2..7727aba2 100644 --- a/etl/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/etl/genotype/NewVCFLoader.java +++ b/etl/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/etl/genotype/NewVCFLoader.java @@ -9,12 +9,10 @@ import java.util.zip.GZIPOutputStream; import edu.harvard.hms.dbmi.avillach.hpds.data.storage.FileBackedStorageVariantMasksImpl; -import edu.harvard.hms.dbmi.avillach.hpds.storage.FileBackedJavaIndexedStorage; import edu.harvard.hms.dbmi.avillach.hpds.storage.FileBackedJsonIndexStorage; import org.apache.commons.csv.CSVFormat; import org.apache.commons.csv.CSVParser; import org.apache.commons.csv.CSVRecord; -import org.codehaus.jackson.type.TypeReference; import org.slf4j.Logger; import org.slf4j.LoggerFactory; diff --git a/etl/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/data/genotype/BucketIndexBySampleTest.java b/etl/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/data/genotype/BucketIndexBySampleTest.java index b7474ef9..d87686ea 100644 --- a/etl/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/data/genotype/BucketIndexBySampleTest.java +++ b/etl/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/data/genotype/BucketIndexBySampleTest.java @@ -1,24 +1,19 @@ package edu.harvard.hms.dbmi.avillach.hpds.data.genotype; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; - -import java.io.FileInputStream; import java.io.IOException; -import java.io.ObjectInputStream; import java.util.ArrayList; import java.util.Collection; import java.util.HashSet; import java.util.List; import java.util.Set; -import java.util.zip.GZIPInputStream; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Test; import edu.harvard.hms.dbmi.avillach.hpds.etl.genotype.NewVCFLoader; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.springframework.test.context.event.annotation.BeforeTestClass; + +import static org.springframework.test.util.AssertionErrors.*; /** * These tests are in the ETL project so that we can read in data from disk each time instead of storing binfiles @@ -71,7 +66,7 @@ public class BucketIndexBySampleTest { Set variantSet; List patientSet; - @BeforeClass + @BeforeTestClass public static void initializeBinfile() throws Exception { //load variant data NewVCFLoader.main(new String[] {VCF_INDEX_FILE, STORAGE_DIR, MERGED_DIR}); @@ -83,7 +78,7 @@ public static void initializeBinfile() throws Exception { // bucketIndexBySample.printPatientMasks(); } - @Before + @BeforeEach public void setUpTest() { //start with fresh, empty collections variantSet = new HashSet(); diff --git a/etl/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/data/genotype/VariantMetadataIndexTest.java b/etl/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/data/genotype/VariantMetadataIndexTest.java index c62eaadd..476318ad 100644 --- a/etl/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/data/genotype/VariantMetadataIndexTest.java +++ b/etl/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/data/genotype/VariantMetadataIndexTest.java @@ -1,19 +1,19 @@ package edu.harvard.hms.dbmi.avillach.hpds.data.genotype; -import static org.junit.Assert.assertArrayEquals; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; - import java.io.*; import java.util.List; import java.util.Map; import java.util.TreeMap; import java.util.zip.GZIPInputStream; -import org.junit.*; - import edu.harvard.hms.dbmi.avillach.hpds.data.genotype.caching.VariantBucketHolder; import edu.harvard.hms.dbmi.avillach.hpds.etl.genotype.VariantMetadataLoader; +import org.junit.jupiter.api.Test; +import org.springframework.test.context.event.annotation.BeforeTestClass; + +import static org.junit.jupiter.api.Assertions.assertThrows; +import static org.springframework.test.util.AssertionErrors.assertEquals; +import static org.springframework.test.util.AssertionErrors.assertNotNull; public class VariantMetadataIndexTest { @@ -37,7 +37,7 @@ public class VariantMetadataIndexTest { private static final String spec5 = "4,9856624,CAAAAA,CA"; private static final String spec5Info = "AC=3033;AF=6.05631e-01;NS=2504;AN=5008;EAS_AF=5.23800e-01;EUR_AF=7.54500e-01;AFR_AF=4.28900e-01;AMR_AF=7.82400e-01;SAS_AF=6.50300e-01;DP=20851;VT=INDEL"; - @BeforeClass + @BeforeTestClass public static void initializeBinfile() throws Exception { VariantMetadataLoader.main(new String[] {"./src/test/resources/test_vcfIndex.tsv", binFile, "target/VariantMetadataStorage.bin"}); @@ -54,21 +54,21 @@ public static void initializeBinfile() throws Exception { public void test_2a_variantFromFile_1_WasLoaded() { String[] data = vmi.findBySingleVariantSpec("14,19038291,C,A", bucketCache); String[] expecteds = {"AC=14;AF=2.79553e-03;NS=2504;AN=5008;EAS_AF=0.00000e+00;EUR_AF=1.09000e-02;AFR_AF=0.00000e+00;AMR_AF=4.30000e-03;SAS_AF=0.00000e+00;DP=32694;AA=.|||;VT=SNP"}; - assertArrayEquals("The expected values were not found.", expecteds, data); + assertEquals("The expected values were not found.", expecteds, data); } @Test public void test_2b_variantFromFile_2_WasLoaded() { String[] data = vmi.findBySingleVariantSpec("14,21089541,A,G", bucketCache); String[] expecteds = {"AC=20;AF=3.99361e-03;NS=2504;AN=5008;EAS_AF=0.00000e+00;EUR_AF=0.00000e+00;AFR_AF=1.44000e-02;AMR_AF=1.40000e-03;SAS_AF=0.00000e+00;DP=18507;AA=A|||;VT=SNP"}; - assertArrayEquals("The expected values were not found.", expecteds, data); + assertEquals("The expected values were not found.", expecteds, data); } @Test public void test_2c_variantFromFile_3_WasNotLoaded() { String[] data = vmi.findBySingleVariantSpec("14,21616876,G,A", bucketCache); String[] expecteds = {}; - assertArrayEquals("The expected values were not found.", expecteds, data); + assertEquals("The expected values were not found.", expecteds, data); } @Test @@ -83,13 +83,13 @@ public void test_4_MultipleVariantSpec() { assertEquals("Wrong number of records in response.", data[0].size(), 2); variants.stream().forEach(variant->{ - assertArrayEquals("The expected values were not found.", expectedResult.get(variant), data[0].get(variant)); + assertEquals("The expected values were not found.", expectedResult.get(variant), data[0].get(variant)); }); Map[] data2 = new Map[] {vmi.findByMultipleVariantSpec(variants.subList(0, 1))}; assertEquals("Wrong number of records in response.", 1, data2[0].size()); - assertArrayEquals("The expected values were not found.", expectedResult.get(variants.get(0)), data2[0].get(variants.get(0))); + assertEquals("The expected values were not found.", expectedResult.get(variants.get(0)), data2[0].get(variants.get(0))); } @@ -104,7 +104,7 @@ public void testMultipleVariantSpecSamePOS() { assertEquals("Wrong number of records in response.", data[0].size(), 2); variants.stream().forEach(variant->{ - assertArrayEquals("The expected values were not found.", expectedResult.get(variant), data[0].get(variant)); + assertEquals("The expected values were not found.", expectedResult.get(variant), data[0].get(variant)); }); } @@ -118,7 +118,7 @@ public void testMultipleVariantSpecSamePOSAndREF() { assertEquals("Wrong number of records in response.", data[0].size(), 2); variants.stream().forEach(variant->{ - assertArrayEquals("The expected values were not found.", expectedResult.get(variant), data[0].get(variant)); + assertEquals("The expected values were not found.", expectedResult.get(variant), data[0].get(variant)); }); } @@ -132,23 +132,25 @@ public void testMultipleVariantSpecSamePOSAndALT() { assertEquals("Wrong number of records in response.", data[0].size(), 2); variants.stream().forEach(variant->{ - assertArrayEquals("The expected values were not found.", expectedResult.get(variant), data[0].get(variant)); + assertEquals("The expected values were not found.", expectedResult.get(variant), data[0].get(variant)); }); } /** * The google API that we use throws an IllegalStateException on duplicate entries */ - @Test (expected = IllegalStateException.class) + @Test public void testMultipleVariantSpecSameSpec() { - List variants = List.of(spec1, spec1); - Map expectedResult = Map.of( - spec1, new String[]{spec1Info}); - Map[] data = new Map[] {vmi.findByMultipleVariantSpec(variants)}; - - assertEquals("Wrong number of records in response.", data[0].size(), 1); - variants.stream().forEach(variant->{ - assertArrayEquals("The expected values were not found.", expectedResult.get(variant), data[0].get(variant)); + assertThrows(IllegalStateException.class, () -> { + List variants = List.of(spec1, spec1); + Map expectedResult = Map.of( + spec1, new String[]{spec1Info}); + Map[] data = new Map[] {vmi.findByMultipleVariantSpec(variants)}; + + assertEquals("Wrong number of records in response.", data[0].size(), 1); + variants.stream().forEach(variant->{ + assertEquals("The expected values were not found.", expectedResult.get(variant), data[0].get(variant)); + }); }); } diff --git a/pom.xml b/pom.xml index eb56fe89..02f8e8a6 100644 --- a/pom.xml +++ b/pom.xml @@ -3,6 +3,12 @@ xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd"> 4.0.0 + + org.springframework.boot + spring-boot-starter-parent + 3.1.5 + + edu.harvard.hms.dbmi.avillach.hpds pic-sure-hpds 3.0.0-SNAPSHOT @@ -19,7 +25,6 @@ client-api - 1.8.6 UTF-8 1.4.10 @@ -144,25 +149,22 @@ - junit - junit + org.springframework.boot + spring-boot-starter-test test - ch.qos.logback - logback-core - - - ch.qos.logback - logback-classic - - - org.slf4j - slf4j-api + org.springframework.boot + spring-boot-starter-web + + org.springframework.boot + spring-boot-starter-tomcat + provided + edu.harvard.hms.dbmi.avillach.hpds common @@ -197,21 +199,28 @@ edu.harvard.hms.dbmi.avillach pic-sure-resource-api 2.1.0-SNAPSHOT - - - ch.qos.logback - logback-core - 1.2.9 - - - ch.qos.logback - logback-classic - 1.2.9 - - - org.slf4j - slf4j-api - 1.7.25 + + + org.apache.logging.log4j + log4j-core + + + org.slf4j + slf4j-log4j12 + + + org.slf4j + slf4j-api + + + ch.qos.logback + logback-classic + + + org.slf4j + slf4j-jdk14 + + com.google.guava @@ -238,16 +247,6 @@ commons-io 2.7 - - org.apache.cxf - cxf-rt-frontend-jaxrs - 3.2.5 - - - org.apache.cxf - cxf-rt-rs-client - 3.2.5 - org.codehaus.jackson jackson-core-asl @@ -278,17 +277,6 @@ activation 1.1.1 - - org.codehaus.jackson - jackson-jaxrs - ${jackson.version} - - - junit - junit - 4.13.1 - test - org.mockito mockito-core @@ -300,40 +288,20 @@ ojdbc10 19.17.0.0 - - org.springframework - spring-jdbc - 5.1.1.RELEASE - com.github.ben-manes.caffeine caffeine 3.1.1 - - org.springframework - spring-test - 4.3.30.RELEASE - - - org.springframework - spring-webflux - 6.0.13 - io.projectreactor.netty reactor-netty 1.1.12 - org.springframework - spring-web - 6.0.13 - - - org.springframework - spring-context - 6.0.13 + com.fasterxml.jackson.core + jackson-databind + 2.15.3 diff --git a/processing/pom.xml b/processing/pom.xml index 19fc7e8c..66d9d1e3 100644 --- a/processing/pom.xml +++ b/processing/pom.xml @@ -25,12 +25,6 @@ mockito-core test - - javax - javaee-api - 8.0 - provided - org.springframework spring-webflux @@ -39,13 +33,5 @@ io.projectreactor.netty reactor-netty - - org.springframework - spring-web - - - org.springframework - spring-context - diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessor.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessor.java index b6322d46..ec90384c 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessor.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessor.java @@ -46,8 +46,6 @@ public class AbstractProcessor { private LoadingCache> store; - private final VariantService variantService; - private final PhenotypeMetaStore phenotypeMetaStore; private final GenomicProcessor genomicProcessor; @@ -77,8 +75,6 @@ public AbstractProcessor( genomicDataDirectory = System.getProperty("HPDS_GENOMIC_DATA_DIRECTORY", "/opt/local/hpds/all/"); this.phenotypeMetaStore = phenotypeMetaStore; - // todo: get rid of this - this.variantService = new VariantService(genomicDataDirectory); this.genomicProcessor = genomicProcessor; CACHE_SIZE = Integer.parseInt(System.getProperty("CACHE_SIZE", "100")); @@ -136,12 +132,11 @@ public AbstractProcessor( public AbstractProcessor(PhenotypeMetaStore phenotypeMetaStore, LoadingCache> store, Map infoStores, List infoStoreColumns, - VariantService variantService, GenomicProcessor genomicProcessor) { + GenomicProcessor genomicProcessor) { this.phenotypeMetaStore = phenotypeMetaStore; this.store = store; this.infoStores = infoStores; this.infoStoreColumns = infoStoreColumns; - this.variantService = variantService; this.genomicProcessor = genomicProcessor; CACHE_SIZE = Integer.parseInt(System.getProperty("CACHE_SIZE", "100")); @@ -186,7 +181,7 @@ protected Set idSetsForEachFilter(Query query) { if (distributableQuery.hasFilters()) { BigInteger patientMaskForVariantInfoFilters = genomicProcessor.getPatientMask(distributableQuery); - return patientMaskToPatientIdSet(patientMaskForVariantInfoFilters); + return genomicProcessor.patientMaskToPatientIdSet(patientMaskForVariantInfoFilters); } return distributableQuery.getPatientIds(); @@ -225,18 +220,6 @@ private DistributableQuery getDistributableQuery(Query query) { return distributableQuery; } - public Set patientMaskToPatientIdSet(BigInteger patientMask) { - Set ids = new HashSet<>(); - String bitmaskString = patientMask.toString(2); - for(int x = 2;x < bitmaskString.length()-2;x++) { - if('1'==bitmaskString.charAt(x)) { - String patientId = variantService.getPatientIds()[x-2].trim(); - ids.add(Integer.parseInt(patientId)); - } - } - return ids; - } - /** * Process each filter in the query and return a list of patient ids that should be included in the * result. @@ -428,7 +411,7 @@ public String[] getPatientIds() { } public Optional getMasks(String path, VariantBucketHolder variantMasksVariantBucketHolder) { - return variantService.getMasks(path, variantMasksVariantBucketHolder); + return genomicProcessor.getMasks(path, variantMasksVariantBucketHolder); } // todo: handle this locally, we do not want this in the genomic processor diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessor.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessor.java index e25bd869..41f3faac 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessor.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessor.java @@ -1,7 +1,11 @@ package edu.harvard.hms.dbmi.avillach.hpds.processing; +import edu.harvard.hms.dbmi.avillach.hpds.data.genotype.VariantMasks; +import edu.harvard.hms.dbmi.avillach.hpds.data.genotype.caching.VariantBucketHolder; + import java.math.BigInteger; import java.util.Collection; +import java.util.Optional; import java.util.Set; public interface GenomicProcessor { @@ -14,4 +18,6 @@ public interface GenomicProcessor { Collection getVariantList(DistributableQuery distributableQuery); String[] getPatientIds(); + + Optional getMasks(String path, VariantBucketHolder variantMasksVariantBucketHolder); } diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorNodeImpl.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorNodeImpl.java index d4fcd5e1..3e197f39 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorNodeImpl.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorNodeImpl.java @@ -352,4 +352,9 @@ public String[] getPatientIds() { return variantService.getPatientIds(); } + @Override + public Optional getMasks(String path, VariantBucketHolder variantMasksVariantBucketHolder) { + return variantService.getMasks(path, variantMasksVariantBucketHolder); + } + } diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorParentImpl.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorParentImpl.java index bf47ae9b..ce1d6441 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorParentImpl.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/GenomicProcessorParentImpl.java @@ -1,5 +1,7 @@ package edu.harvard.hms.dbmi.avillach.hpds.processing; +import edu.harvard.hms.dbmi.avillach.hpds.data.genotype.VariantMasks; +import edu.harvard.hms.dbmi.avillach.hpds.data.genotype.caching.VariantBucketHolder; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -8,6 +10,7 @@ import java.math.BigInteger; import java.util.Collection; import java.util.List; +import java.util.Optional; import java.util.Set; import java.util.stream.Collectors; @@ -65,4 +68,15 @@ public String[] getPatientIds() { // todo: verify all nodes have the same potients return nodes.get(0).getPatientIds(); } + + @Override + public Optional getMasks(String path, VariantBucketHolder variantMasksVariantBucketHolder) { + for (GenomicProcessor node : nodes) { + Optional masks = node.getMasks(path, variantMasksVariantBucketHolder); + if (masks.isPresent()) { + return masks; + } + } + return Optional.empty(); + } } diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/TimeseriesProcessor.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/TimeseriesProcessor.java index 55130c02..fe539659 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/TimeseriesProcessor.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/TimeseriesProcessor.java @@ -69,7 +69,8 @@ public void runQuery(Query query, AsyncResult result) { log.error("Exception exporting time data", e); } } else { - throw new NotAuthorizedException("Data Export is not authorized for this system"); + // todo: create an exception for this and handle it with an appropriate response code + throw new RuntimeException("Data Export is not authorized for this system"); } return; } diff --git a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClient.java b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClient.java index d3abdb5f..d63facda 100644 --- a/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClient.java +++ b/processing/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClient.java @@ -1,5 +1,7 @@ package edu.harvard.hms.dbmi.avillach.hpds.processing.genomic; +import edu.harvard.hms.dbmi.avillach.hpds.data.genotype.VariantMasks; +import edu.harvard.hms.dbmi.avillach.hpds.data.genotype.caching.VariantBucketHolder; import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; import edu.harvard.hms.dbmi.avillach.hpds.processing.DistributableQuery; import edu.harvard.hms.dbmi.avillach.hpds.processing.GenomicProcessor; @@ -10,6 +12,7 @@ import java.math.BigInteger; import java.util.Collection; +import java.util.Optional; import java.util.Set; public class GenomicProcessorRestClient implements GenomicProcessor { @@ -60,4 +63,9 @@ public Collection getVariantList(DistributableQuery distributableQuery) public String[] getPatientIds() { return new String[0]; } + + @Override + public Optional getMasks(String path, VariantBucketHolder variantMasksVariantBucketHolder) { + throw new RuntimeException("Not Implemented"); + } } diff --git a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/Testing504MVariants.java b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/Testing504MVariants.java index 7a6d63e8..833a44da 100644 --- a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/Testing504MVariants.java +++ b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/Testing504MVariants.java @@ -7,7 +7,7 @@ import java.util.Random; import org.apache.commons.io.output.ByteArrayOutputStream; -import org.junit.Test; +import org.junit.jupiter.api.Test; public class Testing504MVariants { diff --git a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessorTest.java b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessorTest.java index 0d0a16c7..db3058ad 100644 --- a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessorTest.java +++ b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/AbstractProcessorTest.java @@ -4,20 +4,20 @@ import edu.harvard.hms.dbmi.avillach.hpds.data.genotype.FileBackedByteIndexedInfoStore; import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; import edu.harvard.hms.dbmi.avillach.hpds.storage.FileBackedByteIndexedStorage; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.ArgumentCaptor; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import java.util.*; -import static org.mockito.ArgumentMatchers.any; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; import static org.mockito.Mockito.*; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class AbstractProcessorTest { private AbstractProcessor abstractProcessor; @@ -36,7 +36,7 @@ public class AbstractProcessorTest { public static final List EXAMPLE_VARIANT_SEVERITIES = List.of("HIGH", "MODERATE", "LOW"); - @Before + @BeforeEach public void setup() { FileBackedByteIndexedInfoStore mockInfoStore = mock(FileBackedByteIndexedInfoStore.class); FileBackedByteIndexedStorage mockIndexedStorage = mock(FileBackedByteIndexedStorage.class); @@ -61,7 +61,6 @@ public void setup() { null, infoStores, null, - variantService, genomicProcessor ); } diff --git a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/CountProcessorTest.java b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/CountProcessorTest.java index ccd9fbfd..030e9b46 100644 --- a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/CountProcessorTest.java +++ b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/CountProcessorTest.java @@ -1,20 +1,21 @@ package edu.harvard.hms.dbmi.avillach.hpds.processing; -import static org.junit.Assert.assertEquals; +import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; +import org.mockito.Mock; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.test.context.event.annotation.BeforeTestClass; import java.io.IOException; -import java.util.*; - -import org.junit.Before; -import org.junit.Test; +import java.util.ArrayList; +import java.util.List; +import java.util.Map; -import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; -import static org.mockito.Mockito.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.mockito.Mockito.when; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class CountProcessorTest { private CountProcessor countProcessor; @@ -22,7 +23,7 @@ public class CountProcessorTest { @Mock private AbstractProcessor mockAbstractProcessor; - @Before + @BeforeTestClass public void before() { countProcessor = new CountProcessor(mockAbstractProcessor); } diff --git a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/PatientVariantJoinHandlerTest.java b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/PatientVariantJoinHandlerTest.java index de1feb1e..9daf37af 100644 --- a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/PatientVariantJoinHandlerTest.java +++ b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/PatientVariantJoinHandlerTest.java @@ -1,23 +1,22 @@ package edu.harvard.hms.dbmi.avillach.hpds.processing; import edu.harvard.hms.dbmi.avillach.hpds.data.genotype.VariantMasks; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; +import org.springframework.test.context.event.annotation.BeforeTestClass; import java.math.BigInteger; -import java.util.List; import java.util.Optional; import java.util.Set; import java.util.TreeSet; import java.util.stream.Collectors; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.mockito.Mockito.*; -import static org.junit.Assert.*; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class PatientVariantJoinHandlerTest { @Mock @@ -29,7 +28,7 @@ public class PatientVariantJoinHandlerTest { public static final Set PATIENT_IDS_INTEGERS = Set.of(PATIENT_IDS).stream().map(Integer::parseInt).collect(Collectors.toSet()); public static final String[] VARIANT_INDEX = {"16,61642243,A,T", "16,61642252,A,G", "16,61642256,C,T", "16,61642257,G,A", "16,61642258,G,A", "16,61642259,G,A", "16,61642260,G,A", "16,61642261,G,A"}; - @Before + @BeforeTestClass public void setUp() { patientVariantJoinHandler = new PatientVariantJoinHandler(variantService); when(variantService.getVariantIndex()).thenReturn(VARIANT_INDEX); diff --git a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/VariantIndexTest.java b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/VariantIndexTest.java index 34c18416..da51723e 100644 --- a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/VariantIndexTest.java +++ b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/VariantIndexTest.java @@ -1,9 +1,11 @@ package edu.harvard.hms.dbmi.avillach.hpds.processing; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.Set; -import static org.junit.Assert.*; + +import static org.junit.jupiter.api.Assertions.assertArrayEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; public class VariantIndexTest { diff --git a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/VariantListQueryTest.java b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/VariantListQueryTest.java index cf1c1419..71f1906d 100644 --- a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/VariantListQueryTest.java +++ b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/VariantListQueryTest.java @@ -1,23 +1,21 @@ package edu.harvard.hms.dbmi.avillach.hpds.processing; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertTrue; - import java.io.FileNotFoundException; import java.io.IOException; import java.util.*; -import org.junit.Ignore; -import org.junit.Test; - -import edu.harvard.hms.dbmi.avillach.hpds.data.genotype.VariantStore; import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query.VariantInfoFilter; -import org.junit.runner.RunWith; + +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; + +import static org.junit.jupiter.api.Assertions.assertEquals; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class VariantListQueryTest { @Mock @@ -90,7 +88,7 @@ public void testVariantListWithVariantInfoFiltersWithMultipleVariantsButNoInters assertEquals("[]", t.runVariantListQuery(q)); } - @Ignore + @Disabled public void testVariantListWithVariantInfoFiltersWithMultipleVariantsWithIntersectingKeys() throws Exception { ArrayList> data = new ArrayList<>(List.of( Set.of(42), @@ -139,7 +137,7 @@ public void testVariantListWithTwoVariantInfoFiltersWithMultipleVariantsWithInte assertTrue(variantList.contains("2,3456,C,A")); }*/ - @Ignore + @Disabled public void testVariantListWithVariantInfoFiltersWithOnlyOneFilterCriteria() throws Exception { ArrayList> data = new ArrayList>(List.of( Set.of(42))); diff --git a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClientTest.java b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClientTest.java index 08809722..7a34454f 100644 --- a/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClientTest.java +++ b/processing/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/processing/genomic/GenomicProcessorRestClientTest.java @@ -3,7 +3,7 @@ import com.fasterxml.jackson.core.JsonProcessingException; import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; import edu.harvard.hms.dbmi.avillach.hpds.processing.DistributableQuery; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.math.BigInteger; import java.util.ArrayList; @@ -17,7 +17,7 @@ public class GenomicProcessorRestClientTest { @Test - public void test() throws JsonProcessingException { + public void simpleTest() { DistributableQuery distributableQuery = new DistributableQuery(); List variantInfoFilters = new ArrayList<>(); diff --git a/processing/src/test/resources/log4j.properties b/processing/src/test/resources/log4j.properties deleted file mode 100644 index 5e798180..00000000 --- a/processing/src/test/resources/log4j.properties +++ /dev/null @@ -1,9 +0,0 @@ -# Root logger option -log4j.rootLogger=INFO, stdout - -# Direct log messages to stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n - \ No newline at end of file diff --git a/service/pom.xml b/service/pom.xml index 234c131d..8467508c 100644 --- a/service/pom.xml +++ b/service/pom.xml @@ -32,26 +32,10 @@ org.apache.commons commons-math3 - - org.apache.cxf - cxf-rt-frontend-jaxrs - - - org.apache.cxf - cxf-rt-rs-client - com.google.guava guava - - org.codehaus.jackson - jackson-core-asl - - - org.codehaus.jackson - jackson-mapper-asl - javax.xml.bind jaxb-api @@ -68,10 +52,6 @@ javax.activation activation - - org.codehaus.jackson - jackson-jaxrs - org.springframework spring-web @@ -86,6 +66,10 @@ mockito-core test + + org.springframework.boot + spring-boot-starter-web + diff --git a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/HpdsApplication.java b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/HpdsApplication.java new file mode 100644 index 00000000..9da0b46c --- /dev/null +++ b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/HpdsApplication.java @@ -0,0 +1,15 @@ +package edu.harvard.hms.dbmi.avillach.hpds.service; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; +import org.springframework.context.annotation.ComponentScan; + +@SpringBootApplication +@ComponentScan("edu.harvard.hms.dbmi.avillach.hpds") +public class HpdsApplication { + + public static void main(String[] args) { + SpringApplication.run(HpdsApplication.class, args); + } + +} \ No newline at end of file diff --git a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/PicSureService.java b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/PicSureService.java index 12287521..7f5f7b8a 100644 --- a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/PicSureService.java +++ b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/PicSureService.java @@ -5,17 +5,12 @@ import java.util.Map.Entry; import java.util.stream.Collectors; -import javax.ws.rs.*; -import javax.ws.rs.core.HttpHeaders; -import javax.ws.rs.core.Response; -import javax.ws.rs.core.Response.ResponseBuilder; -import javax.ws.rs.core.Response.Status; - import edu.harvard.hms.dbmi.avillach.hpds.service.util.Paginator; -import org.apache.http.entity.ContentType; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpStatus; import org.springframework.http.MediaType; import com.fasterxml.jackson.core.JsonParseException; @@ -26,19 +21,19 @@ import com.google.common.collect.ImmutableMap; import edu.harvard.dbmi.avillach.domain.*; -import edu.harvard.dbmi.avillach.service.IResourceRS; import edu.harvard.dbmi.avillach.util.UUIDv5; import edu.harvard.hms.dbmi.avillach.hpds.crypto.Crypto; import edu.harvard.hms.dbmi.avillach.hpds.data.genotype.FileBackedByteIndexedInfoStore; import edu.harvard.hms.dbmi.avillach.hpds.data.phenotype.ColumnMeta; import edu.harvard.hms.dbmi.avillach.hpds.data.query.Query; import edu.harvard.hms.dbmi.avillach.hpds.processing.*; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; +import org.springframework.web.bind.annotation.*; -@Path("PIC-SURE") -@Produces("application/json") -@Component("picSureService") -public class PicSureService implements IResourceRS { +@RequestMapping(value = "PIC-SURE", produces = "application/json") +@RestController +public class PicSureService { @Autowired public PicSureService(QueryService queryService, TimelineProcessor timelineProcessor, CountProcessor countProcessor, @@ -71,8 +66,7 @@ public PicSureService(QueryService queryService, TimelineProcessor timelineProce private static final String QUERY_METADATA_FIELD = "queryMetadata"; private static final int RESPONSE_CACHE_SIZE = 50; - @POST - @Path("/info") + @PostMapping("/info") public ResourceInfo info(QueryRequest request) { ResourceInfo info = new ResourceInfo(); info.setName("PhenoCube v1.0-SNAPSHOT"); @@ -136,8 +130,7 @@ public ResourceInfo info(QueryRequest request) { return info; } - @POST - @Path("/search") + @PostMapping("/search") public SearchResults search(QueryRequest searchJson) { Set> allColumns = abstractProcessor.getDictionary().entrySet(); @@ -179,23 +172,22 @@ public SearchResults search(QueryRequest searchJson) { .setSearchQuery(searchJson.getQuery().toString()); } - @POST - @Path("/query") - public QueryStatus query(QueryRequest queryJson) { + @PostMapping("/query") + public ResponseEntity query(QueryRequest queryJson) { if (Crypto.hasKey(Crypto.DEFAULT_KEY_NAME)) { try { Query query = convertIncomingQuery(queryJson); - return convertToQueryStatus(queryService.runQuery(query)); + return ResponseEntity.ok(convertToQueryStatus(queryService.runQuery(query))); } catch (IOException e) { log.error("IOException caught in query processing:", e); - throw new ServerErrorException(500); + return ResponseEntity.status(500).build(); } catch (ClassNotFoundException e) { - throw new ServerErrorException(500); + return ResponseEntity.status(500).build(); } } else { QueryStatus status = new QueryStatus(); status.setResourceStatus("Resource is locked."); - return status; + return ResponseEntity.ok(status); } } @@ -221,11 +213,8 @@ private QueryStatus convertToQueryStatus(AsyncResult entity) { return status; } - @POST - @Path("/query/{resourceQueryId}/result") - @Produces(MediaType.TEXT_PLAIN_VALUE) - @Override - public Response queryResult(@PathParam("resourceQueryId") UUID queryId, QueryRequest resultRequest) { + @PostMapping(value = "/query/{resourceQueryId}/result", produces = MediaType.TEXT_PLAIN_VALUE) + public ResponseEntity queryResult(@PathVariable("resourceQueryId") UUID queryId, QueryRequest resultRequest) { AsyncResult result = queryService.getResultFor(queryId.toString()); if (result == null) { // This happens sometimes when users immediately request the status for a query @@ -234,66 +223,58 @@ public Response queryResult(@PathParam("resourceQueryId") UUID queryId, QueryReq try { Thread.sleep(100); } catch (InterruptedException e) { - return Response.status(500).build(); + return ResponseEntity.status(500).build(); } result = queryService.getResultFor(queryId.toString()); if (result == null) { - return Response.status(404).build(); + return ResponseEntity.status(404).build(); } } if (result.status == AsyncResult.Status.SUCCESS) { result.stream.open(); - return Response.ok(result.stream).build(); + return ResponseEntity.ok(result.stream); } else { - return Response.status(400).entity("Status : " + result.status.name()).build(); + return ResponseEntity.status(400).body("Status : " + result.status.name()); } } - @POST - @Path("/query/{resourceQueryId}/status") - @Override - public QueryStatus queryStatus(@PathParam("resourceQueryId") UUID queryId, QueryRequest request) { + @PostMapping("/query/{resourceQueryId}/status") + public QueryStatus queryStatus(@PathVariable("resourceQueryId") UUID queryId, QueryRequest request) { return convertToQueryStatus(queryService.getStatusFor(queryId.toString())); } - @POST - @Path("/query/format") - public Response queryFormat(QueryRequest resultRequest) { + @PostMapping("/query/format") + public ResponseEntity queryFormat(QueryRequest resultRequest) { try { // The toString() method here has been overridden to produce a human readable // value - return Response.ok().entity(convertIncomingQuery(resultRequest).toString()).build(); + return ResponseEntity.ok(convertIncomingQuery(resultRequest).toString()); } catch (IOException e) { - return Response.ok() - .entity("An error occurred formatting the query for display: " + e.getLocalizedMessage()).build(); + return ResponseEntity.status(500).body("An error occurred formatting the query for display: " + e.getLocalizedMessage()); } } - @POST - @Path("/query/sync") - @Produces(MediaType.TEXT_PLAIN_VALUE) - public Response querySync(QueryRequest resultRequest) { + @PostMapping(value = "/query/sync", produces = MediaType.TEXT_PLAIN_VALUE) + public ResponseEntity querySync(QueryRequest resultRequest) { if (Crypto.hasKey(Crypto.DEFAULT_KEY_NAME)) { try { return _querySync(resultRequest); } catch (IOException e) { log.error("IOException caught: ", e); - return Response.serverError().build(); + return ResponseEntity.status(500).build(); } } else { - return Response.status(403).entity("Resource is locked").build(); + return ResponseEntity.status(403).body("Resource is locked"); } } - @GET - @Path("/search/values/") - @Override + @GetMapping("/search/values/") public PaginatedSearchResult searchGenomicConceptValues( - @QueryParam("genomicConceptPath") String genomicConceptPath, - @QueryParam("query") String query, - @QueryParam("page") int page, - @QueryParam("size") int size + @RequestParam("genomicConceptPath") String genomicConceptPath, + @RequestParam("query") String query, + @RequestParam("page") int page, + @RequestParam("size") int size ) { if (page < 1) { throw new IllegalArgumentException("Page must be greater than 0"); @@ -305,7 +286,7 @@ public PaginatedSearchResult searchGenomicConceptValues( return paginator.paginate(matchingValues, page, size); } - private Response _querySync(QueryRequest resultRequest) throws IOException { + private ResponseEntity _querySync(QueryRequest resultRequest) throws IOException { Query incomingQuery; incomingQuery = convertIncomingQuery(resultRequest); log.info("Query Converted"); @@ -320,12 +301,12 @@ private Response _querySync(QueryRequest resultRequest) throws IOException { "isContinuous", store.isContinuous, "min", store.min, "max", store.max)); } }); - return Response.ok(infoStores, MediaType.APPLICATION_JSON_VALUE).build(); + return ResponseEntity.ok(infoStores); case DATAFRAME: case SECRET_ADMIN_DATAFRAME: case DATAFRAME_MERGED: - QueryStatus status = query(resultRequest); + QueryStatus status = query(resultRequest).getBody(); while (status.getResourceStatus().equalsIgnoreCase("RUNNING") || status.getResourceStatus().equalsIgnoreCase("PENDING")) { status = queryStatus(UUID.fromString(status.getResourceResultId()), null); @@ -335,57 +316,53 @@ private Response _querySync(QueryRequest resultRequest) throws IOException { AsyncResult result = queryService.getResultFor(status.getResourceResultId()); if (result.status == AsyncResult.Status.SUCCESS) { result.stream.open(); - return queryOkResponse(result.stream, incomingQuery).build(); + return queryOkResponse(result.stream, incomingQuery); } - return Response.status(400).entity("Status : " + result.status.name()).build(); + return ResponseEntity.status(400).body("Status : " + result.status.name()); case CROSS_COUNT: - return queryOkResponse(countProcessor.runCrossCounts(incomingQuery), incomingQuery) - .header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON).build(); + return queryOkResponse(countProcessor.runCrossCounts(incomingQuery), incomingQuery); case CATEGORICAL_CROSS_COUNT: - return queryOkResponse(countProcessor.runCategoryCrossCounts(incomingQuery), incomingQuery) - .header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON).build(); + return queryOkResponse(countProcessor.runCategoryCrossCounts(incomingQuery), incomingQuery); case CONTINUOUS_CROSS_COUNT: - return queryOkResponse(countProcessor.runContinuousCrossCounts(incomingQuery), incomingQuery) - .header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON).build(); + return queryOkResponse(countProcessor.runContinuousCrossCounts(incomingQuery), incomingQuery); case OBSERVATION_COUNT: - return queryOkResponse(countProcessor.runObservationCount(incomingQuery), incomingQuery).build(); + return queryOkResponse(countProcessor.runObservationCount(incomingQuery), incomingQuery); case OBSERVATION_CROSS_COUNT: - return queryOkResponse(countProcessor.runObservationCrossCounts(incomingQuery), incomingQuery) - .header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON).build(); + return queryOkResponse(countProcessor.runObservationCrossCounts(incomingQuery), incomingQuery); case VARIANT_COUNT_FOR_QUERY: - return queryOkResponse(countProcessor.runVariantCount(incomingQuery), incomingQuery) - .header(HttpHeaders.CONTENT_TYPE, ContentType.APPLICATION_JSON).build(); + return queryOkResponse(countProcessor.runVariantCount(incomingQuery), incomingQuery); case VARIANT_LIST_FOR_QUERY: - return queryOkResponse(variantListProcessor.runVariantListQuery(incomingQuery), incomingQuery).build(); + return queryOkResponse(variantListProcessor.runVariantListQuery(incomingQuery), incomingQuery); case VCF_EXCERPT: - return queryOkResponse(variantListProcessor.runVcfExcerptQuery(incomingQuery, true), incomingQuery).build(); + return queryOkResponse(variantListProcessor.runVcfExcerptQuery(incomingQuery, true), incomingQuery); case AGGREGATE_VCF_EXCERPT: - return queryOkResponse(variantListProcessor.runVcfExcerptQuery(incomingQuery, false), incomingQuery) - .build(); + return queryOkResponse(variantListProcessor.runVcfExcerptQuery(incomingQuery, false), incomingQuery); case TIMELINE_DATA: return queryOkResponse(mapper.writeValueAsString(timelineProcessor.runTimelineQuery(incomingQuery)), - incomingQuery).build(); + incomingQuery); case COUNT: - return queryOkResponse(countProcessor.runCounts(incomingQuery), incomingQuery).build(); + return queryOkResponse(countProcessor.runCounts(incomingQuery), incomingQuery); default: // no valid type - return Response.status(Status.BAD_REQUEST).build(); + return ResponseEntity.status(500).build(); } } - private ResponseBuilder queryOkResponse(Object obj, Query incomingQuery) { - return Response.ok(obj).header(QUERY_METADATA_FIELD, UUIDv5.UUIDFromString(incomingQuery.toString())); + private ResponseEntity queryOkResponse(Object obj, Query incomingQuery) { + HttpHeaders responseHeaders = new HttpHeaders(); + responseHeaders.set(QUERY_METADATA_FIELD, UUIDv5.UUIDFromString(incomingQuery.toString()).toString()); + return new ResponseEntity<>(obj, responseHeaders, HttpStatus.OK); } } diff --git a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/QueryService.java b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/QueryService.java index 54481f59..c2fc7b78 100644 --- a/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/QueryService.java +++ b/service/src/main/java/edu/harvard/hms/dbmi/avillach/hpds/service/QueryService.java @@ -17,12 +17,14 @@ import edu.harvard.hms.dbmi.avillach.hpds.processing.*; import edu.harvard.hms.dbmi.avillach.hpds.processing.AsyncResult.Status; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @Service public class QueryService { private static final int RESULTS_CACHE_SIZE = 50; + private final int SMALL_JOB_LIMIT; private final int LARGE_TASK_THREADS; private final int SMALL_TASK_THREADS; @@ -46,15 +48,21 @@ public class QueryService { @Autowired - public QueryService (AbstractProcessor abstractProcessor, QueryProcessor queryProcessor, TimeseriesProcessor timeseriesProcessor, CountProcessor countProcessor) { + public QueryService (AbstractProcessor abstractProcessor, + QueryProcessor queryProcessor, + TimeseriesProcessor timeseriesProcessor, + CountProcessor countProcessor, + @Value("${SMALL_JOB_LIMIT}") Integer smallJobLimit, + @Value("${SMALL_TASK_THREADS}") Integer smallTaskThreads, + @Value("${LARGE_TASK_THREADS}") Integer largeTaskThreads) { this.abstractProcessor = abstractProcessor; this.queryProcessor = queryProcessor; this.timeseriesProcessor = timeseriesProcessor; this.countProcessor = countProcessor; - SMALL_JOB_LIMIT = getIntProp("SMALL_JOB_LIMIT"); - SMALL_TASK_THREADS = getIntProp("SMALL_TASK_THREADS"); - LARGE_TASK_THREADS = getIntProp("LARGE_TASK_THREADS"); + SMALL_JOB_LIMIT = smallJobLimit; + SMALL_TASK_THREADS = smallTaskThreads; + LARGE_TASK_THREADS = largeTaskThreads; /* These have to be of type Runnable(nothing more specific) in order diff --git a/service/src/main/resources/application.properties b/service/src/main/resources/application.properties new file mode 100644 index 00000000..d2dc8be4 --- /dev/null +++ b/service/src/main/resources/application.properties @@ -0,0 +1,3 @@ +SMALL_JOB_LIMIT = 100 +SMALL_TASK_THREADS = 1 +LARGE_TASK_THREADS = 1 \ No newline at end of file diff --git a/service/src/main/resources/beans.xml b/service/src/main/resources/beans.xml deleted file mode 100644 index 7043c04a..00000000 --- a/service/src/main/resources/beans.xml +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - diff --git a/service/src/main/resources/jaxrs-context.xml b/service/src/main/resources/jaxrs-context.xml deleted file mode 100644 index 08a237bf..00000000 --- a/service/src/main/resources/jaxrs-context.xml +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - diff --git a/service/src/main/resources/log4j.properties b/service/src/main/resources/log4j.properties deleted file mode 100644 index 5e798180..00000000 --- a/service/src/main/resources/log4j.properties +++ /dev/null @@ -1,9 +0,0 @@ -# Root logger option -log4j.rootLogger=INFO, stdout - -# Direct log messages to stdout -log4j.appender.stdout=org.apache.log4j.ConsoleAppender -log4j.appender.stdout.Target=System.out -log4j.appender.stdout.layout=org.apache.log4j.PatternLayout -log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss} %-5p %c{1}:%L - %m%n - \ No newline at end of file diff --git a/service/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/service/util/PaginatorTest.java b/service/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/service/util/PaginatorTest.java index 4970917d..7c13f736 100644 --- a/service/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/service/util/PaginatorTest.java +++ b/service/src/test/java/edu/harvard/hms/dbmi/avillach/hpds/service/util/PaginatorTest.java @@ -1,13 +1,14 @@ package edu.harvard.hms.dbmi.avillach.hpds.service.util; import edu.harvard.dbmi.avillach.domain.PaginatedSearchResult; -import org.junit.Test; +import org.junit.jupiter.api.Test; import java.util.List; import java.util.stream.Collectors; import java.util.stream.IntStream; -import static org.junit.Assert.*; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertThrows; public class PaginatorTest { @@ -59,26 +60,35 @@ public void paginate_noResults() { assertEquals(List.of(), paginatedSearchResult.getResults()); } - @Test(expected = IllegalArgumentException.class) + @Test public void paginate_invalidPageZero() { - List values = List.of(); - paginator.paginate(values, 0, 20); + assertThrows(IllegalArgumentException.class, () -> { + List values = List.of(); + paginator.paginate(values, 0, 20); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void paginate_invalidPageNegative() { - List values = List.of(); - paginator.paginate(values, -2, 20); + assertThrows(IllegalArgumentException.class, () -> { + List values = List.of(); + paginator.paginate(values, -2, 20); + }); + } - @Test(expected = IllegalArgumentException.class) + @Test public void paginate_invalidSizeZero() { - List values = List.of(); - paginator.paginate(values, 1, 0); + assertThrows(IllegalArgumentException.class, () -> { + List values = List.of(); + paginator.paginate(values, 1, 0); + }); } - @Test(expected = IllegalArgumentException.class) + @Test public void paginate_invalidSizeNegative() { - List values = List.of(); - paginator.paginate(values, 1, -5); + assertThrows(IllegalArgumentException.class, () -> { + List values = List.of(); + paginator.paginate(values, 1, -5); + }); } } \ No newline at end of file