@Test public void getCacheImagesForApplicationNotInDB() { Application application = new Application(); List<Image> images = imageDAO.getCacheImagesForApplication(application); assertEquals(0, images.size()); images = imageDAO.getCacheImagesForApplication(null); assertEquals(0, images.size()); }
@Override @SuppressWarnings("unchecked") public List<Image> getCacheImagesForApplication(Application application) { if(application == null) { return new ArrayList<Image>(); } try { Query query = entityManager.createQuery("from Image where demo = true and application = :applicationIdentifier"); query.setParameter("applicationIdentifier", application); List<Image> images = (List<Image>) query.getResultList(); return images; } catch(IllegalStateException ex) { logger.debug("Trying to get information for an application that does not exists in the databse"); return new ArrayList<Image>(); } }
ImageDAOJpa implements ImageDAO { @Override @SuppressWarnings("unchecked") public List<Image> getCacheImagesForApplication(Application application) { if(application == null) { return new ArrayList<Image>(); } try { Query query = entityManager.createQuery("from Image where demo = true and application = :applicationIdentifier"); query.setParameter("applicationIdentifier", application); List<Image> images = (List<Image>) query.getResultList(); return images; } catch(IllegalStateException ex) { logger.debug("Trying to get information for an application that does not exists in the databse"); return new ArrayList<Image>(); } } }
ImageDAOJpa implements ImageDAO { @Override @SuppressWarnings("unchecked") public List<Image> getCacheImagesForApplication(Application application) { if(application == null) { return new ArrayList<Image>(); } try { Query query = entityManager.createQuery("from Image where demo = true and application = :applicationIdentifier"); query.setParameter("applicationIdentifier", application); List<Image> images = (List<Image>) query.getResultList(); return images; } catch(IllegalStateException ex) { logger.debug("Trying to get information for an application that does not exists in the databse"); return new ArrayList<Image>(); } }  }
ImageDAOJpa implements ImageDAO { @Override @SuppressWarnings("unchecked") public List<Image> getCacheImagesForApplication(Application application) { if(application == null) { return new ArrayList<Image>(); } try { Query query = entityManager.createQuery("from Image where demo = true and application = :applicationIdentifier"); query.setParameter("applicationIdentifier", application); List<Image> images = (List<Image>) query.getResultList(); return images; } catch(IllegalStateException ex) { logger.debug("Trying to get information for an application that does not exists in the databse"); return new ArrayList<Image>(); } }  @PersistenceContext (unitName = "applicationManagerDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Image getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Image> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(Image image); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(Image image); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(Image image); @Override Image getLastImageWithOvfId(String ovfId); @Override Image getDemoCacheImage(String ovfId, String ovfHref); @Override @SuppressWarnings("unchecked") List<Image> getCacheImagesForApplication(Application application); }
ImageDAOJpa implements ImageDAO { @Override @SuppressWarnings("unchecked") public List<Image> getCacheImagesForApplication(Application application) { if(application == null) { return new ArrayList<Image>(); } try { Query query = entityManager.createQuery("from Image where demo = true and application = :applicationIdentifier"); query.setParameter("applicationIdentifier", application); List<Image> images = (List<Image>) query.getResultList(); return images; } catch(IllegalStateException ex) { logger.debug("Trying to get information for an application that does not exists in the databse"); return new ArrayList<Image>(); } }  @PersistenceContext (unitName = "applicationManagerDB") void setEntityManager(EntityManager entityManager); EntityManager getEntityManager(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) Image getById(int id); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) List<Image> getAll(); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean save(Image image); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean update(Image image); @Override @Transactional(readOnly=false, propagation=Propagation.REQUIRED) boolean delete(Image image); @Override Image getLastImageWithOvfId(String ovfId); @Override Image getDemoCacheImage(String ovfId, String ovfHref); @Override @SuppressWarnings("unchecked") List<Image> getCacheImagesForApplication(Application application);  }