Skip to content
Snippets Groups Projects
Commit 9832a312 authored by Piotr Gawron's avatar Piotr Gawron
Browse files

use mockito for mocking objects

parent d6d2fe3d
No related branches found
No related tags found
1 merge request!853Resolve "replace e.printstacktrace in unit tests"
Pipeline #12028 passed
Showing
with 49 additions and 144 deletions
......@@ -4,6 +4,7 @@ import static org.junit.Assert.*;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
......@@ -104,13 +105,7 @@ public class ModificationResidueTest extends CellDesignerTestFunctions {
@Test(expected = NotImplementedException.class)
public void testInvalidCopy() {
new CellDesignerModificationResidue() {
/**
*
*/
private static final long serialVersionUID = 1L;
}.copy();
Mockito.spy(CellDesignerModificationResidue.class).copy();
}
}
......@@ -3,6 +3,7 @@ package lcsb.mapviewer.model.graphics;
import static org.junit.Assert.*;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
......@@ -27,9 +28,7 @@ public class ArrowTypeDataComparatorTest extends ModelTestFunctions {
public void testCompareDifferent() {
assertTrue(comparator.compare(new ArrowTypeData(), null) != 0);
assertTrue(comparator.compare(null, new ArrowTypeData()) != 0);
assertTrue(comparator.compare(new ArrowTypeData() {
private static final long serialVersionUID = 1L;
}, new ArrowTypeData()) != 0);
assertTrue(comparator.compare(Mockito.spy(ArrowTypeData.class), new ArrowTypeData()) != 0);
ArrowTypeData atd1 = new ArrowTypeData();
ArrowTypeData atd2 = new ArrowTypeData();
......
......@@ -4,6 +4,7 @@ import static org.junit.Assert.*;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.exception.NotImplementedException;
......@@ -41,13 +42,7 @@ public class ArrowTypeDataTest extends ModelTestFunctions {
@Test(expected = NotImplementedException.class)
public void testInvalidCopy() {
new ArrowTypeData() {
/**
*
*/
private static final long serialVersionUID = 1L;
}.copy();
Mockito.spy(ArrowTypeData.class).copy();
}
}
......@@ -6,6 +6,7 @@ import java.awt.Color;
import java.awt.geom.Point2D;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.exception.NotImplementedException;
......@@ -83,9 +84,7 @@ public class PolylineDataComparatorTest extends ModelTestFunctions {
assertTrue(comparator.compare(pd1, pd2) != 0);
assertTrue(comparator.compare(pd2, pd1) != 0);
assertTrue(comparator.compare(pd2, new PolylineData() {
private static final long serialVersionUID = 1L;
}) != 0);
assertTrue(comparator.compare(pd2, Mockito.spy(PolylineData.class)) != 0);
}
}
......@@ -11,6 +11,7 @@ import org.apache.commons.lang3.SerializationUtils;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.Configuration;
......@@ -284,14 +285,7 @@ public class PolylineDataTest extends ModelTestFunctions {
@Test(expected = NotImplementedException.class)
public void testInvalidCopy() throws Exception {
PolylineData pd = new PolylineData() {
/**
*
*/
private static final long serialVersionUID = 1L;
};
pd.copy();
Mockito.spy(PolylineData.class).copy();
}
@Test
......
......@@ -3,8 +3,10 @@ package lcsb.mapviewer.model.map;
import static org.junit.Assert.*;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.model.map.layout.graphics.Layer;
public class OverviewImageComparatorTest extends ModelTestFunctions {
......@@ -61,9 +63,7 @@ public class OverviewImageComparatorTest extends ModelTestFunctions {
assertTrue(0 != oic.compare(oi, null));
assertTrue(0 != oic.compare(null, oi2));
assertTrue(0 != oic.compare(new OverviewImage() {
private static final long serialVersionUID = 1L;
}, oi2));
assertTrue(0 != oic.compare(Mockito.spy(OverviewImage.class), oi2));
oi = new OverviewImage();
oi2 = new OverviewImage();
......
......@@ -3,8 +3,10 @@ package lcsb.mapviewer.model.map;
import static org.junit.Assert.*;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.model.map.layout.graphics.Layer;
public class OverviewImageLinkComparatorTest extends ModelTestFunctions {
......@@ -55,13 +57,7 @@ public class OverviewImageLinkComparatorTest extends ModelTestFunctions {
assertTrue(0 != oic.compare(oi, oi2));
assertTrue(0 != oic.compare(oi, null));
assertTrue(0 != oic.compare(null, oi2));
assertTrue(0 != oic.compare(new OverviewImageLink() {
/**
*
*/
private static final long serialVersionUID = 1L;
}, oi2));
assertTrue(0 != oic.compare(Mockito.spy(OverviewImageLink.class), oi2));
}
@Test
......
......@@ -4,9 +4,11 @@ import static org.junit.Assert.*;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.map.layout.graphics.Layer;
public class OverviewImageLinkTest extends ModelTestFunctions {
......@@ -32,13 +34,7 @@ public class OverviewImageLinkTest extends ModelTestFunctions {
@Test(expected = NotImplementedException.class)
public void testInvalidCopy() {
new OverviewImageLink() {
/**
*
*/
private static final long serialVersionUID = 1L;
}.copy();
Mockito.spy(OverviewImageLink.class).copy();
}
}
......@@ -7,9 +7,11 @@ import java.util.List;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.map.layout.graphics.Layer;
public class OverviewImageTest extends ModelTestFunctions {
......@@ -45,13 +47,7 @@ public class OverviewImageTest extends ModelTestFunctions {
@Test(expected = NotImplementedException.class)
public void testInvalidCopy() {
new OverviewImage() {
/**
*
*/
private static final long serialVersionUID = 1L;
}.copy();
Mockito.spy(OverviewImage.class).copy();
}
}
......@@ -3,8 +3,10 @@ package lcsb.mapviewer.model.map;
import static org.junit.Assert.*;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.model.map.layout.graphics.Layer;
public class OverviewLinkTest extends ModelTestFunctions {
......@@ -18,19 +20,7 @@ public class OverviewLinkTest extends ModelTestFunctions {
@Test
public void testGetPolygonCoord() {
OverviewLink link = new OverviewLink() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public OverviewLink copy() {
// TODO Auto-generated method stub
return null;
}
};
OverviewLink link = Mockito.spy(OverviewLink.class);
String polygon = "1,1 2,2 4,0";
link.setPolygon(polygon);
assertEquals(3, link.getPolygonCoordinates().size());
......@@ -38,19 +28,7 @@ public class OverviewLinkTest extends ModelTestFunctions {
@Test
public void testGetters() {
OverviewLink link = new OverviewLink() {
/**
*
*/
private static final long serialVersionUID = 1L;
@Override
public OverviewLink copy() {
// TODO Auto-generated method stub
return null;
}
};
OverviewLink link = Mockito.spy(OverviewLink.class);
OverviewImage image = new OverviewImage();
int id = 309;
link.setOverviewImage(image);
......
......@@ -3,6 +3,7 @@ package lcsb.mapviewer.model.map;
import static org.junit.Assert.*;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.model.map.model.Model;
......@@ -68,9 +69,7 @@ public class OverviewModelLinkComparatorTest extends ModelTestFunctions {
assertTrue(0 != oic.compare(oi, oi2));
assertTrue(0 != oic.compare(oi, new OverviewModelLink() {
private static final long serialVersionUID = 1L;
}));
assertTrue(0 != oic.compare(oi, Mockito.spy(OverviewModelLink.class)));
}
@Test
......
......@@ -4,6 +4,7 @@ import static org.junit.Assert.*;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.exception.NotImplementedException;
......@@ -55,13 +56,7 @@ public class OverviewModelLinkTest extends ModelTestFunctions {
@Test(expected = NotImplementedException.class)
public void testInvalidCopy() {
new OverviewModelLink() {
/**
*
*/
private static final long serialVersionUID = 1L;
}.copy();
Mockito.spy(OverviewModelLink.class).copy();
}
}
......@@ -4,6 +4,7 @@ import static org.junit.Assert.*;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.exception.NotImplementedException;
......@@ -45,13 +46,7 @@ public class OverviewSearchLinkTest extends ModelTestFunctions {
@Test(expected = NotImplementedException.class)
public void testInvalidCopy() {
new OverviewSearchLink() {
/**
*
*/
private static final long serialVersionUID = 1L;
}.copy();
Mockito.spy(OverviewSearchLink.class).copy();
}
}
......@@ -4,6 +4,7 @@ import static org.junit.Assert.*;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.exception.NotImplementedException;
......@@ -54,12 +55,7 @@ public class SearchIndexTest extends ModelTestFunctions {
@Test(expected = NotImplementedException.class)
public void testCopyInvalid() {
new SearchIndex() {
/**
*
*/
private static final long serialVersionUID = 1L;
}.copy();
Mockito.spy(SearchIndex.class).copy();
}
@Test
......
......@@ -7,9 +7,11 @@ import java.util.List;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.map.layout.graphics.Layer;
public class GeneVariationColorSchemaTest extends ModelTestFunctions {
......@@ -70,14 +72,7 @@ public class GeneVariationColorSchemaTest extends ModelTestFunctions {
@Test(expected = NotImplementedException.class)
public void testInvalidCopy() {
GeneVariationColorSchema schema = new GeneVariationColorSchema() {
/**
*
*/
private static final long serialVersionUID = 1L;
};
schema.copy();
Mockito.spy(GeneVariationColorSchema.class).copy();
}
}
......@@ -3,9 +3,11 @@ package lcsb.mapviewer.model.map.layout;
import static org.junit.Assert.*;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.map.layout.graphics.Layer;
public class GeneVariationTest extends ModelTestFunctions {
......@@ -52,15 +54,7 @@ public class GeneVariationTest extends ModelTestFunctions {
@Test(expected = NotImplementedException.class)
public void testInvalidCopy() throws Exception {
GeneVariation gv = new GeneVariation() {
/**
*
*/
private static final long serialVersionUID = 1L;
};
gv.copy();
Mockito.spy(GeneVariation.class).copy();
}
}
......@@ -4,6 +4,7 @@ import static org.junit.Assert.*;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.exception.NotImplementedException;
......@@ -42,13 +43,6 @@ public class GenericColorSchemaTest extends ModelTestFunctions {
@Test(expected = NotImplementedException.class)
public void testInvalidCopy() {
GenericColorSchema schema = new GenericColorSchema() {
/**
*
*/
private static final long serialVersionUID = 1L;
};
schema.copy();
Mockito.spy(GenericColorSchema.class).copy();
}
}
......@@ -4,11 +4,13 @@ import static org.junit.Assert.*;
import org.apache.commons.lang3.SerializationUtils;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.Configuration;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.cache.UploadedFileEntry;
import lcsb.mapviewer.model.map.layout.graphics.Layer;
public class LayoutTest extends ModelTestFunctions {
......@@ -69,14 +71,7 @@ public class LayoutTest extends ModelTestFunctions {
@Test(expected = NotImplementedException.class)
public void testInvalidCopy() {
Layout layout = new Layout() {
/**
*
*/
private static final long serialVersionUID = 1L;
};
layout.copy();
Mockito.spy(Layout.class).copy();
}
@Test
......
......@@ -3,6 +3,7 @@ package lcsb.mapviewer.model.map.layout.graphics;
import static org.junit.Assert.*;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.exception.NotImplementedException;
......@@ -78,13 +79,7 @@ public class LayerComparatorTest extends ModelTestFunctions {
assertTrue(comparator.compare(layer1, null) != 0);
assertTrue(comparator.compare(null, layer1) != 0);
assertTrue(comparator.compare(layer1, new Layer() {
/**
*
*/
private static final long serialVersionUID = 1L;
}) != 0);
assertTrue(comparator.compare(layer1, Mockito.spy(Layer.class)) != 0);
layer1 = getLayer();
layer2 = getLayer();
......
......@@ -5,6 +5,7 @@ import static org.junit.Assert.*;
import java.awt.Color;
import org.junit.*;
import org.mockito.Mockito;
import lcsb.mapviewer.ModelTestFunctions;
import lcsb.mapviewer.common.exception.NotImplementedException;
......@@ -106,9 +107,7 @@ public class LayerOvalComparatorTest extends ModelTestFunctions {
public void testDifferent2() {
LayerOval layer1 = getLayerOval();
assertTrue(comparator.compare(layer1, new LayerOval() {
private static final long serialVersionUID = 1L;
}) != 0);
assertTrue(comparator.compare(layer1, Mockito.spy(LayerOval.class)) != 0);
}
@Test(expected = NotImplementedException.class)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment