@Test public final void executeTest() { List<GadgetDefinition> defs = new ArrayList<GadgetDefinition>(); for (int i = 0; i < NUMBER_OF_DEFS; i++) { defs.add(new GadgetDefinition()); } final int total = 20; final int secondPageStartIndex = 10; final int secondPageEndIndex = 19; final PagedSet<GadgetDefinition> firstPage = new PagedSet<GadgetDefinition>(); firstPage.setTotal(total); firstPage.setFromIndex(0); firstPage.setToIndex(9); firstPage.setPagedSet(defs); final PagedSet<GadgetDefinition> secondPage = new PagedSet<GadgetDefinition>(); secondPage.setTotal(total); secondPage.setFromIndex(secondPageStartIndex); secondPage.setToIndex(secondPageEndIndex); secondPage.setPagedSet(defs); context.checking(new Expectations() { { oneOf(gadgetDefMapper).findAll(firstPage.getFromIndex(), firstPage.getToIndex()); will(returnValue(firstPage)); oneOf(gadgetDefMapper).findAll(secondPage.getFromIndex(), secondPage.getToIndex()); will(returnValue(secondPage)); exactly(firstPage.getTotal()).of(populator).populate(with(any(GadgetDefinition.class)), with(any(String.class))); exactly(firstPage.getTotal()).of(gadgetDefMapper).reindex(with(any(GadgetDefinition.class))); oneOf(gadgetDefMapper).flush(); } }); sut.execute(); context.assertIsSatisfied(); }
public void execute() { stopWatch.reset(); stopWatch.start(); try { PagedSet<GadgetDefinition> gadgetDefs = null; BasicPager pager = new BasicPager(); pager.setPageSize(PAGE_SIZE); pager.setStartItem(0); pager.setEndItem(PAGE_SIZE - 1); pager.setMaxCount(PAGE_SIZE); int indexedGadgetsCount = 0; while (true) { gadgetDefs = gadgetDefMapper.findAll(pager.getStartItem(), pager.getEndItem()); pager.setEndItem(gadgetDefs.getToIndex()); pager.setMaxCount(gadgetDefs.getTotal()); pager.setPageSize(PAGE_SIZE); for (GadgetDefinition def : gadgetDefs.getPagedSet()) { indexedGadgetsCount++; populator.populate(def, def.getUrl()); gadgetDefMapper.reindex(def); } if (pager.isNextPageable()) { pager.nextPage(); } else { break; } } logger.info("Total Gadgets indexed: " + indexedGadgetsCount); } catch (Exception ex) { logger.error("Error occurred refreshing the Gadget Definition Index", ex); } gadgetDefMapper.flush(); stopWatch.stop(); logger.info("Gadget Definition Index Refresh Job: elapsed time: " + DurationFormatUtils.formatDurationHMS(stopWatch.getTime())); }
GadgetDefinitionReindexTask { public void execute() { stopWatch.reset(); stopWatch.start(); try { PagedSet<GadgetDefinition> gadgetDefs = null; BasicPager pager = new BasicPager(); pager.setPageSize(PAGE_SIZE); pager.setStartItem(0); pager.setEndItem(PAGE_SIZE - 1); pager.setMaxCount(PAGE_SIZE); int indexedGadgetsCount = 0; while (true) { gadgetDefs = gadgetDefMapper.findAll(pager.getStartItem(), pager.getEndItem()); pager.setEndItem(gadgetDefs.getToIndex()); pager.setMaxCount(gadgetDefs.getTotal()); pager.setPageSize(PAGE_SIZE); for (GadgetDefinition def : gadgetDefs.getPagedSet()) { indexedGadgetsCount++; populator.populate(def, def.getUrl()); gadgetDefMapper.reindex(def); } if (pager.isNextPageable()) { pager.nextPage(); } else { break; } } logger.info("Total Gadgets indexed: " + indexedGadgetsCount); } catch (Exception ex) { logger.error("Error occurred refreshing the Gadget Definition Index", ex); } gadgetDefMapper.flush(); stopWatch.stop(); logger.info("Gadget Definition Index Refresh Job: elapsed time: " + DurationFormatUtils.formatDurationHMS(stopWatch.getTime())); } }
GadgetDefinitionReindexTask { public void execute() { stopWatch.reset(); stopWatch.start(); try { PagedSet<GadgetDefinition> gadgetDefs = null; BasicPager pager = new BasicPager(); pager.setPageSize(PAGE_SIZE); pager.setStartItem(0); pager.setEndItem(PAGE_SIZE - 1); pager.setMaxCount(PAGE_SIZE); int indexedGadgetsCount = 0; while (true) { gadgetDefs = gadgetDefMapper.findAll(pager.getStartItem(), pager.getEndItem()); pager.setEndItem(gadgetDefs.getToIndex()); pager.setMaxCount(gadgetDefs.getTotal()); pager.setPageSize(PAGE_SIZE); for (GadgetDefinition def : gadgetDefs.getPagedSet()) { indexedGadgetsCount++; populator.populate(def, def.getUrl()); gadgetDefMapper.reindex(def); } if (pager.isNextPageable()) { pager.nextPage(); } else { break; } } logger.info("Total Gadgets indexed: " + indexedGadgetsCount); } catch (Exception ex) { logger.error("Error occurred refreshing the Gadget Definition Index", ex); } gadgetDefMapper.flush(); stopWatch.stop(); logger.info("Gadget Definition Index Refresh Job: elapsed time: " + DurationFormatUtils.formatDurationHMS(stopWatch.getTime())); } GadgetDefinitionReindexTask();  GadgetDefinitionReindexTask(final GadgetDefinitionMapper inGadgetDefMapper,
            final GadgetDefinitionPopulator inPopulator); }
