@Test public void test_getAllRegisteredApps_noResults() { List<IRegisteredApp> apps = new ArrayList<IRegisteredApp>(); Mockito.when(em.createQuery("SELECT a FROM RegisteredApp a", IRegisteredApp.class)).thenReturn(query); Mockito.when(query.getResultList()).thenReturn(apps); IRegisteredApp[] allApps = dbClientToTest.getAllRegisteredApps(); Assert.assertEquals(0, allApps.length); }
@Override public IRegisteredApp[] getAllRegisteredApps() { TypedQuery<IRegisteredApp> query = em.createQuery("SELECT a FROM RegisteredApp a", IRegisteredApp.class); List<IRegisteredApp> results = query.getResultList(); if (results == null) { return new IRegisteredApp[0]; } return results.toArray(new IRegisteredApp[results.size()]); }
RegisteredAppDatabaseClient extends DatabaseClient<IRegisteredApp> implements IRegisteredAppDatabaseClient { @Override public IRegisteredApp[] getAllRegisteredApps() { TypedQuery<IRegisteredApp> query = em.createQuery("SELECT a FROM RegisteredApp a", IRegisteredApp.class); List<IRegisteredApp> results = query.getResultList(); if (results == null) { return new IRegisteredApp[0]; } return results.toArray(new IRegisteredApp[results.size()]); } }
RegisteredAppDatabaseClient extends DatabaseClient<IRegisteredApp> implements IRegisteredAppDatabaseClient { @Override public IRegisteredApp[] getAllRegisteredApps() { TypedQuery<IRegisteredApp> query = em.createQuery("SELECT a FROM RegisteredApp a", IRegisteredApp.class); List<IRegisteredApp> results = query.getResultList(); if (results == null) { return new IRegisteredApp[0]; } return results.toArray(new IRegisteredApp[results.size()]); }  }
RegisteredAppDatabaseClient extends DatabaseClient<IRegisteredApp> implements IRegisteredAppDatabaseClient { @Override public IRegisteredApp[] getAllRegisteredApps() { TypedQuery<IRegisteredApp> query = em.createQuery("SELECT a FROM RegisteredApp a", IRegisteredApp.class); List<IRegisteredApp> results = query.getResultList(); if (results == null) { return new IRegisteredApp[0]; } return results.toArray(new IRegisteredApp[results.size()]); }  @Override IRegisteredApp getAppById(String id); @Override void storeModifiedApp(IRegisteredApp app); @Override IRegisteredApp[] getAllRegisteredApps(); }
RegisteredAppDatabaseClient extends DatabaseClient<IRegisteredApp> implements IRegisteredAppDatabaseClient { @Override public IRegisteredApp[] getAllRegisteredApps() { TypedQuery<IRegisteredApp> query = em.createQuery("SELECT a FROM RegisteredApp a", IRegisteredApp.class); List<IRegisteredApp> results = query.getResultList(); if (results == null) { return new IRegisteredApp[0]; } return results.toArray(new IRegisteredApp[results.size()]); }  @Override IRegisteredApp getAppById(String id); @Override void storeModifiedApp(IRegisteredApp app); @Override IRegisteredApp[] getAllRegisteredApps();  }