diff --git a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/family/PedigreeGraphAnalysis.java b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/family/PedigreeGraphAnalysis.java index 3d49b12c7fb..2e99c99c2fd 100644 --- a/opencga-analysis/src/main/java/org/opencb/opencga/analysis/family/PedigreeGraphAnalysis.java +++ b/opencga-analysis/src/main/java/org/opencb/opencga/analysis/family/PedigreeGraphAnalysis.java @@ -57,7 +57,7 @@ protected void check() throws Exception { OpenCGAResult familyResult = catalogManager.getFamilyManager().get(study, pedigreeParams.getFamilyId(), QueryOptions.empty(), token); if (familyResult.getNumResults() != 1) { - throw new ToolException("Unable to compute the pedigree graph imae. Family '" + pedigreeParams.getFamilyId() + "' not found"); + throw new ToolException("Unable to compute the pedigree graph image. Family '" + pedigreeParams.getFamilyId() + "' not found"); } family = familyResult.first(); diff --git a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/family/FamilyAnalysisTest.java b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/family/FamilyAnalysisTest.java index bd4944f868a..467437cb916 100644 --- a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/family/FamilyAnalysisTest.java +++ b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/family/FamilyAnalysisTest.java @@ -1,6 +1,8 @@ package org.opencb.opencga.analysis.family; import org.apache.commons.lang3.StringUtils; +import org.hamcrest.CoreMatchers; +import org.hamcrest.MatcherAssert; import org.junit.*; import org.junit.rules.ExpectedException; import org.opencb.biodata.models.clinical.Disorder; @@ -184,8 +186,8 @@ public void updateTest() throws CatalogException { .first(); PedigreeGraph pedigreeGraph = updatedFamily.getPedigreeGraph(); - assertTrue(pedigreeGraph.getBase64().startsWith("iVBORw0KGgoAAAANSUhEUgAAAeAAAAHg")); - assertTrue(pedigreeGraph.getBase64().endsWith("5UIf81hI8AAAAASUVORK5CYII=")); + MatcherAssert.assertThat(pedigreeGraph.getBase64(), CoreMatchers.startsWith("iVBORw0KGgoAAAANSUhEUgAAAeAAAAHg=")); + MatcherAssert.assertThat(pedigreeGraph.getBase64(), CoreMatchers.endsWith("5UIf81hI8AAAAASUVORK5CYII=")); } @Test @@ -207,8 +209,8 @@ public void testPedigreeGraphAnalysis() throws ToolException, IOException { sessionIdUser); String b64Image = PedigreeGraphUtils.getB64Image(outDir); - assertTrue(b64Image.startsWith("iVBORw0KGgoAAAANSUhEUgAAAeAAAAHg")); - assertTrue(b64Image.endsWith("s3Rj5UIf81hI8AAAAASUVORK5CYII=")); + MatcherAssert.assertThat(b64Image, CoreMatchers.startsWith("iVBORw0KGgoAAAANSUhEUgAAAeAAAAHg")); + MatcherAssert.assertThat(b64Image, CoreMatchers.endsWith("s3Rj5UIf81hI8AAAAASUVORK5CYII=")); assertEquals(family.getPedigreeGraph().getBase64(), b64Image); } diff --git a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/rga/RgaEngineTest.java b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/rga/RgaEngineTest.java index 8439c56e88b..9283ab82efb 100644 --- a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/rga/RgaEngineTest.java +++ b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/rga/RgaEngineTest.java @@ -15,16 +15,17 @@ import org.opencb.opencga.catalog.managers.CatalogManager; import org.opencb.opencga.core.config.Configuration; import org.opencb.opencga.core.config.storage.StorageConfiguration; -import org.opencb.opencga.core.models.analysis.knockout.*; +import org.opencb.opencga.core.models.analysis.knockout.KnockoutByIndividual; import org.opencb.opencga.core.testclassification.duration.MediumTests; import org.opencb.opencga.storage.core.StorageEngineFactory; +import org.opencb.opencga.storage.hadoop.variant.HadoopVariantStorageTest; import java.io.IOException; import java.io.InputStream; import java.util.ArrayList; import java.util.List; -import static org.junit.Assert.*; +import static org.junit.Assert.assertEquals; @Category(MediumTests.class) public class RgaEngineTest { @@ -38,7 +39,10 @@ public class RgaEngineTest { private List knockoutByIndividualList = new ArrayList<>(2); - @Rule + @Rule(order = 0) + public HadoopVariantStorageTest.HadoopSolrSupport solrSupport = new HadoopVariantStorageTest.HadoopSolrSupport(); + + @Rule(order = 1) public RgaSolrExtenalResource solr = new RgaSolrExtenalResource(); @Before diff --git a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/variant/VariantAnalysisTest.java b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/variant/VariantAnalysisTest.java index 9c21fc99464..14c61ea51a1 100644 --- a/opencga-analysis/src/test/java/org/opencb/opencga/analysis/variant/VariantAnalysisTest.java +++ b/opencga-analysis/src/test/java/org/opencb/opencga/analysis/variant/VariantAnalysisTest.java @@ -168,8 +168,6 @@ public void setUp() throws Throwable { // System.setProperty("opencga.log.level", "INFO"); // Configurator.reconfigure(); if (!indexed) { - indexed = true; - opencga.after(); opencga.before(storageEngine); @@ -251,6 +249,7 @@ public void setUp() throws Throwable { if (storageEngine.equals(HadoopVariantStorageEngine.STORAGE_ENGINE_ID)) { VariantHbaseTestUtils.printVariants(((VariantHadoopDBAdaptor) engine.getDBAdaptor()), Paths.get(opencga.createTmpOutdir("_hbase_print_variants")).toUri()); } + indexed = true; } // Reset engines opencga.getStorageEngineFactory().close(); @@ -279,7 +278,8 @@ public void setUpCatalogManager() throws IOException, CatalogException { String projectId = catalogManager.getProjectManager().create(new ProjectCreateParams() .setId(PROJECT) - .setDescription("Project about some genomes").setOrganism(new ProjectOrganism("hsapiens", "grch38")), + .setDescription("Project about some genomes") + .setOrganism(new ProjectOrganism("hsapiens", "GRCh38")), new QueryOptions(ParamConstants.INCLUDE_RESULT_PARAM, true), token).first().getId(); catalogManager.getStudyManager().create(projectId, STUDY, null, "Phase 1", "Done", null, null, null, null, null, token); @@ -1013,6 +1013,7 @@ public void testHRDetect() throws Exception { toolRunner.execute(HRDetectAnalysis.class, hrdParams, new ObjectMap(ParamConstants.STUDY_PARAM, CANCER_STUDY), hrdetectOutDir, null, token); java.io.File hrDetectFile = hrdetectOutDir.resolve(HRDetectAnalysis.HRDETECT_SCORES_FILENAME_DEFAULT).toFile(); + assertTrue("File missing : " + hrDetectFile, hrDetectFile.exists()); byte[] bytes = Files.readAllBytes(hrDetectFile.toPath()); System.out.println(new String(bytes)); assertTrue(hrDetectFile.exists()); diff --git a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/PedigreeGraphUtils.java b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/PedigreeGraphUtils.java index b56966a44e8..480781b0e21 100644 --- a/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/PedigreeGraphUtils.java +++ b/opencga-catalog/src/main/java/org/opencb/opencga/catalog/utils/PedigreeGraphUtils.java @@ -11,8 +11,12 @@ import org.opencb.opencga.core.models.family.PedigreeGraph; import org.opencb.opencga.core.models.individual.Individual; -import java.io.*; +import java.io.File; +import java.io.FileNotFoundException; +import java.io.IOException; +import java.io.PrintWriter; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; import java.util.*; @@ -85,11 +89,8 @@ public static String getB64Image(Path outDir) throws IOException { if (!imgFile.exists()) { throw new IOException("Pedigree graph image file (" + PEDIGREE_IMAGE_FILENAME + ") not found at " + outDir); } - - FileInputStream fileInputStreamReader = new FileInputStream(imgFile); - byte[] bytes = new byte[(int) imgFile.length()]; - fileInputStreamReader.read(bytes); - return new String(Base64.getEncoder().encode(bytes), StandardCharsets.UTF_8); + byte[] bytes = Files.readAllBytes(imgFile.toPath()); + return Base64.getEncoder().encodeToString(bytes); } public static Object getJsonPedigreeGraph(Path outDir) throws IOException { @@ -107,9 +108,7 @@ public static String getTsvPedigreeGraph(Path outDir) throws IOException { throw new IOException("Pedigree graph TSV file (" + PEDIGREE_TSV_FILENAME + ") not found at " + outDir); } - FileInputStream fileInputStreamReader = new FileInputStream(tsvFile); - byte[] bytes = new byte[(int) tsvFile.length()]; - fileInputStreamReader.read(bytes); + byte[] bytes = Files.readAllBytes(tsvFile.toPath()); return new String(bytes, StandardCharsets.UTF_8); } diff --git a/opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-core/src/test/java/org/opencb/opencga/storage/hadoop/variant/HadoopVariantStorageSearchIntersectTest.java b/opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-core/src/test/java/org/opencb/opencga/storage/hadoop/variant/HadoopVariantStorageSearchIntersectTest.java index 6213553b2a5..f73ad2af141 100644 --- a/opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-core/src/test/java/org/opencb/opencga/storage/hadoop/variant/HadoopVariantStorageSearchIntersectTest.java +++ b/opencga-storage/opencga-storage-hadoop/opencga-storage-hadoop-core/src/test/java/org/opencb/opencga/storage/hadoop/variant/HadoopVariantStorageSearchIntersectTest.java @@ -33,10 +33,10 @@ @Category(LongTests.class) public class HadoopVariantStorageSearchIntersectTest extends VariantStorageSearchIntersectTest implements HadoopVariantStorageTest { - @ClassRule + @ClassRule(order = 0) public static HadoopSolrSupport solrSupport = new HadoopSolrSupport(); - @ClassRule + @ClassRule(order = 1) public static ExternalResource externalResource = new HadoopExternalResource(); @Override