@Test public void testPersistence() { try { em.getTransaction().begin(); Student u = new Student(); u.setScore(12); u.setName("eskatos"); em.persist(u); assertTrue(em.contains(u)); em.remove(u); assertFalse(em.contains(u)); em.getTransaction().commit(); } catch (Exception ex) { em.getTransaction().rollback(); ex.printStackTrace(); fail("Exception during testPersistence"); } }
/** * Sets a new score for the student. * * @param newScore Integer. The new score to set. */ public void setScore(int newScore) { student.setScore(newScore); }
/** When called; increases the students score by the amount set in REWARD_SCORE (10) */ protected void increaseScore() { student.setScore(student.getScore() + REWARD_SCORE); }