package de.fau.osr.core.db.dao.impl;

import static org.junit.Assert.*;

import java.util.List;

import org.junit.BeforeClass;
import org.junit.Test;

import de.fau.osr.core.db.DBOperation;
import de.fau.osr.core.db.dao.RequirementDao;
import de.fau.osr.core.db.domain.Requirement;

public class RequirementDaoImplementationTest {

	RequirementDao dao = new RequirementDaoImplementation();
	
	
	@Test
	public void testAdd() {
		Requirement r = prepareData();
		assertTrue(dao.persist(DBOperation.ADD,r));
		
		/*List<Requirement> l = dao.getAllRequirement();
		System.out.println(l.size());
		assertNotNull(l);
		*/
		r.setDescription("upd");
		assertTrue(dao.persist(DBOperation.UPDATE, r));
		
		assertTrue(dao.persist(DBOperation.DELETE, r));
	}


	
	public Requirement prepareData(){
		Requirement r = new Requirement();
		r.setId("Test"+Math.random());
		r.setTitle("title-test");
		r.setDescription("desc-test");
		r.setStoryPoint(1);
		return r;
	}
	
	

}

@@ -35,160 +35,8 @@
 l;%0A%0A
-import static org.junit.Assert.*;%0A%0Aimport java.util.List;%0A%0Aimport org.junit.BeforeClass;%0Aimport org.junit.Test;%0A%0Aimport de.fau.osr.core.db.DBOperation;%0A
 impo
@@ -239,15 +239,19 @@
 %09%0A%09%0A
+//
 %09@Test%0A
+//
 %09pub
@@ -271,16 +271,18 @@
 Add() %7B%0A
+//
 %09%09Requir
@@ -306,16 +306,18 @@
 Data();%0A
+//
 %09%09assert
@@ -354,19 +354,21 @@
 DD,r));%0A
-%09%09%0A
+//%0A//
 %09%09/*List
@@ -410,16 +410,18 @@
 ment();%0A
+//
 %09%09System
@@ -444,16 +444,18 @@
 ize());%0A
+//
 %09%09assert
@@ -470,13 +470,17 @@
 l);%0A
+//
 %09%09*/%0A
+//
 %09%09r.
@@ -502,16 +502,18 @@
 %22upd%22);%0A
+//
 %09%09assert
@@ -558,11 +558,13 @@
 ));%0A
-%09%09%0A
+//%0A//
 %09%09as
@@ -609,16 +609,18 @@
 E, r));%0A
+//
 %09%7D%0A%0A%0A%09%0A%09

disable test with real db connection. will be replaced with mocked/memory db later.