Skip to content

Commit

Permalink
Initial spring boot commit. Needs more testing
Browse files Browse the repository at this point in the history
  • Loading branch information
ramari16 committed Nov 5, 2023
1 parent 5bbd8a8 commit dc95c51
Show file tree
Hide file tree
Showing 39 changed files with 323 additions and 440 deletions.
7 changes: 1 addition & 6 deletions client-api/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,7 @@
</properties>

<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.13.1</version>
<scope>test</scope>
</dependency>

</dependencies>

<build>
Expand Down
4 changes: 2 additions & 2 deletions common/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,8 @@
<artifactId>guava</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-jaxrs</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
</dependencies>
</project>
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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 {
}

Expand Down
Original file line number Diff line number Diff line change
@@ -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";
Expand All @@ -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);
Expand All @@ -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");
});
}
}
8 changes: 2 additions & 6 deletions data/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,8 @@
<artifactId>commons-csv</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-core-asl</artifactId>
</dependency>
<dependency>
<groupId>org.codehaus.jackson</groupId>
<artifactId>jackson-mapper-asl</artifactId>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>edu.harvard.hms.dbmi.avillach</groupId>
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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;
}
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
18 changes: 1 addition & 17 deletions etl/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,6 @@

<name>etl</name>
<dependencies>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>1.2.9</version>
</dependency>
<dependency>
<groupId>org.apache.commons</groupId>
<artifactId>commons-compress</artifactId>
Expand All @@ -30,19 +25,8 @@
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-core</artifactId>
<version>2.10.5</version>
<artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-annotations</artifactId>
<version>2.10.5</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.core</groupId>
<artifactId>jackson-databind</artifactId>
<version>2.10.5.1</version>
</dependency>
<dependency>
<groupId>edu.harvard.hms.dbmi.avillach.hpds</groupId>
<artifactId>data</artifactId>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -71,7 +66,7 @@ public class BucketIndexBySampleTest {
Set<String> variantSet;
List<Integer> patientSet;

@BeforeClass
@BeforeTestClass
public static void initializeBinfile() throws Exception {
//load variant data
NewVCFLoader.main(new String[] {VCF_INDEX_FILE, STORAGE_DIR, MERGED_DIR});
Expand All @@ -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<String>();
Expand Down
Loading

0 comments on commit dc95c51

Please sign in to comment.