-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
test: add Pharmacogenomics Junit tests, #TASK-4769, #TASK-4761
- Loading branch information
Showing
2 changed files
with
92 additions
and
1 deletion.
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
83 changes: 83 additions & 0 deletions
83
...b/src/test/java/org/opencb/cellbase/lib/impl/core/PharmacogenomicsMongoDBAdaptorTest.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,83 @@ | ||
/* | ||
* Copyright 2015-2020 OpenCB | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package org.opencb.cellbase.lib.impl.core; | ||
|
||
import org.hamcrest.CoreMatchers; | ||
import org.junit.jupiter.api.Test; | ||
import org.opencb.biodata.models.core.Gene; | ||
import org.opencb.biodata.models.pharma.PharmaChemical; | ||
import org.opencb.biodata.models.variant.avro.Constraint; | ||
import org.opencb.biodata.models.variant.avro.Expression; | ||
import org.opencb.biodata.models.variant.avro.ExpressionCall; | ||
import org.opencb.cellbase.core.api.GeneQuery; | ||
import org.opencb.cellbase.core.api.PharmaChemicalQuery; | ||
import org.opencb.cellbase.core.api.query.AbstractQuery; | ||
import org.opencb.cellbase.core.api.query.LogicalList; | ||
import org.opencb.cellbase.core.result.CellBaseDataResult; | ||
import org.opencb.cellbase.lib.GenericMongoDBAdaptorTest; | ||
import org.opencb.cellbase.lib.managers.GeneManager; | ||
import org.opencb.cellbase.lib.managers.PharmacogenomicsManager; | ||
|
||
import java.io.IOException; | ||
import java.util.*; | ||
import java.util.stream.Collectors; | ||
|
||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.junit.jupiter.api.Assertions.assertEquals; | ||
import static org.junit.jupiter.api.Assertions.assertTrue; | ||
|
||
/** | ||
* Created by jtarraga on 08/21/23. | ||
*/ | ||
public class PharmacogenomicsMongoDBAdaptorTest extends GenericMongoDBAdaptorTest { | ||
|
||
public PharmacogenomicsMongoDBAdaptorTest() throws IOException { | ||
super(); | ||
} | ||
|
||
@Test | ||
public void testQueryName() throws Exception { | ||
PharmacogenomicsManager pharmacogenomicsManager = cellBaseManagerFactory.getPharmacogenomicsManager(SPECIES, ASSEMBLY); | ||
|
||
Map<String, String> paramMap = new HashMap<>(); | ||
paramMap.put("name", "galantamine"); | ||
paramMap.put("include", "id,name"); | ||
paramMap.put(AbstractQuery.DATA_RELEASE, String.valueOf(dataRelease)); | ||
|
||
PharmaChemicalQuery chemicalQuery = new PharmaChemicalQuery(paramMap); | ||
chemicalQuery.setCount(Boolean.TRUE); | ||
|
||
CellBaseDataResult<PharmaChemical> cellBaseDataResult = pharmacogenomicsManager.search(chemicalQuery); | ||
Check failure on line 64 in cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/core/PharmacogenomicsMongoDBAdaptorTest.java GitHub Actions / Surefire tests reportPharmacogenomicsMongoDBAdaptorTest.testQueryName
Raw output
|
||
|
||
assertEquals(1, cellBaseDataResult.getNumMatches()); | ||
assertEquals("PA449726", cellBaseDataResult.first().getId()); | ||
} | ||
|
||
@Test | ||
public void testQuery() throws Exception { | ||
PharmacogenomicsManager pharmacogenomicsManager = cellBaseManagerFactory.getPharmacogenomicsManager(SPECIES, ASSEMBLY); | ||
|
||
PharmaChemicalQuery chemicalQuery = new PharmaChemicalQuery(); | ||
chemicalQuery.setGeneNames(Collections.singletonList("PRKCE")); | ||
chemicalQuery.setDataRelease(dataRelease); | ||
chemicalQuery.setCount(Boolean.TRUE); | ||
|
||
CellBaseDataResult<PharmaChemical> cellBaseDataResult = pharmacogenomicsManager.search(chemicalQuery); | ||
Check failure on line 79 in cellbase-lib/src/test/java/org/opencb/cellbase/lib/impl/core/PharmacogenomicsMongoDBAdaptorTest.java GitHub Actions / Surefire tests reportPharmacogenomicsMongoDBAdaptorTest.testQuery
Raw output
|
||
|
||
assertEquals(6, cellBaseDataResult.getNumMatches()); | ||
} | ||
} |