// Path: jee7-search-service/src/main/java/ch/demo/dom/Discipline.java
// @XmlEnum(String.class)
// public enum Discipline {
//     /** Maths. */
//     MATHEMATICS("Mathematics"),
//     /** Biology. */
//     BIOLOGY("Biology"),
//     /** French. */
//     FRENCH("French"),
//     /** English. */
//     ENGLISH("English"),
//     /** German. */
//     GERMAN("German"),
//     /** History. */
//     HISTORY("History"),
//     /** Geography. */
//     GEOGRAPHY("Geography");
// 
//     /**
//      * Constructor.
//      * 
//      * @param name
//      *            of the discipline.
//      */
//     private Discipline(final String pName) {
//         this.name = pName;
//     }
// 
//     /** The actual name of the discipline. */
//     private String name;
// 
//     /** {@inheritDoc} */
//     @Override
//     public String toString() {
//         return this.name;
//     }
// 
// }
// 
// Path: jee7-search-service/src/main/java/ch/demo/dom/Grade.java
// @Entity
// @Table(name = "GRADES")
// public class Grade implements Serializable {
// 
// 	/** The serial-id. */
// 	private static final long serialVersionUID = -1369317473509616839L;
// 
// 	/** The unique id. */
// 	@Id
// 	@GeneratedValue(strategy = GenerationType.AUTO)
// 	private long id;
// 
// 	/** The discipline of this grade. */
// 	@Column(name = "DISCIPLINE", nullable = false)
// 	private Discipline discipline;
// 
// 	/** The actual grade. */
// 	@Column(name = "GRADE", nullable = true)
// 	private Integer grade;
// 
// 	/** The student that has obtained this grade. */
// 	@ManyToOne
// 	private Student student;
// 
// 	/**
// 	 * Constructor that builds a grade for a given discipline.
// 	 * 
// 	 * @param discipline
// 	 *            to grade.
// 	 */
// 	public Grade(final Discipline discipline) {
// 		setDiscipline(discipline);
// 	}
// 
// 	/**
// 	 * Constructor that builds a grade for a given discipline.
// 	 * 
// 	 * @param discipline
// 	 *            to grade.
// 	 * @param grade
// 	 *            the actual grade.
// 	 */
// 	public Grade(final Discipline discipline, final Integer grade) {
// 		this(discipline);
// 		this.setGrade(grade);
// 	}
// 
// 	/**
// 	 * Constructor that builds a grade for a given discipline.
// 	 * 
// 	 */
// 	public Grade() {
// 	}
// 
// 	/**
// 	 * @return the discipline
// 	 */
// 	public final Discipline getDiscipline() {
// 		return discipline;
// 	}
// 
// 	/**
// 	 * @param discipline
// 	 *            to set
// 	 */
// 	public final void setDiscipline(final Discipline pDiscipline) {
// 		this.discipline = pDiscipline;
// 	}
// 
// 	/**
// 	 * @return the grade
// 	 */
// 	public final Integer getGrade() {
// 		return grade;
// 	}
// 
// 	/**
// 	 * @param grade
// 	 *            the grade to set
// 	 */
// 	public final void setGrade(final Integer pGrade) {
// 		this.grade = pGrade;
// 	}
// 
// 	/**
// 	 * @return the id
// 	 */
// 	public final long getId() {
// 		return id;
// 	}
// 
// 	/**
// 	 * @return the student
// 	 */
// 	public Student getStudent() {
// 		return student;
// 	}
// 
// 	/**
// 	 * @param student
// 	 *            the student to set
// 	 */
// 	public void setStudent(final Student pStudent) {
// 		this.student = pStudent;
// 	}
// 
// }


import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import ch.demo.dom.Discipline;
import ch.demo.dom.Grade;
import ch.demo.test.IntegrationTest;
import junit.framework.Assert;
		int numberOfGrades = results.size();

		query = em.createQuery("SELECT g FROM Grade g where g.studentId = :studentId", Grade.class);
		query.setParameter("studentId", "001");
		int numberOf001Grades = query.getResultList().size();
		
		Grade g = new Grade("001", new Date(), Discipline.BIOLOGY, 40);
		service.addGrade(g);
		g = new Grade("001", new Date(), Discipline.MATHEMATICS, 10);
		service.addGrade(g);
		g = new Grade("001", new Date(), Discipline.ENGLISH, 20);
		service.addGrade(g);
		g = new Grade("002", new Date(), Discipline.ENGLISH, 40);
		service.addGrade(g);

		query = em.createQuery("SELECT g FROM Grade g", Grade.class);
		results = query.getResultList();
		Assert.assertEquals(numberOfGrades + 4, results.size());

		query = em.createQuery("SELECT g FROM Grade g where g.studentId = :studentId", Grade.class);
		query.setParameter("studentId", "001");
		results = query.getResultList();
		Assert.assertEquals(numberOf001Grades + 3, results.size());
	}

	@Test
	public void shouldRemoveGrade() {
		Grade g = new Grade("001", new Date(), Discipline.BIOLOGY, 40);
		service.addGrade(g);
		TypedQuery<Grade> query = em.createQuery("SELECT g FROM Grade g", Grade.class);
// Path: jee7-search-service/src/main/java/ch/demo/dom/Discipline.java
// @XmlEnum(String.class)
// public enum Discipline {
//     /** Maths. */
//     MATHEMATICS("Mathematics"),
//     /** Biology. */
//     BIOLOGY("Biology"),
//     /** French. */
//     FRENCH("French"),
//     /** English. */
//     ENGLISH("English"),
//     /** German. */
//     GERMAN("German"),
//     /** History. */
//     HISTORY("History"),
//     /** Geography. */
//     GEOGRAPHY("Geography");
// 
//     /**
//      * Constructor.
//      * 
//      * @param name
//      *            of the discipline.
//      */
//     private Discipline(final String pName) {
//         this.name = pName;
//     }
// 
//     /** The actual name of the discipline. */
//     private String name;
// 
//     /** {@inheritDoc} */
//     @Override
//     public String toString() {
//         return this.name;
//     }
// 
// }
// 
// Path: jee7-search-service/src/main/java/ch/demo/dom/Grade.java
// @Entity
// @Table(name = "GRADES")
// public class Grade implements Serializable {
// 
// 	/** The serial-id. */
// 	private static final long serialVersionUID = -1369317473509616839L;
// 
// 	/** The unique id. */
// 	@Id
// 	@GeneratedValue(strategy = GenerationType.AUTO)
// 	private long id;
// 
// 	/** The discipline of this grade. */
// 	@Column(name = "DISCIPLINE", nullable = false)
// 	private Discipline discipline;
// 
// 	/** The actual grade. */
// 	@Column(name = "GRADE", nullable = true)
// 	private Integer grade;
// 
// 	/** The student that has obtained this grade. */
// 	@ManyToOne
// 	private Student student;
// 
// 	/**
// 	 * Constructor that builds a grade for a given discipline.
// 	 * 
// 	 * @param discipline
// 	 *            to grade.
// 	 */
// 	public Grade(final Discipline discipline) {
// 		setDiscipline(discipline);
// 	}
// 
// 	/**
// 	 * Constructor that builds a grade for a given discipline.
// 	 * 
// 	 * @param discipline
// 	 *            to grade.
// 	 * @param grade
// 	 *            the actual grade.
// 	 */
// 	public Grade(final Discipline discipline, final Integer grade) {
// 		this(discipline);
// 		this.setGrade(grade);
// 	}
// 
// 	/**
// 	 * Constructor that builds a grade for a given discipline.
// 	 * 
// 	 */
// 	public Grade() {
// 	}
// 
// 	/**
// 	 * @return the discipline
// 	 */
// 	public final Discipline getDiscipline() {
// 		return discipline;
// 	}
// 
// 	/**
// 	 * @param discipline
// 	 *            to set
// 	 */
// 	public final void setDiscipline(final Discipline pDiscipline) {
// 		this.discipline = pDiscipline;
// 	}
// 
// 	/**
// 	 * @return the grade
// 	 */
// 	public final Integer getGrade() {
// 		return grade;
// 	}
// 
// 	/**
// 	 * @param grade
// 	 *            the grade to set
// 	 */
// 	public final void setGrade(final Integer pGrade) {
// 		this.grade = pGrade;
// 	}
// 
// 	/**
// 	 * @return the id
// 	 */
// 	public final long getId() {
// 		return id;
// 	}
// 
// 	/**
// 	 * @return the student
// 	 */
// 	public Student getStudent() {
// 		return student;
// 	}
// 
// 	/**
// 	 * @param student
// 	 *            the student to set
// 	 */
// 	public void setStudent(final Student pStudent) {
// 		this.student = pStudent;
// 	}
// 
// }


// Path: jee7-grade-service/src/test/java/ch/demo/business/service/GradeServiceImplTest.java
import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;
import javax.inject.Inject;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;
import javax.persistence.Query;
import javax.persistence.TypedQuery;
import org.jboss.arquillian.container.test.api.Deployment;
import org.jboss.arquillian.junit.Arquillian;
import org.jboss.shrinkwrap.api.ShrinkWrap;
import org.jboss.shrinkwrap.api.asset.EmptyAsset;
import org.jboss.shrinkwrap.api.spec.JavaArchive;
import org.junit.Test;
import org.junit.experimental.categories.Category;
import org.junit.runner.RunWith;
import ch.demo.dom.Discipline;
import ch.demo.dom.Grade;
import ch.demo.test.IntegrationTest;
import junit.framework.Assert;

		int numberOfGrades = results.size();

		query = em.createQuery("SELECT g FROM Grade g where g.studentId = :studentId", Grade.class);
		query.setParameter("studentId", "001");
		int numberOf001Grades = query.getResultList().size();
		
		Grade g = new Grade("001", new Date(), Discipline.BIOLOGY, 40);
		service.addGrade(g);
		g = new Grade("001", new Date(), Discipline.MATHEMATICS, 10);
		service.addGrade(g);
		g = new Grade("001", new Date(), Discipline.ENGLISH, 20);
		service.addGrade(g);
		g = new Grade("002", new Date(), Discipline.ENGLISH, 40);
		service.addGrade(g);

		query = em.createQuery("SELECT g FROM Grade g", Grade.class);
		results = query.getResultList();
		Assert.assertEquals(numberOfGrades + 4, results.size());

		query = em.createQuery("SELECT g FROM Grade g where g.studentId = :studentId", Grade.class);
		query.setParameter("studentId", "001");
		results = query.getResultList();
		Assert.assertEquals(numberOf001Grades + 3, results.size());
	}

	@Test
	public void shouldRemoveGrade() {
		Grade g = new Grade("001", new Date(), Discipline.BIOLOGY, 40);
		service.addGrade(g);
		TypedQuery<Grade> query = em.createQuery("SELECT g FROM Grade g", Grade.class);
		List<Grade> results = query.getResultList();