@Test
  public void findByPushApplicationID() {
    final String pushApplicationID1 = "888";

    assertThat(pushApplicationDao.findByPushApplicationID(pushApplicationID1)).isNotNull();
    assertThat(pushApplicationDao.findByPushApplicationID(pushApplicationID1).getName())
        .isEqualTo("Push App 1");
    assertThat(pushApplicationDao.findByPushApplicationID("13245632")).isNull();
  }
  @Test
  public void updatePushApplication() {
    final String pushApplicationID1 = "888";

    final PushApplication pushApplication1 =
        pushApplicationDao.findByPushApplicationID(pushApplicationID1);
    assertThat(pushApplication1).isNotNull();
    assertThat(pushApplication1.getName()).isEqualTo("Push App 1");

    pushApplication1.setName("Cool Push App 1");
    pushApplicationDao.update(pushApplication1);

    assertThat(pushApplicationDao.findByPushApplicationID(pushApplicationID1)).isNotNull();
    assertThat(pushApplicationDao.findByPushApplicationID(pushApplicationID1).getName())
        .isEqualTo("Cool Push App 1");
  }
 private List<Application> wrapApplication(List<PushMessageInformation> pushMessageInformations) {
   final List<Application> applications =
       new ArrayList<Application>(pushMessageInformations.size());
   for (PushMessageInformation pushMessageInformation : pushMessageInformations) {
     String applicationName =
         pushApplicationDao
             .findByPushApplicationID(pushMessageInformation.getPushApplicationId())
             .getName();
     final Application application =
         new Application(
             applicationName,
             pushMessageInformation.getPushApplicationId(),
             pushMessageInformation.getTotalReceivers(),
             pushMessageInformation.getSubmitDate());
     applications.add(application);
   }
   return applications;
 }
  @Test
  public void primaryKeyUnmodifiedAfterUpdate() {
    final String id = "1";
    PushApplication pa = pushApplicationDao.find(id);

    assertThat(pa.getId()).isEqualTo(id);

    final PushApplication pushApplication1 =
        pushApplicationDao.findByPushApplicationID(pa.getPushApplicationID());
    pushApplication1.setName("Cool Push App 1");
    pushApplicationDao.update(pushApplication1);

    entityManager.flush();
    entityManager.clear();

    pa = pushApplicationDao.find(id);

    assertThat(pa.getName()).isEqualTo("Cool Push App 1");
  }
  @Test
  public void deletePushApplicationIncludingVariantAndInstallations() {
    final String id = "888";

    final PushApplication pa = pushApplicationDao.findByPushApplicationID(id);

    pushApplicationDao.delete(pa);
    // flush to be sure that it's in the database
    entityManager.flush();
    // clear the cache otherwise finding the entity will not perform a select but get the entity
    // from cache
    entityManager.clear();

    // Installation should be gone:
    assertThat(entityManager.find(Installation.class, "1")).isNull();

    // Variant should be gone:
    assertThat(entityManager.find(AndroidVariant.class, "1")).isNull();

    // PushApp should be gone:
    assertThat(pushApplicationDao.find(id)).isNull();
  }