AbstractResumeBreakPointManager implements ResumeBreakPointManager, Closeable { protected final String getInventoryPositionData() { JsonObject result = new JsonObject(); JsonObject unfinished = new JsonObject(); Set<String> finished = Sets.newHashSet(); for (Entry<String, PositionManager<InventoryPosition>> entry : inventoryPositionManagerMap.entrySet()) { if (entry.getValue().getPosition() instanceof FinishedInventoryPosition) { finished.add(entry.getKey()); continue; } unfinished.add(entry.getKey(), entry.getValue().getPosition().toJson()); } result.add(UNFINISHED, unfinished); result.add(FINISHED, GSON.toJsonTree(finished)); return result.toString(); }  @Override void close();  }
@Test public void assertPrimaryKeyPositionJson() { resumeBreakPointManager.getInventoryPositionManagerMap().put("ds0.t_order_1#0", new InventoryPositionManager<>(new PrimaryKeyPosition(0L, 100L))); assertThat(resumeBreakPointManager.getInventoryPositionData(), is("{\"unfinished\":{\"ds0.t_order_1#0\":[0,100]},\"finished\":[]}")); }
@Test public void assertPlaceholderPositionJson() { resumeBreakPointManager.getInventoryPositionManagerMap().put("ds0.t_order_1#0", new InventoryPositionManager<>(new PlaceholderInventoryPosition())); assertThat(resumeBreakPointManager.getInventoryPositionData(), is("{\"unfinished\":{\"ds0.t_order_1#0\":[]},\"finished\":[]}")); assertThat(new PlaceholderInventoryPosition().toJson().toString(), is("[]")); }
@Test public void assertFinishedPositionJson() { resumeBreakPointManager.getInventoryPositionManagerMap().put("ds0.t_order_1#0", new InventoryPositionManager<>(new FinishedInventoryPosition())); assertThat(resumeBreakPointManager.getInventoryPositionData(), is("{\"unfinished\":{},\"finished\":[\"ds0.t_order_1#0\"]}")); assertThat(new FinishedInventoryPosition().toJson().toString(), is("{}")); }
@Test public void assertGetInventoryPositionData() { resumeBreakPointManager.getInventoryPositionManagerMap().put("ds0.t_order_1#0", new InventoryPositionManager<>(new PrimaryKeyPosition(0L, 100L))); resumeBreakPointManager.getInventoryPositionManagerMap().put("ds0.t_order_1#1", new InventoryPositionManager<>(new FinishedInventoryPosition())); resumeBreakPointManager.getInventoryPositionManagerMap().put("ds0.t_order_2", new InventoryPositionManager<>(new PlaceholderInventoryPosition())); resumeBreakPointManager.getInventoryPositionManagerMap().put("ds1.t_order_1#0", new InventoryPositionManager<>(new PrimaryKeyPosition(0L, 200L))); assertThat(resumeBreakPointManager.getInventoryPositionData(), is(inventoryPosition)); }