From 838749dc7f7d35741944a796641400bc7fd0cedc Mon Sep 17 00:00:00 2001 From: Piotr Gawron <piotr.gawron@uni.lu> Date: Mon, 18 Dec 2017 17:14:06 +0100 Subject: [PATCH] unit tests simplified --- .../types/ModifierTypeUtilsTest.java | 415 +++++++++--------- .../model/map/modifier/CatalysisTest.java | 127 +++--- .../model/map/modifier/InhibitionTest.java | 127 +++--- .../model/map/modifier/ModulationTest.java | 127 +++--- .../map/modifier/PhysicalStimulationTest.java | 127 +++--- .../model/map/modifier/TriggerTest.java | 127 +++--- .../map/modifier/UnknownCatalysisTest.java | 127 +++--- .../map/modifier/UnknownInhibitionTest.java | 127 +++--- .../model/map/reaction/ModifierTest.java | 107 +++-- 9 files changed, 685 insertions(+), 726 deletions(-) diff --git a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/types/ModifierTypeUtilsTest.java b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/types/ModifierTypeUtilsTest.java index 91176fc9f1..8d1cc6df9c 100644 --- a/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/types/ModifierTypeUtilsTest.java +++ b/converter-CellDesigner/src/test/java/lcsb/mapviewer/converter/model/celldesigner/types/ModifierTypeUtilsTest.java @@ -12,6 +12,7 @@ import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.Test; +import org.mockito.Mockito; import lcsb.mapviewer.common.exception.InvalidArgumentException; import lcsb.mapviewer.common.exception.InvalidStateException; @@ -29,236 +30,234 @@ import lcsb.mapviewer.model.map.species.Species; public class ModifierTypeUtilsTest { - ModifierTypeUtils utils = new ModifierTypeUtils(); + ModifierTypeUtils utils = new ModifierTypeUtils(); - Modifier invalidModifier = new Modifier() { - private static final long serialVersionUID = 1L; - }; + Modifier invalidModifier = Mockito.mock(Modifier.class, Mockito.CALLS_REAL_METHODS); - @AfterClass - public static void tearDownAfterClass() throws Exception { - } + @AfterClass + public static void tearDownAfterClass() throws Exception { + } - @Before - public void setUp() throws Exception { - } + @Before + public void setUp() throws Exception { + } - @After - public void tearDown() throws Exception { - } + @After + public void tearDown() throws Exception { + } - @Test - public void testGetInvalidModifierTypeForClazz() { - ModifierType type = utils.getModifierTypeForClazz(invalidModifier.getClass()); - assertNull(type); - } + @Test + public void testGetInvalidModifierTypeForClazz() { + ModifierType type = utils.getModifierTypeForClazz(invalidModifier.getClass()); + assertNull(type); + } - @Test - public void testGetInvalidStringTypeByModifier() { - String type = utils.getStringTypeByModifier(invalidModifier); - assertNull(type); - } + @Test + public void testGetInvalidStringTypeByModifier() { + String type = utils.getStringTypeByModifier(invalidModifier); + assertNull(type); + } - @Test - public void testGetTargetLineIndexByInvalidModifier() { - try { - utils.getTargetLineIndexByModifier(invalidModifier); - fail("Exception expected"); - } catch (InvalidArgumentException e) { - assertTrue(e.getMessage().contains("Unknown modifier class")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } + @Test + public void testGetTargetLineIndexByInvalidModifier() { + try { + utils.getTargetLineIndexByModifier(invalidModifier); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + assertTrue(e.getMessage().contains("Unknown modifier class")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } - } + } - @Test - public void testGetTargetLineIndexByInvalidModifier2() { - try { - NodeOperator operator = new AndOperator(); - operator.addInput(new Reactant()); - utils.getTargetLineIndexByModifier(operator); - fail("Exception expected"); - } catch (InvalidArgumentException e) { - assertTrue(e.getMessage().contains("Invalid NodeOperator")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testGetTargetLineIndexByInvalidModifier2() { + try { + NodeOperator operator = new AndOperator(); + operator.addInput(new Reactant()); + utils.getTargetLineIndexByModifier(operator); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + assertTrue(e.getMessage().contains("Invalid NodeOperator")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testGetTargetLineIndexByInvalidModifier3() { - try { - NodeOperator operator = new AndOperator(); - operator.addInput(invalidModifier); - utils.getTargetLineIndexByModifier(operator); - fail("Exception expected"); - } catch (InvalidArgumentException e) { - assertTrue(e.getMessage().contains("Unknown modifier class")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testGetTargetLineIndexByInvalidModifier3() { + try { + NodeOperator operator = new AndOperator(); + operator.addInput(invalidModifier); + utils.getTargetLineIndexByModifier(operator); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + assertTrue(e.getMessage().contains("Unknown modifier class")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testGetAnchorPointOnReactionRectByInvalidType() { - try { - Reaction reaction = new Reaction(); - Reactant reactant = new Reactant(); - Product product = new Product(); - reactant.setLine(new PolylineData(new Point2D.Double(), new Point2D.Double())); - product.setLine(new PolylineData(new Point2D.Double(), new Point2D.Double())); - reaction.addReactant(reactant); - reaction.addProduct(product); - Point2D point = utils.getAnchorPointOnReactionRect(reaction, "0,0"); - assertNotNull(point); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testGetAnchorPointOnReactionRectByInvalidType() { + try { + Reaction reaction = new Reaction(); + Reactant reactant = new Reactant(); + Product product = new Product(); + reactant.setLine(new PolylineData(new Point2D.Double(), new Point2D.Double())); + product.setLine(new PolylineData(new Point2D.Double(), new Point2D.Double())); + reaction.addReactant(reactant); + reaction.addProduct(product); + Point2D point = utils.getAnchorPointOnReactionRect(reaction, "0,0"); + assertNotNull(point); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testGetAnchorPointOnReactionRectByInvalidType2() { - try { - Reaction reaction = new Reaction(); - Reactant reactant = new Reactant(); - Product product = new Product(); - reactant.setLine(new PolylineData(new Point2D.Double(), new Point2D.Double())); - product.setLine(new PolylineData(new Point2D.Double(), new Point2D.Double())); - reaction.addReactant(reactant); - reaction.addProduct(product); - utils.getAnchorPointOnReactionRect(reaction, "0"); - fail("Exception expected"); - } catch (InvalidArgumentException e) { - assertTrue(e.getMessage().contains("Invalid targetLineIndex")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testGetAnchorPointOnReactionRectByInvalidType2() { + try { + Reaction reaction = new Reaction(); + Reactant reactant = new Reactant(); + Product product = new Product(); + reactant.setLine(new PolylineData(new Point2D.Double(), new Point2D.Double())); + product.setLine(new PolylineData(new Point2D.Double(), new Point2D.Double())); + reaction.addReactant(reactant); + reaction.addProduct(product); + utils.getAnchorPointOnReactionRect(reaction, "0"); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + assertTrue(e.getMessage().contains("Invalid targetLineIndex")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testGetAnchorPointOnReactionRectByInvalidType3() { - try { - Reaction reaction = new Reaction(); - Reactant reactant = new Reactant(); - Product product = new Product(); - reactant.setLine(new PolylineData(new Point2D.Double(), new Point2D.Double())); - product.setLine(new PolylineData(new Point2D.Double(), new Point2D.Double())); - reaction.addReactant(reactant); - reaction.addProduct(product); - utils.getAnchorPointOnReactionRect(reaction, "10,10"); - fail("Exception expected"); - } catch (InvalidArgumentException e) { - assertTrue(e.getMessage().contains("Unknown targetLineIndex")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testGetAnchorPointOnReactionRectByInvalidType3() { + try { + Reaction reaction = new Reaction(); + Reactant reactant = new Reactant(); + Product product = new Product(); + reactant.setLine(new PolylineData(new Point2D.Double(), new Point2D.Double())); + product.setLine(new PolylineData(new Point2D.Double(), new Point2D.Double())); + reaction.addReactant(reactant); + reaction.addProduct(product); + utils.getAnchorPointOnReactionRect(reaction, "10,10"); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + assertTrue(e.getMessage().contains("Unknown targetLineIndex")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testUpdateLineEndPointForInvalidModifier() { - try { - utils.updateLineEndPoint(invalidModifier); - fail("Exception expected"); - } catch (InvalidArgumentException e) { - assertTrue(e.getMessage().contains("Unknown modifier class")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testUpdateLineEndPointForInvalidModifier() { + try { + utils.updateLineEndPoint(invalidModifier); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + assertTrue(e.getMessage().contains("Unknown modifier class")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testUpdateLineEndPointForInvalidModifier2() { - try { - NodeOperator operator = new AndOperator(); - operator.addInput(new Product()); - operator.addInput(invalidModifier); - utils.updateLineEndPoint(operator); - fail("Exception expected"); - } catch (InvalidArgumentException e) { - assertTrue(e.getMessage().contains("Unknown modifier class")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testUpdateLineEndPointForInvalidModifier2() { + try { + NodeOperator operator = new AndOperator(); + operator.addInput(new Product()); + operator.addInput(invalidModifier); + utils.updateLineEndPoint(operator); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + assertTrue(e.getMessage().contains("Unknown modifier class")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testUpdateLineEndPointForInvalidModifier3() { - try { - NodeOperator operator = new AndOperator(); - operator.addInput(new Product()); - operator.addInput(new Product()); - utils.updateLineEndPoint(operator); - fail("Exception expected"); - } catch (InvalidArgumentException e) { - assertTrue(e.getMessage().contains("Operator contains invalid input")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testUpdateLineEndPointForInvalidModifier3() { + try { + NodeOperator operator = new AndOperator(); + operator.addInput(new Product()); + operator.addInput(new Product()); + utils.updateLineEndPoint(operator); + fail("Exception expected"); + } catch (InvalidArgumentException e) { + assertTrue(e.getMessage().contains("Operator contains invalid input")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCreateInvalidModifierForStringType2() throws Exception { - // artificial implementation of Modifier that is invalid - class InvalidModifier extends Modifier { - private static final long serialVersionUID = 1L; + @Test + public void testCreateInvalidModifierForStringType2() throws Exception { + // artificial implementation of Modifier that is invalid + class InvalidModifier extends Modifier { + private static final long serialVersionUID = 1L; - @SuppressWarnings("unused") - public InvalidModifier() { - throw new NotImplementedException(); - } + @SuppressWarnings("unused") + public InvalidModifier() { + throw new NotImplementedException(); + } - @SuppressWarnings("unused") - public InvalidModifier(Species alias, CellDesignerElement<?> element) { - throw new NotImplementedException(); - } - } + @SuppressWarnings("unused") + public InvalidModifier(Species alias, CellDesignerElement<?> element) { + throw new NotImplementedException(); + } + } - // mopdify one of the elements of OperatorType so it will have invalid - // implementation - ModifierType typeToModify = ModifierType.CATALYSIS; - Class<? extends Modifier> clazz = typeToModify.getClazz(); + // mopdify one of the elements of OperatorType so it will have invalid + // implementation + ModifierType typeToModify = ModifierType.CATALYSIS; + Class<? extends Modifier> clazz = typeToModify.getClazz(); - try { - Field field = typeToModify.getClass().getDeclaredField("clazz"); - field.setAccessible(true); - field.set(typeToModify, InvalidModifier.class); + try { + Field field = typeToModify.getClass().getDeclaredField("clazz"); + field.setAccessible(true); + field.set(typeToModify, InvalidModifier.class); - // and check if we catch properly information about problematic - // implementation - utils.createModifierForStringType(typeToModify.getStringName(), new GenericProtein("id")); - fail("Exceptione expected"); - } catch (InvalidStateException e) { - assertTrue(e.getMessage().contains("Problem with instantiation of Modifier class")); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } finally { - // restore correct values for the modified type (if not then other test - // might fail...) - Field field = typeToModify.getClass().getDeclaredField("clazz"); - field.setAccessible(true); - field.set(typeToModify, clazz); - } - } + // and check if we catch properly information about problematic + // implementation + utils.createModifierForStringType(typeToModify.getStringName(), new GenericProtein("id")); + fail("Exceptione expected"); + } catch (InvalidStateException e) { + assertTrue(e.getMessage().contains("Problem with instantiation of Modifier class")); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } finally { + // restore correct values for the modified type (if not then other test + // might fail...) + Field field = typeToModify.getClass().getDeclaredField("clazz"); + field.setAccessible(true); + field.set(typeToModify, clazz); + } + } - @Test - public void testCreateModifierForStringType2() throws Exception { - try { - utils.createModifierForStringType("unjkType", null); - fail("Exceptione expected"); - } catch (InvalidArgumentException e) { - assertTrue(e.getMessage().contains("Unknown modifier type")); - } - } + @Test + public void testCreateModifierForStringType2() throws Exception { + try { + utils.createModifierForStringType("unjkType", null); + fail("Exceptione expected"); + } catch (InvalidArgumentException e) { + assertTrue(e.getMessage().contains("Unknown modifier type")); + } + } } diff --git a/model/src/test/java/lcsb/mapviewer/model/map/modifier/CatalysisTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/CatalysisTest.java index ba1b40daf9..661fa42125 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/CatalysisTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/CatalysisTest.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.graphics.PolylineData; @@ -14,76 +15,70 @@ import lcsb.mapviewer.model.map.species.AntisenseRna; public class CatalysisTest { - @Before - public void setUp() throws Exception { - } + @Before + public void setUp() throws Exception { + } - @After - public void tearDown() throws Exception { - } + @After + public void tearDown() throws Exception { + } - @Test - public void testSerialization() { - try { - SerializationUtils.serialize(new Catalysis()); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new Catalysis()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor() { - try { - Catalysis modifier = new Catalysis(new AntisenseRna("unk_id")); - assertNotNull(modifier); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor() { + try { + Catalysis modifier = new Catalysis(new AntisenseRna("unk_id")); + assertNotNull(modifier); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor2() { - try { - Catalysis modifier = new Catalysis(new AntisenseRna("unk_id")); - modifier.setLine(new PolylineData()); - Catalysis modifier2 = new Catalysis(modifier); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor2() { + try { + Catalysis modifier = new Catalysis(new AntisenseRna("unk_id")); + modifier.setLine(new PolylineData()); + Catalysis modifier2 = new Catalysis(modifier); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCopy() { - try { - Catalysis modifier = new Catalysis(new AntisenseRna("unk_id")); - modifier.setLine(new PolylineData()); - Catalysis modifier2 = modifier.copy(); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testCopy() { + try { + Catalysis modifier = new Catalysis(new AntisenseRna("unk_id")); + modifier.setLine(new PolylineData()); + Catalysis modifier2 = modifier.copy(); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCopyInvalid() { - try { - new Catalysis() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); - fail("Exception expected"); - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testCopyInvalid() { + try { + Mockito.mock(Catalysis.class, Mockito.CALLS_REAL_METHODS).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/modifier/InhibitionTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/InhibitionTest.java index 3f8af64c8d..b33292c49c 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/InhibitionTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/InhibitionTest.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.graphics.PolylineData; @@ -14,77 +15,71 @@ import lcsb.mapviewer.model.map.species.GenericProtein; public class InhibitionTest { - @Before - public void setUp() throws Exception { - } + @Before + public void setUp() throws Exception { + } - @After - public void tearDown() throws Exception { - } + @After + public void tearDown() throws Exception { + } - @Test - public void testSerialization() { - try { - SerializationUtils.serialize(new Inhibition()); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new Inhibition()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor() { - try { - Inhibition modifier = new Inhibition(new GenericProtein("unk_id")); - assertNotNull(modifier); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor() { + try { + Inhibition modifier = new Inhibition(new GenericProtein("unk_id")); + assertNotNull(modifier); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor2() { - try { - Inhibition modifier = new Inhibition(new GenericProtein("unk_id")); - modifier.setLine(new PolylineData()); - Inhibition modifier2 = new Inhibition(modifier); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor2() { + try { + Inhibition modifier = new Inhibition(new GenericProtein("unk_id")); + modifier.setLine(new PolylineData()); + Inhibition modifier2 = new Inhibition(modifier); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCopy() { - try { - Inhibition modifier = new Inhibition(new GenericProtein("unk_id")); - modifier.setLine(new PolylineData()); - Inhibition modifier2 = modifier.copy(); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testCopy() { + try { + Inhibition modifier = new Inhibition(new GenericProtein("unk_id")); + modifier.setLine(new PolylineData()); + Inhibition modifier2 = modifier.copy(); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCopyInvalid() { - try { - new Inhibition() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); - fail("Exception expected"); - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testCopyInvalid() { + try { + Mockito.mock(Inhibition.class, Mockito.CALLS_REAL_METHODS).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/modifier/ModulationTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/ModulationTest.java index d465085a0e..626ae7b4a6 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/ModulationTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/ModulationTest.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.graphics.PolylineData; @@ -14,77 +15,71 @@ import lcsb.mapviewer.model.map.species.GenericProtein; public class ModulationTest { - @Before - public void setUp() throws Exception { - } + @Before + public void setUp() throws Exception { + } - @After - public void tearDown() throws Exception { - } + @After + public void tearDown() throws Exception { + } - @Test - public void testSerialization() { - try { - SerializationUtils.serialize(new Modulation()); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new Modulation()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor() { - try { - Modulation modifier = new Modulation(new GenericProtein("unk_id")); - assertNotNull(modifier); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor() { + try { + Modulation modifier = new Modulation(new GenericProtein("unk_id")); + assertNotNull(modifier); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor2() { - try { - Modulation modifier = new Modulation(new GenericProtein("unk_id")); - modifier.setLine(new PolylineData()); - Modulation modifier2 = new Modulation(modifier); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor2() { + try { + Modulation modifier = new Modulation(new GenericProtein("unk_id")); + modifier.setLine(new PolylineData()); + Modulation modifier2 = new Modulation(modifier); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCopyInvalid() { - try { - new Modulation() { + @Test + public void testCopyInvalid() { + try { + Mockito.mock(Modulation.class, Mockito.CALLS_REAL_METHODS).copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); - fail("Exception expected"); - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testCopy() { - try { - Modulation modifier = new Modulation(new GenericProtein("unk_id")); - modifier.setLine(new PolylineData()); - Modulation modifier2 = modifier.copy(); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testCopy() { + try { + Modulation modifier = new Modulation(new GenericProtein("unk_id")); + modifier.setLine(new PolylineData()); + Modulation modifier2 = modifier.copy(); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } } diff --git a/model/src/test/java/lcsb/mapviewer/model/map/modifier/PhysicalStimulationTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/PhysicalStimulationTest.java index 106238c323..29821f55d0 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/PhysicalStimulationTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/PhysicalStimulationTest.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.graphics.PolylineData; @@ -14,77 +15,71 @@ import lcsb.mapviewer.model.map.species.GenericProtein; public class PhysicalStimulationTest { - @Before - public void setUp() throws Exception { - } + @Before + public void setUp() throws Exception { + } - @After - public void tearDown() throws Exception { - } + @After + public void tearDown() throws Exception { + } - @Test - public void testSerialization() { - try { - SerializationUtils.serialize(new PhysicalStimulation()); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new PhysicalStimulation()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor() { - try { - PhysicalStimulation modifier = new PhysicalStimulation(new GenericProtein("unk_id")); - assertNotNull(modifier); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor() { + try { + PhysicalStimulation modifier = new PhysicalStimulation(new GenericProtein("unk_id")); + assertNotNull(modifier); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor2() { - try { - PhysicalStimulation modifier = new PhysicalStimulation(new GenericProtein("unk_id")); - modifier.setLine(new PolylineData()); - PhysicalStimulation modifier2 = new PhysicalStimulation(modifier); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor2() { + try { + PhysicalStimulation modifier = new PhysicalStimulation(new GenericProtein("unk_id")); + modifier.setLine(new PolylineData()); + PhysicalStimulation modifier2 = new PhysicalStimulation(modifier); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCopyInvalid() { - try { - new PhysicalStimulation() { + @Test + public void testCopyInvalid() { + try { + Mockito.mock(PhysicalStimulation.class, Mockito.CALLS_REAL_METHODS).copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); - fail("Exception expected"); - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } - - @Test - public void testCopy() { - try { - PhysicalStimulation modifier = new PhysicalStimulation(new GenericProtein("unk_id")); - modifier.setLine(new PolylineData()); - PhysicalStimulation modifier2 = modifier.copy(); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testCopy() { + try { + PhysicalStimulation modifier = new PhysicalStimulation(new GenericProtein("unk_id")); + modifier.setLine(new PolylineData()); + PhysicalStimulation modifier2 = modifier.copy(); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } } diff --git a/model/src/test/java/lcsb/mapviewer/model/map/modifier/TriggerTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/TriggerTest.java index f0d3ebb23b..d6b71b5fda 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/TriggerTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/TriggerTest.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.graphics.PolylineData; @@ -14,77 +15,71 @@ import lcsb.mapviewer.model.map.species.GenericProtein; public class TriggerTest { - @Before - public void setUp() throws Exception { - } + @Before + public void setUp() throws Exception { + } - @After - public void tearDown() throws Exception { - } + @After + public void tearDown() throws Exception { + } - @Test - public void testSerialization() { - try { - SerializationUtils.serialize(new Trigger()); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new Trigger()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor() { - try { - Trigger modifier = new Trigger(new GenericProtein("unk_id")); - assertNotNull(modifier); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor() { + try { + Trigger modifier = new Trigger(new GenericProtein("unk_id")); + assertNotNull(modifier); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor2() { - try { - Trigger modifier = new Trigger(new GenericProtein("unk_id")); - modifier.setLine(new PolylineData()); - Trigger modifier2 = new Trigger(modifier); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor2() { + try { + Trigger modifier = new Trigger(new GenericProtein("unk_id")); + modifier.setLine(new PolylineData()); + Trigger modifier2 = new Trigger(modifier); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCopy() { - try { - Trigger modifier = new Trigger(new GenericProtein("unk_id")); - modifier.setLine(new PolylineData()); - Trigger modifier2 = modifier.copy(); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testCopy() { + try { + Trigger modifier = new Trigger(new GenericProtein("unk_id")); + modifier.setLine(new PolylineData()); + Trigger modifier2 = modifier.copy(); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCopyInvalid() { - try { - new Trigger() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); - fail("Exception expected"); - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testCopyInvalid() { + try { + Mockito.mock(Trigger.class, Mockito.CALLS_REAL_METHODS).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/modifier/UnknownCatalysisTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownCatalysisTest.java index dcf4d289ae..31c679e2bf 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownCatalysisTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownCatalysisTest.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.graphics.PolylineData; @@ -14,77 +15,71 @@ import lcsb.mapviewer.model.map.species.GenericProtein; public class UnknownCatalysisTest { - @Before - public void setUp() throws Exception { - } + @Before + public void setUp() throws Exception { + } - @After - public void tearDown() throws Exception { - } + @After + public void tearDown() throws Exception { + } - @Test - public void testSerialization() { - try { - SerializationUtils.serialize(new UnknownCatalysis()); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new UnknownCatalysis()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor() { - try { - UnknownCatalysis modifier = new UnknownCatalysis(new GenericProtein("unk_id")); - assertNotNull(modifier); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor() { + try { + UnknownCatalysis modifier = new UnknownCatalysis(new GenericProtein("unk_id")); + assertNotNull(modifier); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor2() { - try { - UnknownCatalysis modifier = new UnknownCatalysis(new GenericProtein("unk_id")); - modifier.setLine(new PolylineData()); - UnknownCatalysis modifier2 = new UnknownCatalysis(modifier); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor2() { + try { + UnknownCatalysis modifier = new UnknownCatalysis(new GenericProtein("unk_id")); + modifier.setLine(new PolylineData()); + UnknownCatalysis modifier2 = new UnknownCatalysis(modifier); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCopy() { - try { - UnknownCatalysis modifier = new UnknownCatalysis(new GenericProtein("unk_id")); - modifier.setLine(new PolylineData()); - UnknownCatalysis modifier2 = modifier.copy(); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testCopy() { + try { + UnknownCatalysis modifier = new UnknownCatalysis(new GenericProtein("unk_id")); + modifier.setLine(new PolylineData()); + UnknownCatalysis modifier2 = modifier.copy(); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCopyInvalid() { - try { - new UnknownCatalysis() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); - fail("Exception expected"); - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testCopyInvalid() { + try { + Mockito.mock(UnknownCatalysis.class, Mockito.CALLS_REAL_METHODS).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/modifier/UnknownInhibitionTest.java b/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownInhibitionTest.java index c50a4c87e2..33de793ebd 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownInhibitionTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/modifier/UnknownInhibitionTest.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.graphics.PolylineData; @@ -14,77 +15,71 @@ import lcsb.mapviewer.model.map.species.GenericProtein; public class UnknownInhibitionTest { - @Before - public void setUp() throws Exception { - } + @Before + public void setUp() throws Exception { + } - @After - public void tearDown() throws Exception { - } + @After + public void tearDown() throws Exception { + } - @Test - public void testSerialization() { - try { - SerializationUtils.serialize(new UnknownInhibition()); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new UnknownInhibition()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor() { - try { - UnknownInhibition modifier = new UnknownInhibition(new GenericProtein("unk_id")); - assertNotNull(modifier); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor() { + try { + UnknownInhibition modifier = new UnknownInhibition(new GenericProtein("unk_id")); + assertNotNull(modifier); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor2() { - try { - UnknownInhibition modifier = new UnknownInhibition(new GenericProtein("unk_id")); - modifier.setLine(new PolylineData()); - UnknownInhibition modifier2 = new UnknownInhibition(modifier); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor2() { + try { + UnknownInhibition modifier = new UnknownInhibition(new GenericProtein("unk_id")); + modifier.setLine(new PolylineData()); + UnknownInhibition modifier2 = new UnknownInhibition(modifier); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCopy() { - try { - UnknownInhibition modifier = new UnknownInhibition(new GenericProtein("unk_id")); - modifier.setLine(new PolylineData()); - UnknownInhibition modifier2 = modifier.copy(); - assertNotNull(modifier2); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testCopy() { + try { + UnknownInhibition modifier = new UnknownInhibition(new GenericProtein("unk_id")); + modifier.setLine(new PolylineData()); + UnknownInhibition modifier2 = modifier.copy(); + assertNotNull(modifier2); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCopyInvalid() { - try { - new UnknownInhibition() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); - fail("Exception expected"); - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testCopyInvalid() { + try { + Mockito.mock(UnknownInhibition.class, Mockito.CALLS_REAL_METHODS).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/reaction/ModifierTest.java b/model/src/test/java/lcsb/mapviewer/model/map/reaction/ModifierTest.java index 4730c68acd..bf8bfdeb93 100644 --- a/model/src/test/java/lcsb/mapviewer/model/map/reaction/ModifierTest.java +++ b/model/src/test/java/lcsb/mapviewer/model/map/reaction/ModifierTest.java @@ -7,72 +7,67 @@ 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.graphics.PolylineData; public class ModifierTest { - @Before - public void setUp() throws Exception { - } + @Before + public void setUp() throws Exception { + } - @After - public void tearDown() throws Exception { - } + @After + public void tearDown() throws Exception { + } - @Test - public void testSerialization() { - try { - SerializationUtils.serialize(new Modifier()); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testSerialization() { + try { + SerializationUtils.serialize(new Modifier()); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testConstructor() { - try { - Modifier original = new Modifier(); - original.setLine(new PolylineData()); - Modifier modifier = new Modifier(original); - assertNotNull(modifier); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testConstructor() { + try { + Modifier original = new Modifier(); + original.setLine(new PolylineData()); + Modifier modifier = new Modifier(original); + assertNotNull(modifier); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testCopy() { - try { - Modifier original = new Modifier(); - original.setLine(new PolylineData()); - Modifier modifier = original.copy(); - assertNotNull(modifier); - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testCopy() { + try { + Modifier original = new Modifier(); + original.setLine(new PolylineData()); + Modifier modifier = original.copy(); + assertNotNull(modifier); + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } - @Test - public void testInvalidCopy() { - try { - new Modifier() { - - /** - * - */ - private static final long serialVersionUID = 1L; - }.copy(); - fail("Exception expected"); - } catch (NotImplementedException e) { - } catch (Exception e) { - e.printStackTrace(); - throw e; - } - } + @Test + public void testInvalidCopy() { + try { + Mockito.mock(Modifier.class, Mockito.CALLS_REAL_METHODS).copy(); + fail("Exception expected"); + } catch (NotImplementedException e) { + } catch (Exception e) { + e.printStackTrace(); + throw e; + } + } } -- GitLab