Skip to content

Commit

Permalink
test: update JUnit tests, #TASK-5564
Browse files Browse the repository at this point in the history
On branch TASK-5564
Changes to be committed:
	modified:   cellbase-core/src/test/java/org/opencb/cellbase/core/config/CellBaseConfigurationTest.java
	modified:   cellbase-core/src/test/resources/configuration.yml
	modified:   cellbase-lib/src/test/java/org/opencb/cellbase/lib/builders/ConservationBuilderTest.java
	modified:   cellbase-lib/src/test/java/org/opencb/cellbase/lib/builders/RepeatsBuilderTest.java
	modified:   cellbase-lib/src/test/resources/configuration.test.yaml
	new file:   cellbase-lib/src/test/resources/conservation/gerpVersion.json
	new file:   cellbase-lib/src/test/resources/conservation/phastConsVersion.json
	new file:   cellbase-lib/src/test/resources/conservation/phyloPVersion.json
	new file:   cellbase-lib/src/test/resources/regulation/motifFeaturesVersion.json
	new file:   cellbase-lib/src/test/resources/regulation/regulatoryBuildVersion.json
	modified:   cellbase-lib/src/test/resources/repeats/repeats.test.json.gz
	renamed:    cellbase-lib/src/test/resources/repeats/windowMasker.txt.gz -> cellbase-lib/src/test/resources/repeats/windowmaskerSdust.txt.gz
	modified:   pom.xml
  • Loading branch information
jtarraga committed Jul 3, 2024
1 parent 694b81d commit c8e719a
Show file tree
Hide file tree
Showing 13 changed files with 637 additions and 185 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ public void defaultOutdir() {

@Test
public void vertebrates() {
Assertions.assertEquals(9, cellBaseConfiguration.getSpecies().getVertebrates().size());
Assertions.assertEquals(11, cellBaseConfiguration.getSpecies().getVertebrates().size());
}

@Test
Expand Down
408 changes: 314 additions & 94 deletions cellbase-core/src/test/resources/configuration.yml

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,15 @@
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.eclipse.jetty.util.ajax.JSON;
import org.opencb.biodata.models.core.GenomicScoreRegion;
import org.opencb.biodata.models.variant.avro.Repeat;
import org.opencb.cellbase.core.config.CellBaseConfiguration;
import org.opencb.cellbase.core.serializer.CellBaseFileSerializer;
import org.opencb.cellbase.core.serializer.CellBaseJsonFileSerializer;
import org.opencb.cellbase.lib.EtlCommons;
import org.opencb.commons.utils.FileUtils;

import java.io.BufferedReader;
Expand All @@ -40,10 +42,9 @@ public class ConservationBuilderTest {

private final int BATCH_SIZE = 100;

@Disabled
@Test
public void testParse() throws Exception {
CellBaseConfiguration configuration = CellBaseConfiguration.load(getClass().getResourceAsStream("configuration.test.yaml"));

Path conservationDir = Paths.get(ConservationBuilderTest.class.getResource("/conservation").toURI());
CellBaseFileSerializer serializer = new CellBaseJsonFileSerializer(Paths.get("/tmp/"), "gerp.test");
(new ConservationBuilder(conservationDir, BATCH_SIZE, serializer)).parse();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@

package org.opencb.cellbase.lib.builders;

import static org.junit.jupiter.api.Assertions.assertEquals;

import org.junit.jupiter.api.Test;
import org.eclipse.jetty.util.ajax.JSON;
import org.opencb.biodata.models.variant.avro.Repeat;
Expand All @@ -28,11 +26,14 @@

import java.io.BufferedReader;
import java.io.IOException;
import java.net.URL;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.HashSet;
import java.util.Set;

import static org.junit.jupiter.api.Assertions.*;


/**
* Created by fjlopez on 10/05/17.
Expand All @@ -47,13 +48,20 @@ public RepeatsBuilderTest() {

@Test
public void testParse() throws Exception {
CellBaseConfiguration configuration = CellBaseConfiguration.load(getClass().getResourceAsStream("configuration.test.yaml"));
CellBaseConfiguration configuration = CellBaseConfiguration.load(getClass().getClassLoader().getResourceAsStream("configuration.test.yaml"));
Path repeatsFilesDir = Paths.get(getClass().getResource("/repeats").getPath());
CellBaseFileSerializer serializer = new CellBaseJsonFileSerializer(Paths.get("/tmp/"), "repeats.test");
(new RepeatsBuilder(repeatsFilesDir, serializer, configuration)).parse();
serializer.close();
assertEquals(loadRepeatSet(Paths.get(getClass().getResource("/repeats/repeats.test.json.gz").getFile())),
loadRepeatSet(Paths.get("/tmp/repeats.test.json.gz")));
Set<Repeat> expected = loadRepeatSet(Paths.get(getClass().getClassLoader().getResource("repeats/repeats.test.json.gz").getPath()));
Set<Repeat> current = loadRepeatSet(Paths.get("/tmp/repeats.test.json.gz"));
assertEquals(expected.size(), current.size());
for (Repeat repeat : expected) {
assertTrue(current.contains(repeat));
}
for (Repeat repeat : current) {
assertTrue(expected.contains(repeat));
}
}

private Set<Repeat> loadRepeatSet(Path path) throws IOException {
Expand Down
Loading

0 comments on commit c8e719a

Please sign in to comment.