From ca7beee0a495abb98ebf1d3c773246e801f5219c Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Thu, 29 Jun 2017 16:49:13 +0200 Subject: [PATCH] skip invalid cell designer files --- .../CellDesigner2SbgnmlConversionTest.java | 25 +++++++++++-------- 1 file changed, 15 insertions(+), 10 deletions(-) diff --git a/converter-SBGNML/src/test/java/lcsb/mapviewer/converter/model/sbgnml/CellDesigner2SbgnmlConversionTest.java b/converter-SBGNML/src/test/java/lcsb/mapviewer/converter/model/sbgnml/CellDesigner2SbgnmlConversionTest.java index 62d728acb6..e2a8401386 100644 --- a/converter-SBGNML/src/test/java/lcsb/mapviewer/converter/model/sbgnml/CellDesigner2SbgnmlConversionTest.java +++ b/converter-SBGNML/src/test/java/lcsb/mapviewer/converter/model/sbgnml/CellDesigner2SbgnmlConversionTest.java @@ -8,6 +8,7 @@ import java.nio.file.Paths; import java.util.ArrayList; import java.util.Collection; +import org.apache.commons.io.FileUtils; import org.apache.log4j.Logger; import org.junit.Test; import org.junit.runner.RunWith; @@ -22,9 +23,9 @@ import lcsb.mapviewer.model.map.model.Model; @RunWith(Parameterized.class) public class CellDesigner2SbgnmlConversionTest { - Logger logger = Logger.getLogger(CellDesigner2SbgnmlConversionTest.class.getName()); + private static Logger logger = Logger.getLogger(CellDesigner2SbgnmlConversionTest.class.getName()); - private Path testPath; + private Path testPath; public CellDesigner2SbgnmlConversionTest(Path testPath) { this.testPath = testPath; @@ -32,15 +33,19 @@ public class CellDesigner2SbgnmlConversionTest { @Parameters(name = "{index} : {0}") public static Collection<Object[]> data() throws IOException { - Collection<Object[]> data = new ArrayList<Object[]>(); + Collection<Object[]> data = new ArrayList<>(); Files.walk(Paths.get("../converter-CellDesigner/testFiles")).forEach(fPath -> { - if (Files.isRegularFile(fPath) && fPath.toString().endsWith(".xml")) { - String tempPath = fPath.toString().substring(fPath.toString().indexOf("testFiles") + "testFiles".length() + 1); - if (!tempPath.contains("_full")) { - // String tName = - // fPath.toString().substring(fPath.toString().indexOf("testFiles") + - // "testFiles".length(), fPath.toString().indexOf(".xml")); - data.add(new Object[] { fPath }); + if (Files.isRegularFile(fPath) && fPath.toString().endsWith(".xml")&& fPath.toString().indexOf("invalid")==-1) { + try { + String tempPath = fPath.toString().substring(fPath.toString().indexOf("testFiles") + "testFiles".length() + 1); + if (!tempPath.contains("_full")) { + String content = FileUtils.readFileToString(fPath.toFile()); + if (content.indexOf("xmlns:celldesigner") >= 0) { + data.add(new Object[] { fPath }); + } + } + } catch (Exception e) { + throw new RuntimeException(); } } }); -- GitLab