@Test public void testDBUnitDataSetGadgetsInFord1Tab() { final int fordFirstTabExpectedGadgetCount = 3; final int zoneOne = 0; final int zoneThree = 2; Tab fordTab1 = jpaTabMapper.findById(fordsFirstTabId); assertEquals("Ford's 1st tab didn't have an expected number of gadgets.", fordFirstTabExpectedGadgetCount, fordTab1.getGadgets().size()); List<Gadget> tab1Gadgets = new ArrayList<Gadget>(fordTab1.getGadgets()); HashMap<Long, Gadget> tab1Map = new HashMap<Long, Gadget>(); for (Gadget g : tab1Gadgets) { tab1Map.put(g.getId(), g); } String message = "A gadget in Ford's first tab has an unexpected gadget url"; 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, zoneOne, tab1Map.get(fordsFirstTabFirstGadgetId).getZoneNumber()); assertEquals(message, zoneOne, tab1Map.get(fordsFirstTabSecondGadgetId).getZoneNumber()); assertEquals(message, zoneThree, tab1Map.get(fordsFirstTabThirdGadgetId).getZoneNumber()); message = "A gadget in Ford's first tab has an unexpected zoneIndex"; assertEquals(message, 0, tab1Map.get(fordsFirstTabFirstGadgetId).getZoneIndex()); assertEquals(message, 1, tab1Map.get(fordsFirstTabSecondGadgetId).getZoneIndex()); assertEquals(message, 0, tab1Map.get(fordsFirstTabThirdGadgetId).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);  }