-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test coverage for oan-rest, updating models to have equals and hashco…
…de, adding neo4j harness for tests
- Loading branch information
Showing
20 changed files
with
506 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
neo4j.embedded.ephemeral=true |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
package org.jax.oan; | ||
|
||
import org.jax.oan.core.Assay; | ||
import org.jax.oan.core.Disease; | ||
import org.jax.oan.core.Gene; | ||
import org.jax.oan.core.Phenotype; | ||
import org.monarchinitiative.phenol.ontology.data.TermId; | ||
|
||
import java.util.List; | ||
|
||
public class TestData { | ||
public static List<Disease> diseases(){ | ||
return List.of( | ||
new Disease(TermId.of("MONDO:099233"),"Really bad one"), | ||
new Disease(TermId.of("DECIPHER:434444"),"Kinda bad one") | ||
); | ||
} | ||
|
||
public static List<Phenotype> phenotypes(){ | ||
return List.of( | ||
new Phenotype(TermId.of("HP:099233"),"Long legs"), | ||
new Phenotype(TermId.of("HP:434444"),"Big bicep small arm") | ||
); | ||
} | ||
|
||
public static List<Assay> assays(){ | ||
return List.of( | ||
new Assay(TermId.of("LOINC:55555"),"Special bicep test") | ||
); | ||
} | ||
|
||
public static List<Gene> genes(){ | ||
return List.of( | ||
new Gene(TermId.of("NCBIGene:00093"),"TP4"), | ||
new Gene(TermId.of("NCBIGene:02002"),"YZ") | ||
); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
70 changes: 70 additions & 0 deletions
70
oan-rest/src/test/java/org/jax/oan/repository/DiseaseRepositoryTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
package org.jax.oan.repository; | ||
|
||
import io.micronaut.test.extensions.junit5.annotation.MicronautTest; | ||
import jakarta.inject.Inject; | ||
import org.jax.oan.core.Gene; | ||
import org.jax.oan.core.Phenotype; | ||
import org.jax.oan.core.PhenotypeMetadata; | ||
import org.junit.jupiter.api.AfterAll; | ||
import org.junit.jupiter.api.BeforeAll; | ||
import org.junit.jupiter.api.Test; | ||
import org.junit.jupiter.api.TestInstance; | ||
import org.monarchinitiative.phenol.ontology.data.TermId; | ||
import org.neo4j.driver.Driver; | ||
import org.neo4j.driver.Session; | ||
import org.neo4j.driver.Transaction; | ||
|
||
import java.util.List; | ||
|
||
import static org.junit.jupiter.api.Assertions.*; | ||
|
||
@TestInstance(TestInstance.Lifecycle.PER_CLASS) | ||
@MicronautTest | ||
class DiseaseRepositoryTest { | ||
|
||
@Inject | ||
Driver driver; | ||
|
||
@Inject | ||
DiseaseRepository diseaseRepository; | ||
|
||
@BeforeAll | ||
void initialize() { | ||
try(Transaction tx = driver.session().beginTransaction()){ | ||
tx.run("CREATE (d:Disease {id: 'OMIM:092320', name: 'Some bad disease'})"); | ||
tx.run("CREATE (p: Phenotype {id: 'HP:000001', name: 'short stature', category: ''})"); | ||
tx.run("CREATE (g:Gene {id: 'NCBIGene:9999', name: 'TX2'})"); | ||
tx.run("CREATE (g:Gene {id: 'NCBIGene:7777', name: 'MNN'})"); | ||
tx.run("MATCH (d:Disease {id: 'OMIM:092320'}), (p:Phenotype {id: 'HP:000001'})" + | ||
"MERGE (d)-[:MANIFESTS]->(p)<-[:WITH_METADATA {context: 'OMIM:092320'}]-(pm: PhenotypeMetadata {onset: '', frequency: '1/1', sex: 'female'," + | ||
"sources: '' })"); | ||
tx.run("MATCH (d:Disease {id: 'OMIM:092320'}), (g:Gene {id: 'NCBIGene:7777'}) " + | ||
"MERGE (d)-[:EXPRESSES]->(g)"); | ||
tx.run("MATCH (d:Disease {id: 'OMIM:092320'}), (g:Gene {id: 'NCBIGene:9999'}) " + | ||
"MERGE (d)-[:EXPRESSES]->(g)"); | ||
tx.commit(); | ||
} | ||
} | ||
|
||
@Test | ||
void findGenesByDisease() { | ||
List<Gene> genes = diseaseRepository.findGenesByDisease(TermId.of("OMIM:092320")); | ||
List<Gene> expected = List.of( | ||
new Gene(TermId.of("NCBIGene:9999"),"TX2"), | ||
new Gene(TermId.of("NCBIGene:7777"),"MNN") | ||
); | ||
assertTrue( | ||
expected.containsAll(genes) | ||
); | ||
} | ||
|
||
@Test | ||
void findPhenotypesByDisease() { | ||
List<Phenotype> phenotypes = diseaseRepository.findPhenotypesByDisease(TermId.of("OMIM:092320")); | ||
List<Phenotype> expected = List.of( | ||
new Phenotype(TermId.of("HP:000001"), "short stature", "", new PhenotypeMetadata("female", "", "1/1", List.of())) | ||
); | ||
|
||
assertTrue(phenotypes.containsAll(expected)); | ||
} | ||
} |
Oops, something went wrong.