Skip to content

Commit

Permalink
test: fix FamilyAnalysisTest JUnit tests, #TASK-6780
Browse files Browse the repository at this point in the history
  • Loading branch information
jtarraga committed Oct 8, 2024
1 parent 3b7a8df commit d1ba697
Showing 1 changed file with 19 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,9 @@ public void tearDown() throws Exception {
}

@Test
public void creationTest() {
public void creationTest() throws IOException {
PedigreeGraph pedigreeGraph = family.getPedigreeGraph();
assertTrue(pedigreeGraph.getBase64().startsWith("iVBORw0KGgoAAAANSUhEUgAAAeA"));
assertTrue(pedigreeGraph.getBase64().endsWith("AIDB6Bwfs3Rj5UIf81hI8AAAAASUVORK5CYII="));
assertEquals(runAndGetPedigreeImageB64(family), pedigreeGraph.getBase64());
}

@Test
Expand All @@ -130,7 +129,7 @@ public void twoMemberFamilyTest() throws CatalogException {
}

@Test
public void threeMemberNoDisorderFamilyTest() throws CatalogException {
public void threeMemberNoDisorderFamilyTest() throws CatalogException, IOException {
FamilyUpdateParams updateParams = new FamilyUpdateParams();

QueryOptions queryOptions = new QueryOptions()
Expand All @@ -140,33 +139,30 @@ public void threeMemberNoDisorderFamilyTest() throws CatalogException {
.first();

PedigreeGraph pedigreeGraph = updatedFamily.getPedigreeGraph();
assertTrue(pedigreeGraph.getBase64().startsWith("iVBORw0KGgoAAAANSUhEUgAAAeAAAAH"));
assertTrue(pedigreeGraph.getBase64().endsWith("2WENFPAsd1MAAAAASUVORK5CYII="));
assertEquals(runAndGetPedigreeImageB64(updatedFamily), pedigreeGraph.getBase64());
}

@Test
public void threeGenerationFamilyTest() throws CatalogException {
public void threeGenerationFamilyTest() throws CatalogException, IOException {
Family threeGenFamily = createThreeGenerationFamily("Cos-Cos", true).first();
PedigreeGraph pedigreeGraph = threeGenFamily.getPedigreeGraph();
assertTrue(pedigreeGraph.getBase64().startsWith("iVBORw0KGgoAAAANSUhEUgAAAeAAAAHgCA"));
assertTrue(pedigreeGraph.getBase64().endsWith("h9S2DROnwXOvwAAAABJRU5ErkJggg=="));
assertEquals(runAndGetPedigreeImageB64(threeGenFamily), pedigreeGraph.getBase64());
}

@Test
public void threeGenerationFamilyWithoutDisorderTest() throws CatalogException {
public void threeGenerationFamilyWithoutDisorderTest() throws CatalogException, IOException {
Family threeGenFamily = createThreeGenerationFamily("Hello-Hello", false).first();
PedigreeGraph pedigreeGraph = threeGenFamily.getPedigreeGraph();
assertTrue(pedigreeGraph.getBase64().startsWith("iVBORw0KGgoAAAANSUhEUgAAAeAAAAHgC"));
assertTrue(pedigreeGraph.getBase64().endsWith("wNJj9EVvh8HVQAAAABJRU5ErkJggg=="));
assertEquals(runAndGetPedigreeImageB64(threeGenFamily), pedigreeGraph.getBase64());
}

@Test
public void test2Member2GenerationFamilyTest() throws CatalogException {
public void test2Member2GenerationFamilyTest() throws CatalogException, IOException {
Family family = create2Member2GenerationDummyFamily("Colo-Colo", "father222-sample", "child2222-sample").first();

PedigreeGraph pedigreeGraph = family.getPedigreeGraph();
assertTrue(pedigreeGraph.getBase64().startsWith("iVBORw0KGgoAAAANSUhEUgAAA"));
assertTrue(pedigreeGraph.getBase64().endsWith("qkAAAAASUVORK5CYII="));

assertEquals(runAndGetPedigreeImageB64(family), pedigreeGraph.getBase64());
}

@Test
Expand Down Expand Up @@ -205,9 +201,6 @@ public void testPedigreeGraphAnalysis() throws ToolException, IOException {
false, sessionIdUser);

String b64Image = PedigreeGraphUtils.getB64Image(outDir);
MatcherAssert.assertThat(b64Image, CoreMatchers.startsWith("iVBORw0KGgoAAAANSUhEUgAAAeAAAAHg"));
MatcherAssert.assertThat(b64Image, CoreMatchers.endsWith("s3Rj5UIf81hI8AAAAASUVORK5CYII="));

assertEquals(family.getPedigreeGraph().getBase64(), b64Image);
}

Expand Down Expand Up @@ -477,4 +470,12 @@ private static DataResult<Family> create2Member2GenerationDummyFamily(String fam

return familyOpenCGAResult;
}


public String runAndGetPedigreeImageB64(Family family) throws IOException {
Path scratchDir = Paths.get(opencga.createTmpOutdir());
PedigreeGraph pedigreeGraph = PedigreeGraphUtils.getPedigreeGraph(family, opencga.getOpencgaHome(), scratchDir);
return pedigreeGraph.getBase64();

}
}

0 comments on commit d1ba697

Please sign in to comment.