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

parent can sometimes be already properly assigned

parent 297b5031
Pipeline #46522 passed with stage
in 17 minutes and 59 seconds
......@@ -142,7 +142,9 @@ public class CopyCommand extends NewModelCommand {
original = connection.getParentModel();
copy = copies.get(original);
if (copy == null) {
throw new InvalidModelException("Original model contain reference to model that wasn't copied");
if (!original.equals(modelCopy)) {
throw new InvalidModelException("Original model contain reference to model that wasn't copied");
}
} else {
connection.setParentModel(copy);
}
......
package lcsb.mapviewer.commands;
import static org.junit.Assert.*;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertNotEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import java.awt.geom.Point2D;
import java.util.*;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.List;
import org.apache.commons.lang3.mutable.MutableBoolean;
import org.junit.*;
import org.junit.After;
import org.junit.Before;
import org.junit.Test;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.model.graphics.PolylineData;
import lcsb.mapviewer.model.map.MiriamData;
......@@ -17,11 +24,22 @@ import lcsb.mapviewer.model.map.compartment.SquareCompartment;
import lcsb.mapviewer.model.map.kinetics.SbmlFunction;
import lcsb.mapviewer.model.map.kinetics.SbmlParameter;
import lcsb.mapviewer.model.map.layout.graphics.Layer;
import lcsb.mapviewer.model.map.model.*;
import lcsb.mapviewer.model.map.reaction.*;
import lcsb.mapviewer.model.map.model.Author;
import lcsb.mapviewer.model.map.model.ElementSubmodelConnection;
import lcsb.mapviewer.model.map.model.Model;
import lcsb.mapviewer.model.map.model.ModelComparator;
import lcsb.mapviewer.model.map.model.ModelFullIndexed;
import lcsb.mapviewer.model.map.model.ModelSubmodelConnection;
import lcsb.mapviewer.model.map.model.SubmodelType;
import lcsb.mapviewer.model.map.reaction.AbstractNode;
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.StateTransitionReaction;
import lcsb.mapviewer.model.map.reaction.type.TransportReaction;
import lcsb.mapviewer.model.map.species.*;
import lcsb.mapviewer.model.map.species.Complex;
import lcsb.mapviewer.model.map.species.Element;
import lcsb.mapviewer.model.map.species.GenericProtein;
public class CopyCommandTest extends CommandTestFunctions {
......@@ -219,17 +237,6 @@ public class CopyCommandTest extends CommandTestFunctions {
assertEquals(0, comparator.compare(model, copy));
}
@Test(expected = InvalidArgumentException.class)
public void testCopyModelWithSubmodelsThrowException() throws Exception {
Model model = getModel();
Model model2 = getModel();
model2.setNotes("ASDSA2");
model.getElementByElementId("a_id")
.setSubmodel(new ElementSubmodelConnection(model2, SubmodelType.DOWNSTREAM_TARGETS));
new CopyCommand(model).execute();
}
private Model getModel() {
Model model = new ModelFullIndexed(null);
model.setName("nam" + counter++);
......
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