package org.devilry.core.session.dao;

import org.devilry.core.session.TreeManagerRemote;
import org.devilry.core.session.TreeManagerImpl;

import javax.naming.NamingException;

import java.util.Calendar;
import java.util.GregorianCalendar;

public class AbstractDeliveryDaoTst extends AbstractDaoTst {

	long uioId, matnatId;
	
	DeliveryRemote delivery;
	
	PeriodNodeRemote periodNode;
	long periodId;
	long periodId2;
	
	AssignmentNodeRemote assignmentNode;
	long assignmentId;
	long assignmentId2;
	
	
	protected void setupEjbContainer() throws NamingException {
		super.setupEjbContainer();
		
		// Nodes
		NodeRemote node = getRemoteBean(NodeImpl.class);
		uioId = node.create("uio", "UiO");
		matnatId = node.create("matnat", "Faculty of Mathematics", uioId);
		
		// Course
		CourseNodeRemote courseNode = getRemoteBean(CourseNodeImpl.class);
		long inf1000Id = courseNode.create("inf1000", "Object oriented programming", matnatId);

		Calendar start = new GregorianCalendar(2009, 00, 01);
		Calendar end = new GregorianCalendar(2009, 05, 15);

		// Period
		periodNode = getRemoteBean(PeriodNodeImpl.class);
		periodId1 = periodNode.create("spring09", "Spring 2009", start.getTime(), end.getTime(), inf1000Id);
		periodId2 = periodNode.create("fall09", "Fall 2009", start.getTime(), end.getTime(), inf1000Id);
		
		// Assignment
		assignmentNode = getRemoteBean(AssignmentNodeImpl.class);
		assignmentId = assignmentNode.create("Oblig1", "Obligatory assignment 1", periodId);
		assignmentId2 = assignmentNode.create("Oblig2", "Obligatory assignment 2", periodId);
		
		assignmentId2 = assignmentNode.create("Oblig1", "Obligatory assignment 1", periodId2);
		
		
		
//		TreeManagerRemote tm = getRemoteBean(TreeManagerImpl.class);
		
//		long id = tm.addNode("uio", "Universitet i Oslo");
//		id = tm.addCourseNode("inf1000", "INF1000", "First programming course.", id);
//		id = tm.addPeriodNode("spring2009", new GregorianCalendar(2009, 1, 1).getTime(),
//				new GregorianCalendar(2009, 6, 15).getTime(), id);
		
//		assignmentId = tm.addAssignmentNode("Oblig1", "Obligatory assignment 1", id);
//		AssignmentNodeRemote assignment = getRemoteBean(AssignmentNodeImpl.class);
//		assignment.init(assignmentId);
//		delivery = getRemoteBean(DeliveryImpl.class);
//		delivery.init(assignment.addDelivery());
	}
}

@@ -1119,17 +1119,16 @@
 periodId
-1
  = perio
@@ -1309,24 +1309,86 @@
 1000Id);%0A%09%09%0A
+%09%09Calendar deadline = new GregorianCalendar(2009, 05, 17);%0A%09%09%0A
 %09%09// Assignm
@@ -1531,109 +1531,252 @@
 1%22, 
-periodId);%0A%09%09assignmentId2 = assignmentNode.create(%22Oblig2%22, %22Obligatory assignment 2%22, periodId);%0A%09%09
+deadline.getTime(), periodId);%0A%09%09%0A%09%09deadline = new GregorianCalendar(2009, 06, 17);%0A%09%09assignmentId2 = assignmentNode.create(%22Oblig2%22, %22Obligatory assignment 2%22, deadline.getTime(), periodId);%0A%09%09%0A%09%09deadline = new GregorianCalendar(2009, 07, 17);
 %0A%09%09a
@@ -1848,16 +1848,36 @@
 ment 1%22,
+ deadline.getTime(),
  periodI

Use new create method