Commit 48fb447c authored by Piotr Gawron's avatar Piotr Gawron
Browse files

test modified to use mockito

parent 69cf66ee
......@@ -8,166 +8,163 @@ 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.Configuration;
import lcsb.mapviewer.common.exception.InvalidArgumentException;
import lcsb.mapviewer.common.exception.NotImplementedException;
import lcsb.mapviewer.model.map.modifier.Catalysis;
import lcsb.mapviewer.model.map.species.AntisenseRna;
import lcsb.mapviewer.model.map.species.Drug;
public class AntisenseRnaRegionTest {
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testSerialization() {
try {
SerializationUtils.serialize(new AntisenseRnaRegion());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testConstructor1() {
try {
AntisenseRnaRegion antisenseRna = new AntisenseRnaRegion();
AntisenseRnaRegion antisenseRna2 = new AntisenseRnaRegion(antisenseRna);
assertNotNull(antisenseRna2);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testUpdate() {
try {
AntisenseRnaRegion antisenseRna = new AntisenseRnaRegion();
antisenseRna.setState(ModificationState.EMPTY);
antisenseRna.setName("as");
antisenseRna.setPos(3.0);
AntisenseRnaRegion antisenseRna2 = new AntisenseRnaRegion();
antisenseRna2.update(antisenseRna);
assertEquals(antisenseRna.getState(), antisenseRna2.getState());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testInvalidUpdate() {
try {
AntisenseRnaRegion antisenseRna = new AntisenseRnaRegion();
AntisenseRnaRegion antisenseRna2 = new AntisenseRnaRegion();
antisenseRna.setIdAntisenseRnaRegion("@1");
antisenseRna2.setIdAntisenseRnaRegion("@");
antisenseRna2.update(antisenseRna);
fail("Exception expected");
} catch (InvalidArgumentException e) {
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testGetters() {
try {
AntisenseRnaRegion region = new AntisenseRnaRegion(new AntisenseRnaRegion());
int id = 91;
AntisenseRna species = new AntisenseRna("id");
double pos = 4.6;
double size = 5.3;
AntisenseRnaRegionType type = AntisenseRnaRegionType.CODING_REGION;
String name = "nam";
String idAntisenseRnaRegion = "iddd";
region.setId(id);
region.setSpecies(species);
region.setPos(pos);
region.setSize(size);
region.setType(type);
region.setName(name);
region.setIdAntisenseRnaRegion(idAntisenseRnaRegion);
region.setState(ModificationState.ACETYLATED);
assertEquals(id, region.getId());
assertEquals(species, region.getSpecies());
assertEquals(pos, region.getPos(), Configuration.EPSILON);
assertEquals(size, region.getSize(), Configuration.EPSILON);
assertEquals(type, region.getType());
assertEquals(name, region.getName());
assertEquals(idAntisenseRnaRegion, region.getIdAntisenseRnaRegion());
assertEquals(ModificationState.ACETYLATED, region.getState());
try {
region.setSize("text");
fail("Exception expected");
} catch (InvalidArgumentException e) {
}
try {
region.setPos("text");
fail("Exception expected");
} catch (InvalidArgumentException e) {
}
region.setSize("1.0");
region.setPos("1.0");
assertEquals(1.0, region.getPos(), Configuration.EPSILON);
assertEquals(1.0, region.getSize(), Configuration.EPSILON);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testToString() {
try {
assertNotNull(new AntisenseRnaRegion().toString());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testCopy() {
try {
AntisenseRnaRegion degraded = new AntisenseRnaRegion().copy();
assertNotNull(degraded);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testInvalidCopy() {
try {
new AntisenseRnaRegion() {
/**
*
*/
private static final long serialVersionUID = 1L;
}.copy();
fail("Exception expected");
} catch (NotImplementedException e) {
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Before
public void setUp() throws Exception {
}
@After
public void tearDown() throws Exception {
}
@Test
public void testSerialization() {
try {
SerializationUtils.serialize(new AntisenseRnaRegion());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testConstructor1() {
try {
AntisenseRnaRegion antisenseRna = new AntisenseRnaRegion();
AntisenseRnaRegion antisenseRna2 = new AntisenseRnaRegion(antisenseRna);
assertNotNull(antisenseRna2);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testUpdate() {
try {
AntisenseRnaRegion antisenseRna = new AntisenseRnaRegion();
antisenseRna.setState(ModificationState.EMPTY);
antisenseRna.setName("as");
antisenseRna.setPos(3.0);
AntisenseRnaRegion antisenseRna2 = new AntisenseRnaRegion();
antisenseRna2.update(antisenseRna);
assertEquals(antisenseRna.getState(), antisenseRna2.getState());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testInvalidUpdate() {
try {
AntisenseRnaRegion antisenseRna = new AntisenseRnaRegion();
AntisenseRnaRegion antisenseRna2 = new AntisenseRnaRegion();
antisenseRna.setIdAntisenseRnaRegion("@1");
antisenseRna2.setIdAntisenseRnaRegion("@");
antisenseRna2.update(antisenseRna);
fail("Exception expected");
} catch (InvalidArgumentException e) {
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testGetters() {
try {
AntisenseRnaRegion region = new AntisenseRnaRegion(new AntisenseRnaRegion());
int id = 91;
AntisenseRna species = new AntisenseRna("id");
double pos = 4.6;
double size = 5.3;
AntisenseRnaRegionType type = AntisenseRnaRegionType.CODING_REGION;
String name = "nam";
String idAntisenseRnaRegion = "iddd";
region.setId(id);
region.setSpecies(species);
region.setPos(pos);
region.setSize(size);
region.setType(type);
region.setName(name);
region.setIdAntisenseRnaRegion(idAntisenseRnaRegion);
region.setState(ModificationState.ACETYLATED);
assertEquals(id, region.getId());
assertEquals(species, region.getSpecies());
assertEquals(pos, region.getPos(), Configuration.EPSILON);
assertEquals(size, region.getSize(), Configuration.EPSILON);
assertEquals(type, region.getType());
assertEquals(name, region.getName());
assertEquals(idAntisenseRnaRegion, region.getIdAntisenseRnaRegion());
assertEquals(ModificationState.ACETYLATED, region.getState());
try {
region.setSize("text");
fail("Exception expected");
} catch (InvalidArgumentException e) {
}
try {
region.setPos("text");
fail("Exception expected");
} catch (InvalidArgumentException e) {
}
region.setSize("1.0");
region.setPos("1.0");
assertEquals(1.0, region.getPos(), Configuration.EPSILON);
assertEquals(1.0, region.getSize(), Configuration.EPSILON);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testToString() {
try {
assertNotNull(new AntisenseRnaRegion().toString());
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testCopy() {
try {
AntisenseRnaRegion degraded = new AntisenseRnaRegion().copy();
assertNotNull(degraded);
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
@Test
public void testInvalidCopy() {
try {
Mockito.mock(AntisenseRnaRegion.class, Mockito.CALLS_REAL_METHODS).copy();
fail("Exception expected");
} catch (NotImplementedException e) {
} catch (Exception e) {
e.printStackTrace();
throw e;
}
}
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment