Commit 0bc2881e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

unit tests fixed

parent beb2f312
Pipeline #10160 failed with stage
in 10 minutes and 55 seconds
......@@ -44,6 +44,7 @@ import lcsb.mapviewer.common.EventStorageLoggerAppender;
import lcsb.mapviewer.common.exception.InvalidXmlSchemaException;
import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.converter.InvalidInputDataExecption;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.InconsistentModelException;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelComparator;
......@@ -234,14 +235,30 @@ public abstract class CellDesignerTestFunctions {
protected void testXmlSerialization(Model model)
throws InconsistentModelException, UnsupportedEncodingException, InvalidInputDataExecption {
CellDesignerXmlParser parser = new CellDesignerXmlParser();
String xml = parser.model2String(model);
InputStream is = new ByteArrayInputStream(xml.getBytes("UTF-8"));
Model model2 = parser.createModel(new ConverterParams().inputStream(is).sizeAutoAdjust(false));
for (BioEntity bioEntity : model.getBioEntities()) {
bioEntity.setZ(null);
}
Model model2 = serializeModel(model);
model.setName(null);
ModelComparator comparator = new ModelComparator();
assertEquals(0, comparator.compare(model, model2));
}
protected Model serializeModel(Model model)
throws InconsistentModelException, UnsupportedEncodingException, InvalidInputDataExecption {
CellDesignerXmlParser parser = new CellDesignerXmlParser();
String xmlString = parser.model2String(model);
InputStream is = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
Model model2 = parser.createModel(new ConverterParams().inputStream(is).sizeAutoAdjust(false));
for (BioEntity bioEntity : model2.getBioEntities()) {
bioEntity.setZ(null);
}
return model2;
}
}
......@@ -470,11 +470,7 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
alias2.setName("PDK2");
model.addElement(alias2);
CellDesignerXmlParser parser = new CellDesignerXmlParser();
String xmlString = parser.model2String(model);
InputStream is = new ByteArrayInputStream(xmlString.getBytes());
Model model2 = parser.createModel(new ConverterParams().inputStream(is).sizeAutoAdjust(false));
Model model2 = serializeModel(model);
assertEquals(0, modelComparator.compare(model, model2));
......@@ -1078,11 +1074,7 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions {
protein.addSynonym("&");
model.addElement(protein);
CellDesignerXmlParser parser = new CellDesignerXmlParser();
String xmlString = parser.model2String(model);
InputStream is = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
Model model2 = parser.createModel(new ConverterParams().inputStream(is));
Model model2 = serializeModel(model);
assertEquals(0, modelComparator.compare(model, model2));
......
......@@ -7,8 +7,6 @@ import static org.junit.Assert.assertTrue;
import java.awt.Color;
import java.io.ByteArrayInputStream;
import java.io.InputStream;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
......@@ -98,7 +96,6 @@ public class ComplexParserTests extends CellDesignerTestFunctions {
}
}
@Test
public void testParseTextWithBackground() throws Exception {
try {
......@@ -413,14 +410,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions {
alias.setName("name & no-name");
model.addElement(alias);
CellDesignerXmlParser parser = new CellDesignerXmlParser();
String string = parser.model2String(model);
InputStream stream = new ByteArrayInputStream(string.getBytes(StandardCharsets.UTF_8));
ConverterParams params = new ConverterParams().inputStream(stream).sizeAutoAdjust(false);
Model model2 = parser.createModel(params);
Model model2 = serializeModel(model);
ModelComparator comparator = new ModelComparator();
......@@ -443,14 +433,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions {
alias.setName("name\rno-name");
model.addElement(alias);
CellDesignerXmlParser parser = new CellDesignerXmlParser();
String string = parser.model2String(model);
InputStream stream = new ByteArrayInputStream(string.getBytes(StandardCharsets.UTF_8));
ConverterParams params = new ConverterParams().inputStream(stream).sizeAutoAdjust(false);
Model model2 = parser.createModel(params);
Model model2 = serializeModel(model);
ModelComparator comparator = new ModelComparator();
......@@ -485,5 +468,4 @@ public class ComplexParserTests extends CellDesignerTestFunctions {
}
}
}
......@@ -26,6 +26,7 @@ import lcsb.mapviewer.converter.graphics.AbstractImageGenerator;
import lcsb.mapviewer.converter.graphics.NormalImageGenerator;
import lcsb.mapviewer.converter.graphics.PngImageGenerator;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelComparator;
......@@ -91,11 +92,16 @@ public class GenericSbmlParserTest {
assertNotNull(model2);
ModelComparator comparator = new ModelComparator(1.0);
for (BioEntity bioEntity: model.getBioEntities()) {
bioEntity.setZ(null);
}
for (BioEntity bioEntity: model2.getBioEntities()) {
bioEntity.setZ(null);
}
assertEquals(0, comparator.compare(model, model2));
FileUtils.deleteDirectory(new File(dir));
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
throw e;
}
......
......@@ -4,6 +4,7 @@ import java.awt.Desktop;
import java.awt.geom.Point2D;
import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.InputStream;
import java.nio.file.Files;
import java.util.List;
......@@ -17,7 +18,9 @@ import lcsb.mapviewer.converter.ConverterParams;
import lcsb.mapviewer.converter.graphics.AbstractImageGenerator;
import lcsb.mapviewer.converter.graphics.NormalImageGenerator;
import lcsb.mapviewer.converter.graphics.PngImageGenerator;
import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser;
import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.BioEntity;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.reaction.Product;
......@@ -117,6 +120,21 @@ public class SbmlTestFunctions {
// showImage(result);
return result;
}
protected Model getModelAfterCellDEsignerSerializing(Model model) throws Exception {
CellDesignerXmlParser parser = new CellDesignerXmlParser();
String xmlString = parser.model2String(model);
InputStream is = new ByteArrayInputStream(xmlString.getBytes("UTF-8"));
Model model2 = parser.createModel(new ConverterParams().inputStream(is).sizeAutoAdjust(false));
for (BioEntity bioEntity : model2.getBioEntities()) {
bioEntity.setZ(null);
}
for (BioEntity bioEntity : model.getBioEntities()) {
bioEntity.setZ(null);
}
return model2;
}
......
......@@ -385,6 +385,7 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions {
assertEquals("test", pathway.getName());
assertEquals("5", pathway.getVisibilityLevel());
assertEquals((Integer)11, pathway.getZ());
} catch (Exception e) {
e.printStackTrace();
......
......@@ -42,6 +42,7 @@
<celldesigner:layerNotes>
test
SemanticZoomLevelVisibility: 5
Z-Index: 11
</celldesigner:layerNotes>
<celldesigner:bounds x="140.0" y="173.0" w="242.0" h="178.0"/>
<celldesigner:paint color="ff000000"/>
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment