Commit 62a81824 authored by Piotr Gawron's avatar Piotr Gawron

test refactored -> bunch of tests changed into parametreized test

parent eef85ed0
......@@ -2,16 +2,20 @@ package lcsb.mapviewer.persist.dao;
import static org.junit.Assert.assertEquals;
import java.util.List;
import java.io.IOException;
import java.util.*;
import javax.persistence.Column;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.mockito.Mockito;
import lcsb.mapviewer.model.Project;
import lcsb.mapviewer.persist.PersistTestFunctions;
@RunWith(Parameterized.class)
public class BaseDaoTest extends PersistTestFunctions {
@SuppressWarnings("unchecked")
......@@ -32,40 +36,31 @@ public class BaseDaoTest extends PersistTestFunctions {
String val = "xxxx";
}
@Test
public void testGetValidationTooLongString() throws Exception {
assertEquals(1, dao.getValidationIssues(new ToLongString()).size());
}
private Object testedObject;
@Test
public void testGetValidationNotNullString() throws Exception {
assertEquals(1, dao.getValidationIssues(new NullString()).size());
public BaseDaoTest(String testName, Class<?> testedClass) throws Exception {
this.testedObject = testedClass.newInstance();
}
@Test
public void testGetValidationNotNullDouble() throws Exception {
assertEquals(1, dao.getValidationIssues(new NullDouble()).size());
@Parameters(name = "{index} : {0}")
public static Collection<Object[]> data() throws IOException {
Collection<Object[]> data = new ArrayList<Object[]>();
data.add(new Object[] { "Too long String", ToLongString.class });
data.add(new Object[] { "Null String when not nullable", NullString.class });
data.add(new Object[] { "Null Double when not nullable", NullDouble.class });
return data;
}
@Test
public void testGetValidationIssues() throws Exception {
String id = new String(new char[300]).replace('\0', 'x');
Project project = new Project(id);
List<String> issues = dao.getValidationIssues(project);
assertEquals(1, issues.size());
public void testGetValidation() throws Exception {
assertEquals(1, dao.getValidationIssues(testedObject).size());
}
@Test
public void testFixValidationIssues() throws Exception {
String id = new String(new char[300]).replace('\0', 'x');
Project project = new Project(id);
dao.fixValidationIssues(project);
List<String> issues = dao.getValidationIssues(project);
public void testFixValidation() throws Exception {
dao.fixValidationIssues(testedObject);
List<String> issues = dao.getValidationIssues(testedObject);
assertEquals(0, issues.size());
}
......
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