From a7270a5434616e3f947b71878b4c1f6805cc4a92 Mon Sep 17 00:00:00 2001
From: Piotr Gawron <piotr.gawron@uni.lu>
Date: Wed, 20 Dec 2017 16:14:02 +0100
Subject: [PATCH] getModel method added to BioEntity

---
 .../annotation/RestAnnotationParserTest.java  | 818 ++++++++----------
 .../lcsb/mapviewer/model/map/BioEntity.java   | 298 ++++---
 .../model/map/reaction/Reaction.java          |   6 +-
 .../mapviewer/model/map/species/Element.java  |   5 +-
 4 files changed, 513 insertions(+), 614 deletions(-)

diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParserTest.java
index 7c68b06fff..2ed94bcb8f 100644
--- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParserTest.java
+++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/annotation/RestAnnotationParserTest.java
@@ -6,8 +6,6 @@ import static org.junit.Assert.assertNotNull;
 import static org.junit.Assert.assertTrue;
 import static org.junit.Assert.fail;
 
-import java.util.ArrayList;
-import java.util.Collection;
 import java.util.List;
 import java.util.Set;
 
@@ -16,6 +14,7 @@ import org.apache.xerces.dom.DocumentImpl;
 import org.junit.After;
 import org.junit.Before;
 import org.junit.Test;
+import org.mockito.Mockito;
 import org.w3c.dom.Document;
 import org.w3c.dom.Node;
 
