@Test public void testSingleMatch() { int slotCount = 3; SlotMatchResult[] slotMatchResults = new SlotMatchResult[slotCount]; slotMatchResults[0] = new SlotMatchResult(0, true, 10, 15); slotMatchResults[1] = new SlotMatchResult(1, false, 20, -1); slotMatchResults[2] = new SlotMatchResult(2, false, 123456789, 123456788); CallbackContext ctx = new CallbackContext(slotMatchResults); Slot[] actualSlots = ctx.nextAwaitingSlots(); Slot[] expSlots = new Slot[slotCount]; expSlots[0] = new Slot(0, 16); expSlots[1] = new Slot(1, 20); expSlots[2] = new Slot(2, 123456789); assertArrayEquals(expSlots, actualSlots); }
public Slot[] nextAwaitingSlots() { Slot[] nextAwaitingSlots = new Slot[slotMatchResults.length]; for (int i = 0; i < slotMatchResults.length; i++) { SlotMatchResult slotMatchResult = slotMatchResults[i]; long nextAwaitingOffset; if (slotMatchResult.isMatch()) { nextAwaitingOffset = 1 + slotMatchResult.getTriggeringOffset(); } else { nextAwaitingOffset = slotMatchResult.getAwaitingOffset(); } nextAwaitingSlots[i] = new Slot(slotMatchResult.getIndex(), nextAwaitingOffset); } return nextAwaitingSlots; }
CallbackContext { public Slot[] nextAwaitingSlots() { Slot[] nextAwaitingSlots = new Slot[slotMatchResults.length]; for (int i = 0; i < slotMatchResults.length; i++) { SlotMatchResult slotMatchResult = slotMatchResults[i]; long nextAwaitingOffset; if (slotMatchResult.isMatch()) { nextAwaitingOffset = 1 + slotMatchResult.getTriggeringOffset(); } else { nextAwaitingOffset = slotMatchResult.getAwaitingOffset(); } nextAwaitingSlots[i] = new Slot(slotMatchResult.getIndex(), nextAwaitingOffset); } return nextAwaitingSlots; } }
CallbackContext { public Slot[] nextAwaitingSlots() { Slot[] nextAwaitingSlots = new Slot[slotMatchResults.length]; for (int i = 0; i < slotMatchResults.length; i++) { SlotMatchResult slotMatchResult = slotMatchResults[i]; long nextAwaitingOffset; if (slotMatchResult.isMatch()) { nextAwaitingOffset = 1 + slotMatchResult.getTriggeringOffset(); } else { nextAwaitingOffset = slotMatchResult.getAwaitingOffset(); } nextAwaitingSlots[i] = new Slot(slotMatchResult.getIndex(), nextAwaitingOffset); } return nextAwaitingSlots; } CallbackContext(SlotMatchResult[] slotMatchResults); }
CallbackContext { public Slot[] nextAwaitingSlots() { Slot[] nextAwaitingSlots = new Slot[slotMatchResults.length]; for (int i = 0; i < slotMatchResults.length; i++) { SlotMatchResult slotMatchResult = slotMatchResults[i]; long nextAwaitingOffset; if (slotMatchResult.isMatch()) { nextAwaitingOffset = 1 + slotMatchResult.getTriggeringOffset(); } else { nextAwaitingOffset = slotMatchResult.getAwaitingOffset(); } nextAwaitingSlots[i] = new Slot(slotMatchResult.getIndex(), nextAwaitingOffset); } return nextAwaitingSlots; } CallbackContext(SlotMatchResult[] slotMatchResults); SlotMatchResult[] getSlotMatchResults(); int getSlotCount(); Slot[] nextAwaitingSlots(); long getTriggerTime(); }
CallbackContext { public Slot[] nextAwaitingSlots() { Slot[] nextAwaitingSlots = new Slot[slotMatchResults.length]; for (int i = 0; i < slotMatchResults.length; i++) { SlotMatchResult slotMatchResult = slotMatchResults[i]; long nextAwaitingOffset; if (slotMatchResult.isMatch()) { nextAwaitingOffset = 1 + slotMatchResult.getTriggeringOffset(); } else { nextAwaitingOffset = slotMatchResult.getAwaitingOffset(); } nextAwaitingSlots[i] = new Slot(slotMatchResult.getIndex(), nextAwaitingOffset); } return nextAwaitingSlots; } CallbackContext(SlotMatchResult[] slotMatchResults); SlotMatchResult[] getSlotMatchResults(); int getSlotCount(); Slot[] nextAwaitingSlots(); long getTriggerTime();  }