Skip to content
Snippets Groups Projects
Commit ca3f245d authored by Piotr Gawron's avatar Piotr Gawron
Browse files

speed up of chemical unit test

parent 5cf7061b
No related branches found
No related tags found
2 merge requests!630WIP: Resolve "The privileges of a new user are not saved in some cases",!386Resolve "Continous integration tests"
......@@ -42,6 +42,13 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
Logger logger = Logger.getLogger(ChemicalParserTest.class);
final MiriamData parkinsonDiseaseId = new MiriamData(MiriamType.MESH_2012, "D010300");
final MiriamData dystoniaDisease = new MiriamData(MiriamType.MESH_2012, "C538007");
MiriamData glutathioneDisulfideChemicalId = new MiriamData(MiriamType.TOXICOGENOMIC_CHEMICAL, "D019803");
MiriamData stilbeneOxideChemicalId = new MiriamData(MiriamType.TOXICOGENOMIC_CHEMICAL, "C025906");
// lazabemide with one Gene MAOB and therapeutic and 3 publications
MiriamData lazabemideChemicalId = new MiriamData(MiriamType.TOXICOGENOMIC_CHEMICAL, "C059303");
@Autowired
private ChemicalParser chemicalParser;
......@@ -130,34 +137,13 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
@Test
public void testFindByIDFromChemicalList() throws Exception {
try {
// Parkinson disease
Map<MiriamData, String> listFromDB = chemicalParser.getChemicalsForDisease(parkinsonDiseaseId);
assertNotNull(listFromDB);
assertTrue(!listFromDB.isEmpty());
Map.Entry<MiriamData, String> entry = listFromDB.entrySet().iterator().next();
assertNotNull(entry);
// Get the first entry
String chemicalName1 = entry.getValue();
assertTrue((chemicalName1 != null) && !chemicalName1.trim().isEmpty());
chemicalName1 = chemicalName1.trim().toLowerCase();
MiriamData chemicalId1 = entry.getKey();
assertTrue(
(chemicalId1 != null) && (chemicalId1.getResource() != null) && !chemicalId1.getResource().trim().isEmpty());
// Dopamine with 23 Gens and 60 publication and one marker/mechanism and
// 60 publications
MiriamData chemicalId2 = new MiriamData(MiriamType.TOXICOGENOMIC_CHEMICAL, "D019803");
// lazabemide with one Gene MAOB and therapeutic and 3 publications
MiriamData chemicalId3 = new MiriamData(MiriamType.TOXICOGENOMIC_CHEMICAL, "C059303");
// caramiphen with no genes and one therapeutic
MiriamData chemicalId4 = new MiriamData(MiriamType.TOXICOGENOMIC_CHEMICAL, "C004519");
List<MiriamData> idsList = new ArrayList<MiriamData>();
idsList.add(chemicalId1);
idsList.add(chemicalId2);
idsList.add(chemicalId3);
idsList.add(chemicalId4);
List<MiriamData> idsList = new ArrayList<>();
idsList.add(stilbeneOxideChemicalId);
idsList.add(lazabemideChemicalId);
List<Chemical> chemcials = chemicalParser.getChemicals(parkinsonDiseaseId, idsList);
assertEquals(idsList.size(), chemcials.size());
for (Chemical chem : chemcials) {
assertNotNull(chem);
for (Target t : chem.getInferenceNetwork()) {
......@@ -177,10 +163,9 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
@Test
public void testGetGlutathioneDisulfideData() throws Exception {
try {
MiriamData glutathioneDisulfideId = new MiriamData(MiriamType.TOXICOGENOMIC_CHEMICAL, "D019803");
List<MiriamData> idsList = new ArrayList<>();
idsList.add(glutathioneDisulfideId);
idsList.add(glutathioneDisulfideChemicalId);
List<Chemical> chemicals = chemicalParser.getChemicals(parkinsonDiseaseId, idsList);
assertEquals(1, chemicals.size());
......@@ -197,12 +182,13 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
@Test
public void testGetChemicalBySynonym() throws Exception {
try {
List<Chemical> chemicals = chemicalParser.getChemicalsBySynonym(parkinsonDiseaseId, "MPTP");
String glutathioneDisulfideSynonym = "GSSG";
List<Chemical> chemicals = chemicalParser.getChemicalsBySynonym(parkinsonDiseaseId, glutathioneDisulfideSynonym);
assertEquals(1, chemicals.size());
Chemical mptp = chemicals.get(0);
assertTrue(mptp.getSynonyms().contains("MPTP"));
assertTrue(mptp.getSynonyms().contains(glutathioneDisulfideSynonym));
} catch (Exception e) {
e.printStackTrace();
throw e;
......@@ -252,9 +238,8 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
Map<MiriamData, String> listFromDB = chemicalParser.getChemicalsForDisease(parkinsonDiseaseId);
assertNotNull(listFromDB);
assertTrue(!listFromDB.isEmpty());
MiriamData chemicalId = new MiriamData(MiriamType.TOXICOGENOMIC_CHEMICAL, "D015039");
List<MiriamData> idsList = new ArrayList<MiriamData>();
idsList.add(chemicalId);
List<MiriamData> idsList = new ArrayList<>();
idsList.add(stilbeneOxideChemicalId);
List<Chemical> chemcials = chemicalParser.getChemicals(parkinsonDiseaseId, idsList);
assertNotNull(chemcials);
assertTrue(chemcials.size() > 0);
......@@ -285,10 +270,11 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
@Test
public void testGetByTarget() throws Exception {
try {
MiriamData target = new MiriamData(MiriamType.HGNC_SYMBOL, "TNF");
MiriamData target = new MiriamData(MiriamType.HGNC_SYMBOL, "GCH1");
List<MiriamData> targets = new ArrayList<>();
targets.add(target);
List<Chemical> list = chemicalParser.getChemicalListByTarget(targets, parkinsonDiseaseId);
List<Chemical> list = chemicalParser.getChemicalListByTarget(targets, dystoniaDisease);
assertNotNull(list);
assertFalse(list.isEmpty());
......@@ -356,11 +342,10 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
@Test
public void testGetByEntrezTarget() throws Exception {
try {
// Parkinson disease
MiriamData target = new MiriamData(MiriamType.ENTREZ, "6647");
MiriamData target = new MiriamData(MiriamType.ENTREZ, "2643");
List<MiriamData> targets = new ArrayList<>();
targets.add(target);
List<Chemical> list = chemicalParser.getChemicalListByTarget(targets, parkinsonDiseaseId);
List<Chemical> list = chemicalParser.getChemicalListByTarget(targets, dystoniaDisease);
assertTrue(list.size() > 0);
} catch (Exception e) {
e.printStackTrace();
......@@ -371,7 +356,6 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
@Test
public void testGetByTarget2() throws Exception {
try {
// Parkinson disease
MiriamData target = new MiriamData(MiriamType.HGNC_SYMBOL, "GALM");
List<MiriamData> targets = new ArrayList<>();
targets.add(target);
......@@ -406,22 +390,6 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
}
}
@Test
public void testGetByTargetXXX() throws Exception {
try {
// Parkinson disease
MiriamData target = new MiriamData(MiriamType.HGNC_SYMBOL, "SOD1");
List<MiriamData> targets = new ArrayList<>();
targets.add(target);
List<Chemical> list = chemicalParser.getChemicalListByTarget(targets, parkinsonDiseaseId);
assertNotNull(list);
assertTrue(!list.isEmpty());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testRefreshInvalidCacheQuery() throws Exception {
try {
......@@ -533,7 +501,7 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
// count
assertEquals(2, getErrors().size());
// there are no genes (we have one that is invalid and should be
// discarderd)
// discarded)
assertEquals(0, result.getInferenceNetwork().size());
assertEquals(ChemicalDirectEvidence.THERAPEUTIC, result.getDirectEvidence());
......@@ -632,10 +600,9 @@ public class ChemicalParserTest extends AnnotationTestFunctions {
Model model = getModelForFile("testFiles/target_chemical/target.xml", false);
project.addModel(model);
List<String> result = chemicalParser.getSuggestedQueryList(project, parkinsonDiseaseId);
List<String> result = chemicalParser.getSuggestedQueryList(project, dystoniaDisease);
assertTrue(result.size() > 0);
logger.debug(result);
} catch (Exception e) {
e.printStackTrace();
......
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment