@Test public void testDBUnitDataSetGadgetsInFord3Tab() { final int expectedNumberOfGadgetsIn3rdTab = 7; Tab fordTab3 = jpaTabMapper.findById(fordsThirdTabId); assertEquals("Ford's 3rd tab didn't have an expected number of gadgets.", expectedNumberOfGadgetsIn3rdTab, fordTab3.getGadgets().size()); List<Gadget> tab3Gadgets = new ArrayList<Gadget>(fordTab3.getGadgets()); HashMap<Long, Gadget> tab3Map = new HashMap<Long, Gadget>(); for (Gadget g : tab3Gadgets) { tab3Map.put(g.getId(), g); } String message = "A gadget in Ford's third tab has an unexpected gadget url"; assertEquals(message, "http: .getGadgetDefinition().getUrl()); assertEquals(message, "http: .getGadgetDefinition().getUrl()); assertEquals(message, "http: .getGadgetDefinition().getUrl()); assertEquals(message, "http: .getGadgetDefinition().getUrl()); assertEquals(message, "http: .getGadgetDefinition().getUrl()); assertEquals(message, "http: .getGadgetDefinition().getUrl()); assertEquals(message, "http: .getGadgetDefinition().getUrl()); message = "A gadget in Ford's first tab has an unexpected zoneNumber"; assertEquals(message, 0, tab3Map.get(fordsThirdTabFirstGadgetId).getZoneNumber()); assertEquals(message, 0, tab3Map.get(fordsThirdTabSecondGadgetId).getZoneNumber()); assertEquals(message, 0, tab3Map.get(fordsThirdTabThirdGadgetId).getZoneNumber()); assertEquals(message, 1, tab3Map.get(fordsThirdTabFourthGadgetId).getZoneNumber()); message = "A gadget in Ford's first tab has an unexpected zoneIndex"; assertEquals(message, 0, tab3Map.get(fordsThirdTabFirstGadgetId).getZoneIndex()); assertEquals(message, 1, tab3Map.get(fordsThirdTabSecondGadgetId).getZoneIndex()); assertEquals(message, 2, tab3Map.get(fordsThirdTabThirdGadgetId).getZoneIndex()); assertEquals(message, 0, tab3Map.get(fordsThirdTabFourthGadgetId).getZoneIndex()); }
public Tab findById(final Long tabId) { Query q = entityManager.createQuery( "from Tab t left join fetch t.template where t.id = :tabId and t.deleted = 'false'").setParameter( "tabId", tabId); Tab tab = (Tab) q.getSingleResult(); tab.getGadgets().size(); return tab; }
TabMapper { public Tab findById(final Long tabId) { Query q = entityManager.createQuery( "from Tab t left join fetch t.template where t.id = :tabId and t.deleted = 'false'").setParameter( "tabId", tabId); Tab tab = (Tab) q.getSingleResult(); tab.getGadgets().size(); return tab; } }
TabMapper { public Tab findById(final Long tabId) { Query q = entityManager.createQuery( "from Tab t left join fetch t.template where t.id = :tabId and t.deleted = 'false'").setParameter( "tabId", tabId); Tab tab = (Tab) q.getSingleResult(); tab.getGadgets().size(); return tab; } TabMapper(final QueryOptimizer inQueryOptimizer); }
TabMapper { public Tab findById(final Long tabId) { Query q = entityManager.createQuery( "from Tab t left join fetch t.template where t.id = :tabId and t.deleted = 'false'").setParameter( "tabId", tabId); Tab tab = (Tab) q.getSingleResult(); tab.getGadgets().size(); return tab; } TabMapper(final QueryOptimizer inQueryOptimizer); TabTemplate getTabTemplate(final String type); void setUndeleteGadgetWindowInMinutes(final int undeleteWindowInMinutes); @PersistenceContext void setEntityManager(final EntityManager inEntityManager); Tab findById(final Long tabId); TabTemplate findByGadgetId(final Long gadgetId); Tab findTabByGadgetId(final Long gadgetId); Tab findById(final Integer tabId); void flush(); void deleteGadget(final Gadget gadgetToDelete); Gadget undeleteGadget(final long gadgetId); @SuppressWarnings("unchecked") void moveGadget(final Long gadgetId, final Long sourceTabTemplateId, final Integer sourceZoneIndex,
            final Integer sourceZoneNumber, final Long targetTabTemplateId, final Integer targetZoneIndex,
            final Integer targetZoneNumber); }
TabMapper { public Tab findById(final Long tabId) { Query q = entityManager.createQuery( "from Tab t left join fetch t.template where t.id = :tabId and t.deleted = 'false'").setParameter( "tabId", tabId); Tab tab = (Tab) q.getSingleResult(); tab.getGadgets().size(); return tab; } TabMapper(final QueryOptimizer inQueryOptimizer); TabTemplate getTabTemplate(final String type); void setUndeleteGadgetWindowInMinutes(final int undeleteWindowInMinutes); @PersistenceContext void setEntityManager(final EntityManager inEntityManager); Tab findById(final Long tabId); TabTemplate findByGadgetId(final Long gadgetId); Tab findTabByGadgetId(final Long gadgetId); Tab findById(final Integer tabId); void flush(); void deleteGadget(final Gadget gadgetToDelete); Gadget undeleteGadget(final long gadgetId); @SuppressWarnings("unchecked") void moveGadget(final Long gadgetId, final Long sourceTabTemplateId, final Integer sourceZoneIndex,
            final Integer sourceZoneNumber, final Long targetTabTemplateId, final Integer targetZoneIndex,
            final Integer targetZoneNumber);  }