Commit ecd2643e authored by Piotr Gawron's avatar Piotr Gawron
Browse files

after database restriction changed some test required fixing

parent b49cfa90
......@@ -12,13 +12,19 @@ import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.transaction.annotation.Transactional;
import lcsb.mapviewer.common.geometry.PointTransformation;
import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.compartment.Compartment;
import lcsb.mapviewer.model.map.layout.graphics.LayerRect;
import lcsb.mapviewer.model.map.reaction.Product;
import lcsb.mapviewer.model.map.reaction.Reactant;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.reaction.type.ModulationReaction;
import lcsb.mapviewer.model.map.reaction.type.TransportReaction;
import lcsb.mapviewer.model.map.species.AntisenseRna;
import lcsb.mapviewer.model.map.species.Chemical;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.GenericProtein;
import lcsb.mapviewer.model.map.species.Ion;
import lcsb.mapviewer.model.map.species.Phenotype;
......@@ -36,6 +42,8 @@ public abstract class PersistTestFunctions {
@SuppressWarnings("unused")
private Logger logger = LogManager.getLogger(PersistTestFunctions.class);
PointTransformation pt = new PointTransformation();
public double EPSILON = 1e-6;
@Autowired
......@@ -136,14 +144,29 @@ public abstract class PersistTestFunctions {
return rna;
}
protected TransportReaction createReaction() {
protected TransportReaction createReaction(Element reactantElement, Element productElement) {
TransportReaction result = new TransportReaction("re" + identifierCounter++);
result.setZ(zIndex++);
addLines(reactantElement, productElement, result);
return result;
}
protected ModulationReaction createModulationReaction() {
private void addLines(Element reactantElement, Element productElement, Reaction result) {
Product product = new Product(productElement);
product.setLine(new PolylineData(productElement.getCenter(),
pt.getPointOnLine(reactantElement.getCenter(), productElement.getCenter(), 0.6)));
result.addProduct(product);
Reactant reactant = new Reactant(reactantElement);
reactant.setLine(new PolylineData(productElement.getCenter(),
pt.getPointOnLine(reactantElement.getCenter(), productElement.getCenter(), 0.4)));
result.addReactant(reactant);
result.setZ(zIndex++);
result.setLine(new PolylineData(pt.getPointOnLine(reactantElement.getCenter(), productElement.getCenter(), 0.4),
pt.getPointOnLine(reactantElement.getCenter(), productElement.getCenter(), 0.6)));
}
protected ModulationReaction createModulationReaction(Element reactantElement, Element productElement) {
ModulationReaction result = new ModulationReaction("re" + identifierCounter++);
addLines(reactantElement, productElement, result);
result.setZ(zIndex++);
return result;
}
......
......@@ -18,8 +18,6 @@ import lcsb.mapviewer.model.map.layout.graphics.Layer;
import lcsb.mapviewer.model.map.layout.graphics.LayerRect;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.reaction.Product;
import lcsb.mapviewer.model.map.reaction.Reactant;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.GenericProtein;
......@@ -158,9 +156,7 @@ public class CommentDaoTest extends PersistTestFunctions {
LayerRect lr = createRect();
layer.addLayerRect(lr);
Reaction reaction = createReaction();
reaction.addProduct(new Product(alias));
reaction.addReactant(new Reactant(alias2));
Reaction reaction = createReaction(alias2, alias);
reaction.setIdReaction("re" + identifierCounter++);
model.addReaction(reaction);
......
......@@ -25,8 +25,6 @@ import lcsb.mapviewer.model.map.layout.Layout;
import lcsb.mapviewer.model.map.layout.graphics.Layer;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.reaction.Product;
import lcsb.mapviewer.model.map.reaction.Reactant;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.Protein;
......@@ -178,9 +176,7 @@ public class LayoutDaoTest extends PersistTestFunctions {
layer.addLayerRect(createRect());
Reaction reaction = createReaction();
reaction.addProduct(new Product(alias));
reaction.addReactant(new Reactant(alias2));
Reaction reaction = createReaction(alias2, alias);
model.addReaction(reaction);
Protein protein = createProtein(264.8333333333335, 517.75, 86.0, 46.0, "pr1");
......
......@@ -8,7 +8,8 @@ import static org.junit.Assert.assertTrue;
import java.awt.geom.Point2D;
import org.apache.logging.log4j.*;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
......@@ -30,8 +31,6 @@ import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelComparator;
import lcsb.mapviewer.model.map.model.ModelData;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.reaction.Product;
import lcsb.mapviewer.model.map.reaction.Reactant;
import lcsb.mapviewer.model.map.reaction.Reaction;
import lcsb.mapviewer.model.map.reaction.type.ModulationReaction;
import lcsb.mapviewer.model.map.species.Complex;
......@@ -235,9 +234,7 @@ public class ModelDaoTest extends PersistTestFunctions {
public void testModulationReaction() throws Exception {
try {
Model model = createModel();
ModulationReaction reaction = createModulationReaction();
reaction.addProduct(new Product(model.getElementByElementId("sa2")));
reaction.addReactant(new Reactant(model.getElementByElementId("sa1117")));
ModulationReaction reaction = createModulationReaction(model.getElementByElementId("sa1117"), model.getElementByElementId("sa2"));
model.addReaction(reaction);
project.addModel(model);
......@@ -396,7 +393,6 @@ public class ModelDaoTest extends PersistTestFunctions {
}
}
private Model createModel() {
Model model = new ModelFullIndexed(null);
......@@ -431,9 +427,7 @@ public class ModelDaoTest extends PersistTestFunctions {
layer.addLayerRect(createRect());
Reaction reaction = createReaction();
reaction.addProduct(new Product(alias));
reaction.addReactant(new Reactant(alias2));
Reaction reaction = createReaction(alias2, alias);
model.addReaction(reaction);
alias = createProtein(264.8333333333335, 517.75, 86.0, 46.0, "pr1");
......
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