@Test
public void testUsingWatch() throws Exception {
BasicEventConsumer consumer = new BasicEventConsumer(getEventDescriptor());
WatchDataSourceRegistry watchRegistry = new WatchDataSourceRegistry();
Watch watch = consumer.createWatch(watchRegistry);
Assert.assertNotNull(watch);
Assert.assertNotNull("Check Watch accessor", consumer.getWatch());
Assert.assertTrue("Only one watch should be created, calling createWatch twice should return the same watch",
watch.equals(consumer.createWatch(watchRegistry)));
Listener listener = new Listener();
consumer.register(listener);
Producer p = new Producer();
p.createDEH();
ServiceItem serviceItem = createServiceItem(p);
EventRegistration eventRegistration = consumer.register(serviceItem);
Assert.assertNotNull(eventRegistration);
p.fire();
p.fire();
Assert.assertTrue("Should have gotten 2, got "+watch.getCalculables().values().size(),
watch.getCalculables().values().size()==2);
Calculable[] calculables = watch.getWatchDataSource().getCalculable();
Assert.assertTrue("Should have gotten 2, got "+calculables.length, calculables.length==2);
for (Calculable calculable : calculables)
System.out.println("==> " + calculable.getValue());
}