private void assertEqualsMD(MessageDelivery expected, MessageDelivery actual) {
   assertEquals(expected.getId(), actual.getId());
   assertEquals(expected.getDelivererSystemId(), actual.getDelivererSystemId());
   assertEquals(expected.getDelivererTypeName(), actual.getDelivererTypeName());
   assertEquals(expected.getDeliveryStatus(), actual.getDeliveryStatus());
   assertEquals(expected.getMessage().getId(), actual.getMessage().getId());
 }
  @Test
  @Override
  public void testUpdate() {
    MessageDelivery m = messageDeliveryService.getMessageDelivery(MESSAGE_DELIV.getId());
    m.setDelivererTypeName("eagle");
    m.setDeliveryStatus(MessageDeliveryStatus.UNDELIVERED);
    m.setDelivererSystemId("1234");
    messageDeliveryService.saveMessageDelivery(m);

    MessageDelivery m2 = messageDeliveryService.getMessageDelivery(m.getId());
    assertNotNull(m2);

    assertEqualsMD(m, m2);
  }
  @Test
  @Override
  public void testReadById() {
    MessageDelivery m = messageDeliveryService.getMessageDelivery(MESSAGE_DELIV.getId());

    assertEqualsMD(MESSAGE_DELIV, m);
  }
 @Test(expected = DataAccessException.class)
 @Override
 public void testInvalidUpdate() {
   final MessageDelivery m = messageDeliveryService.getMessageDelivery(MESSAGE_DELIV.getId());
   m.setDelivererTypeName(null);
   messageDeliveryService.saveMessageDelivery(m);
 }
  @Test
  @Override
  public void testCreate() {
    MessageDelivery md = new MessageDelivery();
    md.setDelivererTypeName("pigeon");
    md.setMessage(MESSAGE);

    messageDeliveryService.saveMessageDelivery(md);

    assertNotNull(md.getId());
    Collection<MessageDelivery> ms = messageDeliveryService.getAllMessageDeliveries();
    assertNotNull(ms);
    assertEquals(2, ms.size());

    MessageDelivery md2 = messageDeliveryService.getMessageDelivery(md.getId());
    assertNotNull(md2);

    assertEqualsMD(md, md2);
  }
  @Test
  @Override
  public void testDelete() {
    messageDeliveryService.deleteMessageDelivery(MESSAGE_DELIV);

    Collection<MessageDelivery> ms = messageDeliveryService.getAllMessageDeliveries();
    assertNotNull(ms);
    assertEquals(0, ms.size());

    assertNull(messageDeliveryService.getMessageDelivery(MESSAGE_DELIV.getId()));
  }