From f8f4a66f18d3dedcb61da5a5758fb03d09691870 Mon Sep 17 00:00:00 2001 From: "piotr.gawron" <piotr.gawron@uni-new> Date: Wed, 5 Oct 2016 14:25:28 +0200 Subject: [PATCH] model javadoc added and structure refactoried --- .../services/ModelAnnotatorTest.java | 14 +- .../lcsb/mapviewer/run/ConsoleConverter.java | 2 +- .../celldesigner/CellDesignerXmlParser.java | 6 +- .../alias/ComplexAliasXmlParser.java | 2 +- .../alias/SpeciesAliasXmlParser.java | 2 +- .../CellDesignerXmlParserTest.java | 12 +- .../celldesigner/ComplexParserTests.java | 4 +- .../celldesigner/LayerXmlParserTest.java | 10 +- .../alias/SpeciesAliasXmlParserTest.java | 4 +- .../ReactionCollectionXmlParserTest.java | 24 +-- .../reaction/ReactionFromXmlTest.java | 8 +- .../reaction/ReactionParserTests.java | 24 +-- .../reaction/ReactionToXmlTest.java | 8 +- .../species/ComplexParserTest.java | 10 +- .../SpeciesCollectionXmlParserTest.java | 4 +- .../model/sbgnml/SbgnmlXmlParser.java | 6 +- .../graphics/NormalImageGeneratorTest.java | 6 +- .../graphics/PdfImageGeneratorTest.java | 2 +- .../placefinder/AllPlaceFinderTest.java | 24 +-- .../converter/ComplexZipConverterTest.java | 22 +-- .../lcsb/mapviewer/commands/CopyCommand.java | 12 +- .../commands/CreateHierarchyCommand.java | 4 +- .../commands/CommandTestFunctions.java | 4 +- .../mapviewer/commands/CopyCommandTest.java | 10 +- .../lcsb/mapviewer/model/map/MiriamType.java | 13 +- .../lcsb/mapviewer/model/map/model/Model.java | 12 +- .../model/map/model/ModelFullIndexed.java | 47 +++-- .../model/map/species/AntisenseRna.java | 43 ++++- .../map/species/AntisenseRnaComparator.java | 10 +- .../mapviewer/model/map/species/Chemical.java | 15 ++ .../model/map/species/ChemicalComparator.java | 44 ++++- .../mapviewer/model/map/species/Complex.java | 30 +-- .../model/map/species/ComplexComparator.java | 2 +- .../mapviewer/model/map/species/Degraded.java | 26 ++- .../model/map/species/DegradedComparator.java | 8 +- .../mapviewer/model/map/species/Drug.java | 25 ++- .../model/map/species/DrugComparator.java | 14 +- .../mapviewer/model/map/species/Element.java | 174 ++++++++++-------- .../model/map/species/ElementComparator.java | 5 +- .../mapviewer/model/map/species/Gene.java | 40 +++- .../model/map/species/GeneComparator.java | 6 + .../model/map/species/GenericProtein.java | 26 ++- .../map/species/GenericProteinComparator.java | 6 + .../lcsb/mapviewer/model/map/species/Ion.java | 26 ++- .../model/map/species/IonChannelProtein.java | 26 ++- .../species/IonChannelProteinComparator.java | 6 + .../model/map/species/IonComparator.java | 12 +- .../model/map/species/Phenotype.java | 25 ++- .../map/species/PhenotypeComparator.java | 6 + .../mapviewer/model/map/species/Protein.java | 28 ++- .../model/map/species/ProteinComparator.java | 33 ++-- .../model/map/species/ReceptorProtein.java | 25 ++- .../species/ReceptorProteinComparator.java | 6 + .../lcsb/mapviewer/model/map/species/Rna.java | 42 ++++- .../model/map/species/RnaComparator.java | 6 + .../model/map/species/SimpleMolecule.java | 26 ++- .../map/species/SimpleMoleculeComparator.java | 32 +--- .../mapviewer/model/map/species/Species.java | 37 ++-- .../model/map/species/SpeciesComparator.java | 117 ++++++++---- .../model/map/species/TruncatedProtein.java | 25 ++- .../species/TruncatedProteinComparator.java | 14 +- .../mapviewer/model/map/species/Unknown.java | 25 ++- .../model/map/species/UnknownComparator.java | 14 +- .../mapviewer/model/map/MiriamTypeTest.java | 19 +- .../BottomSquareCompartmentTest.java | 12 +- .../map/compartment/CompartmentTest.java | 33 ++-- .../LeftSquareCompartmentTest.java | 12 +- .../map/compartment/OvalCompartmentTest.java | 15 +- .../RightSquareCompartmentTest.java | 16 +- .../compartment/SquareCompartmentTest.java | 11 +- .../compartment/TopSquareCompartmentTest.java | 10 +- ...AliasSubmodelConnectionComparatorTest.java | 6 +- .../model/map/model/ModelComparatorTest.java | 22 +-- .../model/map/model/ModelFullIndexedTest.java | 146 +++++++++++---- ...ModelSubmodelConnectionComparatorTest.java | 4 +- .../mapviewer/model/map/model/ModelTest.java | 28 +-- .../SubmodelConnectionComparatorTest.java | 4 +- .../reaction/NodeOperatorComparatorTest.java | 8 + .../model/map/species/AllSpeciesTests.java | 6 + .../species/AntisenseRnaComparatorTest.java | 13 +- .../model/map/species/AntisenseRnaTest.java | 10 +- .../map/species/ChemicalComparatorTest.java | 84 +++++++++ .../map/species/ComplexComparatorTest.java | 38 +--- .../model/map/species/ComplexTest.java | 40 +++- .../map/species/DegradedComparatorTest.java | 10 +- .../model/map/species/DegradedTest.java | 64 ++++++- .../model/map/species/DrugComparatorTest.java | 10 +- .../mapviewer/model/map/species/DrugTest.java | 10 +- .../map/species/ElementComparatorTest.java | 6 +- .../model/map/species/GeneComparatorTest.java | 10 +- .../mapviewer/model/map/species/GeneTest.java | 10 +- .../species/GenericProteinComparatorTest.java | 84 +++++++++ .../model/map/species/GenericProteinTest.java | 10 +- .../IonChannelProteinComparatorTest.java | 84 +++++++++ .../model/map/species/IonComparatorTest.java | 10 +- .../mapviewer/model/map/species/IonTest.java | 10 +- .../map/species/PhenotypeComparatorTest.java | 13 +- .../model/map/species/PhenotypeTest.java | 34 +++- .../map/species/ProteinComparatorTest.java | 110 ++++++----- .../ReceptorProteinComparatorTest.java | 84 +++++++++ .../map/species/ReceptorProteinTest.java | 10 +- .../model/map/species/RnaComparatorTest.java | 10 +- .../mapviewer/model/map/species/RnaTest.java | 10 +- .../species/SimpleMoleculeComparatorTest.java | 14 +- .../model/map/species/SimpleMoleculeTest.java | 10 +- .../map/species/SpeciesComparatorTest.java | 3 - .../TruncatedProteinComparatorTest.java | 84 +++++++++ .../map/species/TruncatedProteinTest.java | 10 +- .../map/species/UnknownComparatorTest.java | 10 +- .../model/map/species/UnknownTest.java | 10 +- .../modelutils/map/ElementUtilsTest.java | 36 ++++ .../wikipathway/XML/ModelContructor.java | 10 +- .../wikipathway/XML/ModelToGPMLTest.java | 2 +- .../mapviewer/persist/dao/ProjectDaoTest.java | 16 +- .../persist/dao/map/CommentDaoTest.java | 18 +- .../persist/dao/map/LayoutDaoTest.java | 18 +- .../persist/dao/map/ModelDaoTest.java | 20 +- .../dao/map/graph/DataMiningDaoTest.java | 2 +- .../dao/map/layout/alias/AliasDaoTest.java | 16 +- .../map/layout/alias/AntisenseRnaTest.java | 2 +- .../persist/dao/map/layout/alias/RnaTest.java | 2 +- .../services/impl/SearchServiceTest.java | 8 +- .../search/data/FullAliasViewFactoryTest.java | 8 +- .../search/db/drug/DrugViewFactoryTest.java | 2 +- 124 files changed, 1860 insertions(+), 868 deletions(-) create mode 100644 model/src/test/java/lcsb/mapviewer/model/map/species/ChemicalComparatorTest.java create mode 100644 model/src/test/java/lcsb/mapviewer/model/map/species/GenericProteinComparatorTest.java create mode 100644 model/src/test/java/lcsb/mapviewer/model/map/species/IonChannelProteinComparatorTest.java create mode 100644 model/src/test/java/lcsb/mapviewer/model/map/species/ReceptorProteinComparatorTest.java create mode 100644 model/src/test/java/lcsb/mapviewer/model/map/species/TruncatedProteinComparatorTest.java diff --git a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java index b75019e872..b920636e1d 100644 --- a/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java +++ b/annotation/src/test/java/lcsb/mapviewer/annotation/services/ModelAnnotatorTest.java @@ -80,8 +80,8 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { proteinAlias2.setName("PDK1"); proteinAlias2.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CAS, "c")); - model.addAlias(proteinAlias1); - model.addAlias(proteinAlias2); + model.addElement(proteinAlias1); + model.addElement(proteinAlias2); modelAnnotator.annotateModel(model, updater, null); @@ -100,12 +100,12 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { Model model = new ModelFullIndexed(null); GenericProtein species = new GenericProtein("id1"); species.setName("SNCA"); - model.addAlias(species); + model.addElement(species); GenericProtein species2 = new GenericProtein("id2"); species2.setName("PDK1"); species2.addMiriamData(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CAS, "c")); - model.addAlias(species2); + model.addElement(species2); model.addReaction(new Reaction()); Map<Class<?>, List<ElementAnnotator>> annotators = new HashMap<>(); @@ -305,9 +305,9 @@ public class ModelAnnotatorTest extends AnnotationTestFunctions { model.addSubmodelConnection(new ModelSubmodelConnection(submodel, SubmodelType.UNKNOWN)); model.addSubmodelConnection(new ModelSubmodelConnection(submodel2, SubmodelType.UNKNOWN)); - model.addAlias(protein); - submodel.addAlias(protein); - submodel2.addAlias(protein); + model.addElement(protein); + submodel.addElement(protein); + submodel2.addElement(protein); final MutableDouble maxProgress = new MutableDouble(0.0); diff --git a/console/src/main/java/lcsb/mapviewer/run/ConsoleConverter.java b/console/src/main/java/lcsb/mapviewer/run/ConsoleConverter.java index 3a237968f4..badffff4c3 100644 --- a/console/src/main/java/lcsb/mapviewer/run/ConsoleConverter.java +++ b/console/src/main/java/lcsb/mapviewer/run/ConsoleConverter.java @@ -130,7 +130,7 @@ public class ConsoleConverter { double angle = x / size * 2 * Math.PI; alias.setX(middleX + Math.sin(angle) * inputOptions.getRadius()); alias.setY(middleY + Math.cos(angle) * inputOptions.getRadius()); - model.addAlias(alias); + model.addElement(alias); x++; } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java index cce1a06bd6..7badb62f75 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParser.java @@ -414,7 +414,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { List<Compartment> aliases = aliasCollectionParser.parseXmlCompartmentAliasCollection(listOfComparmentAlias); for (Element alias : aliases) { rap.processNotes(alias); - model.addAlias(alias); + model.addElement(alias); } } @@ -454,7 +454,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { List<Complex> aliases = aliasCollectionParser.parseXmlComplexAliasCollection(listOfComplexSpeciesAlias); for (Element alias : aliases) { rap.processNotes(alias); - model.addAlias(alias); + model.addElement(alias); } } @@ -462,7 +462,7 @@ public class CellDesignerXmlParser extends XmlParser implements IConverter { List<Species> aliases = aliasCollectionParser.parseXmlSpeciesAliasCollection(listofSpeciesAlias); for (Element alias : aliases) { rap.processNotes(alias); - model.addAlias(alias); + model.addElement(alias); } } diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/ComplexAliasXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/ComplexAliasXmlParser.java index e4d207986e..57f6280526 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/ComplexAliasXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/ComplexAliasXmlParser.java @@ -140,7 +140,7 @@ public class ComplexAliasXmlParser extends AbstractAliasXmlParser<Complex> { result.setState(state); String compartmentAliasId = getNodeAttr("compartmentAlias", aliasNode); if (!compartmentAliasId.isEmpty()) { - Compartment ca = model.getCompartmentAliasByCompartmentAliasId(compartmentAliasId); + Compartment ca = model.getElementByElementId(compartmentAliasId); if (ca == null) { throw new InvalidXmlSchemaException("CompartmentAlias does not exist: " + compartmentAliasId); } else { diff --git a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParser.java b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParser.java index 29e9294458..7b2e486120 100644 --- a/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParser.java +++ b/converter-CellDesigner/src/main/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParser.java @@ -111,7 +111,7 @@ public class SpeciesAliasXmlParser extends AbstractAliasXmlParser<Species> { result.setState(state); String compartmentAliasId = getNodeAttr("compartmentAlias", aliasNode); if (!compartmentAliasId.isEmpty()) { - Compartment ca = model.getCompartmentAliasByCompartmentAliasId(compartmentAliasId); + Compartment ca = model.getElementByElementId(compartmentAliasId); if (ca == null) { throw new InvalidXmlSchemaException("CompartmentAlias does not exist: " + compartmentAliasId); } else { diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParserTest.java index 4f05057943..7c2638d7d4 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/CellDesignerXmlParserTest.java @@ -453,22 +453,22 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions { rap.processNotes( "Symbol: ROS1\r\nName: c-ros oncogene 1 , receptor tyrosine kinase\r\nDescription: RecName: Full=Proto-oncogene tyrosine-protein kinase ROS; EC=2.7.10.1; AltName: Full=Proto-oncogene c-Ros; AltName: Full=Proto-oncogene c-Ros-1; AltName: Full=Receptor tyrosine kinase c-ros oncogene 1; AltName: Full=c-Ros receptor tyrosine kinase; Flags: Precursor;\r\nPrevious Symbols:\r\nSynonyms: ROS, MCF3", speciesAlias); - model.addAlias(speciesAlias); + model.addElement(speciesAlias); GenericProtein alias = new GenericProtein("id"); alias.setName("ROS"); - model.addAlias(alias); + model.addElement(alias); SimpleMolecule speciesAlias2 = new SimpleMolecule("id2"); speciesAlias2.setName("PDK1"); rap.processNotes( "Symbol: ROS1\r\nName: c-ros oncogene 1 , receptor tyrosine kinase\r\nDescription: RecName: Full=Proto-oncogene tyrosine-protein kinase ROS; EC=2.7.10.1; AltName: Full=Proto-oncogene c-Ros; AltName: Full=Proto-oncogene c-Ros-1; AltName: Full=Receptor tyrosine kinase c-ros oncogene 1; AltName: Full=c-Ros receptor tyrosine kinase; Flags: Precursor;\r\nPrevious Symbols:\r\nSynonyms: ROS, MCF3", speciesAlias2); - model.addAlias(speciesAlias2); + model.addElement(speciesAlias2); SimpleMolecule alias2 = new SimpleMolecule("id3"); alias2.setName("PDK1"); - model.addAlias(alias2); + model.addElement(alias2); CellDesignerXmlParser parser = new CellDesignerXmlParser(); String xmlString = parser.toXml(model); @@ -521,7 +521,7 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions { model.setIdModel("id"); Species alias = new GenericProtein("a"); alias.setName("AA"); - model.addAlias(alias); + model.addElement(alias); parser.toXml(model); } catch (Exception e) { @@ -806,7 +806,7 @@ public class CellDesignerXmlParserTest extends CellDesignerTestFunctions { model.setHeight(100); Gene gene = new Gene("gene_id_1"); gene.setName("geneNAME"); - model.addAlias(gene); + model.addElement(gene); String xmlString = parser.toXml(model); assertTrue(xmlString.contains("gene_id_1")); assertTrue(xmlString.contains("geneNAME")); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ComplexParserTests.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ComplexParserTests.java index 53828971c0..dc31440d59 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ComplexParserTests.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/ComplexParserTests.java @@ -256,7 +256,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { model.setHeight(100); GenericProtein alias = new GenericProtein("aid"); alias.setName("name & no-name"); - model.addAlias(alias); + model.addElement(alias); CellDesignerXmlParser parser = new CellDesignerXmlParser(); String string = parser.toXml(model); @@ -286,7 +286,7 @@ public class ComplexParserTests extends CellDesignerTestFunctions { model.setHeight(100); GenericProtein alias = new GenericProtein("aid"); alias.setName("name\rno-name"); - model.addAlias(alias); + model.addElement(alias); CellDesignerXmlParser parser = new CellDesignerXmlParser(); String string = parser.toXml(model); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/LayerXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/LayerXmlParserTest.java index 2353bd3dc5..c653991cf3 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/LayerXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/LayerXmlParserTest.java @@ -148,7 +148,7 @@ public class LayerXmlParserTest extends CellDesignerTestFunctions { try { Model model = new ModelFullIndexed(null); GenericProtein alias = new GenericProtein("sa1"); - model.addAlias(alias); + model.addElement(alias); String xmlString = readFile("testFiles/invalid/group_collection3.xml"); Node node = getNodeFromXmlString(xmlString); @@ -409,16 +409,16 @@ public class LayerXmlParserTest extends CellDesignerTestFunctions { try { Model model = new ModelFullIndexed(null); Species alias = new GenericProtein("sa1035"); - model.addAlias(alias); + model.addElement(alias); alias = new GenericProtein("sa1036"); - model.addAlias(alias); + model.addElement(alias); alias = new GenericProtein("sa1037"); - model.addAlias(alias); + model.addElement(alias); alias = new GenericProtein("sa1038"); - model.addAlias(alias); + model.addElement(alias); String string = "<celldesigner:group id=\"g74\" members=\"sa1035,sa1036,sa1037,sa1038\"/>"; Node node = getNodeFromXmlString(string); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParserTest.java index 90cc28dac5..d60228eb0a 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/alias/SpeciesAliasXmlParserTest.java @@ -56,7 +56,7 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { private Model createStubModel() { Model model = new ModelFullIndexed(null); - model.addAlias(new Compartment("ca1")); + model.addElement(new Compartment("ca1")); return model; } @@ -308,7 +308,7 @@ public class SpeciesAliasXmlParserTest extends CellDesignerTestFunctions { alias.setActivity(true); elements.addElement(new CellDesignerComplexSpecies(testSpeciesId)); - model.addAlias(alias); + model.addElement(alias); SpeciesAliasXmlParser parser = new SpeciesAliasXmlParser(elements, model); String xml = parser.toXml(alias); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParserTest.java index 269ea1ad7b..cd73ccc96c 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionCollectionXmlParserTest.java @@ -104,84 +104,84 @@ public class ReactionCollectionXmlParserTest extends CellDesignerTestFunctions { sa1.setY(200.0); sa1.setWidth(300.0); sa1.setHeight(400.0); - model.addAlias(sa1); + model.addElement(sa1); Species sa2 = new GenericProtein("sa2"); sa2.setX(1050.0); sa2.setY(2050.0); sa2.setWidth(300.0); sa2.setHeight(450.0); - model.addAlias(sa2); + model.addElement(sa2); Species sa3 = new GenericProtein("sa3"); sa3.setX(600.0); sa3.setY(250.0); sa3.setWidth(300.0); sa3.setHeight(400.0); - model.addAlias(sa3); + model.addElement(sa3); Species sa4 = new GenericProtein("sa4"); sa4.setX(550.0); sa4.setY(350.0); sa4.setWidth(300.0); sa4.setHeight(450.0); - model.addAlias(sa4); + model.addElement(sa4); Species sa5 = new GenericProtein("sa5"); sa5.setX(10.0); sa5.setY(250.0); sa5.setWidth(300.0); sa5.setHeight(450.0); - model.addAlias(sa5); + model.addElement(sa5); Species sa6 = new GenericProtein("sa6"); sa6.setX(10.0); sa6.setY(250.0); sa6.setWidth(300.0); sa6.setHeight(450.0); - model.addAlias(sa6); + model.addElement(sa6); Species sa10 = new GenericProtein("sa10"); sa10.setX(210.0); sa10.setY(220.0); sa10.setWidth(320.0); sa10.setHeight(250.0); - model.addAlias(sa10); + model.addElement(sa10); Species sa11 = new GenericProtein("sa11"); sa11.setX(11.0); sa11.setY(320.0); sa11.setWidth(321.0); sa11.setHeight(150.0); - model.addAlias(sa11); + model.addElement(sa11); Species sa12 = new GenericProtein("sa12"); sa12.setX(12.0); sa12.setY(20.0); sa12.setWidth(321.0); sa12.setHeight(150.0); - model.addAlias(sa12); + model.addElement(sa12); Species sa13 = new GenericProtein("sa13"); sa13.setX(513.0); sa13.setY(20.0); sa13.setWidth(321.0); sa13.setHeight(150.0); - model.addAlias(sa13); + model.addElement(sa13); Species sa14 = new GenericProtein("sa14"); sa14.setX(14.0); sa14.setY(820.0); sa14.setWidth(321.0); sa14.setHeight(150.0); - model.addAlias(sa14); + model.addElement(sa14); Species sa15 = new GenericProtein("sa15"); sa15.setX(815.0); sa15.setY(620.0); sa15.setWidth(321.0); sa15.setHeight(150.0); - model.addAlias(sa15); + model.addElement(sa15); return model; } diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXmlTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXmlTest.java index 9e568dd336..cc85c6f0e7 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXmlTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionFromXmlTest.java @@ -38,16 +38,16 @@ public class ReactionFromXmlTest extends CellDesignerTestFunctions { parser = new ReactionXmlParser(elements); Species alias = new GenericProtein("sa1"); - model.addAlias(alias); + model.addElement(alias); alias = new GenericProtein("sa2"); - model.addAlias(alias); + model.addElement(alias); alias = new GenericProtein("sa3"); - model.addAlias(alias); + model.addElement(alias); alias = new GenericProtein("sa4"); - model.addAlias(alias); + model.addElement(alias); elements.addElement(new CellDesignerGenericProtein("s1")); elements.addElement(new CellDesignerGenericProtein("s2")); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionParserTests.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionParserTests.java index c9f057780d..82e37d7d14 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionParserTests.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionParserTests.java @@ -1550,7 +1550,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions { sa1.setY(200.0); sa1.setWidth(300.0); sa1.setHeight(400.0); - model.addAlias(sa1); + model.addElement(sa1); elements.addAlias(sa1, new CellDesignerGenericProtein("s1")); Species sa2 = new GenericProtein("sa2"); @@ -1558,7 +1558,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions { sa2.setY(2050.0); sa2.setWidth(300.0); sa2.setHeight(450.0); - model.addAlias(sa2); + model.addElement(sa2); elements.addAlias(sa2, new CellDesignerGenericProtein("s2")); Species sa3 = new GenericProtein("sa3"); @@ -1566,7 +1566,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions { sa3.setY(250.0); sa3.setWidth(300.0); sa3.setHeight(400.0); - model.addAlias(sa3); + model.addElement(sa3); elements.addAlias(sa3, new CellDesignerGenericProtein("s3")); Species sa4 = new GenericProtein("sa4"); @@ -1574,7 +1574,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions { sa4.setY(350.0); sa4.setWidth(300.0); sa4.setHeight(450.0); - model.addAlias(sa4); + model.addElement(sa4); elements.addElement(new CellDesignerGenericProtein("s4")); Species sa5 = new GenericProtein("sa5"); @@ -1582,7 +1582,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions { sa5.setY(250.0); sa5.setWidth(300.0); sa5.setHeight(450.0); - model.addAlias(sa5); + model.addElement(sa5); elements.addElement(new CellDesignerGenericProtein("s5")); Species sa6 = new GenericProtein("sa6"); @@ -1590,7 +1590,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions { sa6.setY(250.0); sa6.setWidth(300.0); sa6.setHeight(450.0); - model.addAlias(sa6); + model.addElement(sa6); elements.addElement(new CellDesignerGenericProtein("s6")); @@ -1599,7 +1599,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions { sa10.setY(220.0); sa10.setWidth(320.0); sa10.setHeight(250.0); - model.addAlias(sa10); + model.addElement(sa10); elements.addElement(new CellDesignerGenericProtein("s10")); Species sa11 = new GenericProtein("sa11"); @@ -1607,7 +1607,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions { sa11.setY(320.0); sa11.setWidth(321.0); sa11.setHeight(150.0); - model.addAlias(sa11); + model.addElement(sa11); elements.addElement(new CellDesignerGenericProtein("s11")); Species sa12 = new GenericProtein("sa12"); @@ -1615,7 +1615,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions { sa12.setY(20.0); sa12.setWidth(321.0); sa12.setHeight(150.0); - model.addAlias(sa12); + model.addElement(sa12); elements.addElement(new CellDesignerGenericProtein("s12")); Species sa13 = new GenericProtein("sa13"); @@ -1623,7 +1623,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions { sa13.setY(20.0); sa13.setWidth(321.0); sa13.setHeight(150.0); - model.addAlias(sa13); + model.addElement(sa13); elements.addElement(new CellDesignerGenericProtein("s13")); Species sa14 = new GenericProtein("sa14"); @@ -1631,7 +1631,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions { sa14.setY(820.0); sa14.setWidth(321.0); sa14.setHeight(150.0); - model.addAlias(sa14); + model.addElement(sa14); elements.addElement(new CellDesignerGenericProtein("s14")); Species sa15 = new GenericProtein("sa15"); @@ -1639,7 +1639,7 @@ public class ReactionParserTests extends CellDesignerTestFunctions { sa15.setY(620.0); sa15.setWidth(321.0); sa15.setHeight(150.0); - model.addAlias(sa15); + model.addElement(sa15); elements.addElement(new CellDesignerGenericProtein("s15")); return model; diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXmlTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXmlTest.java index 09d2068026..6599085012 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXmlTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/reaction/ReactionToXmlTest.java @@ -58,7 +58,7 @@ public class ReactionToXmlTest { Model model = new ModelFullIndexed(null); Species alias = new GenericProtein("2"); - model.addAlias(alias); + model.addElement(alias); Reaction reaction = new TransportReaction(); @@ -115,7 +115,7 @@ public class ReactionToXmlTest { Model model = new ModelFullIndexed(null); Species alias = new GenericProtein("2"); - model.addAlias(alias); + model.addElement(alias); Complex complex = new Complex("4"); complex.addAlias(alias); @@ -123,7 +123,7 @@ public class ReactionToXmlTest { alias.setParent(complex); alias.setComplexAlias(complex); - model.addAlias(complex); + model.addElement(complex); Reaction reaction = new TransportReaction(); @@ -152,7 +152,7 @@ public class ReactionToXmlTest { Model model = new ModelFullIndexed(null); Species alias = new GenericProtein("2"); - model.addAlias(alias); + model.addElement(alias); Reaction reaction = new Reaction(); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ComplexParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ComplexParserTest.java index 9416efdc86..80dc4c55f2 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ComplexParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/ComplexParserTest.java @@ -170,7 +170,7 @@ public class ComplexParserTest extends CellDesignerTestFunctions { alias.setParent(ca); - model.addAlias(alias); + model.addElement(alias); ComplexAliasXmlParser parser = new ComplexAliasXmlParser(elements, model); String xml = parser.toXml(alias); @@ -195,7 +195,7 @@ public class ComplexParserTest extends CellDesignerTestFunctions { alias.setCompartmentAlias(ca); - model.addAlias(alias); + model.addElement(alias); ComplexAliasXmlParser parser = new ComplexAliasXmlParser(elements, model); String xml = parser.toXml(alias); @@ -243,7 +243,7 @@ public class ComplexParserTest extends CellDesignerTestFunctions { alias.setHeight(100); alias.setModel(model); - model.addAlias(alias); + model.addElement(alias); ComplexAliasXmlParser parser = new ComplexAliasXmlParser(elements, model); String xml = parser.toXml(alias); @@ -268,7 +268,7 @@ public class ComplexParserTest extends CellDesignerTestFunctions { alias.setParent(ca); - model.addAlias(alias); + model.addElement(alias); ComplexAliasXmlParser parser = new ComplexAliasXmlParser(elements, model); String xml = parser.toXml(alias); @@ -291,7 +291,7 @@ public class ComplexParserTest extends CellDesignerTestFunctions { alias.setActivity(true); - model.addAlias(alias); + model.addElement(alias); ComplexAliasXmlParser parser = new ComplexAliasXmlParser(elements, model); String xml = parser.toXml(alias); diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionXmlParserTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionXmlParserTest.java index ca6b5b5173..0357a7fdef 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionXmlParserTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/species/SpeciesCollectionXmlParserTest.java @@ -311,10 +311,10 @@ public class SpeciesCollectionXmlParserTest extends CellDesignerTestFunctions { species.setModel(model); Species alias = species.createAlias("alias" + (x++)); - model.addAlias(alias); + model.addElement(alias); speciesList.add(alias); } - model.addAlias(new Compartment("default")); + model.addElement(new Compartment("default")); String convertedString = parser.speciesCollectionToSbmlString(speciesList); assertNotNull(convertedString); node = getNodeFromXmlString(convertedString); diff --git a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java index 14c9a29591..0383f44f69 100644 --- a/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java +++ b/converter-SBGNML/src/main/java/lcsb/mapviewer/converter/model/sbgnml/SbgnmlXmlParser.java @@ -645,7 +645,7 @@ public class SbgnmlXmlParser { if (g.getCompartmentRef() != null) { Glyph compartmentGlyph = (Glyph) g.getCompartmentRef(); - Compartment compartmentAlias = model.getCompartmentAliasByCompartmentAliasId(compartmentGlyph.getId()); + Compartment compartmentAlias = model.getElementByElementId(compartmentGlyph.getId()); newAlias.setParent(compartmentAlias); newAlias.setCompartmentAlias(compartmentAlias); compartmentAlias.addElement(newAlias); @@ -671,7 +671,7 @@ public class SbgnmlXmlParser { } } - model.addAlias(newAlias); + model.addElement(newAlias); } /** @@ -1504,6 +1504,6 @@ public class SbgnmlXmlParser { compAlias.getX() + compAlias.getThickness() + CONTAINER_NAME_MARGIN, compAlias.getY() + compAlias.getThickness() + CONTAINER_NAME_MARGIN); } - model.addAlias(compAlias); + model.addElement(compAlias); } } diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/NormalImageGeneratorTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/NormalImageGeneratorTest.java index 96d8113bbb..d2f9ef6899 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/NormalImageGeneratorTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/NormalImageGeneratorTest.java @@ -90,7 +90,7 @@ public class NormalImageGeneratorTest { alias.setY(10); alias.setWidth(200); alias.setHeight(50); - model.addAlias(alias); + model.addElement(alias); Species a2 = new GenericProtein("2"); a2.setName("b"); @@ -99,7 +99,7 @@ public class NormalImageGeneratorTest { a2.setWidth(200); a2.setHeight(50); a2.setFontSize(30); - model.addAlias(a2); + model.addElement(a2); return model; } @@ -155,7 +155,7 @@ public class NormalImageGeneratorTest { alias.setY(90); alias.setWidth(100); alias.setHeight(50); - model.addAlias(alias); + model.addElement(alias); return model; } diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/PdfImageGeneratorTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/PdfImageGeneratorTest.java index a69271674f..86428c73d4 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/PdfImageGeneratorTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/PdfImageGeneratorTest.java @@ -94,7 +94,7 @@ public class PdfImageGeneratorTest { alias.setY(90); alias.setWidth(100); alias.setHeight(50); - model.addAlias(alias); + model.addElement(alias); return model; } diff --git a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/placefinder/AllPlaceFinderTest.java b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/placefinder/AllPlaceFinderTest.java index aee2aa52a3..15dd6e4f68 100644 --- a/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/placefinder/AllPlaceFinderTest.java +++ b/converter-graphics/src/test/java/lcsb/mapviewer/converter/graphics/placefinder/AllPlaceFinderTest.java @@ -27,7 +27,7 @@ public class AllPlaceFinderTest { public void oneEmptyCompartments() throws InvalidXmlSchemaException, IOException { String actual = null; Model model = new ModelFullIndexed(null); - model.addAlias(createCompartmentAlias(94.0, 70.0, 355.0, 173.0)); + model.addElement(createCompartmentAlias(94.0, 70.0, 355.0, 173.0)); for (Compartment alias : model.getCompartmentsAliases()) { PlaceFinder pf = new PlaceFinder(model); @@ -43,8 +43,8 @@ public class AllPlaceFinderTest { public void twoSeparatedCompartments() throws InvalidXmlSchemaException, IOException { String actual = null; Model model = new ModelFullIndexed(null); - model.addAlias(createCompartmentAlias(70.0, 81.0, 229.0, 213.0)); - model.addAlias(createCompartmentAlias(332.0, 66.0, 188.0, 255.0)); + model.addElement(createCompartmentAlias(70.0, 81.0, 229.0, 213.0)); + model.addElement(createCompartmentAlias(332.0, 66.0, 188.0, 255.0)); String expected = ""; for (Compartment alias : model.getCompartmentsAliases()) { @@ -60,9 +60,9 @@ public class AllPlaceFinderTest { public void twoIntersectingCompartments() throws InvalidXmlSchemaException, IOException { Model model = new ModelFullIndexed(null); Compartment alias = createCompartmentAlias(87.0, 56.0, 235.0, 219.0); - model.addAlias(alias); + model.addElement(alias); Compartment alias2 = createCompartmentAlias(227.0, 17.0, 290.0, 317.0); - model.addAlias(alias2); + model.addElement(alias2); PlaceFinder pf = new PlaceFinder(model); Rectangle2D rect = pf.getRetangle(alias2); @@ -74,8 +74,8 @@ public class AllPlaceFinderTest { @Test public void oneCompartmentCompletlyOverlapSecondOne() throws InvalidXmlSchemaException, IOException { Model model = new ModelFullIndexed(null); - model.addAlias(createCompartmentAlias(45.0, 38.0, 174.0, 169.0)); - model.addAlias(createCompartmentAlias(118.0, 85.0, 60.0, 68.0)); + model.addElement(createCompartmentAlias(45.0, 38.0, 174.0, 169.0)); + model.addElement(createCompartmentAlias(118.0, 85.0, 60.0, 68.0)); double actual = 0.0; for (Compartment alias : model.getCompartmentsAliases()) { PlaceFinder pf = new PlaceFinder(model); @@ -88,9 +88,9 @@ public class AllPlaceFinderTest { @Test public void perfectOverlapingOfThreeCompartments() throws InvalidXmlSchemaException, IOException { Model model = new ModelFullIndexed(null); - model.addAlias(createCompartmentAlias(226.0, 70.0, 138.0, 112.0)); - model.addAlias(createCompartmentAlias(163.0, 70.0, 138.0, 112.0)); - model.addAlias(createCompartmentAlias(88.0, 70.0, 138.0, 112.0)); + model.addElement(createCompartmentAlias(226.0, 70.0, 138.0, 112.0)); + model.addElement(createCompartmentAlias(163.0, 70.0, 138.0, 112.0)); + model.addElement(createCompartmentAlias(88.0, 70.0, 138.0, 112.0)); double actual = 0.0; Rectangle2D result = null; for (Compartment alias : model.getCompartmentsAliases()) { @@ -133,8 +133,8 @@ public class AllPlaceFinderTest { @Test public void problematic() throws InvalidXmlSchemaException, IOException { Model model = new ModelFullIndexed(null); - model.addAlias(createCompartmentAlias(4521.0, 0.0, 10000.0, 6000.0)); - model.addAlias(createCompartmentAlias(4828.0, 0.0, 5172.0, 6000.0)); + model.addElement(createCompartmentAlias(4521.0, 0.0, 10000.0, 6000.0)); + model.addElement(createCompartmentAlias(4828.0, 0.0, 5172.0, 6000.0)); double actual = 0.0; for (Compartment alias : model.getCompartmentsAliases()) { PlaceFinder pf = new PlaceFinder(model); diff --git a/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java b/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java index 62f7709fc9..cc87a72141 100644 --- a/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java +++ b/converter/src/test/java/lcsb/mapviewer/converter/ComplexZipConverterTest.java @@ -60,44 +60,44 @@ public class ComplexZipConverterTest { Model result = new ModelFullIndexed(null); Species sa1 = new GenericProtein("sa1"); - result.addAlias(sa1); + result.addElement(sa1); Species sa2 = new GenericProtein("sa2"); - result.addAlias(sa2); + result.addElement(sa2); Species sa3 = new GenericProtein("sa3"); - result.addAlias(sa3); + result.addElement(sa3); Species sa4 = new Phenotype("sa4"); - result.addAlias(sa4); + result.addElement(sa4); Complex ca1 = new Complex("ca1"); ca1.setName("main"); - result.addAlias(ca1); + result.addElement(ca1); Species sa5 = new GenericProtein("sa5"); sa5.setName("sa1"); - result.addAlias(sa5); + result.addElement(sa5); ca1.addAlias(sa5); Species sa6 = new Phenotype("sa6"); sa6.setName("sa4"); - result.addAlias(sa6); + result.addElement(sa6); ca1.addAlias(sa6); Complex ca2 = new Complex("ca2"); ca2.setName("s1"); - result.addAlias(ca2); + result.addElement(ca2); Species sa7 = new GenericProtein("sa7"); sa7.setName("sa1"); - result.addAlias(sa7); + result.addElement(sa7); ca2.addAlias(sa7); Complex ca3 = new Complex("cs3"); ca3.setName("s2"); - result.addAlias(ca3); + result.addElement(ca3); Complex ca4 = new Complex("cs4"); ca4.setName("s3"); - result.addAlias(ca4); + result.addElement(ca4); Reaction r1 = new TransportReaction(); r1.addReactant(new Reactant(sa5)); diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/CopyCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/CopyCommand.java index 70253198c1..fbab64735f 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/CopyCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/CopyCommand.java @@ -178,7 +178,7 @@ public class CopyCommand extends NewModelCommand { if (alias instanceof Compartment) { Compartment copy = ((Compartment) alias).copy(); copy.getElements().clear(); - result.addAlias(copy); + result.addElement(copy); } } @@ -194,15 +194,15 @@ public class CopyCommand extends NewModelCommand { // the trick is that in addAlias also some connections are added, so // lets clear info about parents - result.addAlias(copy); + result.addElement(copy); if (ca != null) { - ca = result.getCompartmentAliasByCompartmentAliasId(ca.getElementId()); + ca = result.getElementByElementId(ca.getElementId()); copy.setCompartmentAlias(ca); } if (parent instanceof Compartment) { ca = (Compartment) parent; - ca = result.getCompartmentAliasByCompartmentAliasId(ca.getElementId()); + ca = result.getElementByElementId(ca.getElementId()); copy.setParent(ca); } } else if (alias instanceof Compartment) { @@ -367,7 +367,7 @@ public class CopyCommand extends NewModelCommand { private void updateAliasReferences(Element alias, Model model, Model originalModel) { if (alias instanceof Compartment) { Compartment compartmentAlias = (Compartment) alias; - Compartment original = originalModel.getCompartmentAliasByCompartmentAliasId(alias.getElementId()); + Compartment original = originalModel.getElementByElementId(alias.getElementId()); for (Element a : original.getElements()) { compartmentAlias.addElement(model.getElementByElementId(a.getElementId())); } @@ -402,7 +402,7 @@ public class CopyCommand extends NewModelCommand { alias.setModel(model); if (alias.getCompartmentAlias() != null) { - alias.setCompartmentAlias(model.getCompartmentAliasByCompartmentAliasId(alias.getCompartmentAlias().getElementId())); + alias.setCompartmentAlias(model.getElementByElementId(alias.getCompartmentAlias().getElementId())); } } } diff --git a/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java b/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java index 98ff78e39a..14ec54cc19 100644 --- a/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java +++ b/model-command/src/main/java/lcsb/mapviewer/commands/CreateHierarchyCommand.java @@ -157,7 +157,7 @@ public class CreateHierarchyCommand extends ModelCommand { alias.setNamePoint( new Point2D.Double(rect.getX() + DEFAULT_TITLE_X_COORD_IN_ARTIFITIAL_COMPARTMENT, rect.getY() + DEFAULT_TITLE_Y_COORD_IN_ARTIFITIAL_COMPARTMENT)); - model.addAlias(alias); + model.addElement(alias); } for (LayerText text : layer.getTexts()) { PathwayCompartment alias = new PathwayCompartment("art" + (id++)); @@ -170,7 +170,7 @@ public class CreateHierarchyCommand extends ModelCommand { alias.setNamePoint( new Point2D.Double(text.getX() + DEFAULT_TITLE_X_COORD_IN_ARTIFITIAL_COMPARTMENT, text.getY() + DEFAULT_TITLE_Y_COORD_IN_ARTIFITIAL_COMPARTMENT)); - model.addAlias(alias); + model.addElement(alias); } } diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/CommandTestFunctions.java b/model-command/src/test/java/lcsb/mapviewer/commands/CommandTestFunctions.java index 685dc44f7c..0ca7374b24 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/CommandTestFunctions.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/CommandTestFunctions.java @@ -53,11 +53,11 @@ public abstract class CommandTestFunctions { alias.setFormerSymbols(list2); Complex complexAlias = new Complex("complex_alias_id"); - model.addAlias(complexAlias); + model.addElement(complexAlias); complexAlias.addAlias(alias); - model.addAlias(alias); + model.addElement(alias); return model; } diff --git a/model-command/src/test/java/lcsb/mapviewer/commands/CopyCommandTest.java b/model-command/src/test/java/lcsb/mapviewer/commands/CopyCommandTest.java index 6336703fe6..cf881e785b 100644 --- a/model-command/src/test/java/lcsb/mapviewer/commands/CopyCommandTest.java +++ b/model-command/src/test/java/lcsb/mapviewer/commands/CopyCommandTest.java @@ -61,7 +61,7 @@ public class CopyCommandTest extends CommandTestFunctions { GenericProtein protein = new GenericProtein("A"); protein.setNotes(null); - model.addAlias(protein); + model.addElement(protein); Model copy = new CopyCommand(model).execute(); @@ -83,14 +83,14 @@ public class CopyCommandTest extends CommandTestFunctions { GenericProtein protein = new GenericProtein("A"); protein.setNotes(null); complexAlias.addAlias(protein); - model.addAlias(protein); - model.addAlias(complexAlias); + model.addElement(protein); + model.addElement(complexAlias); GenericProtein alias = new GenericProtein("B"); alias.setNotes(null); complexAlias.addAlias(alias); - model.addAlias(alias); + model.addElement(alias); Model copy = new CopyCommand(model).execute(); @@ -281,7 +281,7 @@ public class CopyCommandTest extends CommandTestFunctions { GenericProtein alias = new GenericProtein("a_id"); alias.setName("ad"); - model.addAlias(alias); + model.addElement(alias); Layer layer = new Layer(); layer.setName("layer name"); diff --git a/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java b/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java index 08822f4c56..e4d697d089 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/MiriamType.java @@ -488,19 +488,10 @@ public enum MiriamType { this.uris.add(string); } for (Class<?> clazz : classes) { - if (AnnotatedObject.class.isAssignableFrom(clazz)) { - this.validClass.add((Class<? extends AnnotatedObject>) clazz); - } else { - throw new InvalidArgumentException(); - } + this.validClass.add((Class<? extends AnnotatedObject>) clazz); } for (Class<?> clazz : requiredClasses) { - if (AnnotatedObject.class.isAssignableFrom(clazz)) { - this.requiredClass.add((Class<? extends AnnotatedObject>) clazz); - } else { - throw new InvalidArgumentException(); - } - + this.requiredClass.add((Class<? extends AnnotatedObject>) clazz); } this.registryIdentifier = registryIdentifier; } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java b/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java index 66e27206ac..b29a5720fd 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/Model.java @@ -52,7 +52,7 @@ public interface Model { * @param alias * alias to add */ - void addAlias(Element alias); + void addElement(Element alias); /** * Returns map model version. @@ -146,16 +146,6 @@ public interface Model { */ Set<Reaction> getReactions(); - /** - * Returns compartment alias with the given alias id. - * - * @param id - * compartment alias identifier ({@link Element#aliasId}) - * @return compartment alias with the given compartment alias id - */ - - Compartment getCompartmentAliasByCompartmentAliasId(String id); - /** * @return list of compartment aliases */ diff --git a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java index 84004ea609..72eeeed647 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/model/ModelFullIndexed.java @@ -114,34 +114,34 @@ public class ModelFullIndexed implements Model { } @Override - public void addAlias(Element alias) { - if (alias instanceof Species) { - addSpeciesAlias((Species) alias); - } else if (alias instanceof Compartment) { - addCompartmentAlias((Compartment) alias); + public void addElement(Element element) { + if (element.getElementId() == null || element.getElementId().isEmpty()) { + throw new InvalidArgumentException("Element identifier cannot be empty"); + } + if (element instanceof Species) { + addSpecies((Species) element); + } else if (element instanceof Compartment) { + addCompartmentAlias((Compartment) element); } else { - throw new InvalidArgumentException("Unknown type of alias: " + alias); + throw new InvalidArgumentException("Unknown type of element: " + element); } } /** * Adds {@link Species} to the model. * - * @param al + * @param species * alias to add */ - private void addSpeciesAlias(Species al) { - if (al.getElementId() == null || al.getElementId().isEmpty()) { - throw new InvalidArgumentException("Alias identifier cannot be empty"); - } - modelData.addAlias(al); + private void addSpecies(Species species) { + modelData.addAlias(species); - Element alias2 = aliasByAliasId.get(al.getElementId()); + Element alias2 = aliasByAliasId.get(species.getElementId()); if (alias2 == null) { - aliasByAliasId.put(al.getElementId(), al); - aliasByDbId.put(al.getId(), al); + aliasByAliasId.put(species.getElementId(), species); + aliasByDbId.put(species.getId(), species); } else { - throw new InvalidArgumentException("Alias with duplicated id: " + al.getElementId()); + throw new InvalidArgumentException("Species with duplicated id: " + species.getElementId()); } } @@ -225,11 +225,6 @@ public class ModelFullIndexed implements Model { } } - @Override - public Compartment getCompartmentAliasByCompartmentAliasId(String id) { - return (Compartment) aliasByAliasId.get(id); - } - @Override public List<Compartment> getCompartmentsAliases() { List<Compartment> result = new ArrayList<Compartment>(); @@ -254,7 +249,7 @@ public class ModelFullIndexed implements Model { @Override public void addAliases(List<? extends Element> aliases) { for (Element alias : aliases) { - addAlias(alias); + addElement(alias); } } @@ -770,10 +765,10 @@ public class ModelFullIndexed implements Model { @Override public List<Species> getSpeciesList() { - List<Species> result = new ArrayList<Species>(); - for (Element alias : modelData.getAliases()) { - if (alias instanceof Species) { - result.add((Species) alias); + List<Species> result = new ArrayList<>(); + for (Element element : modelData.getAliases()) { + if (element instanceof Species) { + result.add((Species) element); } } return result; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRna.java b/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRna.java index 386f48cd6d..779352ff3a 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRna.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRna.java @@ -15,6 +15,12 @@ import org.hibernate.annotations.LazyCollectionOption; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; +/** + * Entity representing antisense rna element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("ANTISENSE_RNA_ALIAS") public class AntisenseRna extends Species { @@ -22,16 +28,29 @@ public class AntisenseRna extends Species { /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; + /** + * List of {@link AntisenseRnaRegion regions} related to this + * {@link AntisenseRna}. + */ @Cascade({ CascadeType.ALL }) @OneToMany(mappedBy = "species") @LazyCollection(LazyCollectionOption.FALSE) - private List<AntisenseRnaRegion> regions = new ArrayList<>(); + private List<AntisenseRnaRegion> regions = new ArrayList<>(); + /** + * Empty constructor required by hibernate. + */ AntisenseRna() { } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public AntisenseRna(AntisenseRna original) { super(original); for (AntisenseRnaRegion region : original.getRegions()) { @@ -39,15 +58,27 @@ public class AntisenseRna extends Species { } } + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + public AntisenseRna(String elementId) { + setElementId(elementId); + } + + /** + * Adds {@link AntisenseRnaRegion} to the object. + * + * @param antisenseRnaRegionAlias + * alement to be added + */ public void addRegion(AntisenseRnaRegion antisenseRnaRegionAlias) { regions.add(antisenseRnaRegionAlias); antisenseRnaRegionAlias.setSpecies(this); } - public AntisenseRna(String aliasId) { - setElementId(aliasId); - } - @Override public AntisenseRna copy() { if (this.getClass() == AntisenseRna.class) { diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparator.java index f886d20073..e7dfa3ef10 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparator.java @@ -11,8 +11,14 @@ import lcsb.mapviewer.common.comparator.StringSetComparator; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; +/** + * Comparator class used for comparing {@link AntisenseRna} objects. + * + * @author Piotr Gawron + * + */ public class AntisenseRnaComparator implements Comparator<AntisenseRna> { - + /** * Default class logger. */ @@ -98,7 +104,7 @@ public class AntisenseRnaComparator implements Comparator<AntisenseRna> { if (stringSetComparator.compare(set1, set2) != 0) { return stringSetComparator.compare(set1, set2); } - + return 0; } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Chemical.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Chemical.java index 72703817ac..bec1401d70 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Chemical.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Chemical.java @@ -4,6 +4,12 @@ import javax.persistence.Column; import javax.persistence.DiscriminatorValue; import javax.persistence.Entity; +/** + * Entity representing chemical element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("CHEMICAL_ALIAS") public abstract class Chemical extends Species { @@ -37,9 +43,18 @@ public abstract class Chemical extends Species { private String inChIKey; + /** + * Empty constructor required by hibernate. + */ Chemical() { } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public Chemical(Chemical original) { super(original); smiles = original.getSmiles(); diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/ChemicalComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ChemicalComparator.java index 4b9cba9976..c9d1bb5ff3 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/ChemicalComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ChemicalComparator.java @@ -5,23 +5,36 @@ import java.util.Comparator; import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; +import lcsb.mapviewer.common.comparator.StringComparator; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Comparator class used for comparing {@link Chemical} objects. + * + * @author Piotr Gawron + * + */ public class ChemicalComparator implements Comparator<Chemical> { /** * Default class logger. */ - @SuppressWarnings("unused") - private static Logger logger = Logger.getLogger(ChemicalComparator.class); + private static Logger logger = Logger.getLogger(ChemicalComparator.class); /** * Epsilon value used for comparison of doubles. */ - private double epsilon; + private double epsilon; - private IonComparator ionAliasComparator; - private SimpleMoleculeComparator simpleMoleculeAliasComparator; + /** + * Comparator for {@link Ion} implementation of {@link Chemical}. + */ + private IonComparator ionAliasComparator; + + /** + * Comparator for {@link SimpleMolecule} implementation of {@link Chemical}. + */ + private SimpleMoleculeComparator simpleMoleculeAliasComparator; /** * Constructor that requires {@link #epsilon} parameter. @@ -55,9 +68,7 @@ public class ChemicalComparator implements Comparator<Chemical> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(Chemical.class)) { - return internalCompare(arg0, arg1); - } else if (arg0.getClass().equals(Ion.class)) { + if (arg0.getClass().equals(Ion.class)) { return ionAliasComparator.compare((Ion) arg0, (Ion) arg1); } else if (arg0.getClass().equals(SimpleMolecule.class)) { return simpleMoleculeAliasComparator.compare((SimpleMolecule) arg0, (SimpleMolecule) arg1); @@ -87,6 +98,23 @@ public class ChemicalComparator implements Comparator<Chemical> { if (result != 0) { return result; } + StringComparator stringComparator = new StringComparator(); + + if (stringComparator.compare(arg0.getSmiles(), arg1.getSmiles()) != 0) { + logger.debug("Smiles different: " + arg0.getSmiles() + ", " + arg1.getSmiles()); + return stringComparator.compare(arg0.getSmiles(), arg1.getSmiles()); + } + + if (stringComparator.compare(arg0.getInChIKey(), arg1.getInChIKey()) != 0) { + logger.debug("InChIKey different: " + arg0.getInChIKey() + ", " + arg1.getInChIKey()); + return stringComparator.compare(arg0.getInChIKey(), arg1.getInChIKey()); + } + + if (stringComparator.compare(arg0.getInChI(), arg1.getInChI()) != 0) { + logger.debug("InChI different: " + arg0.getInChI() + ", " + arg1.getInChI()); + return stringComparator.compare(arg0.getInChI(), arg1.getInChI()); + } + return 0; } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Complex.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Complex.java index 3e3d0b78d6..6d63bf94fd 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Complex.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Complex.java @@ -17,7 +17,8 @@ import org.hibernate.annotations.CascadeType; import lcsb.mapviewer.common.exception.NotImplementedException; /** - * Class that represents alias of a complex in the model. + * Class that represents complex in the model. Complex elements contain + * subelements. * * @author Piotr Gawron * @@ -29,12 +30,12 @@ public class Complex extends Species { /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; /** * Default class logger. */ - private static Logger logger = Logger.getLogger(Complex.class); + private static Logger logger = Logger.getLogger(Complex.class); /** * List of aliases that are in this complex alias (only aliases that lies @@ -42,15 +43,15 @@ public class Complex extends Species { */ @Cascade({ CascadeType.ALL }) @OneToMany(fetch = FetchType.EAGER, mappedBy = "complexAlias") - private List<Species> aliases = new ArrayList<>(); + private List<Species> aliases = new ArrayList<>(); /** * State of the complex species. */ - private String structuralState = null; + private String structuralState = null; /** - * Default constructor. + * Empty constructor required by hibernate. */ Complex() { super(); @@ -73,13 +74,13 @@ public class Complex extends Species { } /** - * Constructor that creates complex alias with given alias id. + * Default constructor. * - * @param aliasId - * identifier of the alias + * @param elementId + * uniqe (within model) element identifier */ - public Complex(String aliasId) { - super(aliasId); + public Complex(String elementId) { + super(elementId); } /** @@ -172,6 +173,12 @@ public class Complex extends Species { this.structuralState = structuralState; } + /** + * Returns all children and subchildren elements for this element. Only non + * {@link Complex} children will be returned. + * + * @return all children and subchildren elements for this element + */ public Set<Species> getAllSimpleChildren() { Set<Species> result = new HashSet<>(); for (Species element : getAliases()) { @@ -189,5 +196,4 @@ public class Complex extends Species { return "Complex"; } - } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/ComplexComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ComplexComparator.java index 992a54475f..6b005eed4a 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/ComplexComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ComplexComparator.java @@ -13,7 +13,7 @@ import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.NotImplementedException; /** - * This class implements comparator interface for ComplexAlias. + * This class implements comparator interface for {@link Complex}. * * @author Piotr Gawron * diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Degraded.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Degraded.java index 0fcb066a14..d030136fce 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Degraded.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Degraded.java @@ -5,6 +5,12 @@ import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Entity representing degraded element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("DEGRADED_ALIAS") public class Degraded extends Species { @@ -13,15 +19,30 @@ public class Degraded extends Species { */ private static final long serialVersionUID = 1L; + /** + * Empty constructor required by hibernate. + */ Degraded() { } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public Degraded(Degraded original) { super(original); } - public Degraded(String aliasId) { - super.setElementId(aliasId); + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + public Degraded(String elementId) { + super.setElementId(elementId); } @Override @@ -38,5 +59,4 @@ public class Degraded extends Species { return "Degraded"; } - } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/DegradedComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/DegradedComparator.java index 7f16484bd8..ef33ffeb78 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/DegradedComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/DegradedComparator.java @@ -7,8 +7,14 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Comparator class used for comparing {@link Degraded} objects. + * + * @author Piotr Gawron + * + */ public class DegradedComparator implements Comparator<Degraded> { - + /** * Default class logger. */ diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Drug.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Drug.java index 82b2735f03..aec5c847fd 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Drug.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Drug.java @@ -5,6 +5,12 @@ import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Entity representing drug element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("DRUG_ALIAS") public class Drug extends Species { @@ -13,15 +19,30 @@ public class Drug extends Species { */ private static final long serialVersionUID = 1L; + /** + * Empty constructor required by hibernate. + */ Drug() { } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public Drug(Drug original) { super(original); } - public Drug(String aliasId) { - setElementId(aliasId); + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + public Drug(String elementId) { + setElementId(elementId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/DrugComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/DrugComparator.java index cc33157ba8..0f64edd06d 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/DrugComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/DrugComparator.java @@ -7,8 +7,14 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Comparator class used for comparing {@link Drug} objects. + * + * @author Piotr Gawron + * + */ public class DrugComparator implements Comparator<Drug> { - + /** * Default class logger. */ @@ -61,9 +67,9 @@ public class DrugComparator implements Comparator<Drug> { } /** - * This method compares only the fields that are defined in DrugAlias - * class in inheritence tree. By the design it calls also comparator of the - * upper (SpeciesAlias) class. + * This method compares only the fields that are defined in DrugAlias class in + * inheritence tree. By the design it calls also comparator of the upper + * (SpeciesAlias) class. * * @param arg0 * first object to compare 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 7f165e052d..a00cdb5d9a 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 @@ -48,11 +48,9 @@ import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelData; /** - * Abstract class representing alias objects in the model. Aliases are objects - * that contains graphical representation data for element (like, species, - * compartments; but not reactions) in the map. It is possible to connect many - * aliases to one element (they reference to one instance of the element, but - * show them in different places on the map). + * Abstract class representing objects in the model. Elements are objects that + * contains graphical representation data for element and metainformation about + * element (like symbol, name, etc.). * * @author Piotr Gawron * @@ -67,42 +65,42 @@ public abstract class Element implements AnnotatedObject, Serializable { /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; /** * Default font size for alias element. */ - private static final double DEFAULT_FONT_SIZE = 12.0; + private static final double DEFAULT_FONT_SIZE = 12.0; /** * Maximum length of the valid synonym name. */ - private static final int MAX_SYNONYM_LENGTH = 255; + private static final int MAX_SYNONYM_LENGTH = 255; /** * Comparator of aliases that takes into consideration size (width*height) of * aliases. */ public static final Comparator<Element> SIZE_COMPARATOR = new Comparator<Element>() { - @Override - public int compare(Element alias1, Element alias2) { - - double size = alias1.getWidth() * alias1.getHeight(); - double size2 = alias2.getWidth() * alias2.getHeight(); - if (size < size2) { - return 1; - } else if (size > size2) { - return -1; - } else { - return 0; + @Override + public int compare(Element alias1, Element alias2) { + + double size = alias1.getWidth() * alias1.getHeight(); + double size2 = alias2.getWidth() * alias2.getHeight(); + if (size < size2) { + return 1; + } else if (size > size2) { + return -1; + } else { + return 0; + } } - } - }; + }; /** * Default class logger. */ - private static Logger logger = Logger.getLogger(Element.class); + private static Logger logger = Logger.getLogger(Element.class); /** * Database identifier. @@ -110,7 +108,7 @@ public abstract class Element implements AnnotatedObject, Serializable { @Id @GeneratedValue(strategy = GenerationType.IDENTITY) @Column(name = "idDb", unique = true, nullable = false) - private int id; + private int id; /** * This object reference to the parent alias. Parent is a ComplexAlias which @@ -127,56 +125,56 @@ public abstract class Element implements AnnotatedObject, Serializable { * Map model object to which alias belongs to. */ @ManyToOne(fetch = FetchType.LAZY) - private ModelData model; + private ModelData model; /** * Submodel that is extension of these element alias. */ @ManyToOne(fetch = FetchType.LAZY, cascade = javax.persistence.CascadeType.ALL) - private AliasSubmodelConnection submodel; + private AliasSubmodelConnection submodel; /** * CompartmentAlias where alias is located. When alias lies outside of every * compartment then null value is assigned. */ @ManyToOne - private Compartment compartmentAlias; + private Compartment compartmentAlias; /** - * Unique string identifier within one model object (usually imported - * from external source from which map was imported). + * Unique string identifier within one model object (usually imported from + * external source from which map was imported). */ - private String elementId; + private String elementId; /** * X coordinate on the map where alias is located (top left corner). */ - private Double x; + private Double x; /** * Y coordinate on the map where alias is located (top left corner). */ - private Double y; + private Double y; /** * Width of the alias. */ - private Double width; + private Double width; /** * Height of the alias. */ - private Double height; + private Double height; /** * Size of the font used for description. */ - private Double fontSize; + private Double fontSize; /** * Color of filling. */ - private Color color; + private Color color; /** * From which level alias should be visible. @@ -185,7 +183,7 @@ public abstract class Element implements AnnotatedObject, Serializable { * @see lcsb.mapviewer.converter.graphics.AbstractImageGenerator.Params#level * AbstractImageGenerator.Params#level */ - private int visibilityLevel; + private int visibilityLevel; /** * From which level alias should be transparent. @@ -193,45 +191,45 @@ public abstract class Element implements AnnotatedObject, Serializable { * @see #visibilityLevel * @see AbstractImageGenerator.Params#level */ - private int transparencyLevel; + private int transparencyLevel; /** * List of search indexes that describe this element. */ @Cascade({ CascadeType.ALL }) @OneToMany(fetch = FetchType.EAGER, mappedBy = "source", orphanRemoval = true) - private List<SearchIndex> searchIndexes = new ArrayList<SearchIndex>(); + private List<SearchIndex> searchIndexes = new ArrayList<SearchIndex>(); /** * Notes describing this element. */ @Column(name = "notes", columnDefinition = "TEXT") - private String notes = ""; + private String notes = ""; /** * Symbol of the element. */ - private String symbol; + private String symbol; /** * Full name of the element. */ - private String fullName; + private String fullName; /** * Abbreviation associated with the element. */ - private String abbreviation; + private String abbreviation; /** * Formula associated with the element. */ - private String formula; + private String formula; /** * Short name of the element. */ - private String name = ""; + private String name = ""; /** * Lists of all synonyms used for describing this element. @@ -244,7 +242,7 @@ public abstract class Element implements AnnotatedObject, Serializable { @Column(name = "synonym") @IndexColumn(name = "idx") @Cascade({ org.hibernate.annotations.CascadeType.ALL }) - private List<String> synonyms = new ArrayList<>(); + private List<String> synonyms = new ArrayList<>(); /** * List of former symbols used to describe this element. @@ -257,7 +255,7 @@ public abstract class Element implements AnnotatedObject, Serializable { @Column(name = "symbol") @IndexColumn(name = "idx") @Cascade({ org.hibernate.annotations.CascadeType.ALL }) - private List<String> formerSymbols = new ArrayList<>(); + private List<String> formerSymbols = new ArrayList<>(); /** * Set of miriam annotations for this element. @@ -266,49 +264,55 @@ public abstract class Element implements AnnotatedObject, Serializable { @ManyToMany(fetch = FetchType.EAGER) @JoinTable(name = "element_miriam", joinColumns = { @JoinColumn(name = "element_id", referencedColumnName = "idDb", nullable = false, updatable = false) }, inverseJoinColumns = { @JoinColumn(name = "miriam_id", referencedColumnName = "idDb", nullable = true, updatable = true) }) - private Set<MiriamData> miriamData = new HashSet<>(); + private Set<MiriamData> miriamData = new HashSet<>(); /** - * Constructor that initialize alias with the data from the parameter alias. + * Constructor that creates a copy of the element given in the parameter. * - * @param param - * source alias - */ - protected Element(Element param) { - elementId = param.getElementId(); - x = param.getX(); - y = param.getY(); - width = param.getWidth(); - height = param.getHeight(); - fontSize = param.getFontSize(); - parent = param.getParent(); - visibilityLevel = param.getVisibilityLevel(); - color = param.getColor(); - for (SearchIndex searchIndex : param.getSearchIndexes()) { + * @param original + * original object that will be used for creating copy + */ + protected Element(Element original) { + elementId = original.getElementId(); + x = original.getX(); + y = original.getY(); + width = original.getWidth(); + height = original.getHeight(); + fontSize = original.getFontSize(); + parent = original.getParent(); + visibilityLevel = original.getVisibilityLevel(); + color = original.getColor(); + for (SearchIndex searchIndex : original.getSearchIndexes()) { searchIndexes.add(searchIndex.copy()); } - if (param.getSubmodel() != null) { - setSubmodel(param.getSubmodel().copy()); + if (original.getSubmodel() != null) { + setSubmodel(original.getSubmodel().copy()); } - this.notes = param.notes; - this.symbol = param.symbol; - this.fullName = param.fullName; - this.name = param.getName(); - addSynonyms(param.getSynonyms()); - addFormerSymbols(param.getFormerSymbols()); + this.notes = original.notes; + this.symbol = original.symbol; + this.fullName = original.fullName; + this.name = original.getName(); + addSynonyms(original.getSynonyms()); + addFormerSymbols(original.getFormerSymbols()); - addMiriamData(param.getMiriamData()); - this.abbreviation = param.getAbbreviation(); - this.formula = param.getFormula(); + addMiriamData(original.getMiriamData()); + this.abbreviation = original.getAbbreviation(); + this.formula = original.getFormula(); } + /** + * Adds list of former symbol to the object. + * + * @param formerSymbols + * list of former symbols to add + */ public void addFormerSymbols(List<String> formerSymbols) { this.formerSymbols.addAll(formerSymbols); } /** - * Default constructor. + * Empty constructor required by hibernate. */ protected Element() { super(); @@ -1050,15 +1054,31 @@ public abstract class Element implements AnnotatedObject, Serializable { this.notes = notes; } + /** + * Adds former symbol to the object. + * + * @param formerSymbol + * former symbol to add + */ public void addFormerSymbol(String formerSymbol) { formerSymbols.add(formerSymbol); - } - public void addSynonym(String string) { - synonyms.add(string); + /** + * Adds synonym to object. + * + * @param synonym + * synonym to be added + */ + public void addSynonym(String synonym) { + synonyms.add(synonym); } + /** + * Return human readable {@link String} representing class. + * + * @return human readable {@link String} representing class + */ public abstract String getStringType(); } \ No newline at end of file diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/ElementComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ElementComparator.java index 72c7ed7861..0800590d1b 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/ElementComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ElementComparator.java @@ -19,11 +19,10 @@ import lcsb.mapviewer.model.map.compartment.CompartmentComparator; import lcsb.mapviewer.model.map.model.AliasSubmodelConnectionComparator; /** - * This class implements comparator interface for Alias. It also handles - * comparison of subclasses of Alias class. + * Comparator class used for comparing {@link Element} objects. * * @author Piotr Gawron - * + * */ public class ElementComparator implements Comparator<Element> { /** diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Gene.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Gene.java index da92b8f45f..db6c9cb840 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Gene.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Gene.java @@ -15,6 +15,12 @@ import org.hibernate.annotations.LazyCollectionOption; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.ModificationResidue; +/** + * Entity representing gene element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("GENE_ALIAS") public class Gene extends Species { @@ -22,7 +28,7 @@ public class Gene extends Species { /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; /** * List of modifications for the Gene. @@ -30,11 +36,20 @@ public class Gene extends Species { @Cascade({ CascadeType.ALL }) @OneToMany(mappedBy = "species", orphanRemoval = true) @LazyCollection(LazyCollectionOption.FALSE) - private List<ModificationResidue> modificationResidues = new ArrayList<>(); + private List<ModificationResidue> modificationResidues = new ArrayList<>(); + /** + * Empty constructor required by hibernate. + */ Gene() { } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public Gene(Gene original) { super(original); for (ModificationResidue mr : original.getModificationResidues()) { @@ -42,16 +57,28 @@ public class Gene extends Species { } } + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + public Gene(String elementId) { + setElementId(elementId); + } + + /** + * Adds {@link ModificationResidue}. + * + * @param modificationResidue + * {@link ModificationResidue} to be added + */ public void addModificationResidue(ModificationResidue modificationResidue) { modificationResidues.add(modificationResidue); modificationResidue.setSpecies(this); } - public Gene(String aliasId) { - setElementId(aliasId); - } - @Override public Gene copy() { if (this.getClass() == Gene.class) { @@ -83,5 +110,4 @@ public class Gene extends Species { return "Gene"; } - } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/GeneComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/GeneComparator.java index d67f46e73a..5ec522cc4f 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/GeneComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/GeneComparator.java @@ -11,6 +11,12 @@ import lcsb.mapviewer.common.comparator.StringSetComparator; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.ModificationResidue; +/** + * Comparator class used for comparing {@link Gene} objects. + * + * @author Piotr Gawron + * + */ public class GeneComparator implements Comparator<Gene> { /** diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/GenericProtein.java b/model/src/main/java/lcsb/mapviewer/model/map/species/GenericProtein.java index aa919053ca..428c069554 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/GenericProtein.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/GenericProtein.java @@ -5,21 +5,43 @@ import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Entity representing generic protein element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("GENERIC_PROTEIN_ALIAS") public class GenericProtein extends Protein { + /** * */ private static final long serialVersionUID = 1L; + /** + * Empty constructor required by hibernate. + */ GenericProtein() { } - public GenericProtein(String aliasId) { - super(aliasId); + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + public GenericProtein(String elementId) { + super(elementId); } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public GenericProtein(GenericProtein original) { super(original); } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/GenericProteinComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/GenericProteinComparator.java index 6b11bf5ef2..4fb7a683db 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/GenericProteinComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/GenericProteinComparator.java @@ -7,6 +7,12 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Comparator class used for comparing {@link GenericProtein} objects. + * + * @author Piotr Gawron + * + */ public class GenericProteinComparator implements Comparator<GenericProtein> { /** diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Ion.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Ion.java index 23ab6180db..8170a7890e 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Ion.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Ion.java @@ -5,23 +5,45 @@ import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Entity representing ion element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("ION_ALIAS") public class Ion extends Chemical { + /** * */ private static final long serialVersionUID = 1L; + /** + * Empty constructor required by hibernate. + */ Ion() { } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public Ion(Ion original) { super(original); } - public Ion(String aliasId) { - setElementId(aliasId); + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + public Ion(String elementId) { + setElementId(elementId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProtein.java b/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProtein.java index 73d4ca35c9..95225bc76e 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProtein.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProtein.java @@ -5,23 +5,45 @@ import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Entity representing ion channel protein element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("ION_CHANNEL_PROTEIN_ALIAS") public class IonChannelProtein extends Protein { + /** * */ private static final long serialVersionUID = 1L; + /** + * Empty constructor required by hibernate. + */ IonChannelProtein() { } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public IonChannelProtein(IonChannelProtein original) { super(original); } - public IonChannelProtein(String aliasId) { - setElementId(aliasId); + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + public IonChannelProtein(String elementId) { + setElementId(elementId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProteinComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProteinComparator.java index 276547baee..4cd44ebde6 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProteinComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/IonChannelProteinComparator.java @@ -7,6 +7,12 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Comparator class used for comparing {@link IonChannelProtein} objects. + * + * @author Piotr Gawron + * + */ public class IonChannelProteinComparator implements Comparator<IonChannelProtein> { /** diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/IonComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/IonComparator.java index e17cad0f42..cddddd1b5b 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/IonComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/IonComparator.java @@ -7,6 +7,12 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Comparator class used for comparing {@link Ion} objects. + * + * @author Piotr Gawron + * + */ public class IonComparator implements Comparator<Ion> { /** @@ -61,9 +67,9 @@ public class IonComparator implements Comparator<Ion> { } /** - * This method compares only the fields that are defined in {@link Ion} - * class in inheritence tree. By the design it calls also comparator of the - * upper {@link Chemical} class. + * This method compares only the fields that are defined in {@link Ion} class + * in inheritence tree. By the design it calls also comparator of the upper + * {@link Chemical} class. * * @param arg0 * first object to compare diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Phenotype.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Phenotype.java index 0fd1e4ce0e..58634bdeee 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Phenotype.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Phenotype.java @@ -5,6 +5,12 @@ import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Entity representing phenotype element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("PHENTOYPE_ALIAS") public class Phenotype extends Species { @@ -14,15 +20,30 @@ public class Phenotype extends Species { */ private static final long serialVersionUID = 1L; + /** + * Empty constructor required by hibernate. + */ Phenotype() { } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public Phenotype(Phenotype original) { super(original); } - public Phenotype(String aliasId) { - setElementId(aliasId); + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + public Phenotype(String elementId) { + setElementId(elementId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/PhenotypeComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/PhenotypeComparator.java index ad63c97a93..b6a01629f0 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/PhenotypeComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/PhenotypeComparator.java @@ -7,6 +7,12 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Comparator class used for comparing {@link Phenotype} objects. + * + * @author Piotr Gawron + * + */ public class PhenotypeComparator implements Comparator<Phenotype> { /** diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Protein.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Protein.java index 7149cffe9d..7fadc2e18f 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Protein.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Protein.java @@ -14,6 +14,12 @@ import org.hibernate.annotations.LazyCollectionOption; import lcsb.mapviewer.model.map.species.field.ModificationResidue; +/** + * Entity representing protein element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("PROTEIN_ALIAS") public abstract class Protein extends Species { @@ -36,10 +42,19 @@ public abstract class Protein extends Species { @LazyCollection(LazyCollectionOption.FALSE) private List<ModificationResidue> modificationResidues = new ArrayList<>(); + /** + * Empty constructor required by hibernate. + */ Protein() { } - public Protein(Protein original) { + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ + protected Protein(Protein original) { super(original); this.structuralState = original.getStructuralState(); for (ModificationResidue mr : original.getModificationResidues()) { @@ -47,8 +62,15 @@ public abstract class Protein extends Species { } } - public Protein(String aliasId) { - super(aliasId); + + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + protected Protein(String elementId) { + super(elementId); } /** diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/ProteinComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ProteinComparator.java index 158be0cb0e..7090a9316c 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/ProteinComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ProteinComparator.java @@ -7,18 +7,22 @@ import java.util.Set; import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.comparator.IntegerComparator; import lcsb.mapviewer.common.comparator.StringComparator; import lcsb.mapviewer.common.comparator.StringSetComparator; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.ModificationResidue; +/** + * Comparator class used for comparing {@link Protein} objects. + * + * @author Piotr Gawron + * + */ public class ProteinComparator implements Comparator<Protein> { /** * Default class logger. */ - @SuppressWarnings("unused") private static Logger logger = Logger.getLogger(ProteinComparator.class); /** @@ -26,9 +30,24 @@ public class ProteinComparator implements Comparator<Protein> { */ private double epsilon; + /** + * Comparator for {@link GenericProtein} implementation of {@link Protein}. + */ private GenericProteinComparator genericProteinAliasComparator; + + /** + * Comparator for {@link IonChannelProtein} implementation of {@link Protein}. + */ private IonChannelProteinComparator ionChannelProteinAliasComparator; + + /** + * Comparator for {@link ReceptorProtein} implementation of {@link Protein}. + */ private ReceptorProteinComparator receptorProteinAliasComparator; + + /** + * Comparator for {@link TruncatedProtein} implementation of {@link Protein}. + */ private TruncatedProteinComparator truncatedProteinAliasComparator; /** @@ -65,9 +84,7 @@ public class ProteinComparator implements Comparator<Protein> { } if (arg0.getClass().equals(arg1.getClass())) { - if (arg0.getClass().equals(Protein.class)) { - return internalCompare(arg0, arg1); - } else if (arg0.getClass().equals(GenericProtein.class)) { + if (arg0.getClass().equals(GenericProtein.class)) { return genericProteinAliasComparator.compare((GenericProtein) arg0, (GenericProtein) arg1); } else if (arg0.getClass().equals(IonChannelProtein.class)) { return ionChannelProteinAliasComparator.compare((IonChannelProtein) arg0, (IonChannelProtein) arg1); @@ -103,14 +120,8 @@ public class ProteinComparator implements Comparator<Protein> { } StringComparator stringComparator = new StringComparator(); - IntegerComparator integerComparator = new IntegerComparator(); StringSetComparator stringSetComparator = new StringSetComparator(); - if (integerComparator.compare(arg0.getHomodimer(), arg1.getHomodimer()) != 0) { - logger.debug("homodimer different: " + arg0.getHomodimer() + ", " + arg1.getHomodimer()); - return integerComparator.compare(arg0.getHomodimer(), arg1.getHomodimer()); - } - if (stringComparator.compare(arg0.getStructuralState(), arg1.getStructuralState()) != 0) { logger.debug("structural state different: " + arg0.getStructuralState() + ", " + arg1.getStructuralState()); return stringComparator.compare(arg0.getStructuralState(), arg1.getStructuralState()); diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProtein.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProtein.java index 71e5c768c2..89aa61cf12 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProtein.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProtein.java @@ -5,6 +5,12 @@ import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Entity representing receptor protein element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("RECEPTOR_PROTEIN_ALIAS") public class ReceptorProtein extends Protein { @@ -13,15 +19,30 @@ public class ReceptorProtein extends Protein { */ private static final long serialVersionUID = 1L; + /** + * Empty constructor required by hibernate. + */ ReceptorProtein() { } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public ReceptorProtein(ReceptorProtein original) { super(original); } - public ReceptorProtein(String aliasId) { - super(aliasId); + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + public ReceptorProtein(String elementId) { + super(elementId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProteinComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProteinComparator.java index f0bc587d0e..724edc151a 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProteinComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/ReceptorProteinComparator.java @@ -7,6 +7,12 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Comparator class used for comparing {@link ReceptorProtein} objects. + * + * @author Piotr Gawron + * + */ public class ReceptorProteinComparator implements Comparator<ReceptorProtein> { /** diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Rna.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Rna.java index c738ee367e..7e3df3a906 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Rna.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Rna.java @@ -15,6 +15,12 @@ import org.hibernate.annotations.LazyCollectionOption; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.RnaRegion; +/** + * Entity representing rna element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("RNA_ALIAS") public class Rna extends Species { @@ -22,7 +28,7 @@ public class Rna extends Species { /** * */ - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; /** * List of rna regions (some rna sequences) in this object. @@ -30,11 +36,20 @@ public class Rna extends Species { @Cascade({ CascadeType.ALL }) @OneToMany(mappedBy = "species", orphanRemoval = true) @LazyCollection(LazyCollectionOption.FALSE) - private List<RnaRegion> regions = new ArrayList<>(); + private List<RnaRegion> regions = new ArrayList<>(); + /** + * Empty constructor required by hibernate. + */ Rna() { } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public Rna(Rna original) { super(original); for (RnaRegion region : original.getRegions()) { @@ -42,14 +57,26 @@ public class Rna extends Species { } } - public Rna(String aliasId) { + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + public Rna(String elementId) { super(); - setElementId(aliasId); + setElementId(elementId); } - public void addRegion(RnaRegion rnaRegionAlias) { - regions.add(rnaRegionAlias); - rnaRegionAlias.setSpecies(this); + /** + * Adds {@link RnaRegion}. + * + * @param rnaRegion + * object to be added + */ + public void addRegion(RnaRegion rnaRegion) { + regions.add(rnaRegion); + rnaRegion.setSpecies(this); } @Override @@ -78,7 +105,6 @@ public class Rna extends Species { this.regions = regions; } - @Override public String getStringType() { return "RNA"; diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/RnaComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/RnaComparator.java index bf6b8bc991..1703a391c1 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/RnaComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/RnaComparator.java @@ -11,6 +11,12 @@ import lcsb.mapviewer.common.comparator.StringSetComparator; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.RnaRegion; +/** + * Comparator class used for comparing {@link Rna} objects. + * + * @author Piotr Gawron + * + */ public class RnaComparator implements Comparator<Rna> { /** diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMolecule.java b/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMolecule.java index f14b3c55ad..37f9f9fbcb 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMolecule.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMolecule.java @@ -5,23 +5,45 @@ import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Entity representing simple molecule element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("SIMPLE_MOLECULE_ALIAS") public class SimpleMolecule extends Chemical { + /** * */ private static final long serialVersionUID = 1L; + /** + * Empty constructor required by hibernate. + */ SimpleMolecule() { } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public SimpleMolecule(SimpleMolecule original) { super(original); } - public SimpleMolecule(String aliasId) { - setElementId(aliasId); + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + public SimpleMolecule(String elementId) { + setElementId(elementId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparator.java index e276ddd994..463b37c0b8 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparator.java @@ -5,11 +5,16 @@ import java.util.Comparator; import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; -import lcsb.mapviewer.common.comparator.StringComparator; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Comparator class used for comparing {@link SimpleMolecule} objects. + * + * @author Piotr Gawron + * + */ public class SimpleMoleculeComparator implements Comparator<SimpleMolecule> { - + /** * Default class logger. */ @@ -62,9 +67,9 @@ public class SimpleMoleculeComparator implements Comparator<SimpleMolecule> { } /** - * This method compares only the fields that are defined in SimpleMoleculeAlias - * class in inheritence tree. By the design it calls also comparator of the - * upper (SpeciesAlias) class. + * This method compares only the fields that are defined in + * SimpleMoleculeAlias class in inheritence tree. By the design it calls also + * comparator of the upper (SpeciesAlias) class. * * @param arg0 * first object to compare @@ -80,23 +85,6 @@ public class SimpleMoleculeComparator implements Comparator<SimpleMolecule> { return result; } - StringComparator stringComparator = new StringComparator(); - - if (stringComparator.compare(arg0.getSmiles(), arg1.getSmiles()) != 0) { - logger.debug("Smiles different: " + arg0.getSmiles() + ", " + arg1.getSmiles()); - return stringComparator.compare(arg0.getSmiles(), arg1.getSmiles()); - } - - if (stringComparator.compare(arg0.getInChIKey(), arg1.getInChIKey()) != 0) { - logger.debug("InChIKey different: " + arg0.getInChIKey() + ", " + arg1.getInChIKey()); - return stringComparator.compare(arg0.getInChIKey(), arg1.getInChIKey()); - } - - if (stringComparator.compare(arg0.getInChI(), arg1.getInChI()) != 0) { - logger.debug("InChI different: " + arg0.getInChI() + ", " + arg1.getInChI()); - return stringComparator.compare(arg0.getInChI(), arg1.getInChI()); - } - return 0; } } diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java index 37eb0ce5fc..712f212bd2 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Species.java @@ -134,9 +134,9 @@ public abstract class Species extends Element { } /** - * Default constructor. + * Empty constructor required by hibernate. */ - public Species() { + Species() { super(); activity = false; lineWidth = 1.0; @@ -147,26 +147,26 @@ public abstract class Species extends Element { * Constructor that initializes data with the information given in the * parameter. * - * @param alias + * @param original * object from which data will be initialized */ - public Species(Species alias) { - super(alias); - activity = alias.getActivity(); - lineWidth = alias.getLineWidth(); - state = alias.getState(); + protected Species(Species original) { + super(original); + activity = original.getActivity(); + lineWidth = original.getLineWidth(); + state = original.getState(); - complexAlias = alias.getComplexAlias(); - aliasStateLabel = alias.getAliasStateLabel(); - aliasStatePrefix = alias.getAliasStatePrefix(); + complexAlias = original.getComplexAlias(); + aliasStateLabel = original.getAliasStateLabel(); + aliasStatePrefix = original.getAliasStatePrefix(); - initialAmount = alias.getInitialAmount(); - charge = alias.getCharge(); - initialConcentration = alias.getInitialConcentration(); - onlySubstanceUnits = alias.getOnlySubstanceUnits(); - homodimer = alias.getHomodimer(); - positionToCompartment = alias.getPositionToCompartment(); - hypothetical = alias.getHypothetical(); + initialAmount = original.getInitialAmount(); + charge = original.getCharge(); + initialConcentration = original.getInitialConcentration(); + onlySubstanceUnits = original.getOnlySubstanceUnits(); + homodimer = original.getHomodimer(); + positionToCompartment = original.getPositionToCompartment(); + hypothetical = original.getHypothetical(); // don't copy reaction nodes } @@ -290,6 +290,7 @@ public abstract class Species extends Element { this.aliasStateLabel = aliasStateLabel; } + @Override public abstract Species copy(); /** diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/SpeciesComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/SpeciesComparator.java index 4ce6963c78..678e18507d 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/SpeciesComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/SpeciesComparator.java @@ -12,33 +12,72 @@ import lcsb.mapviewer.common.comparator.StringComparator; import lcsb.mapviewer.common.exception.NotImplementedException; /** - * This class implements comparator interface for SpeciesAlias. It also handles - * comparison of subclasses of SpeciesAlias class. + * Comparator class used for comparing {@link Species} objects. * * @author Piotr Gawron - * + * */ public class SpeciesComparator implements Comparator<Species> { + /** * Default class logger. */ - private Logger logger = Logger.getLogger(SpeciesComparator.class); - - private AntisenseRnaComparator antisenseRnaAliasComparator; - private ChemicalComparator chemicalAliasComparator; - private ComplexComparator complexAliasComparator; - private DegradedComparator degradedAliasComparator; - private DrugComparator drugAliasComparator; - private GeneComparator geneAliasComparator; - private PhenotypeComparator phenotypeAliasComparator; - private ProteinComparator proteinAliasComparator; - private RnaComparator rnaAliasComparator; - private UnknownComparator unknownAliasComparator; + private Logger logger = Logger.getLogger(SpeciesComparator.class); + + /** + * Comparator for {@link AntisenseRna} implementation of {@link Species}. + */ + private AntisenseRnaComparator antisenseRnaComparator; + + /** + * Comparator for {@link Chemical} implementation of {@link Species}. + */ + private ChemicalComparator chemicalComparator; + + /** + * Comparator for {@link Complex} implementation of {@link Species}. + */ + private ComplexComparator complexComparator; + + /** + * Comparator for {@link Degraded} implementation of {@link Species}. + */ + private DegradedComparator degradedComparator; + + /** + * Comparator for {@link Drug} implementation of {@link Species}. + */ + private DrugComparator drugComparator; + + /** + * Comparator for {@link Gene} implementation of {@link Species}. + */ + private GeneComparator geneComparator; + + /** + * Comparator for {@link Phenotype} implementation of {@link Species}. + */ + private PhenotypeComparator phenotypeComparator; + + /** + * Comparator for {@link Protein} implementation of {@link Species}. + */ + private ProteinComparator proteinComparator; + + /** + * Comparator for {@link Rna} implementation of {@link Species}. + */ + private RnaComparator rnaComparator; + + /** + * Comparator for {@link Unknown} implementation of {@link Species}. + */ + private UnknownComparator unknownComparator; /** * Epsilon value used for comparison of doubles. */ - private double epsilon; + private double epsilon; /** * Constructor that requires {@link #epsilon} parameter. @@ -48,16 +87,16 @@ public class SpeciesComparator implements Comparator<Species> { */ public SpeciesComparator(double epsilon) { this.epsilon = epsilon; - antisenseRnaAliasComparator = new AntisenseRnaComparator(epsilon); - chemicalAliasComparator = new ChemicalComparator(epsilon); - complexAliasComparator = new ComplexComparator(epsilon); - degradedAliasComparator = new DegradedComparator(epsilon); - drugAliasComparator = new DrugComparator(epsilon); - geneAliasComparator = new GeneComparator(epsilon); - phenotypeAliasComparator = new PhenotypeComparator(epsilon); - proteinAliasComparator = new ProteinComparator(epsilon); - rnaAliasComparator = new RnaComparator(epsilon); - unknownAliasComparator = new UnknownComparator(epsilon); + antisenseRnaComparator = new AntisenseRnaComparator(epsilon); + chemicalComparator = new ChemicalComparator(epsilon); + complexComparator = new ComplexComparator(epsilon); + degradedComparator = new DegradedComparator(epsilon); + drugComparator = new DrugComparator(epsilon); + geneComparator = new GeneComparator(epsilon); + phenotypeComparator = new PhenotypeComparator(epsilon); + proteinComparator = new ProteinComparator(epsilon); + rnaComparator = new RnaComparator(epsilon); + unknownComparator = new UnknownComparator(epsilon); } /** @@ -81,25 +120,25 @@ public class SpeciesComparator implements Comparator<Species> { if (arg0.getClass().equals(arg1.getClass())) { if (arg0.getClass().equals(AntisenseRna.class)) { - return antisenseRnaAliasComparator.compare((AntisenseRna) arg0, (AntisenseRna) arg1); + return antisenseRnaComparator.compare((AntisenseRna) arg0, (AntisenseRna) arg1); } else if (arg0 instanceof Chemical) { - return chemicalAliasComparator.compare((Chemical) arg0, (Chemical) arg1); + return chemicalComparator.compare((Chemical) arg0, (Chemical) arg1); } else if (arg0.getClass().equals(Complex.class)) { - return complexAliasComparator.compare((Complex) arg0, (Complex) arg1); + return complexComparator.compare((Complex) arg0, (Complex) arg1); } else if (arg0.getClass().equals(Degraded.class)) { - return degradedAliasComparator.compare((Degraded) arg0, (Degraded) arg1); + return degradedComparator.compare((Degraded) arg0, (Degraded) arg1); } else if (arg0.getClass().equals(Drug.class)) { - return drugAliasComparator.compare((Drug) arg0, (Drug) arg1); + return drugComparator.compare((Drug) arg0, (Drug) arg1); } else if (arg0.getClass().equals(Gene.class)) { - return geneAliasComparator.compare((Gene) arg0, (Gene) arg1); + return geneComparator.compare((Gene) arg0, (Gene) arg1); } else if (arg0.getClass().equals(Phenotype.class)) { - return phenotypeAliasComparator.compare((Phenotype) arg0, (Phenotype) arg1); + return phenotypeComparator.compare((Phenotype) arg0, (Phenotype) arg1); } else if (arg0 instanceof Protein) { - return proteinAliasComparator.compare((Protein) arg0, (Protein) arg1); + return proteinComparator.compare((Protein) arg0, (Protein) arg1); } else if (arg0.getClass().equals(Rna.class)) { - return rnaAliasComparator.compare((Rna) arg0, (Rna) arg1); + return rnaComparator.compare((Rna) arg0, (Rna) arg1); } else if (arg0.getClass().equals(Unknown.class)) { - return unknownAliasComparator.compare((Unknown) arg0, (Unknown) arg1); + return unknownComparator.compare((Unknown) arg0, (Unknown) arg1); } else { throw new NotImplementedException("Don't know how to compare classes: " + arg0.getClass()); } @@ -109,9 +148,9 @@ public class SpeciesComparator implements Comparator<Species> { } /** - * This method compares only the fields that are defined in - * {@link Species} class in inheritence tree. By the design it calls also - * comparator of the upper ({@link Element}) class. + * This method compares only the fields that are defined in {@link Species} + * class in inheritence tree. By the design it calls also comparator of the + * upper ({@link Element}) class. * * @param arg0 * first object to compare diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProtein.java b/model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProtein.java index 58a3d8c52a..2d487478b4 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProtein.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProtein.java @@ -5,6 +5,12 @@ import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Entity representing truncated protein element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("TRUNCATED_PROTEIN_ALIAS") public class TruncatedProtein extends Protein { @@ -13,15 +19,30 @@ public class TruncatedProtein extends Protein { */ private static final long serialVersionUID = 1L; + /** + * Empty constructor required by hibernate. + */ TruncatedProtein() { } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public TruncatedProtein(TruncatedProtein original) { super(original); } - public TruncatedProtein(String aliasId) { - super(aliasId); + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + public TruncatedProtein(String elementId) { + super(elementId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProteinComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProteinComparator.java index a8918abee6..39493f31f0 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProteinComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/TruncatedProteinComparator.java @@ -7,8 +7,14 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Comparator class used for comparing {@link TruncatedProtein} objects. + * + * @author Piotr Gawron + * + */ public class TruncatedProteinComparator implements Comparator<TruncatedProtein> { - + /** * Default class logger. */ @@ -61,9 +67,9 @@ public class TruncatedProteinComparator implements Comparator<TruncatedProtein> } /** - * This method compares only the fields that are defined in TruncatedProteinAlias - * class in inheritence tree. By the design it calls also comparator of the - * upper (SpeciesAlias) class. + * This method compares only the fields that are defined in + * TruncatedProteinAlias class in inheritence tree. By the design it calls + * also comparator of the upper (SpeciesAlias) class. * * @param arg0 * first object to compare diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/Unknown.java b/model/src/main/java/lcsb/mapviewer/model/map/species/Unknown.java index 389c116073..d475d6de9d 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/Unknown.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/Unknown.java @@ -5,6 +5,12 @@ import javax.persistence.Entity; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Entity representing unknown element on the map. + * + * @author Piotr Gawron + * + */ @Entity @DiscriminatorValue("UNKNOWN_ALIAS") public class Unknown extends Species { @@ -14,15 +20,30 @@ public class Unknown extends Species { */ private static final long serialVersionUID = 1L; + /** + * Empty constructor required by hibernate. + */ Unknown() { } + /** + * Constructor that creates a copy of the element given in the parameter. + * + * @param original + * original object that will be used for creating copy + */ public Unknown(Unknown original) { super(original); } - public Unknown(String aliasId) { - setElementId(aliasId); + /** + * Default constructor. + * + * @param elementId + * uniqe (within model) element identifier + */ + public Unknown(String elementId) { + setElementId(elementId); } @Override diff --git a/model/src/main/java/lcsb/mapviewer/model/map/species/UnknownComparator.java b/model/src/main/java/lcsb/mapviewer/model/map/species/UnknownComparator.java index b0654cd439..96aea95884 100644 --- a/model/src/main/java/lcsb/mapviewer/model/map/species/UnknownComparator.java +++ b/model/src/main/java/lcsb/mapviewer/model/map/species/UnknownComparator.java @@ -7,8 +7,14 @@ import org.apache.log4j.Logger; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.NotImplementedException; +/** + * Comparator class used for comparing {@link Unknown} objects. + * + * @author Piotr Gawron + * + */ public class UnknownComparator implements Comparator<Unknown> { - + /** * Default class logger. */ @@ -61,9 +67,9 @@ public class UnknownComparator implements Comparator<Unknown> { } /** - * This method compares only the fields that are defined in UnknownAlias - * class in inheritence tree. By the design it calls also comparator of the - * upper (SpeciesAlias) class. + * This method compares only the fields that are defined in UnknownAlias class + * in inheritence tree. By the design it calls also comparator of the upper + * (SpeciesAlias) class. * * @param arg0 * first object to compare diff --git a/model/src/test/java/lcsb/mapviewer/model/map/MiriamTypeTest.java b/model/src/test/java/lcsb/mapviewer/model/map/MiriamTypeTest.java index 92fed4f8dd..ec19ddedcb 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/MiriamTypeTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/MiriamTypeTest.java @@ -65,6 +65,7 @@ public class MiriamTypeTest { } } + @Test public void testGetMiriamDataFromInvalidIdentifier2() { try { @@ -91,7 +92,7 @@ public class MiriamTypeTest { public void testGetMiriamByUri1() throws Exception { try { MiriamData md = MiriamType.getMiriamByUri("urn:miriam:panther.family:PTHR19384:SF5"); - assertTrue(new MiriamData(MiriamType.PANTHER,"PTHR19384:SF5").equals(md)); + assertTrue(new MiriamData(MiriamType.PANTHER, "PTHR19384:SF5").equals(md)); } catch (Exception e) { e.printStackTrace(); throw e; @@ -102,7 +103,7 @@ public class MiriamTypeTest { public void testGetMiriamByUri2() throws Exception { try { MiriamData md = MiriamType.getMiriamByUri("urn:miriam:panther.family:PTHR19384%3ASF5"); - assertTrue(new MiriamData(MiriamType.PANTHER,"PTHR19384:SF5").equals(md)); + assertTrue(new MiriamData(MiriamType.PANTHER, "PTHR19384:SF5").equals(md)); } catch (Exception e) { e.printStackTrace(); throw e; @@ -113,7 +114,19 @@ public class MiriamTypeTest { public void testGetMiriamByUri3() throws Exception { try { MiriamData md = MiriamType.getMiriamByUri("urn:miriam:panther.family%3APTHR19384%3ASF5"); - assertTrue(new MiriamData(MiriamType.PANTHER,"PTHR19384:SF5").equals(md)); + assertTrue(new MiriamData(MiriamType.PANTHER, "PTHR19384:SF5").equals(md)); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetMiriamByInvalidUri() throws Exception { + try { + MiriamType.getMiriamByUri("invalid_uri"); + fail("Exception expected"); + } catch (InvalidArgumentException e) { } catch (Exception e) { e.printStackTrace(); throw e; diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartmentTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartmentTest.java index 34e53d6e94..cfcd1f7b1a 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartmentTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/BottomSquareCompartmentTest.java @@ -7,10 +7,9 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.compartment.BottomSquareCompartment; -import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; @@ -73,13 +72,8 @@ public class BottomSquareCompartmentTest { @Test public void testInvalidCopy() { try { - new BottomSquareCompartment() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + BottomSquareCompartment compartment = Mockito.spy(BottomSquareCompartment.class); + compartment.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { 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 4fb5698713..179cb23a91 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 @@ -14,16 +14,16 @@ import org.apache.log4j.Logger; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.Configuration; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidStateException; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.compartment.Compartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; -import lcsb.mapviewer.model.map.species.Element; 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.SimpleMolecule; import lcsb.mapviewer.model.map.species.Species; @@ -154,12 +154,12 @@ public class CompartmentTest { private Model createCrossModel() { Model model = new ModelFullIndexed(null); - model.addAlias(new Compartment("default")); + model.addElement(new Compartment("default")); - model.addAlias(createSpeciesAlias(3264.8333333333335, 7517.75, 86.0, 46.0, "sa1115")); - model.addAlias(createSpeciesAlias(3267.6666666666665, 7438.75, 80.0, 40.0, "sa1117")); - model.addAlias(createSpeciesAlias(3261.6666666666665, 7600.75, 92.0, 52.0, "sa1119")); - model.addAlias(createSpeciesAlias(3203.666666666667, 7687.75, 98.0, 58.0, "sa1121")); + model.addElement(createSpeciesAlias(3264.8333333333335, 7517.75, 86.0, 46.0, "sa1115")); + model.addElement(createSpeciesAlias(3267.6666666666665, 7438.75, 80.0, 40.0, "sa1117")); + model.addElement(createSpeciesAlias(3261.6666666666665, 7600.75, 92.0, 52.0, "sa1119")); + model.addElement(createSpeciesAlias(3203.666666666667, 7687.75, 98.0, 58.0, "sa1121")); Species alias = createSpeciesAlias(7817.714285714286, 11287.642857142859, 80.0, 40.0, "sa1422"); Species alias2 = createSpeciesAlias(8224.964285714286, 11241.392857142859, 80.0, 40.0, "sa1419"); @@ -169,11 +169,11 @@ public class CompartmentTest { alias.setParent(alias3); alias2.setParent(alias3); - model.addAlias(alias); - model.addAlias(alias2); - model.addAlias(alias3); + model.addElement(alias); + model.addElement(alias2); + model.addElement(alias3); - model.addAlias(createCompartmentAlias(1380.0, 416.0, 15893.0, 10866.0, "ca1")); + model.addElement(createCompartmentAlias(1380.0, 416.0, 15893.0, 10866.0, "ca1")); return model; } @@ -285,7 +285,7 @@ public class CompartmentTest { compartment.setElements(elements); assertEquals(elements, compartment.getElements()); - + assertNotNull(compartment.getStringType()); } catch (Exception e) { @@ -381,13 +381,8 @@ public class CompartmentTest { @Test public void testInvalidCopy() { try { - new Compartment() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + Compartment compartment = Mockito.spy(Compartment.class); + compartment.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartmentTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartmentTest.java index be0eae8f0a..4b61f698f6 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartmentTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/LeftSquareCompartmentTest.java @@ -7,10 +7,9 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.compartment.Compartment; -import lcsb.mapviewer.model.map.compartment.LeftSquareCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; @@ -73,13 +72,8 @@ public class LeftSquareCompartmentTest { @Test public void testInvalidCopy() { try { - new LeftSquareCompartment() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + LeftSquareCompartment compartment = Mockito.spy(LeftSquareCompartment.class); + compartment.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/OvalCompartmentTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/OvalCompartmentTest.java index 7034f15507..e4f7886231 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/OvalCompartmentTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/OvalCompartmentTest.java @@ -7,9 +7,9 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.compartment.OvalCompartment; public class OvalCompartmentTest { @@ -30,7 +30,7 @@ public class OvalCompartmentTest { throw e; } } - + @Test public void testConstructor() { try { @@ -58,13 +58,8 @@ public class OvalCompartmentTest { @Test public void testInvalidCopy() { try { - new OvalCompartment() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + OvalCompartment compartment = Mockito.spy(OvalCompartment.class); + compartment.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { @@ -72,5 +67,5 @@ public class OvalCompartmentTest { throw e; } } - + } diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartmentTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartmentTest.java index 4d303ceeec..1135e99739 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartmentTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/RightSquareCompartmentTest.java @@ -8,10 +8,9 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.compartment.Compartment; -import lcsb.mapviewer.model.map.compartment.RightSquareCompartment; import lcsb.mapviewer.model.map.model.Model; import lcsb.mapviewer.model.map.model.ModelFullIndexed; @@ -34,7 +33,6 @@ public class RightSquareCompartmentTest { throw e; } } - @Test public void testConstructor1() { @@ -77,7 +75,7 @@ public class RightSquareCompartmentTest { try { RightSquareCompartment alias = new RightSquareCompartment(); alias.setPoint("10", "10"); - assertTrue(alias.getWidth()<0); + assertTrue(alias.getWidth() < 0); } catch (Exception e) { e.printStackTrace(); throw e; @@ -87,13 +85,8 @@ public class RightSquareCompartmentTest { @Test public void testInvalidCopy() { try { - new RightSquareCompartment() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + RightSquareCompartment compartment = Mockito.spy(RightSquareCompartment.class); + compartment.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { @@ -102,5 +95,4 @@ public class RightSquareCompartmentTest { } } - } diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/SquareCompartmentTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/SquareCompartmentTest.java index 643499af11..ec25e462c6 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/SquareCompartmentTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/SquareCompartmentTest.java @@ -7,9 +7,9 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.compartment.SquareCompartment; public class SquareCompartmentTest { @@ -58,13 +58,8 @@ public class SquareCompartmentTest { @Test public void testInvalidCopy() { try { - new SquareCompartment() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + SquareCompartment compartment = Mockito.spy(SquareCompartment.class); + compartment.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartmentTest.java b/model/src/test/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartmentTest.java index 40aba67fbe..244fa59044 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartmentTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/compartment/TopSquareCompartmentTest.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.compartment.Compartment; @@ -74,13 +75,8 @@ public class TopSquareCompartmentTest { @Test public void testInvalidCopy() { try { - new TopSquareCompartment() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + TopSquareCompartment compartment = Mockito.spy(TopSquareCompartment.class); + compartment.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnectionComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnectionComparatorTest.java index 6d28272b8a..56b498f591 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnectionComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/AliasSubmodelConnectionComparatorTest.java @@ -96,13 +96,13 @@ public class AliasSubmodelConnectionComparatorTest { model.setNotes("Some description"); GenericProtein protein = new GenericProtein("A"); protein.setName("ad"); - model.addAlias(protein); + model.addElement(protein); GenericProtein alias = new GenericProtein("a_id"); alias.setName("ad"); - model.addAlias(alias); + model.addElement(alias); - model.addAlias(new Compartment("default")); + model.addElement(new Compartment("default")); Layer layer = new Layer(); layer.setName("layer name"); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelComparatorTest.java index 47c0b2969a..e698bf4ad6 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelComparatorTest.java @@ -86,13 +86,13 @@ public class ModelComparatorTest { Compartment alias = new PathwayCompartment("1"); Compartment alias2 = new PathwayCompartment("12"); - model1.addAlias(alias); - model1.addAlias(alias2); + model1.addElement(alias); + model1.addElement(alias2); alias = new PathwayCompartment("1"); alias2 = new PathwayCompartment("12"); - model2.addAlias(alias); - model2.addAlias(alias2); + model2.addElement(alias); + model2.addElement(alias2); alias2.setElementId("1"); assertTrue(comparator.compare(model1, model2) != 0); @@ -143,9 +143,9 @@ public class ModelComparatorTest { Species mockAlias = Mockito.mock(Species.class); when(mockAlias.getElementId()).thenReturn("1"); - model1.addAlias(mockAlias); + model1.addElement(mockAlias); - model2.addAlias(mockAlias); + model2.addElement(mockAlias); try { comparator.compare(model1, model2); @@ -190,7 +190,7 @@ public class ModelComparatorTest { GenericProtein alias = new GenericProtein("SAd"); - model1.addAlias(alias); + model1.addElement(alias); assertTrue(comparator.compare(model1, model2) != 0); assertTrue(comparator.compare(model2, model1) != 0); @@ -206,7 +206,7 @@ public class ModelComparatorTest { model1 = getModel(); model2 = getModel(); - model1.addAlias(new Compartment("unk_id")); + model1.addElement(new Compartment("unk_id")); assertTrue(comparator.compare(model1, model2) != 0); assertTrue(comparator.compare(model2, model1) != 0); @@ -238,7 +238,7 @@ public class ModelComparatorTest { model1 = getModel(); model2 = getModel(); - model1.addAlias(new GenericProtein("ASdas")); + model1.addElement(new GenericProtein("ASdas")); assertTrue(comparator.compare(model1, model2) != 0); assertTrue(comparator.compare(model2, model1) != 0); @@ -385,9 +385,9 @@ public class ModelComparatorTest { GenericProtein alias = new GenericProtein("a_id"); alias.setName("ad"); - model.addAlias(alias); + model.addElement(alias); - model.addAlias(new Compartment("default")); + model.addElement(new Compartment("default")); Layer layer = new Layer(); layer.setName("layer name"); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelFullIndexedTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelFullIndexedTest.java index d192167efd..ca457e1bc4 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelFullIndexedTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelFullIndexedTest.java @@ -38,8 +38,8 @@ 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.TransportReaction; -import lcsb.mapviewer.model.map.species.Element; 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.Species; import lcsb.mapviewer.model.user.User; @@ -66,12 +66,12 @@ public class ModelFullIndexedTest { Element compartmentAlias = new Compartment("aaa"); Element compartmentAlias3 = new Compartment("aaa3"); Element compartmentAlias2 = new PathwayCompartment("aaa2"); - model.addAlias(proteinAlias); - model.addAlias(proteinAlias2); - model.addAlias(proteinAlias3); - model.addAlias(compartmentAlias); - model.addAlias(compartmentAlias2); - model.addAlias(compartmentAlias3); + model.addElement(proteinAlias); + model.addElement(proteinAlias2); + model.addElement(proteinAlias3); + model.addElement(compartmentAlias); + model.addElement(compartmentAlias2); + model.addElement(compartmentAlias3); Reaction reaction = new TransportReaction(); reaction.addReactant(new Reactant(proteinAlias)); @@ -98,6 +98,55 @@ public class ModelFullIndexedTest { } } + @Test + public void testGetByName() { + try { + String name1 = "1a"; + String name2 = "2a"; + String unknownName = "unk"; + ModelFullIndexed model = new ModelFullIndexed(null); + Species protein = new GenericProtein("id1"); + protein.setName(name1); + Species protein2 = new GenericProtein("id2"); + protein2.setName(name2); + + model.addElement(protein); + model.addElement(protein2); + + List<Element> elements = model.getElementsByName(name1); + List<Element> unkElements = model.getElementsByName(unknownName); + + assertEquals(1, elements.size()); + assertEquals(0, unkElements.size()); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetSpeciesList() { + try { + ModelFullIndexed model = new ModelFullIndexed(null); + Species protein = new GenericProtein("id1"); + Species protein2 = new GenericProtein("id2"); + + model.addElement(protein); + model.addElement(protein2); + model.addElement(new Compartment("compId")); + + + List<Species> speciesList = model.getSpeciesList(); + + assertEquals(2, speciesList.size()); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + @Test public void testConstructor2() { try { @@ -118,7 +167,7 @@ public class ModelFullIndexedTest { try { Element alias = Mockito.mock(Element.class); ModelFullIndexed model = new ModelFullIndexed(null); - model.addAlias(alias); + model.addElement(alias); new ModelFullIndexed(model.getModelData()); @@ -138,9 +187,9 @@ public class ModelFullIndexedTest { Complex alias = new Complex("1"); - model.addAlias(alias); + model.addElement(alias); try { - model.addAlias(alias); + model.addElement(alias); fail("Exception expected"); } catch (InvalidArgumentException e) { } @@ -170,7 +219,7 @@ public class ModelFullIndexedTest { try { ModelFullIndexed model = new ModelFullIndexed(null); - model.addAlias(new Compartment("default")); + model.addElement(new Compartment("default")); Complex alias = new Complex("1"); @@ -178,9 +227,9 @@ public class ModelFullIndexedTest { proteinAlias.setElementId("zz"); proteinAlias.setParent(alias); - model.addAlias(alias); + model.addElement(alias); - model.addAlias(proteinAlias); + model.addElement(proteinAlias); assertEquals(3, model.getAliases().size()); @@ -196,7 +245,7 @@ public class ModelFullIndexedTest { ModelFullIndexed model = new ModelFullIndexed(null); Compartment compAlias = new Compartment("default"); - model.addAlias(compAlias); + model.addElement(compAlias); Complex alias = new Complex("1"); alias.setParent(compAlias); @@ -205,9 +254,9 @@ public class ModelFullIndexedTest { proteinAlias.setElementId("zz"); proteinAlias.setParent(alias); - model.addAlias(alias); + model.addElement(alias); - model.addAlias(proteinAlias); + model.addElement(proteinAlias); assertEquals(3, model.getAliases().size()); @@ -226,7 +275,7 @@ public class ModelFullIndexedTest { Species alias = new GenericProtein("asd"); alias.setElementId("id"); - model.addAlias(alias); + model.addElement(alias); assertNotNull(model.getElementByElementId("id")); @@ -244,9 +293,9 @@ public class ModelFullIndexedTest { Compartment alias = new Compartment("1"); assertEquals(0, model.getCompartmentsAliases().size()); - model.addAlias(alias); + model.addElement(alias); assertEquals(1, model.getCompartmentsAliases().size()); - model.addAlias(alias); + model.addElement(alias); fail("Exception expected"); } catch (InvalidArgumentException e) { @@ -298,7 +347,7 @@ public class ModelFullIndexedTest { Element alias = new GenericProtein("1"); alias.setId(aliasId); assertNull(model.getAliasByDbId(aliasId)); - model.addAlias(alias); + model.addElement(alias); assertEquals(alias, model.getAliasByDbId(aliasId)); } catch (Exception e) { @@ -314,15 +363,15 @@ public class ModelFullIndexedTest { Compartment alias = new Compartment("a1"); alias.setWidth(12); alias.setHeight(12); - model.addAlias(alias); + model.addElement(alias); alias = new Compartment("a2"); alias.setWidth(14); alias.setHeight(14); - model.addAlias(alias); + model.addElement(alias); alias = new Compartment("a3"); alias.setWidth(13); alias.setHeight(13); - model.addAlias(alias); + model.addElement(alias); List<Compartment> aliases = model.getSortedCompartmentsAliases(); assertEquals(196.0, aliases.get(0).getSize(), Configuration.EPSILON); @@ -342,12 +391,12 @@ public class ModelFullIndexedTest { Compartment alias = new Compartment("a1"); alias.setWidth(12); alias.setHeight(12); - model.addAlias(alias); + model.addElement(alias); alias = new Compartment("a2"); alias.setWidth(14); alias.setHeight(14); - model.addAlias(alias); + model.addElement(alias); assertEquals(2, model.getAliases().size()); model.removeAlias(alias); @@ -399,20 +448,49 @@ public class ModelFullIndexedTest { } @Test - public void testRemoveCompartmentAlias() { + public void testAddInvalidElement() { try { ModelFullIndexed model = new ModelFullIndexed(null); + Element element = Mockito.spy(Element.class); + element.setElementId("id"); + model.addElement(element); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testAddInvalidElement2() { + try { + ModelFullIndexed model = new ModelFullIndexed(null); + GenericProtein protein = new GenericProtein((String) null); + model.addElement(protein); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - Compartment parentAlias = new Compartment("parent_id"); + @Test + public void testRemoveCompartment() { + try { + ModelFullIndexed model = new ModelFullIndexed(null); - Compartment alias = new Compartment("child_id"); - alias.setParent(parentAlias); + Compartment parent = new Compartment("parent_id"); + + Compartment compartment = new Compartment("child_id"); + compartment.setParent(parent); - model.addAlias(alias); + model.addElement(compartment); assertEquals(1, model.getAliases().size()); - model.removeAlias(alias); + model.removeAlias(compartment); assertEquals(0, model.getAliases().size()); } catch (Exception e) { @@ -425,7 +503,7 @@ public class ModelFullIndexedTest { public void testRemoveComplexAlias() { try { ModelFullIndexed model = new ModelFullIndexed(null); - model.addAlias(new Compartment("default")); + model.addElement(new Compartment("default")); Complex parentAlias = new Complex("a"); @@ -436,7 +514,7 @@ public class ModelFullIndexedTest { alias.setCompartmentAlias(new Compartment("comp_alias")); alias.setComplexAlias(new Complex("d")); - model.addAlias(alias); + model.addElement(alias); assertEquals(2, model.getAliases().size()); @@ -826,7 +904,7 @@ public class ModelFullIndexedTest { reaction.setIdReaction(reactionId); model.addReaction(reaction); Species alias = new GenericProtein("2"); - model.addAlias(alias); + model.addElement(alias); Collection<AnnotatedObject> obj = model.getAnnotatedObjects(); assertEquals(2, obj.size()); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelSubmodelConnectionComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelSubmodelConnectionComparatorTest.java index fe5dcd2ee1..39759fa416 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelSubmodelConnectionComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelSubmodelConnectionComparatorTest.java @@ -88,9 +88,9 @@ public class ModelSubmodelConnectionComparatorTest { Species alias = new GenericProtein("a_id"); alias.setName("ad"); - model.addAlias(alias); + model.addElement(alias); - model.addAlias(new Compartment("default")); + model.addElement(new Compartment("default")); Layer layer = new Layer(); layer.setName("layer name"); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelTest.java index 120e2ecc90..2325cd8ab9 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/ModelTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/ModelTest.java @@ -51,7 +51,7 @@ public class ModelTest { @Test public void testAddAlias() { try { - model.addAlias(alias); + model.addElement(alias); Element sAlias = model.getElementByElementId(alias.getElementId()); assertNotNull(sAlias); sAlias = model.getElementByElementId(alias.getElementId() + "blbla"); @@ -68,7 +68,7 @@ public class ModelTest { try { Set<Element> aliases = model.getAliases(); assertEquals(0, aliases.size()); - model.addAlias(alias); + model.addElement(alias); assertEquals(1, aliases.size()); Element sAlias = model.getElementByElementId(alias.getElementId()); @@ -79,7 +79,7 @@ public class ModelTest { sAlias = model.getElementByElementId(cAlias.getElementId()); assertNull(sAlias); - model.addAlias(cAlias); + model.addElement(cAlias); assertEquals(2, aliases.size()); sAlias = model.getElementByElementId(cAlias.getElementId()); assertNotNull(sAlias); @@ -155,26 +155,26 @@ public class ModelTest { Species proteinAlias = new GenericProtein("sa1"); proteinAlias.setName("s1"); - model.addAlias(proteinAlias); + model.addElement(proteinAlias); Species proteinAlias2 = new GenericProtein("sa2"); proteinAlias2.setName("s1"); - model.addAlias(proteinAlias2); + model.addElement(proteinAlias2); Species proteinAlias3 = new GenericProtein("sa3"); proteinAlias3.setName("s1"); - model.addAlias(proteinAlias3); + model.addElement(proteinAlias3); Species proteinAlias4 = new GenericProtein("sa4"); proteinAlias4.setName("s5"); proteinAlias4.addMiriamData(new MiriamData(MiriamRelationType.BQ_MODEL_IS, MiriamType.CHEMBL_TARGET, "CHEMBL12345")); - model.addAlias(proteinAlias4); + model.addElement(proteinAlias4); Compartment compartmentAlias = new Compartment("cca"); compartmentAlias.setName("c1"); compartmentAlias.addMiriamData(new MiriamData(MiriamRelationType.BQ_MODEL_IS, MiriamType.CHEBI, "CHEBI:12")); - model.addAlias(compartmentAlias); + model.addElement(compartmentAlias); return model; } @@ -187,32 +187,32 @@ public class ModelTest { Species alias = new GenericProtein("2"); alias.setWidth(100); alias.setHeight(100); - model.addAlias(alias); + model.addElement(alias); alias = new GenericProtein("3"); alias.setWidth(10); alias.setHeight(10); - model.addAlias(alias); + model.addElement(alias); alias = new GenericProtein("4"); alias.setWidth(200); alias.setHeight(100); - model.addAlias(alias); + model.addElement(alias); Compartment cAlias = new Compartment("5"); cAlias.setWidth(10); cAlias.setHeight(20); - model.addAlias(cAlias); + model.addElement(cAlias); cAlias = new Compartment("6"); cAlias.setWidth(100); cAlias.setHeight(200); - model.addAlias(cAlias); + model.addElement(cAlias); cAlias = new Compartment("7"); cAlias.setWidth(20); cAlias.setHeight(30); - model.addAlias(cAlias); + model.addElement(cAlias); List<Element> sortedAliases = model.getAliasesSortedBySize(); if (sortedAliases.size() > 0) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/model/SubmodelConnectionComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/model/SubmodelConnectionComparatorTest.java index 858fc735fe..2351aa6a17 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/model/SubmodelConnectionComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/model/SubmodelConnectionComparatorTest.java @@ -168,9 +168,9 @@ public class SubmodelConnectionComparatorTest { Species alias = new GenericProtein("a_id"); alias.setName("ad"); alias.setElementId("a_id"); - model.addAlias(alias); + model.addElement(alias); - model.addAlias(new Compartment("default")); + model.addElement(new Compartment("default")); Layer layer = new Layer(); layer.setName("layer name"); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/reaction/NodeOperatorComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/reaction/NodeOperatorComparatorTest.java index 752671aace..208cf3e900 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/reaction/NodeOperatorComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/reaction/NodeOperatorComparatorTest.java @@ -81,6 +81,14 @@ public class NodeOperatorComparatorTest { operator1 = createNodeOperator(); operator2 = createNodeOperator(); + Product product= (Product) operator1.getOutputs().get(0); + product.setAlias(new GenericProtein("id666")); + assertTrue(comparator.compare(operator1, operator2) != 0); + assertTrue(comparator.compare(operator2, operator1) != 0); + + operator1 = createNodeOperator(); + operator2 = createNodeOperator(); + reactant = (Reactant) operator1.getInputs().get(0); reactant.getAlias().setName("bla"); assertTrue(comparator.compare(operator1, operator2) != 0); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/AllSpeciesTests.java b/model/src/test/java/lcsb/mapviewer/model/map/species/AllSpeciesTests.java index e788f45443..7d9ef9c87c 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/AllSpeciesTests.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/AllSpeciesTests.java @@ -10,6 +10,7 @@ import lcsb.mapviewer.model.map.species.field.AllFieldTests; @SuiteClasses({ AllFieldTests.class, // AntisenseRnaComparatorTest.class, // AntisenseRnaTest.class, // + ChemicalComparatorTest.class, // ComplexComparatorTest.class, // ComplexTest.class, // DegradedComparatorTest.class, // @@ -19,8 +20,11 @@ import lcsb.mapviewer.model.map.species.field.AllFieldTests; ElementComparatorTest.class, // ElementTest.class, // GeneComparatorTest.class, // + GenericProteinComparatorTest.class, // + GenericProteinTest.class, // GeneTest.class, // IonChannelProteinTest.class, // + IonChannelProteinComparatorTest.class, // IonComparatorTest.class, // IonTest.class, // PhenotypeComparatorTest.class, // @@ -28,6 +32,7 @@ import lcsb.mapviewer.model.map.species.field.AllFieldTests; ProteinComparatorTest.class, // ProteinTest.class, // ReceptorProteinTest.class, // + ReceptorProteinComparatorTest.class, // RnaComparatorTest.class, // RnaTest.class, // SimpleMoleculeComparatorTest.class, // @@ -35,6 +40,7 @@ import lcsb.mapviewer.model.map.species.field.AllFieldTests; SpeciesComparatorTest.class, // SpeciesTest.class, // TruncatedProteinTest.class, // + TruncatedProteinComparatorTest.class, // UnknownComparatorTest.class, // UnknownTest.class, // }) diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparatorTest.java index 6668697f82..09242c6506 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaComparatorTest.java @@ -7,6 +7,7 @@ import static org.junit.Assert.fail; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; @@ -66,9 +67,7 @@ public class AntisenseRnaComparatorTest { unknown.setName("n"); assertTrue(comparator.compare(unknown, aRna2) != 0); - assertTrue(comparator.compare(unknown, new AntisenseRna() { - private static final long serialVersionUID = 1L; - }) != 0); + assertTrue(comparator.compare(unknown, Mockito.mock(AntisenseRna.class)) != 0); } catch (Exception e) { e.printStackTrace(); fail("Unknowne exception occurred"); @@ -91,12 +90,8 @@ public class AntisenseRnaComparatorTest { @Test public void testInvalid() { try { - class Tmp extends AntisenseRna { - private static final long serialVersionUID = 1L; - } - Tmp object = new Tmp(); - - comparator.compare(object, object); + AntisenseRna element = Mockito.mock(AntisenseRna.class); + comparator.compare(element, element); fail("Exception expected"); } catch (NotImplementedException e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaTest.java index 797200f2ec..a6c6ec3bfb 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/AntisenseRnaTest.java @@ -11,6 +11,7 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.AntisenseRnaRegion; @@ -79,13 +80,8 @@ public class AntisenseRnaTest { @Test public void testInvalidCopy() { try { - new AntisenseRna() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + AntisenseRna element = Mockito.spy(AntisenseRna.class); + element.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ChemicalComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ChemicalComparatorTest.java new file mode 100644 index 0000000000..b024670527 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ChemicalComparatorTest.java @@ -0,0 +1,84 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class ChemicalComparatorTest { + + ChemicalComparator comparator = new ChemicalComparator(); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEquals() { + try { + Chemical drug1 = createChemical(); + Chemical drug2 = createChemical(); + + assertEquals(0, comparator.compare(drug1, drug1)); + + assertEquals(0, comparator.compare(drug1, drug2)); + assertEquals(0, comparator.compare(drug2, drug1)); + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + + @Test + public void testDifferent() { + try { + Chemical drug2 = createChemical(); + assertTrue(comparator.compare(null, drug2) != 0); + assertTrue(comparator.compare(drug2, null) != 0); + assertTrue(comparator.compare(null, null) == 0); + + Chemical drug = createChemical(); + drug.setName("n"); + assertTrue(comparator.compare(drug, drug2) != 0); + + assertTrue(comparator.compare(drug, Mockito.mock(Chemical.class)) != 0); + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + + public Chemical createChemical() { + Chemical result = new Ion(); + return result; + } + + @Test + public void testInvalid() { + try { + Chemical object = Mockito.mock(Chemical.class); + + comparator.compare(object, object); + + fail("Exception expected"); + } catch (NotImplementedException e) { + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexComparatorTest.java index 487cc2f5bb..295600e2ca 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ComplexComparatorTest.java @@ -115,10 +115,6 @@ public class ComplexComparatorTest { assertTrue(comparator.compare(alias1, alias2) != 0); assertTrue(comparator.compare(alias2, alias1) != 0); - assertTrue(comparator.compare(alias2, new Complex() { - private static final long serialVersionUID = 1L; - }) != 0); - } catch (Exception e) { e.printStackTrace(); throw e; @@ -152,14 +148,9 @@ public class ComplexComparatorTest { @Test public void testInvalid3() { try { - class Tmp extends Complex { - private static final long serialVersionUID = 1L; - } - ; - Tmp alias1 = new Tmp(); - Tmp alias2 = new Tmp(); + Complex invalidComplex = Mockito.mock(Complex.class); - comparator.compare(alias1, alias2); + comparator.compare(invalidComplex, invalidComplex); fail("Exception expected"); } catch (NotImplementedException e) { @@ -214,23 +205,6 @@ public class ComplexComparatorTest { } } - @Test - public void testInvalidComp() throws Exception { - try { - class Tmp extends Complex { - private static final long serialVersionUID = 1L; - } - - comparator.compare(new Tmp(), new Tmp()); - fail("Exception expected"); - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - - } - @Test public void testInvalidComp2() throws Exception { try { @@ -324,13 +298,7 @@ public class ComplexComparatorTest { assertTrue(comparator.compare(complex1, complex2) != 0); assertTrue(comparator.compare(complex2, complex1) != 0); - assertTrue(comparator.compare(new Complex(), new Complex() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }) != 0); + assertTrue(comparator.compare(new Complex(), Mockito.mock(Complex.class)) != 0); } catch (Exception e) { e.printStackTrace(); 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 ba80d63614..34a28408e0 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 @@ -8,11 +8,9 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; -import lcsb.mapviewer.model.map.species.Complex; -import lcsb.mapviewer.model.map.species.GenericProtein; -import lcsb.mapviewer.model.map.species.Species; public class ComplexTest { @@ -122,15 +120,37 @@ public class ComplexTest { } @Test - public void testInvalidCopy() { + public void testGetters() { try { - new Complex() { + Complex original = new Complex(); + assertNotNull(original.getStringType()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + @Test + public void testGetAllSimpleChildren() { + try { + Complex child = new Complex(); + child.addAlias(new GenericProtein("id2")); + Complex original = new Complex(); + original.addAlias(child); + original.addAlias(new Complex()); + original.addAlias(new GenericProtein("id")); + assertEquals(2, original.getAllSimpleChildren().size()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalidCopy() { + try { + Complex object = Mockito.spy(Complex.class); + object.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/DegradedComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/DegradedComparatorTest.java index fcd2c76542..9256b2a65a 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/DegradedComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/DegradedComparatorTest.java @@ -7,6 +7,7 @@ import static org.junit.Assert.fail; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -60,9 +61,7 @@ public class DegradedComparatorTest { degraded.setName("n"); assertTrue(comparator.compare(degraded, degraded1) != 0); - assertTrue(comparator.compare(degraded, new Degraded() { - private static final long serialVersionUID = 1L; - }) != 0); + assertTrue(comparator.compare(degraded, Mockito.mock(Degraded.class)) != 0); } catch (Exception e) { e.printStackTrace(); fail("Unknowne exception occurred"); @@ -78,10 +77,7 @@ public class DegradedComparatorTest { @Test public void testInvalid() { try { - class Tmp extends Degraded { - private static final long serialVersionUID = 1L; - } - Tmp object = new Tmp(); + Degraded object = Mockito.mock(Degraded.class); comparator.compare(object, object); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/DegradedTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/DegradedTest.java index 7936da6c48..b41fdde8f4 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/DegradedTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/DegradedTest.java @@ -1,17 +1,17 @@ package lcsb.mapviewer.model.map.species; -import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertNotNull; +import static org.junit.Assert.fail; +import org.apache.commons.lang3.SerializationUtils; import org.junit.After; -import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; -public class DegradedTest { +import lcsb.mapviewer.common.exception.NotImplementedException; - @AfterClass - public static void tearDownAfterClass() throws Exception { - } +public class DegradedTest { @Before public void setUp() throws Exception { @@ -22,11 +22,55 @@ public class DegradedTest { } @Test - public void testConstructor() { + public void testSerialization() { + try { + SerializationUtils.serialize(new Degraded()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testConstructor1() { + try { + Degraded degraded = new Degraded(""); + assertNotNull(degraded); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetters() { + try { + Degraded degraded = new Degraded(new Degraded()); + assertNotNull(degraded.getStringType()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testCopy() { + try { + Degraded degraded = new Degraded().copy(); + assertNotNull(degraded); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testInvalidCopy() { try { - String id = "id"; - Degraded degraded = new Degraded(id); - assertEquals(id, degraded.getElementId()); + Degraded object = Mockito.spy(Degraded.class); + object.copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { } catch (Exception e) { e.printStackTrace(); throw e; diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/DrugComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/DrugComparatorTest.java index 058e18c95e..f0568d1dec 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/DrugComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/DrugComparatorTest.java @@ -7,6 +7,7 @@ import static org.junit.Assert.fail; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -51,9 +52,7 @@ public class DrugComparatorTest { drug.setName("n"); assertTrue(comparator.compare(drug, drug2) != 0); - assertTrue(comparator.compare(drug, new Drug() { - private static final long serialVersionUID = 1L; - }) != 0); + assertTrue(comparator.compare(drug, Mockito.mock(Drug.class)) != 0); } catch (Exception e) { e.printStackTrace(); @@ -69,10 +68,7 @@ public class DrugComparatorTest { @Test public void testInvalid() { try { - class Tmp extends Drug { - private static final long serialVersionUID = 1L; - } - Tmp object = new Tmp(); + Drug object = Mockito.mock(Drug.class); comparator.compare(object, object); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/DrugTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/DrugTest.java index cad4f1a371..bb1dd2c8b5 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/DrugTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/DrugTest.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -66,13 +67,8 @@ public class DrugTest { @Test public void testInvalidCopy() { try { - new Drug() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + Drug drug = Mockito.spy(Drug.class); + drug.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ElementComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ElementComparatorTest.java index a9225cc0a5..43cbdec5fc 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/ElementComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ElementComparatorTest.java @@ -134,13 +134,13 @@ public class ElementComparatorTest { model.setNotes("Some description"); GenericProtein protein = new GenericProtein("A"); protein.setName("ad"); - model.addAlias(protein); + model.addElement(protein); Protein alias = new GenericProtein("a_id"); alias.setName("ad"); - model.addAlias(alias); + model.addElement(alias); - model.addAlias(new Compartment("default")); + model.addElement(new Compartment("default")); Layer layer = new Layer(); layer.setName("layer name"); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/GeneComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/GeneComparatorTest.java index 6f2653df93..5d41302f56 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/GeneComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/GeneComparatorTest.java @@ -7,6 +7,7 @@ import static org.junit.Assert.fail; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.ModificationResidue; @@ -66,9 +67,7 @@ public class GeneComparatorTest { gene.setName("n"); assertTrue(comparator.compare(gene, gene2) != 0); - assertTrue(comparator.compare(gene, new Gene() { - private static final long serialVersionUID = 1L; - }) != 0); + assertTrue(comparator.compare(gene, Mockito.mock(Gene.class)) != 0); } catch (Exception e) { e.printStackTrace(); @@ -95,10 +94,7 @@ public class GeneComparatorTest { @Test public void testInvalid() { try { - class Tmp extends Gene { - private static final long serialVersionUID = 1L; - } - Tmp object = new Tmp(); + Gene object = Mockito.mock(Gene.class); comparator.compare(object, object); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/GeneTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/GeneTest.java index d5fad50721..ec7c48dcd1 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/GeneTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/GeneTest.java @@ -11,6 +11,7 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.ModificationResidue; @@ -76,13 +77,8 @@ public class GeneTest { @Test public void testInvalidCopy() { try { - new Gene() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + Gene gene = Mockito.spy(Gene.class); + gene.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/GenericProteinComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/GenericProteinComparatorTest.java new file mode 100644 index 0000000000..08c34c0b73 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/GenericProteinComparatorTest.java @@ -0,0 +1,84 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class GenericProteinComparatorTest { + + GenericProteinComparator comparator = new GenericProteinComparator(); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEquals() { + try { + GenericProtein drug1 = createGenericProtein(); + GenericProtein drug2 = createGenericProtein(); + + assertEquals(0, comparator.compare(drug1, drug1)); + + assertEquals(0, comparator.compare(drug1, drug2)); + assertEquals(0, comparator.compare(drug2, drug1)); + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + + @Test + public void testDifferent() { + try { + GenericProtein drug2 = createGenericProtein(); + assertTrue(comparator.compare(null, drug2) != 0); + assertTrue(comparator.compare(drug2, null) != 0); + assertTrue(comparator.compare(null, null) == 0); + + GenericProtein drug = createGenericProtein(); + drug.setName("n"); + assertTrue(comparator.compare(drug, drug2) != 0); + + assertTrue(comparator.compare(drug, Mockito.mock(GenericProtein.class)) != 0); + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + + public GenericProtein createGenericProtein() { + GenericProtein result = new GenericProtein(); + return result; + } + + @Test + public void testInvalid() { + try { + GenericProtein object = Mockito.mock(GenericProtein.class); + + comparator.compare(object, object); + + fail("Exception expected"); + } catch (NotImplementedException e) { + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/GenericProteinTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/GenericProteinTest.java index 53aa91c095..213f7baefc 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/GenericProteinTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/GenericProteinTest.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -55,13 +56,8 @@ public class GenericProteinTest { @Test public void testCopy2() { try { - new GenericProtein() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + GenericProtein protein = Mockito.spy(GenericProtein.class); + protein.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/IonChannelProteinComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/IonChannelProteinComparatorTest.java new file mode 100644 index 0000000000..b1aae7f059 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/IonChannelProteinComparatorTest.java @@ -0,0 +1,84 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class IonChannelProteinComparatorTest { + + IonChannelProteinComparator comparator = new IonChannelProteinComparator(); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEquals() { + try { + IonChannelProtein drug1 = createIonChannelProtein(); + IonChannelProtein drug2 = createIonChannelProtein(); + + assertEquals(0, comparator.compare(drug1, drug1)); + + assertEquals(0, comparator.compare(drug1, drug2)); + assertEquals(0, comparator.compare(drug2, drug1)); + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + + @Test + public void testDifferent() { + try { + IonChannelProtein drug2 = createIonChannelProtein(); + assertTrue(comparator.compare(null, drug2) != 0); + assertTrue(comparator.compare(drug2, null) != 0); + assertTrue(comparator.compare(null, null) == 0); + + IonChannelProtein drug = createIonChannelProtein(); + drug.setName("n"); + assertTrue(comparator.compare(drug, drug2) != 0); + + assertTrue(comparator.compare(drug, Mockito.mock(IonChannelProtein.class)) != 0); + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + + public IonChannelProtein createIonChannelProtein() { + IonChannelProtein result = new IonChannelProtein(); + return result; + } + + @Test + public void testInvalid() { + try { + IonChannelProtein object = Mockito.mock(IonChannelProtein.class); + + comparator.compare(object, object); + + fail("Exception expected"); + } catch (NotImplementedException e) { + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/IonComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/IonComparatorTest.java index a9e5691708..8163f74c76 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/IonComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/IonComparatorTest.java @@ -7,6 +7,7 @@ import static org.junit.Assert.fail; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -51,9 +52,7 @@ public class IonComparatorTest { ion.setName("n"); assertTrue(comparator.compare(ion, ion2) != 0); - assertTrue(comparator.compare(ion, new Ion() { - private static final long serialVersionUID = 1L; - }) != 0); + assertTrue(comparator.compare(ion, Mockito.mock(Ion.class)) != 0); } catch (Exception e) { e.printStackTrace(); throw e; @@ -68,10 +67,7 @@ public class IonComparatorTest { @Test public void testInvalid() { try { - class Tmp extends Ion { - private static final long serialVersionUID = 1L; - } - Tmp object = new Tmp(); + Ion object = Mockito.mock(Ion.class); comparator.compare(object, object); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/IonTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/IonTest.java index c109339377..dd3a5ace78 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/IonTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/IonTest.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -66,13 +67,8 @@ public class IonTest { @Test public void testInvalidCopy() { try { - new Ion() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + Ion ion = Mockito.spy(Ion.class); + ion.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeComparatorTest.java index 55b6357c7e..8d0db8a144 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeComparatorTest.java @@ -7,6 +7,7 @@ import static org.junit.Assert.fail; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -42,13 +43,9 @@ public class PhenotypeComparatorTest { @Test public void testInvalid() { try { - class Tmp extends Phenotype { - private static final long serialVersionUID = 1L; - } - Tmp phenotype1 = new Tmp(); - Tmp phenotype2 = new Tmp(); + Phenotype phenotype1 = Mockito.mock(Phenotype.class); - comparator.compare(phenotype1, phenotype2); + comparator.compare(phenotype1, phenotype1); fail("Exception expected"); } catch (NotImplementedException e) { @@ -67,9 +64,7 @@ public class PhenotypeComparatorTest { assertTrue(comparator.compare(phenotype2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - assertTrue(comparator.compare(phenotype2, new Phenotype() { - private static final long serialVersionUID = 1L; - }) != 0); + assertTrue(comparator.compare(phenotype2, Mockito.mock(Phenotype.class)) != 0); Phenotype phenotype = createPhenotype(); phenotype2 = createPhenotype(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeTest.java index fd370eb7e4..5342df9a7d 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/PhenotypeTest.java @@ -1,5 +1,6 @@ package lcsb.mapviewer.model.map.species; +import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.fail; @@ -7,6 +8,7 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -42,6 +44,29 @@ public class PhenotypeTest { } } + @Test + public void testConstructor2() { + try { + String id = "idd"; + Phenotype copy = new Phenotype(id); + assertEquals(id, copy.getElementId()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetters() { + try { + Phenotype copy = new Phenotype("id"); + assertNotNull(copy.getStringType()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + @Test public void testCopy() { try { @@ -56,13 +81,8 @@ public class PhenotypeTest { @Test public void testInvalidCopy() { try { - new Phenotype() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + Phenotype phenotype = Mockito.spy(Phenotype.class); + phenotype.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ProteinComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ProteinComparatorTest.java index a96555a5a4..177a924e83 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/ProteinComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ProteinComparatorTest.java @@ -7,7 +7,9 @@ import static org.junit.Assert.fail; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; +import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.ModificationResidue; import lcsb.mapviewer.model.map.species.field.ModificationState; @@ -26,60 +28,86 @@ public class ProteinComparatorTest { @Test public void testEquals() { try { - GenericProtein aRna1 = createProtein(); - GenericProtein aRna2 = createProtein(); + GenericProtein protein1 = createProtein(); + GenericProtein protein2 = createProtein(); - assertEquals(0, comparator.compare(aRna1, aRna1)); + assertEquals(0, comparator.compare(protein1, protein1)); - assertEquals(0, comparator.compare(aRna1, aRna2)); - assertEquals(0, comparator.compare(aRna2, aRna1)); + assertEquals(0, comparator.compare(protein1, protein2)); + assertEquals(0, comparator.compare(protein2, protein1)); + + assertEquals(0, comparator.compare(null, null)); + + assertEquals(0, comparator.compare(new TruncatedProtein(), new TruncatedProtein())); + assertEquals(0, comparator.compare(new ReceptorProtein(), new ReceptorProtein())); + assertEquals(0, comparator.compare(new IonChannelProtein(), new IonChannelProtein())); } catch (Exception e) { e.printStackTrace(); - fail("Unknowne exception occurred"); + throw e; + } + } + + @Test + public void testUnknownProteinImplementations() { + try { + Protein protein1 = Mockito.mock(Protein.class); + assertEquals(0, comparator.compare(protein1, protein1)); + + fail("Exception expected"); + + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; } } @Test public void testDifferent() { try { - GenericProtein aRna1 = createProtein(); - GenericProtein aRna2 = createProtein(); - aRna1.getModificationResidues().get(0).setName("bla"); - assertTrue(comparator.compare(aRna1, aRna2) != 0); - assertTrue(comparator.compare(aRna2, aRna1) != 0); - - aRna1 = createProtein(); - aRna2 = createProtein(); - aRna1.getModificationResidues().clear(); - assertTrue(comparator.compare(aRna1, aRna2) != 0); - assertTrue(comparator.compare(aRna2, aRna1) != 0); - - aRna1 = createProtein(); - aRna2 = createProtein(); - assertTrue(comparator.compare(null, aRna2) != 0); - assertTrue(comparator.compare(aRna2, null) != 0); + GenericProtein protein1 = createProtein(); + GenericProtein protein2 = createProtein(); + assertTrue(comparator.compare(null, protein2) != 0); + assertTrue(comparator.compare(protein2, null) != 0); + + protein1.getModificationResidues().get(0).setName("bla"); + assertTrue(comparator.compare(protein1, protein2) != 0); + assertTrue(comparator.compare(protein2, protein1) != 0); + + protein1 = createProtein(); + protein2 = createProtein(); + protein1.getModificationResidues().clear(); + assertTrue(comparator.compare(protein1, protein2) != 0); + assertTrue(comparator.compare(protein2, protein1) != 0); + + protein1 = createProtein(); + protein2 = createProtein(); + assertTrue(comparator.compare(null, protein2) != 0); + assertTrue(comparator.compare(protein2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - assertTrue(comparator.compare(aRna2, new GenericProtein()) != 0); - - aRna1 = createProtein(); - aRna2 = createProtein(); - aRna1.setName("a"); - assertTrue(comparator.compare(aRna1, aRna2) != 0); - assertTrue(comparator.compare(aRna2, aRna1) != 0); - - aRna1 = createProtein(); - aRna2 = createProtein(); - aRna1.setStructuralState("a"); - assertTrue(comparator.compare(aRna1, aRna2) != 0); - assertTrue(comparator.compare(aRna2, aRna1) != 0); - - aRna1 = createProtein(); - aRna2 = createProtein(); - aRna1.setHomodimer(1); - assertTrue(comparator.compare(aRna1, aRna2) != 0); - assertTrue(comparator.compare(aRna2, aRna1) != 0); + assertTrue(comparator.compare(protein2, new GenericProtein()) != 0); + + protein1 = createProtein(); + protein2 = createProtein(); + protein1.setName("a"); + assertTrue(comparator.compare(protein1, protein2) != 0); + assertTrue(comparator.compare(protein2, protein1) != 0); + + protein1 = createProtein(); + protein2 = createProtein(); + protein1.setStructuralState("a"); + assertTrue(comparator.compare(protein1, protein2) != 0); + assertTrue(comparator.compare(protein2, protein1) != 0); + + protein1 = createProtein(); + protein2 = createProtein(); + protein1.setHomodimer(1); + assertTrue(comparator.compare(protein1, protein2) != 0); + assertTrue(comparator.compare(protein2, protein1) != 0); + + assertTrue(comparator.compare(new GenericProtein(), new TruncatedProtein()) != 0); } catch (Exception e) { e.printStackTrace(); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ReceptorProteinComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ReceptorProteinComparatorTest.java new file mode 100644 index 0000000000..29c5801d47 --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ReceptorProteinComparatorTest.java @@ -0,0 +1,84 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class ReceptorProteinComparatorTest { + + ReceptorProteinComparator comparator = new ReceptorProteinComparator(); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEquals() { + try { + ReceptorProtein drug1 = createReceptorProtein(); + ReceptorProtein drug2 = createReceptorProtein(); + + assertEquals(0, comparator.compare(drug1, drug1)); + + assertEquals(0, comparator.compare(drug1, drug2)); + assertEquals(0, comparator.compare(drug2, drug1)); + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + + @Test + public void testDifferent() { + try { + ReceptorProtein drug2 = createReceptorProtein(); + assertTrue(comparator.compare(null, drug2) != 0); + assertTrue(comparator.compare(drug2, null) != 0); + assertTrue(comparator.compare(null, null) == 0); + + ReceptorProtein drug = createReceptorProtein(); + drug.setName("n"); + assertTrue(comparator.compare(drug, drug2) != 0); + + assertTrue(comparator.compare(drug, Mockito.mock(ReceptorProtein.class)) != 0); + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + + public ReceptorProtein createReceptorProtein() { + ReceptorProtein result = new ReceptorProtein(); + return result; + } + + @Test + public void testInvalid() { + try { + ReceptorProtein object = Mockito.mock(ReceptorProtein.class); + + comparator.compare(object, object); + + fail("Exception expected"); + } catch (NotImplementedException e) { + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/ReceptorProteinTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/ReceptorProteinTest.java index 8d94528dbc..7b8a84dab4 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/ReceptorProteinTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/ReceptorProteinTest.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -55,13 +56,8 @@ public class ReceptorProteinTest { @Test public void testCopy2() { try { - new ReceptorProtein() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + ReceptorProtein protein = Mockito.spy(ReceptorProtein.class); + protein.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/RnaComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/RnaComparatorTest.java index e86a6cf44c..3ead55dee7 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/RnaComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/RnaComparatorTest.java @@ -7,6 +7,7 @@ import static org.junit.Assert.fail; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.ModificationState; @@ -66,9 +67,7 @@ public class RnaComparatorTest { rna.setName("n"); assertTrue(comparator.compare(rna, aRna2) != 0); - assertTrue(comparator.compare(rna, new Rna() { - private static final long serialVersionUID = 1L; - }) != 0); + assertTrue(comparator.compare(rna, Mockito.mock(Rna.class)) != 0); } catch (Exception e) { e.printStackTrace(); @@ -93,10 +92,7 @@ public class RnaComparatorTest { @Test public void testInvalid() { try { - class Tmp extends Rna { - private static final long serialVersionUID = 1L; - } - Tmp object = new Tmp(); + Rna object = Mockito.mock(Rna.class); comparator.compare(object, object); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/RnaTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/RnaTest.java index 9bee28a121..6cde518d7d 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/RnaTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/RnaTest.java @@ -12,6 +12,7 @@ import org.apache.log4j.Logger; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.species.field.RnaRegion; @@ -91,13 +92,8 @@ public class RnaTest { @Test public void testInvalidCopy() { try { - new Rna() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + Rna object = Mockito.spy(Rna.class); + object.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparatorTest.java index fc05700b63..b696a4286f 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeComparatorTest.java @@ -7,6 +7,7 @@ import static org.junit.Assert.fail; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -66,9 +67,7 @@ public class SimpleMoleculeComparatorTest { assertTrue(comparator.compare(simpleMolecule2, null) != 0); assertTrue(comparator.compare(null, null) == 0); - assertTrue(comparator.compare(simpleMolecule1, new SimpleMolecule() { - private static final long serialVersionUID = 1L; - }) != 0); + assertTrue(comparator.compare(simpleMolecule1, Mockito.mock(SimpleMolecule.class)) != 0); } catch (Exception e) { e.printStackTrace(); @@ -79,13 +78,8 @@ public class SimpleMoleculeComparatorTest { @Test public void testInvalid() { try { - class Tmp extends SimpleMolecule { - private static final long serialVersionUID = 1L; - } - ; - Tmp simpleMolecule1 = new Tmp(); - Tmp simpleMolecule2 = new Tmp(); - comparator.compare(simpleMolecule1, simpleMolecule2); + SimpleMolecule simpleMolecule1 = Mockito.mock(SimpleMolecule.class); + comparator.compare(simpleMolecule1, simpleMolecule1); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeTest.java index a2e3158d89..65d2709d38 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/SimpleMoleculeTest.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -66,13 +67,8 @@ public class SimpleMoleculeTest { @Test public void testInvalidCopy() { try { - new SimpleMolecule() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + SimpleMolecule simpleMolecule = Mockito.spy(SimpleMolecule.class); + simpleMolecule.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesComparatorTest.java index cc774a095d..acbe0f722f 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/SpeciesComparatorTest.java @@ -11,7 +11,6 @@ import org.junit.Before; import org.junit.Test; import org.mockito.Mockito; -import lcsb.mapviewer.common.exception.InvalidClassException; import lcsb.mapviewer.common.exception.NotImplementedException; import lcsb.mapviewer.model.map.MiriamData; import lcsb.mapviewer.model.map.MiriamRelationType; @@ -20,7 +19,6 @@ import lcsb.mapviewer.model.map.species.field.PositionToCompartment; public class SpeciesComparatorTest { - SpeciesComparator comparator = new SpeciesComparator(); @Before @@ -147,7 +145,6 @@ public class SpeciesComparatorTest { } } - @Test public void testException() { try { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/TruncatedProteinComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/TruncatedProteinComparatorTest.java new file mode 100644 index 0000000000..8c81b8f89f --- /dev/null +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/TruncatedProteinComparatorTest.java @@ -0,0 +1,84 @@ +package lcsb.mapviewer.model.map.species; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; + +import org.junit.After; +import org.junit.Before; +import org.junit.Test; +import org.mockito.Mockito; + +import lcsb.mapviewer.common.exception.NotImplementedException; + +public class TruncatedProteinComparatorTest { + + TruncatedProteinComparator comparator = new TruncatedProteinComparator(); + + @Before + public void setUp() throws Exception { + } + + @After + public void tearDown() throws Exception { + } + + @Test + public void testEquals() { + try { + TruncatedProtein drug1 = createTruncatedProtein(); + TruncatedProtein drug2 = createTruncatedProtein(); + + assertEquals(0, comparator.compare(drug1, drug1)); + + assertEquals(0, comparator.compare(drug1, drug2)); + assertEquals(0, comparator.compare(drug2, drug1)); + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + + @Test + public void testDifferent() { + try { + TruncatedProtein drug2 = createTruncatedProtein(); + assertTrue(comparator.compare(null, drug2) != 0); + assertTrue(comparator.compare(drug2, null) != 0); + assertTrue(comparator.compare(null, null) == 0); + + TruncatedProtein drug = createTruncatedProtein(); + drug.setName("n"); + assertTrue(comparator.compare(drug, drug2) != 0); + + assertTrue(comparator.compare(drug, Mockito.mock(TruncatedProtein.class)) != 0); + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + + public TruncatedProtein createTruncatedProtein() { + TruncatedProtein result = new TruncatedProtein(); + return result; + } + + @Test + public void testInvalid() { + try { + TruncatedProtein object = Mockito.mock(TruncatedProtein.class); + + comparator.compare(object, object); + + fail("Exception expected"); + } catch (NotImplementedException e) { + + } catch (Exception e) { + e.printStackTrace(); + fail("Unknowne exception occurred"); + } + } + +} diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/TruncatedProteinTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/TruncatedProteinTest.java index 3a00d4471f..1150dc7a2d 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/TruncatedProteinTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/TruncatedProteinTest.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -55,13 +56,8 @@ public class TruncatedProteinTest { @Test public void testCopy2() { try { - new TruncatedProtein() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + TruncatedProtein protein = Mockito.spy(TruncatedProtein.class); + protein.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/UnknownComparatorTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/UnknownComparatorTest.java index a1e0a71553..fbc4809cd9 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/UnknownComparatorTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/UnknownComparatorTest.java @@ -7,6 +7,7 @@ import static org.junit.Assert.fail; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -51,9 +52,7 @@ public class UnknownComparatorTest { unknown.setName("n"); assertTrue(comparator.compare(unknown, unknown2) != 0); - assertTrue(comparator.compare(unknown, new Unknown() { - private static final long serialVersionUID = 1L; - }) != 0); + assertTrue(comparator.compare(unknown, Mockito.mock(Unknown.class)) != 0); } catch (Exception e) { e.printStackTrace(); @@ -69,10 +68,7 @@ public class UnknownComparatorTest { @Test public void testInvalid() { try { - class Tmp extends Unknown { - private static final long serialVersionUID = 1L; - } - Tmp object = new Tmp(); + Unknown object = Mockito.mock(Unknown.class); comparator.compare(object, object); diff --git a/model/src/test/java/lcsb/mapviewer/model/map/species/UnknownTest.java b/model/src/test/java/lcsb/mapviewer/model/map/species/UnknownTest.java index ce6a2a0a88..5dc8c9566d 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/species/UnknownTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/species/UnknownTest.java @@ -7,6 +7,7 @@ import org.apache.commons.lang3.SerializationUtils; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.NotImplementedException; @@ -66,13 +67,8 @@ public class UnknownTest { @Test public void testInvalidCopy() { try { - new Unknown() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); + Unknown object = Mockito.spy(Unknown.class); + object.copy(); fail("Exception expected"); } catch (NotImplementedException e) { } catch (Exception e) { diff --git a/model/src/test/java/lcsb/mapviewer/modelutils/map/ElementUtilsTest.java b/model/src/test/java/lcsb/mapviewer/modelutils/map/ElementUtilsTest.java index 949c2fb8e5..41ef01ea86 100644 --- a/model/src/test/java/lcsb/mapviewer/modelutils/map/ElementUtilsTest.java +++ b/model/src/test/java/lcsb/mapviewer/modelutils/map/ElementUtilsTest.java @@ -5,6 +5,7 @@ import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; import static org.junit.Assert.assertNull; import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; import java.util.LinkedList; import java.util.List; @@ -14,11 +15,15 @@ import org.apache.log4j.Logger; import org.junit.After; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.InvalidArgumentException; +import lcsb.mapviewer.common.exception.NotImplementedException; +import lcsb.mapviewer.model.map.AnnotatedObject; import lcsb.mapviewer.model.map.reaction.Reaction; import lcsb.mapviewer.model.map.reaction.type.UnknownNegativeInfluenceReaction; 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.IonChannelProtein; import lcsb.mapviewer.model.map.species.Protein; @@ -74,6 +79,37 @@ public class ElementUtilsTest { } } + @Test + public void testGetTag2() throws Exception { + try { + ElementUtils elementUtils = new ElementUtils(); + + GenericProtein protein = new GenericProtein("id"); + + assertNotNull(elementUtils.getElementTag(protein, new Object())); + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + + @Test + public void testGetTagForInvalidElement() throws Exception { + try { + ElementUtils elementUtils = new ElementUtils(); + + AnnotatedObject element = Mockito.mock(AnnotatedObject.class); + assertNotNull(elementUtils.getElementTag(element)); + fail("Exception expected"); + } catch (NotImplementedException e) { + + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } + protected void print(ClassTreeNode top, int indent) { if (indent > 10) { throw new InvalidArgumentException(); diff --git a/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelContructor.java b/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelContructor.java index 826bcee04c..40d498bf84 100644 --- a/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelContructor.java +++ b/pathvisio/src/main/java/lcsb/mapviewer/wikipathway/XML/ModelContructor.java @@ -312,7 +312,7 @@ public class ModelContructor { alias.setColor(DEFAULT_COMPLEX_ALIAS_COLOR); data.id2alias.put(group.getGraphId(), alias); - model.addAlias(alias); + model.addElement(alias); } } @@ -334,7 +334,7 @@ public class ModelContructor { Element alias = updateAlias(dataNode, species); data.id2alias.put(dataNode.getGraphId(), alias); - model.addAlias(alias); + model.addElement(alias); } for (Label label : graph.getLabels()) { if (label.isTreatAsNode()) { @@ -344,7 +344,7 @@ public class ModelContructor { Element alias = updateAlias(label, species); data.id2alias.put(label.getGraphId(), alias); - model.addAlias(alias); + model.addElement(alias); } else { LayerText text = createText(label); data.layer.addLayerText(text); @@ -358,7 +358,7 @@ public class ModelContructor { Element alias = updateAlias(shape, species); data.id2alias.put(shape.getGraphId(), alias); - model.addAlias(alias); + model.addElement(alias); } else { if (!shape.isCompartment()) { @@ -372,7 +372,7 @@ public class ModelContructor { } else { Compartment compartment = new Compartment(shape.getGraphId()); Element cmpAl = updateAlias(shape, compartment); - model.addAlias(cmpAl); + model.addElement(cmpAl); } } } diff --git a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/ModelToGPMLTest.java b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/ModelToGPMLTest.java index b69a4bb8b7..2331550164 100644 --- a/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/ModelToGPMLTest.java +++ b/pathvisio/src/test/java/lcsb/mapviewer/wikipathway/XML/ModelToGPMLTest.java @@ -72,7 +72,7 @@ public class ModelToGPMLTest extends WikipathwaysTestFunctions { alias.setX(1); alias.setY(1); - model.addAlias(alias); + model.addElement(alias); String xml = parser.getGPML(model); assertNotNull(xml); diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/ProjectDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/ProjectDaoTest.java index b7e079d5b2..ba1eb26bf8 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/ProjectDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/ProjectDaoTest.java @@ -171,10 +171,10 @@ public class ProjectDaoTest extends PersistTestFunctions { private Model createModel() { Model model = new ModelFullIndexed(null); - model.addAlias(createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "sa2")); - model.addAlias(createSpeciesAlias(267.6666666666665, 438.75, 80.0, 40.0, "sa1117")); - model.addAlias(createSpeciesAlias(261.6666666666665, 600.75, 92.0, 52.0, "sa1119")); - model.addAlias(createSpeciesAlias(203.666666666667, 687.75, 98.0, 58.0, "sa1121")); + model.addElement(createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "sa2")); + model.addElement(createSpeciesAlias(267.6666666666665, 438.75, 80.0, 40.0, "sa1117")); + model.addElement(createSpeciesAlias(261.6666666666665, 600.75, 92.0, 52.0, "sa1119")); + model.addElement(createSpeciesAlias(203.666666666667, 687.75, 98.0, 58.0, "sa1121")); Species alias = createSpeciesAlias(817.714285714286, 287.642857142859, 80.0, 40.0, "sa1422"); Species alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); @@ -184,11 +184,11 @@ public class ProjectDaoTest extends PersistTestFunctions { alias.setParent(alias3); alias2.setParent(alias3); - model.addAlias(alias); - model.addAlias(alias2); - model.addAlias(alias3); + model.addElement(alias); + model.addElement(alias2); + model.addElement(alias3); - model.addAlias(createCompartmentAlias(380.0, 416.0, 1893.0, 1866.0, "ca1")); + model.addElement(createCompartmentAlias(380.0, 416.0, 1893.0, 1866.0, "ca1")); model.setWidth(2000); model.setHeight(2000); return model; diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/CommentDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/CommentDaoTest.java index 4b8a46b053..856380cd3f 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/CommentDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/CommentDaoTest.java @@ -103,13 +103,13 @@ public class CommentDaoTest extends PersistTestFunctions { Model model = new ModelFullIndexed(null); GenericProtein alias = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "sa2"); - model.addAlias(alias); + model.addElement(alias); alias = createSpeciesAlias(267.6666666666665, 438.75, 80.0, 40.0, "sa1117"); - model.addAlias(alias); + model.addElement(alias); alias = createSpeciesAlias(261.6666666666665, 600.75, 92.0, 52.0, "sa1119"); - model.addAlias(alias); + model.addElement(alias); alias = createSpeciesAlias(203.666666666667, 687.75, 98.0, 58.0, "sa1121"); - model.addAlias(alias); + model.addElement(alias); alias = createSpeciesAlias(817.714285714286, 287.642857142859, 80.0, 40.0, "sa1422"); Species alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); @@ -119,12 +119,12 @@ public class CommentDaoTest extends PersistTestFunctions { alias.setParent(alias3); alias2.setParent(alias3); - model.addAlias(alias); - model.addAlias(alias2); - model.addAlias(alias3); + model.addElement(alias); + model.addElement(alias2); + model.addElement(alias3); Compartment cAlias = createCompartmentAlias(380.0, 416.0, 1893.0, 1866.0, "ca1"); - model.addAlias(cAlias); + model.addElement(cAlias); model.setWidth(2000); model.setHeight(2000); @@ -142,7 +142,7 @@ public class CommentDaoTest extends PersistTestFunctions { model.addReaction(reaction); alias = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "pr1"); - model.addAlias(alias); + model.addElement(alias); ModificationResidue mr = new ModificationResidue(); mr.setName("mr"); diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/LayoutDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/LayoutDaoTest.java index f752760343..0e48ff8d14 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/LayoutDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/LayoutDaoTest.java @@ -150,13 +150,13 @@ public class LayoutDaoTest extends PersistTestFunctions { Model model = new ModelFullIndexed(null); Species alias = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "sa2"); - model.addAlias(alias); + model.addElement(alias); alias = createSpeciesAlias(267.6666666666665, 438.75, 80.0, 40.0, "sa1117"); - model.addAlias(alias); + model.addElement(alias); alias = createSpeciesAlias(261.6666666666665, 600.75, 92.0, 52.0, "sa1119"); - model.addAlias(alias); + model.addElement(alias); alias = createSpeciesAlias(203.666666666667, 687.75, 98.0, 58.0, "sa1121"); - model.addAlias(alias); + model.addElement(alias); alias = createSpeciesAlias(817.714285714286, 287.642857142859, 80.0, 40.0, "sa1422"); Species alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); @@ -166,12 +166,12 @@ public class LayoutDaoTest extends PersistTestFunctions { alias.setParent(alias3); alias2.setParent(alias3); - model.addAlias(alias); - model.addAlias(alias2); - model.addAlias(alias3); + model.addElement(alias); + model.addElement(alias2); + model.addElement(alias3); Compartment cAlias = createCompartmentAlias(380.0, 416.0, 1893.0, 1866.0, "ca1"); - model.addAlias(cAlias); + model.addElement(cAlias); model.setWidth(2000); model.setHeight(2000); @@ -189,7 +189,7 @@ public class LayoutDaoTest extends PersistTestFunctions { model.addReaction(reaction); Protein protein = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "pr1"); - model.addAlias(protein); + model.addElement(protein); ModificationResidue mr = new ModificationResidue(); mr.setName("mr"); diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/ModelDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/ModelDaoTest.java index a5126a28a6..b7cd79ee28 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/ModelDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/ModelDaoTest.java @@ -115,7 +115,7 @@ public class ModelDaoTest extends PersistTestFunctions { test = false; for (Element alias : model.getAliases()) { if (alias instanceof Compartment) { - assertNotNull(fullModel.getCompartmentAliasByCompartmentAliasId(alias.getElementId())); + assertNotNull(fullModel.getElementByElementId(alias.getElementId())); test = true; } } @@ -330,13 +330,13 @@ public class ModelDaoTest extends PersistTestFunctions { Model model = new ModelFullIndexed(null); GenericProtein alias = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "sa2"); - model.addAlias(alias); + model.addElement(alias); alias = createSpeciesAlias(267.6666666666665, 438.75, 80.0, 40.0, "sa1117"); - model.addAlias(alias); + model.addElement(alias); alias = createSpeciesAlias(261.6666666666665, 600.75, 92.0, 52.0, "sa1119"); - model.addAlias(alias); + model.addElement(alias); alias = createSpeciesAlias(203.666666666667, 687.75, 98.0, 58.0, "sa1121"); - model.addAlias(alias); + model.addElement(alias); alias = createSpeciesAlias(817.714285714286, 287.642857142859, 80.0, 40.0, "sa1422"); Species alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); @@ -346,12 +346,12 @@ public class ModelDaoTest extends PersistTestFunctions { alias.setParent(alias3); alias2.setParent(alias3); - model.addAlias(alias); - model.addAlias(alias2); - model.addAlias(alias3); + model.addElement(alias); + model.addElement(alias2); + model.addElement(alias3); Compartment cAlias = createCompartmentAlias(380.0, 416.0, 1893.0, 1866.0, "ca1"); - model.addAlias(cAlias); + model.addElement(cAlias); model.setWidth(2000); model.setHeight(2000); @@ -369,7 +369,7 @@ public class ModelDaoTest extends PersistTestFunctions { model.addReaction(reaction); alias = createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "pr1"); - model.addAlias(alias); + model.addElement(alias); ModificationResidue mr = new ModificationResidue(); mr.setName("mr"); diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/graph/DataMiningDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/graph/DataMiningDaoTest.java index 352746c1d4..edc89b4ba9 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/graph/DataMiningDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/graph/DataMiningDaoTest.java @@ -42,7 +42,7 @@ public class DataMiningDaoTest extends PersistTestFunctions { project.setProjectId(projectId); Model model = new ModelFullIndexed(null); Element alias = new GenericProtein("some_el_id"); - model.addAlias(alias); + model.addElement(alias); project.addModel(model); projectDao.add(project); diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest.java index c754a4adc7..a0d5a976a2 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AliasDaoTest.java @@ -71,10 +71,10 @@ public class AliasDaoTest extends PersistTestFunctions { private Model createModel() { Model model = new ModelFullIndexed(null); - model.addAlias(createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "sa2")); - model.addAlias(createSpeciesAlias(267.6666666666665, 438.75, 80.0, 40.0, "sa1117")); - model.addAlias(createSpeciesAlias(261.6666666666665, 600.75, 92.0, 52.0, "sa1119")); - model.addAlias(createSpeciesAlias(203.666666666667, 687.75, 98.0, 58.0, "sa1121")); + model.addElement(createSpeciesAlias(264.8333333333335, 517.75, 86.0, 46.0, "sa2")); + model.addElement(createSpeciesAlias(267.6666666666665, 438.75, 80.0, 40.0, "sa1117")); + model.addElement(createSpeciesAlias(261.6666666666665, 600.75, 92.0, 52.0, "sa1119")); + model.addElement(createSpeciesAlias(203.666666666667, 687.75, 98.0, 58.0, "sa1121")); Species alias = createSpeciesAlias(817.714285714286, 287.642857142859, 80.0, 40.0, "sa1422"); Species alias2 = createSpeciesAlias(224.964285714286, 241.392857142859, 80.0, 40.0, "sa1419"); @@ -84,11 +84,11 @@ public class AliasDaoTest extends PersistTestFunctions { alias.setParent(alias3); alias2.setParent(alias3); - model.addAlias(alias); - model.addAlias(alias2); - model.addAlias(alias3); + model.addElement(alias); + model.addElement(alias2); + model.addElement(alias3); - model.addAlias(createCompartmentAlias(380.0, 416.0, 1893.0, 1866.0, "ca1")); + model.addElement(createCompartmentAlias(380.0, 416.0, 1893.0, 1866.0, "ca1")); model.setWidth(2000); model.setHeight(2000); return model; diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AntisenseRnaTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AntisenseRnaTest.java index 8f8121b864..4faae67b56 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AntisenseRnaTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/AntisenseRnaTest.java @@ -80,7 +80,7 @@ public class AntisenseRnaTest extends PersistTestFunctions { alias.setY(2); alias.setWidth(10); alias.setHeight(20); - model.addAlias(alias); + model.addElement(alias); return model; } diff --git a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/RnaTest.java b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/RnaTest.java index b275d90736..723b4dd75c 100644 --- a/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/RnaTest.java +++ b/persist/src/test/java/lcsb/mapviewer/persist/dao/map/layout/alias/RnaTest.java @@ -79,7 +79,7 @@ public class RnaTest extends PersistTestFunctions { alias.setY(2); alias.setWidth(10); alias.setHeight(20); - model.addAlias(alias); + model.addElement(alias); return model; } diff --git a/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java b/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java index de566229ae..cbe8096960 100644 --- a/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/impl/SearchServiceTest.java @@ -279,11 +279,11 @@ public class SearchServiceTest extends ServiceTestFunctions { proteinAlias.getSynonyms().add("PROT synonym"); proteinAlias.getSynonyms().add("another synonym"); proteinAlias.setFullName("Protein common name"); - model.addAlias(proteinAlias); + model.addElement(proteinAlias); SimpleMolecule alias = new SimpleMolecule("a2"); alias.setName("Molecule2"); - model.addAlias(alias); + model.addElement(alias); int oldVal = Configuration.getAutocompleteSize(); Configuration.setAutocompleteSize(5); @@ -325,11 +325,11 @@ public class SearchServiceTest extends ServiceTestFunctions { GenericProtein proteinAlias = new GenericProtein("a1"); proteinAlias.setName("PROT identifier"); proteinAlias.setNotes("Synonyms: PROT synonym, another synonym\nName: Protein common name"); - model.addAlias(proteinAlias); + model.addElement(proteinAlias); SimpleMolecule alias = new SimpleMolecule("a2"); alias.setName("Molecule2"); - model.addAlias(alias); + model.addElement(alias); List<String> list = searchService.getAutocompleteList(model, "PROT identifier"); assertNotNull(list); diff --git a/service/src/test/java/lcsb/mapviewer/services/search/data/FullAliasViewFactoryTest.java b/service/src/test/java/lcsb/mapviewer/services/search/data/FullAliasViewFactoryTest.java index 45445bb354..538ec5894c 100644 --- a/service/src/test/java/lcsb/mapviewer/services/search/data/FullAliasViewFactoryTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/search/data/FullAliasViewFactoryTest.java @@ -76,14 +76,14 @@ public class FullAliasViewFactoryTest extends ServiceTestFunctions { alias.getMiriamData().add(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.WIKIPEDIA, "144352")); alias.getMiriamData().add(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.PUBMED, "43345")); - model.addAlias(alias); + model.addElement(alias); alias2 = new GenericProtein("AL2"); alias2.setName("blablabla2"); alias2.setX(100.0); alias2.setY(120.0); - model.addAlias(alias2); + model.addElement(alias2); midPoint = new Point2D.Double(30, 100); @@ -104,7 +104,7 @@ public class FullAliasViewFactoryTest extends ServiceTestFunctions { alias3.setX(200.0); alias3.setY(120.0); - model.addAlias(alias3); + model.addElement(alias3); reaction = new NegativeInfluenceReaction(reaction); reaction.getMiriamData().add(new MiriamData(MiriamRelationType.BQ_BIOL_IS_DESCRIBED_BY, MiriamType.CAS, "cc")); @@ -116,7 +116,7 @@ public class FullAliasViewFactoryTest extends ServiceTestFunctions { compartmentAlias.setY(10); compartmentAlias.setWidth(10); compartmentAlias.setHeight(10); - model.addAlias(compartmentAlias); + model.addElement(compartmentAlias); } @After diff --git a/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugViewFactoryTest.java b/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugViewFactoryTest.java index 3e3e73c0fd..14bcf86a90 100644 --- a/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugViewFactoryTest.java +++ b/service/src/test/java/lcsb/mapviewer/services/search/db/drug/DrugViewFactoryTest.java @@ -113,7 +113,7 @@ public class DrugViewFactoryTest extends ServiceTestFunctions { alias.setName("M"); alias.setId(12); model.removeAlias(alias); - model.addAlias(alias); + model.addElement(alias); ElementIdentifier ei = new ElementIdentifier(alias, null); model.setTileSize(256); List<Model> models = new ArrayList<>(); -- GitLab