/** Test if setReceiver correctly changes the Receiver */
  @Test
  public void test08_ChangeReceiver() {
    em.getTransaction().begin();
    List<UserMessage> tps = em.createQuery("from UserMessage", UserMessage.class).getResultList();
    UserMessage instance;
    TradingPartner receiver = new TradingPartner(T_SENDER2_ID, T_SENDER2_ROLE);

    assertTrue(tps.size() == 1);

    instance = tps.get(0);

    instance.setReceiver(receiver);

    em.persist(receiver);
    em.persist(instance);
    em.getTransaction().commit();

    em.getTransaction().begin();
    tps = em.createQuery("from UserMessage", UserMessage.class).getResultList();

    instance = tps.get(0);

    assertEquals(T_SENDER2_ROLE, instance.getReceiver().getRole());

    Iterator<IPartyId> pids = instance.getReceiver().getPartyIds().iterator();
    if (pids.hasNext()) {
      assertEquals(T_SENDER2_ID, pids.next().getId());
    } else
      // There should be a partyid
      fail("Not retrieved the correct Sender");

    em.getTransaction().commit();
  }
  /** Test of getReceiver method, of class UserMessage. */
  @Test
  public void test07_GetReceiver() {
    em.getTransaction().begin();
    List<UserMessage> tps = em.createQuery("from UserMessage", UserMessage.class).getResultList();
    UserMessage instance;

    assertTrue(tps.size() == 1);
    instance = tps.get(0);

    assertEquals(T_RECEIVER1_ROLE, instance.getReceiver().getRole());

    Iterator<IPartyId> pids = instance.getReceiver().getPartyIds().iterator();
    if (pids.hasNext()) {
      assertEquals(T_RECEIVER1_ID, pids.next().getId());
    } else
      // There should be a partyid
      fail("Not retrieved the correct Sender");

    em.getTransaction().commit();
  }