@Test
public void countMessagesPerApplicationID() {
final String loginName = "admin";
final PushApplication pushApp = new PushApplication();
pushApp.setName("app");
pushApp.setPushApplicationID("231231231");
pushApp.setDeveloper(loginName);
entityManager.persist(pushApp);
final PushApplication pushApp1 = new PushApplication();
pushApp1.setName("app1");
pushApp1.setPushApplicationID("231231232");
pushApp1.setDeveloper(loginName);
entityManager.persist(pushApp1);
long number = pushMessageInformationDao.getNumberOfPushMessagesForApplications(loginName);
assertThat(number).isEqualTo(1);
for (int i = 0; i < 100; i++) {
PushMessageInformation pmi = new PushMessageInformation();
pmi.setPushApplicationId(pushApp.getPushApplicationID());
pushMessageInformationDao.create(pmi);
}
number = pushMessageInformationDao.getNumberOfPushMessagesForApplications(loginName);
assertThat(number).isEqualTo(101);
// a few more for different PushApplication...
for (int i = 0; i < 100; i++) {
PushMessageInformation pmi = new PushMessageInformation();
pmi.setPushApplicationId(pushApp1.getPushApplicationID());
pushMessageInformationDao.create(pmi);
}
number = pushMessageInformationDao.getNumberOfPushMessagesForApplications(loginName);