From 2c35221cf69e679fa4470c08a8b59f954b6731d7 Mon Sep 17 00:00:00 2001
From: "piotr.gawron" <piotr.gawron@uni-new>
Date: Sat, 8 Oct 2016 13:07:49 +0200
Subject: [PATCH] test coverage for model

---
 .../commands/CreateHierarchyCommandTest.java  |  3 +--
 .../map/compartment/CompartmentTest.java      | 20 ++++++++++++++++++
 .../model/map/reaction/ReactionTest.java      |  1 +
 .../model/map/species/ComplexTest.java        | 21 ++++++++++++++++++-
 4 files changed, 42 insertions(+), 3 deletions(-)

diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/CreateHierarchyCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/CreateHierarchyCommandTest.java
index 940e935333..4d733b555e 100644
--- a/model-command/src/test/java/lcsb/mapviewer/commands/CreateHierarchyCommandTest.java
+++ b/model-command/src/test/java/lcsb/mapviewer/commands/CreateHierarchyCommandTest.java
@@ -23,7 +23,6 @@ import lcsb.mapviewer.converter.model.celldesigner.CellDesignerXmlParser;
 import lcsb.mapviewer.model.map.compartment.Compartment;
 import lcsb.mapviewer.model.map.compartment.PathwayCompartment;
 import lcsb.mapviewer.model.map.model.Model;
-import lcsb.mapviewer.model.map.species.Complex;
 import lcsb.mapviewer.model.map.species.Element;
 import lcsb.mapviewer.model.map.species.Species;
 
@@ -131,7 +130,7 @@ public class CreateHierarchyCommandTest extends CommandTestFunctions {
 			Model model = getModelForFile("testFiles/artifitial_compartments.xml", false);
 
 			new CreateHierarchyCommand(model, 2, 2).execute();
-			
+
 			assertFalse(model.getElementByElementId("sa1").getCompartment() instanceof PathwayCompartment);
 		} catch (Exception e) {
 			e.printStackTrace();
diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentTest.java
index 4d48aa7f14..bbe1ad98aa 100644
--- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentTest.java
+++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/CompartmentTest.java
@@ -152,6 +152,26 @@ public class CompartmentTest {
 		}
 	}
 
+	@Test
+	public void testDoesntContainsIdenticalSpecies() throws Exception {
+		try {
+			Compartment compartment = new Compartment();
+
+			compartment.setName("AS");
+
+			Species species = new GenericProtein("idd");
+			species.setName("not identical name");
+
+			compartment.addElement(species);
+
+			assertFalse(compartment.containsIdenticalSpecies());
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw e;
+		}
+	}
+
 	private Model createCrossModel() {
 		Model model = new ModelFullIndexed(null);
 		model.addElement(new Compartment("default"));
diff --git a/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionTest.java b/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionTest.java
index 94cd14d33a..7ea08b523f 100644
--- a/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionTest.java
+++ b/model/src/test/java/lcsb/mapviewer/model/map/reaction/ReactionTest.java
@@ -58,6 +58,7 @@ public class ReactionTest extends ModelTestFunctions {
 			Modifier modifier = new Catalysis(species);
 			reaction.addModifier(modifier);
 			assertTrue(reaction.containsElement(species));
+			assertFalse(reaction.containsElement(new GenericProtein("id")));
 		} catch (Exception e) {
 			e.printStackTrace();
 			throw e;
diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexTest.java
index 3990f8888e..6e10c57191 100644
--- a/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexTest.java
+++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexTest.java
@@ -10,9 +10,10 @@ import org.junit.Before;
 import org.junit.Test;
 import org.mockito.Mockito;
 
+import lcsb.mapviewer.ModelTestFunctions;
 import lcsb.mapviewer.common.exception.NotImplementedException;
 
-public class ComplexTest {
+public class ComplexTest extends ModelTestFunctions {
 
 	@Before
 	public void setUp() throws Exception {
@@ -107,6 +108,24 @@ public class ComplexTest {
 		}
 	}
 
+	@Test
+	public void testRemoveNonExistingElement() {
+		try {
+			Complex complex = new Complex();
+			Complex complex2 = new Complex();
+
+			Species protein = new GenericProtein("1");
+			protein.setComplex(complex2);
+			complex.removeElement(protein);
+
+			assertEquals(1, super.getWarnings().size());
+
+		} catch (Exception e) {
+			e.printStackTrace();
+			throw e;
+		}
+	}
+
 	@Test
 	public void testCopy() {
 		try {
-- 
GitLab