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.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;
public class BaseDaoTest extends PersistTestFunctions {
......@@ -32,40 +36,31 @@ public class BaseDaoTest extends PersistTestFunctions {
String val = "xxxx";
public void testGetValidationTooLongString() throws Exception {
assertEquals(1, dao.getValidationIssues(new ToLongString()).size());
private Object testedObject;
public void testGetValidationNotNullString() throws Exception {
assertEquals(1, dao.getValidationIssues(new NullString()).size());
public BaseDaoTest(String testName, Class<?> testedClass) throws Exception {
this.testedObject = testedClass.newInstance();
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;
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());
public void testFixValidationIssues() throws Exception {
String id = new String(new char[300]).replace('\0', 'x');
Project project = new Project(id);
List<String> issues = dao.getValidationIssues(project);
public void testFixValidation() throws Exception {
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