@@ -34,465 +33,362 @@ import lcsb.mapviewer.model.map.species.GenericProtein;
 import lcsb.mapviewer.model.map.species.Species;
 
 public class RestAnnotationParserTest extends CellDesignerTestFunctions {
-	Logger logger = Logger.getLogger(RestAnnotationParserTest.class);
-
-	@Before
-	public void setUp() throws Exception {
-	}
-
-	@After
-	public void tearDown() throws Exception {
-	}
-
-	@Test
-	public void test() throws Exception {
-
-		try {
-			RestAnnotationParser rap = new RestAnnotationParser();
-
-			String response = readFile("testFiles/annotation/sampleDescription.txt");
-
-			List<String> synonyms = rap.getSynonyms(response);
-			assertEquals(3, synonyms.size());
-			assertTrue(synonyms.contains("CAMK"));
-			assertTrue(synonyms.contains("CAMKIV"));
-
-			List<String> formerSymbols = rap.getFormerSymbols(response);
-			assertEquals(0, formerSymbols.size());
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-	}
-
-	@Test
-	public void testParseNotes() throws Exception {
-		try {
-			RestAnnotationParser parser = new RestAnnotationParser();
-			Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes.xml");
-			Species proteinAlias = new GenericProtein("id");
-			parser.processNotes(node.getFirstChild(), proteinAlias);
-			String notes = proteinAlias.getNotes();
-			assertNotNull(notes);
-			assertFalse(notes.contains("body"));
-			assertTrue(notes.contains("some"));
-			// after redoing it should be the same
-			parser.processNotes(node.getFirstChild(), proteinAlias);
-			notes = proteinAlias.getNotes();
-			assertNotNull(notes);
-			assertFalse(notes.contains("body"));
-			assertTrue(notes.contains("some"));
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-	}
-
-	@Test
-	public void testParseNotes2() throws Exception {
-		try {
-			RestAnnotationParser parser = new RestAnnotationParser();
-			Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes3.xml");
-			Species proteinAlias = new GenericProtein("id");
-			parser.processNotes(node.getFirstChild(), proteinAlias);
-			String notes = proteinAlias.getNotes();
-			assertNotNull(notes);
-			assertFalse(notes.contains("body"));
-			assertTrue(notes.contains("some"));
-			// after redoing it should be the same
-			parser.processNotes(node.getFirstChild(), proteinAlias);
-			notes = proteinAlias.getNotes();
-			assertNotNull(notes);
-			assertFalse(notes.contains("body"));
-			assertTrue(notes.contains("some"));
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-	}
-
-	@Test
-	public void testParseNotes3() throws Exception {
-		try {
-			RestAnnotationParser parser = new RestAnnotationParser();
-			Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes4.xml");
-			Species proteinAlias = new GenericProtein("id");
-			proteinAlias.setNotes("text");
-			parser.processNotes(node.getFirstChild(), proteinAlias);
-			String notes = proteinAlias.getNotes();
-			assertNotNull(notes);
-			assertFalse(notes.contains("body"));
-			assertTrue(notes.contains("some"));
-			// after redoing it should be the same
-			parser.processNotes(node.getFirstChild(), proteinAlias);
-			notes = proteinAlias.getNotes();
-			assertNotNull(notes);
-			assertFalse(notes.contains("body"));
-			assertTrue(notes.contains("some"));
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-	}
-
-	@Test
-	public void testParseCollisionNotes() throws Exception {
-		try {
-			RestAnnotationParser parser = new RestAnnotationParser();
-			Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes2.xml");
-
-			GenericProtein protein = new GenericProtein("pr_id1");
-			protein.addSynonym("a1");
-			protein.addFormerSymbol("a1");
-			protein.setFullName("yyy");
-			protein.setAbbreviation("aaaa");
-			protein.setCharge(9);
-			protein.setSymbol("D");
-			parser.processNotes(node.getFirstChild(), protein);
-			assertEquals(1, protein.getSynonyms().size());
-			assertEquals(1, protein.getFormerSymbols().size());
-
-			assertEquals(6, getWarnings().size());
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-	}
-
-	@Test
-	public void testParseInvalidNotes1() throws Exception {
-		try {
-			RestAnnotationParser parser = new RestAnnotationParser();
-			Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes_invalid_charge.xml");
-
-			Species proteinAlias = new GenericProtein("id");
-			parser.processNotes(node.getFirstChild(), proteinAlias);
-
-			assertEquals(1, getWarnings().size());
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-	}
-
-	@Test
-	public void testParseCollisionNotes2() throws Exception {
-		try {
-			RestAnnotationParser parser = new RestAnnotationParser();
-			Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes2.xml");
-			Reaction reaction = new Reaction();
-			reaction.addSynonym("a1");
-			reaction.setAbbreviation("aaaa");
-			reaction.setSubsystem("sss");
-			reaction.setGeneProteinReaction("str");
-			reaction.setFormula("xxx");
-			reaction.setMechanicalConfidenceScore(-45);
-			reaction.setUpperBound(4.5);
-			reaction.setLowerBound(4.5);
-
-			parser.processNotes(node.getFirstChild(), reaction);
-
-			assertEquals(8, getWarnings().size());
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-	}
-
-	@Test
-	public void testMoveAnnotationsFromNotes() throws Exception {
-		try {
-			Model model = getModelForFile("testFiles/copyingAnnotationModel.xml");
-
-			Set<Element> elements = model.getElements();
-			for (Element element : elements) {
-				if (element.getName().equals("blabla")) {
-					assertEquals(2, element.getMiriamData().size());
-					element.getMiriamData().add(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.PUBMED, "12345"));
-					element.getMiriamData().add(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.PUBMED, "333666"));
-					assertEquals(2, element.getMiriamData().size());
-				}
-				assertFalse(element.getNotes().contains("rdf:RDF"));
-			}
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-	}
-
-	@Test
-	public void testProcessRdfDescription() throws Exception {
-		try {
-			RestAnnotationParser rap = new RestAnnotationParser();
-			Species speciesAlias = new GenericProtein("id");
-			speciesAlias.setNotes(
-					"begining\n" + "<rdf:RDF>" + "<rdf:Description rdf:about=\"#s2157\">\n" + "<bqmodel:is>\n" + "<rdf:Bag>\n"
-							+ "<rdf:li rdf:resource=\"urn:miriam:obo.chebi:CHEBI%3A17515\"/>\n" + "</rdf:Bag>\n" + "</bqmodel:is>\n" + "</rdf:Description>\n" + "</rdf:RDF>"
-							+ "\nend ending");
-			rap.processRdfDescription(speciesAlias);
-			assertEquals("begining\n\nend ending", speciesAlias.getNotes());
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-	}
-
-	@Test
-	public void testGetMiriamDataFromAnnotation() throws Exception {
-		try {
-			RestAnnotationParser rap = new RestAnnotationParser();
-			String response = readFile("testFiles/annotation/sampleDescription.txt");
-
-			Set<MiriamData> set = rap.getMiriamData(response);
-			for (MiriamData miriamData : set) {
-				if (miriamData.getDataType().equals(MiriamType.KEGG_GENES)) {
-					assertTrue(miriamData.getResource().contains("hsa"));
-				}
-			}
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-
-	}
-
-	@Test
-	public void testGetMiriamDataFromEmpty() throws Exception {
-		try {
-			RestAnnotationParser rap = new RestAnnotationParser();
-
-			Set<MiriamData> set = rap.getMiriamData(null);
-			assertEquals(0, set.size());
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-
-	}
-
-	@Test
-	public void testCreateAnnotationString() throws Exception {
-		try {
-			RestAnnotationParser rap = new RestAnnotationParser();
-
-			String former1 = "form1";
-			String former2 = "form2";
-			GenericProtein element = new GenericProtein("id");
-			element.addFormerSymbol(former1);
-			element.addFormerSymbol(former2);
-			element.setCharge(1);
-			String str = rap.createAnnotationString(element, true);
-			assertTrue(str.contains(former1));
-			assertTrue(str.contains(former2));
-
-			for (NoteField field : NoteField.values()) {
-				if (field.getClazz().isAssignableFrom(element.getClass()) || CellDesignerElement.class.isAssignableFrom(field.getClazz())) {
-					assertTrue("Export string doesn't contain info about: " + field.getCommonName(), str.indexOf(field.getCommonName()) >= 0);
-				}
-
-			}
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-
-	}
-
-	@Test
-	public void testGetFormerSymbolsFromInvalidStr() throws Exception {
-		try {
-			RestAnnotationParser rap = new RestAnnotationParser();
-
-			assertEquals(0, rap.getFormerSymbols(null).size());
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-
-	}
-
-	@Test
-	public void testGetNotesInvalid() throws Exception {
-		try {
-			RestAnnotationParser rap = new RestAnnotationParser();
-
-			Document xmlDoc = new DocumentImpl();
-			Node node = xmlDoc.createElement("bla");
-
-			rap.getNotes(node);
-			fail("Exception expected");
-		} catch (InvalidArgumentException e) {
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-
-	}
-
-	@Test
-	public void testProcessNotesForInvalidElement() throws Exception {
-		try {
-			RestAnnotationParser parser = new RestAnnotationParser();
-			Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes4.xml");
-			parser.processNotes(node.getFirstChild(), new BioEntity() {
-				/**
-				 * 
-				 */
-				private static final long serialVersionUID = 1L;
-
-				@Override
-				public void setSynonyms(List<String> synonyms) {
-				}
-
-				@Override
-				public void setSymbol(String symbol) {
-				}
-
-				@Override
-				public void setNotes(String notes) {
-				}
-
-				@Override
-				public void setName(String name) {
-				}
-
-				@Override
-				public void setFormula(String formula) {
-				}
-
-				@Override
-				public void setAbbreviation(String abbreviation) {
-				}
-
-				@Override
-				public List<String> getSynonyms() {
-					return new ArrayList<>();
-				}
-
-				@Override
-				public String getSymbol() {
-					return "";
-				}
-
-				@Override
-				public String getNotes() {
-					return "";
-				}
-
-				@Override
-				public String getName() {
-					return "";
-				}
-
-				@Override
-				public Collection<MiriamData> getMiriamData() {
-					return null;
-				}
-
-				@Override
-				public String getFormula() {
-					return null;
-				}
-
-				@Override
-				public String getAbbreviation() {
-					return null;
-				}
-
-				@Override
-				public void addMiriamData(MiriamData md) {
-				}
-
-				@Override
-				public void addMiriamData(Collection<MiriamData> miriamData) {
-				}
-
-				@Override
-				public int getId() {
-					// TODO Auto-generated method stub
-					return 0;
-				}
-
-				@Override
-				public String getStringType() {
-					// TODO Auto-generated method stub
-					return null;
-				}
-
-				@Override
-				public void setVisibilityLevel(String zoomLevelVisibility) {
-					// TODO Auto-generated method stub
-					
-				}
-
-				@Override
-				public String getVisibilityLevel() {
-					// TODO Auto-generated method stub
-					return null;
-				}
-
-				@Override
-				public void setVisibilityLevel(Integer zoomLevelVisibility) {
-					// TODO Auto-generated method stub
-					
-				}
-
-        @Override
-        public String getElementId() {
-          // TODO Auto-generated method stub
-          return null;
+  Logger logger = Logger.getLogger(RestAnnotationParserTest.class);
+
+  @Before
+  public void setUp() throws Exception {
+  }
+
+  @After
+  public void tearDown() throws Exception {
+  }
+
+  @Test
+  public void test() throws Exception {
+
+    try {
+      RestAnnotationParser rap = new RestAnnotationParser();
+
+      String response = readFile("testFiles/annotation/sampleDescription.txt");
+
+      List<String> synonyms = rap.getSynonyms(response);
+      assertEquals(3, synonyms.size());
+      assertTrue(synonyms.contains("CAMK"));
+      assertTrue(synonyms.contains("CAMKIV"));
+
+      List<String> formerSymbols = rap.getFormerSymbols(response);
+      assertEquals(0, formerSymbols.size());
+
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+  }
+
+  @Test
+  public void testParseNotes() throws Exception {
+    try {
+      RestAnnotationParser parser = new RestAnnotationParser();
+      Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes.xml");
+      Species proteinAlias = new GenericProtein("id");
+      parser.processNotes(node.getFirstChild(), proteinAlias);
+      String notes = proteinAlias.getNotes();
+      assertNotNull(notes);
+      assertFalse(notes.contains("body"));
+      assertTrue(notes.contains("some"));
+      // after redoing it should be the same
+      parser.processNotes(node.getFirstChild(), proteinAlias);
+      notes = proteinAlias.getNotes();
+      assertNotNull(notes);
+      assertFalse(notes.contains("body"));
+      assertTrue(notes.contains("some"));
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+  }
+
+  @Test
+  public void testParseNotes2() throws Exception {
+    try {
+      RestAnnotationParser parser = new RestAnnotationParser();
+      Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes3.xml");
+      Species proteinAlias = new GenericProtein("id");
+      parser.processNotes(node.getFirstChild(), proteinAlias);
+      String notes = proteinAlias.getNotes();
+      assertNotNull(notes);
+      assertFalse(notes.contains("body"));
+      assertTrue(notes.contains("some"));
+      // after redoing it should be the same
+      parser.processNotes(node.getFirstChild(), proteinAlias);
+      notes = proteinAlias.getNotes();
+      assertNotNull(notes);
+      assertFalse(notes.contains("body"));
+      assertTrue(notes.contains("some"));
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+  }
+
+  @Test
+  public void testParseNotes3() throws Exception {
+    try {
+      RestAnnotationParser parser = new RestAnnotationParser();
+      Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes4.xml");
+      Species proteinAlias = new GenericProtein("id");
+      proteinAlias.setNotes("text");
+      parser.processNotes(node.getFirstChild(), proteinAlias);
+      String notes = proteinAlias.getNotes();
+      assertNotNull(notes);
+      assertFalse(notes.contains("body"));
+      assertTrue(notes.contains("some"));
+      // after redoing it should be the same
+      parser.processNotes(node.getFirstChild(), proteinAlias);
+      notes = proteinAlias.getNotes();
+      assertNotNull(notes);
+      assertFalse(notes.contains("body"));
+      assertTrue(notes.contains("some"));
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+  }
+
+  @Test
+  public void testParseCollisionNotes() throws Exception {
+    try {
+      RestAnnotationParser parser = new RestAnnotationParser();
+      Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes2.xml");
+
+      GenericProtein protein = new GenericProtein("pr_id1");
+      protein.addSynonym("a1");
+      protein.addFormerSymbol("a1");
+      protein.setFullName("yyy");
+      protein.setAbbreviation("aaaa");
+      protein.setCharge(9);
+      protein.setSymbol("D");
+      parser.processNotes(node.getFirstChild(), protein);
+      assertEquals(1, protein.getSynonyms().size());
+      assertEquals(1, protein.getFormerSymbols().size());
+
+      assertEquals(6, getWarnings().size());
+
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+  }
+
+  @Test
+  public void testParseInvalidNotes1() throws Exception {
+    try {
+      RestAnnotationParser parser = new RestAnnotationParser();
+      Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes_invalid_charge.xml");
+
+      Species proteinAlias = new GenericProtein("id");
+      parser.processNotes(node.getFirstChild(), proteinAlias);
+
+      assertEquals(1, getWarnings().size());
+
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+  }
+
+  @Test
+  public void testParseCollisionNotes2() throws Exception {
+    try {
+      RestAnnotationParser parser = new RestAnnotationParser();
+      Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes2.xml");
+      Reaction reaction = new Reaction();
+      reaction.addSynonym("a1");
+      reaction.setAbbreviation("aaaa");
+      reaction.setSubsystem("sss");
+      reaction.setGeneProteinReaction("str");
+      reaction.setFormula("xxx");
+      reaction.setMechanicalConfidenceScore(-45);
+      reaction.setUpperBound(4.5);
+      reaction.setLowerBound(4.5);
+
+      parser.processNotes(node.getFirstChild(), reaction);
+
+      assertEquals(8, getWarnings().size());
+
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+  }
+
+  @Test
+  public void testMoveAnnotationsFromNotes() throws Exception {
+    try {
+      Model model = getModelForFile("testFiles/copyingAnnotationModel.xml");
+
+      Set<Element> elements = model.getElements();
+      for (Element element : elements) {
+        if (element.getName().equals("blabla")) {
+          assertEquals(2, element.getMiriamData().size());
+          element.getMiriamData()
+              .add(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.PUBMED, "12345"));
+          element.getMiriamData()
+              .add(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.PUBMED, "333666"));
+          assertEquals(2, element.getMiriamData().size());
         }
-			});
-			fail("Exception expected");
-		} catch (NotImplementedException e) {
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-	}
-
-	@Test
-	public void testProcessInvalidNotes() throws Exception {
-		try {
-			RestAnnotationParser parser = new RestAnnotationParser();
-			String str = super.readFile("testFiles/xmlNodeTestExamples/notes5.xml");
-
-			parser.processNotes(str, new GenericProtein("id"));
-
-			assertEquals(1, getWarnings().size());
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-	}
-
-	@Test
-	public void testProcessNotes() throws Exception {
-		try {
-			String newNotes = "new notes";
-			String oldNotes = "old notes";
-			RestAnnotationParser parser = new RestAnnotationParser();
-			String str = "Description: " + newNotes + "\n" + oldNotes;
-			GenericProtein protein = new GenericProtein("id");
-			parser.processNotes(str, protein);
-
-			assertTrue(protein.getNotes().contains(newNotes));
-			assertTrue(protein.getNotes().contains(oldNotes));
-			assertFalse(protein.getNotes().contains("Description"));
-
-		} catch (Exception e) {
-			e.printStackTrace();
-			throw e;
-		}
-	}
+        assertFalse(element.getNotes().contains("rdf:RDF"));
+      }
+
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+  }
+
+  @Test
+  public void testProcessRdfDescription() throws Exception {
+    try {
+      RestAnnotationParser rap = new RestAnnotationParser();
+      Species speciesAlias = new GenericProtein("id");
+      speciesAlias.setNotes("begining\n" + "<rdf:RDF>" + "<rdf:Description rdf:about=\"#s2157\">\n" + "<bqmodel:is>\n"
+          + "<rdf:Bag>\n" + "<rdf:li rdf:resource=\"urn:miriam:obo.chebi:CHEBI%3A17515\"/>\n" + "</rdf:Bag>\n"
+          + "</bqmodel:is>\n" + "</rdf:Description>\n" + "</rdf:RDF>" + "\nend ending");
+      rap.processRdfDescription(speciesAlias);
+      assertEquals("begining\n\nend ending", speciesAlias.getNotes());
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+  }
+
+  @Test
+  public void testGetMiriamDataFromAnnotation() throws Exception {
+    try {
+      RestAnnotationParser rap = new RestAnnotationParser();
+      String response = readFile("testFiles/annotation/sampleDescription.txt");
+
+      Set<MiriamData> set = rap.getMiriamData(response);
+      for (MiriamData miriamData : set) {
+        if (miriamData.getDataType().equals(MiriamType.KEGG_GENES)) {
+          assertTrue(miriamData.getResource().contains("hsa"));
+        }
+      }
+
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+
+  }
+
+  @Test
+  public void testGetMiriamDataFromEmpty() throws Exception {
+    try {
+      RestAnnotationParser rap = new RestAnnotationParser();
+
+      Set<MiriamData> set = rap.getMiriamData(null);
+      assertEquals(0, set.size());
+
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+
+  }
+
+  @Test
+  public void testCreateAnnotationString() throws Exception {
+    try {
+      RestAnnotationParser rap = new RestAnnotationParser();
+
+      String former1 = "form1";
+      String former2 = "form2";
+      GenericProtein element = new GenericProtein("id");
+      element.addFormerSymbol(former1);
+      element.addFormerSymbol(former2);
+      element.setCharge(1);
+      String str = rap.createAnnotationString(element, true);
+      assertTrue(str.contains(former1));
+      assertTrue(str.contains(former2));
+
+      for (NoteField field : NoteField.values()) {
+        if (field.getClazz().isAssignableFrom(element.getClass())
+            || CellDesignerElement.class.isAssignableFrom(field.getClazz())) {
+          assertTrue("Export string doesn't contain info about: " + field.getCommonName(),
+              str.indexOf(field.getCommonName()) >= 0);
+        }
+
+      }
+
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+
+  }
+
+  @Test
+  public void testGetFormerSymbolsFromInvalidStr() throws Exception {
+    try {
+      RestAnnotationParser rap = new RestAnnotationParser();
+
+      assertEquals(0, rap.getFormerSymbols(null).size());
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+
+  }
+
+  @Test
+  public void testGetNotesInvalid() throws Exception {
+    try {
+      RestAnnotationParser rap = new RestAnnotationParser();
+
+      Document xmlDoc = new DocumentImpl();
+      Node node = xmlDoc.createElement("bla");
+
+      rap.getNotes(node);
+      fail("Exception expected");
+    } catch (InvalidArgumentException e) {
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+
+  }
+
+  @Test
+  public void testProcessNotesForInvalidElement() throws Exception {
+    try {
+      RestAnnotationParser parser = new RestAnnotationParser();
+      Document node = getXmlDocumentFromFile("testFiles/xmlNodeTestExamples/notes4.xml");
+      BioEntity bioEntity = Mockito.mock(BioEntity.class);
+      Mockito.when(bioEntity.getNotes()).thenReturn("");
+      parser.processNotes(node.getFirstChild(), bioEntity);
+      fail("Exception expected");
+    } catch (NotImplementedException e) {
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+  }
+
+  @Test
+  public void testProcessInvalidNotes() throws Exception {
+    try {
+      RestAnnotationParser parser = new RestAnnotationParser();
+      String str = super.readFile("testFiles/xmlNodeTestExamples/notes5.xml");
+
+      parser.processNotes(str, new GenericProtein("id"));
+
+      assertEquals(1, getWarnings().size());
+
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+  }
+
+  @Test
+  public void testProcessNotes() throws Exception {
+    try {
+      String newNotes = "new notes";
+      String oldNotes = "old notes";
+      RestAnnotationParser parser = new RestAnnotationParser();
+      String str = "Description: " + newNotes + "\n" + oldNotes;
+      GenericProtein protein = new GenericProtein("id");
+      parser.processNotes(str, protein);
+
+      assertTrue(protein.getNotes().contains(newNotes));
+      assertTrue(protein.getNotes().contains(oldNotes));
+      assertFalse(protein.getNotes().contains("Description"));
+
+    } catch (Exception e) {
+      e.printStackTrace();
+      throw e;
+    }
+  }
 
 }
diff --git a/model/src/main/java/lcsb/mapviewer/model/map/BioEntity.java b/model/src/main/java/lcsb/mapviewer/model/map/BioEntity.java
index 8361b25af4..70319d5914 100644
--- a/model/src/main/java/lcsb/mapviewer/model/map/BioEntity.java
+++ b/model/src/main/java/lcsb/mapviewer/model/map/BioEntity.java
@@ -4,6 +4,8 @@ import java.io.Serializable;
 import java.util.Collection;
 import java.util.List;
 
+import lcsb.mapviewer.model.map.model.Model;
+
 /**
  * Interface that describes bio entity on the map (like Protein or Reaction).
  * 
@@ -11,149 +13,149 @@ import java.util.List;
  * 
  */
 public interface BioEntity extends Serializable {
-	/**
-	 * Returns list of {@link MiriamData annotations} for the object.
-	 * 
-	 * @return list of {@link MiriamData annotations} for the object
-	 */
-	Collection<MiriamData> getMiriamData();
-
-	/**
-	 * Adds miriam annotations to the element.
-	 * 
-	 * @param miriamData
-	 *          set of miriam annotations to be added
-	 */
-	void addMiriamData(Collection<MiriamData> miriamData);
-
-	/**
-	 * Adds miriam annotation to the element.
-	 * 
-	 * @param md
-	 *          miriam annotation to be added
-	 */
-	void addMiriamData(MiriamData md);
-
-	/**
-	 * Returns the name of the object.
-	 * 
-	 * @return the name of the object
-	 */
-	String getName();
-
-	/**
-	 * Returns notes about the object.
-	 * 
-	 * @return notes about the object
-	 */
-	String getNotes();
-
-	/**
-	 * Sets notes about the object.
-	 * 
-	 * @param notes
-	 *          new notes
-	 */
-	void setNotes(String notes);
-
-	/**
-	 * Returns the symbol of the element.
-	 * 
-	 * @return the symbol of the element
-	 */
-	String getSymbol();
-
-	/**
-	 * Sets symbol of the element.
-	 * 
-	 * @param symbol
-	 *          new symbol
-	 */
-	void setSymbol(String symbol);
-
-	/**
-	 * Get list of synonyms.
-	 * 
-	 * @return list of synonyms
-	 */
-	List<String> getSynonyms();
-
-	/**
-	 * Sets list of synonyms to the element.
-	 * 
-	 * @param synonyms
-	 *          new list
-	 */
-	void setSynonyms(List<String> synonyms);
-
-	/**
-	 * Returns the abbreviation.
-	 * 
-	 * @return the abbreviation
-	 */
-	String getAbbreviation();
-
-	/**
-	 * Sets abbreviation.
-	 * 
-	 * @param abbreviation
-	 *          new abbreviation
-	 */
-	void setAbbreviation(String abbreviation);
-
-	/**
-	 * Sets formula.
-	 * 
-	 * @param formula
-	 *          new formula
-	 */
-	void setFormula(String formula);
-
-	/**
-	 * Returns the formula.
-	 * 
-	 * @return the formula
-	 */
-	String getFormula();
-
-	/**
-	 * Sets the name to the object.
-	 * 
-	 * @param name
-	 *          name of the object
-	 * 
-	 */
-	void setName(String name);
-
-	/**
-	 * Returns database identifier of the object.
-	 * 
-	 * @return database identifier of the object
-	 */
-	int getId();
-
-	/**
-	 * Return human readable {@link String} representing class.
-	 * 
-	 * @return human readable {@link String} representing class
-	 */
-	String getStringType();
-
-	/**
-	 * Sets semantic zoom level visibility.
-	 * 
-	 * @param zoomLevelVisibility
-	 *          semantic zoom level visibility
-	 */
-	void setVisibilityLevel(String zoomLevelVisibility);
-	
-	/**
-	 * Sets semantic zoom level visibility.
-	 * 
-	 * @param zoomLevelVisibility
-	 *          semantic zoom level visibility
-	 */
-	void setVisibilityLevel(Integer zoomLevelVisibility);
+  /**
+   * Returns list of {@link MiriamData annotations} for the object.
+   *
+   * @return list of {@link MiriamData annotations} for the object
+   */
+  Collection<MiriamData> getMiriamData();
+
+  /**
+   * Adds miriam annotations to the element.
+   *
+   * @param miriamData
+   *          set of miriam annotations to be added
+   */
+  void addMiriamData(Collection<MiriamData> miriamData);
+
+  /**
+   * Adds miriam annotation to the element.
+   *
+   * @param md
+   *          miriam annotation to be added
+   */
+  void addMiriamData(MiriamData md);
+
+  /**
+   * Returns the name of the object.
+   *
+   * @return the name of the object
+   */
+  String getName();
+
+  /**
+   * Returns notes about the object.
+   *
+   * @return notes about the object
+   */
+  String getNotes();
+
+  /**
+   * Sets notes about the object.
+   *
+   * @param notes
+   *          new notes
+   */
+  void setNotes(String notes);
+
+  /**
+   * Returns the symbol of the element.
+   *
+   * @return the symbol of the element
+   */
+  String getSymbol();
+
+  /**
+   * Sets symbol of the element.
+   *
+   * @param symbol
+   *          new symbol
+   */
+  void setSymbol(String symbol);
+
+  /**
+   * Get list of synonyms.
+   *
+   * @return list of synonyms
+   */
+  List<String> getSynonyms();
+
+  /**
+   * Sets list of synonyms to the element.
+   *
+   * @param synonyms
+   *          new list
+   */
+  void setSynonyms(List<String> synonyms);
+
+  /**
+   * Returns the abbreviation.
+   *
+   * @return the abbreviation
+   */
+  String getAbbreviation();
+
+  /**
+   * Sets abbreviation.
+   *
+   * @param abbreviation
+   *          new abbreviation
+   */
+  void setAbbreviation(String abbreviation);
+
+  /**
+   * Sets formula.
+   *
+   * @param formula
+   *          new formula
+   */
+  void setFormula(String formula);
+
+  /**
+   * Returns the formula.
+   *
+   * @return the formula
+   */
+  String getFormula();
+
+  /**
+   * Sets the name to the object.
+   *
+   * @param name
+   *          name of the object
+   *
+   */
+  void setName(String name);
+
+  /**
+   * Returns database identifier of the object.
+   *
+   * @return database identifier of the object
+   */
+  int getId();
+
+  /**
+   * Return human readable {@link String} representing class.
+   *
+   * @return human readable {@link String} representing class
+   */
+  String getStringType();
+
+  /**
+   * Sets semantic zoom level visibility.
+   *
+   * @param zoomLevelVisibility
+   *          semantic zoom level visibility
+   */
+  void setVisibilityLevel(String zoomLevelVisibility);
+
+  /**
+   * Sets semantic zoom level visibility.
+   *
+   * @param zoomLevelVisibility
+   *          semantic zoom level visibility
+   */
+  void setVisibilityLevel(Integer zoomLevelVisibility);
 
 	/**
 	 * Returns semantic zoom level visibility.
@@ -161,6 +163,14 @@ public interface BioEntity extends Serializable {
 	 * @return semantic zoom level visibility
 	 */
     String getVisibilityLevel();
-    
+
     String getElementId();
+
+  /**
+   * Returns the {@link Model} where BioEntity is located.
+   *
+   * @return the model
+   */
+  Model getModel();
+
 }
diff --git a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java
index e3c6c3187f..5d04e7781c 100644
--- a/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java
+++ b/model/src/main/java/lcsb/mapviewer/model/map/reaction/Reaction.java
@@ -727,12 +727,8 @@ public class Reaction implements BioEntity {
     this.model = model2.getModelData();
   }
 
-  /**
-   * Returns model where reaction is locacted.
-   * 
-   * @return model where reaction is locacted.
-   */
   @XmlTransient
+  @Override
   public Model getModel() {
     return model.getModel();
   }
diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java
index b6a16ea78d..a7e4a20b82 100644
--- a/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java
+++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Element.java
@@ -767,11 +767,8 @@ public abstract class Element implements BioEntity, Serializable {
     this.transparencyLevel = transparencyLevel;
   }
 
-  /**
-   * @return the model
-   * @see #model
-   */
   @XmlTransient
+  @Override
   public Model getModel() {
     return model.getModel();
   }
-- 
GitLab