@Test(timeout=10000) public void testGetChanges() throws Exception { agent.getInterpreter().source(getClass().getResource("OutputEventTest_testGetChanges.soar")); final List<List<OutputChange>> changes = new ArrayList<List<OutputChange>>(); final AtomicReference<Identifier> stuffId = new AtomicReference<Identifier>(); agent.getEvents().addListener(OutputEvent.class, new SoarEventListener() { @Override public void onEvent(SoarEvent event) { final OutputEvent oe = (OutputEvent) event; if(changes.size() == 0) { stuffId.set(oe.getOutputValue(oe.getInputOutput().getOutputLink(), oe.getInputOutput().getSymbols().createString("stuff")).asIdentifier()); } changes.add(Lists.newArrayList(oe.getChanges())); } }); agent.runForever(); assertNotNull(stuffId.get()); validateChanges(changes.get(0), triples( agent.getInputOutput().getOutputLink(), "stuff", stuffId.get()), triples()); validateChanges(changes.get(1), triples(stuffId.get(), 1, 1), triples()); validateChanges(changes.get(2), triples(stuffId.get(), 2, 1, stuffId.get(), 2, 2), triples()); validateChanges(changes.get(3), triples(stuffId.get(), 3, 1, stuffId.get(), 3, 2, stuffId.get(), 3, 3), triples(stuffId.get(), 1, 1, stuffId.get(), 2, 1)); validateChanges(changes.get(4), triples(stuffId.get(), 4, 1, stuffId.get(), 4, 2, stuffId.get(), 4, 3, stuffId.get(), 4, 4), triples(stuffId.get(), 3, 1)); validateChanges(changes.get(5), triples(stuffId.get(), 5, 1, stuffId.get(), 5, 2, stuffId.get(), 5, 3, stuffId.get(), 5, 4, stuffId.get(), 5, 5), triples(stuffId.get(), 2, 2, stuffId.get(), 3, 2, stuffId.get(), 4, 1, stuffId.get(), 4, 2)); assertEquals(6, changes.size()); }
public Iterator<OutputChange> getChanges() { if(changes == null) { changes = new ArrayList<OutputChange>(); if(wmes != lastOutputSet) { calculateAdditions(); calculateRemovals(); } } return changes.iterator(); }
OutputEvent extends AbstractInputOutputEvent { public Iterator<OutputChange> getChanges() { if(changes == null) { changes = new ArrayList<OutputChange>(); if(wmes != lastOutputSet) { calculateAdditions(); calculateRemovals(); } } return changes.iterator(); } }
OutputEvent extends AbstractInputOutputEvent { public Iterator<OutputChange> getChanges() { if(changes == null) { changes = new ArrayList<OutputChange>(); if(wmes != lastOutputSet) { calculateAdditions(); calculateRemovals(); } } return changes.iterator(); } OutputEvent(InputOutput io, OutputMode mode, Set<Wme> wmes, Set<Wme> lastOutputSet); }
OutputEvent extends AbstractInputOutputEvent { public Iterator<OutputChange> getChanges() { if(changes == null) { changes = new ArrayList<OutputChange>(); if(wmes != lastOutputSet) { calculateAdditions(); calculateRemovals(); } } return changes.iterator(); } OutputEvent(InputOutput io, OutputMode mode, Set<Wme> wmes, Set<Wme> lastOutputSet); OutputMode getMode(); Iterator<Wme> getWmes(); Iterator<OutputChange> getChanges(); Symbol getOutputValue(Identifier id, Symbol attr); }
OutputEvent extends AbstractInputOutputEvent { public Iterator<OutputChange> getChanges() { if(changes == null) { changes = new ArrayList<OutputChange>(); if(wmes != lastOutputSet) { calculateAdditions(); calculateRemovals(); } } return changes.iterator(); } OutputEvent(InputOutput io, OutputMode mode, Set<Wme> wmes, Set<Wme> lastOutputSet); OutputMode getMode(); Iterator<Wme> getWmes(); Iterator<OutputChange> getChanges(); Symbol getOutputValue(Identifier id, Symbol attr);  }