GadgetDefinitionReindexTask { public void execute() { stopWatch.reset(); stopWatch.start(); try { PagedSet<GadgetDefinition> gadgetDefs = null; BasicPager pager = new BasicPager(); pager.setPageSize(PAGE_SIZE); pager.setStartItem(0); pager.setEndItem(PAGE_SIZE - 1); pager.setMaxCount(PAGE_SIZE); int indexedGadgetsCount = 0; while (true) { gadgetDefs = gadgetDefMapper.findAll(pager.getStartItem(), pager.getEndItem()); pager.setEndItem(gadgetDefs.getToIndex()); pager.setMaxCount(gadgetDefs.getTotal()); pager.setPageSize(PAGE_SIZE); for (GadgetDefinition def : gadgetDefs.getPagedSet()) { indexedGadgetsCount++; populator.populate(def, def.getUrl()); gadgetDefMapper.reindex(def); } if (pager.isNextPageable()) { pager.nextPage(); } else { break; } } logger.info("Total Gadgets indexed: " + indexedGadgetsCount); } catch (Exception ex) { logger.error("Error occurred refreshing the Gadget Definition Index", ex); } gadgetDefMapper.flush(); stopWatch.stop(); logger.info("Gadget Definition Index Refresh Job: elapsed time: " + DurationFormatUtils.formatDurationHMS(stopWatch.getTime())); } GadgetDefinitionReindexTask();  GadgetDefinitionReindexTask(final GadgetDefinitionMapper inGadgetDefMapper,
            final GadgetDefinitionPopulator inPopulator); void execute(); }
GadgetDefinitionReindexTask { public void execute() { stopWatch.reset(); stopWatch.start(); try { PagedSet<GadgetDefinition> gadgetDefs = null; BasicPager pager = new BasicPager(); pager.setPageSize(PAGE_SIZE); pager.setStartItem(0); pager.setEndItem(PAGE_SIZE - 1); pager.setMaxCount(PAGE_SIZE); int indexedGadgetsCount = 0; while (true) { gadgetDefs = gadgetDefMapper.findAll(pager.getStartItem(), pager.getEndItem()); pager.setEndItem(gadgetDefs.getToIndex()); pager.setMaxCount(gadgetDefs.getTotal()); pager.setPageSize(PAGE_SIZE); for (GadgetDefinition def : gadgetDefs.getPagedSet()) { indexedGadgetsCount++; populator.populate(def, def.getUrl()); gadgetDefMapper.reindex(def); } if (pager.isNextPageable()) { pager.nextPage(); } else { break; } } logger.info("Total Gadgets indexed: " + indexedGadgetsCount); } catch (Exception ex) { logger.error("Error occurred refreshing the Gadget Definition Index", ex); } gadgetDefMapper.flush(); stopWatch.stop(); logger.info("Gadget Definition Index Refresh Job: elapsed time: " + DurationFormatUtils.formatDurationHMS(stopWatch.getTime())); } GadgetDefinitionReindexTask();  GadgetDefinitionReindexTask(final GadgetDefinitionMapper inGadgetDefMapper,
            final GadgetDefinitionPopulator inPopulator); void execute();  }