String c = "tweet:"+Math.abs(r.nextInt());
String f = "from:"+Math.abs(r.nextInt());
String u = "user:"+Math.abs(r.nextInt());
MessageCorrelation m = new MessageCorrelation(UUID.randomUUID(), f, c, System.currentTimeMillis(), TransportType.Dummy, u);
datastore.registerMessageCorrelation(m);
Set<MessageCorrelation> cc = datastore.getMessageCorrelations(c, f, u, TransportType.Dummy);
assertTrue("correct pid returned", cc.contains(m));
datastore.unregisterMessageCorrelation(m);
assertTrue("nothing left", ! datastore.getMessageCorrelations(c, f, u, TransportType.Dummy).contains(m));
//listen({to:"user", messageId:"foo"})
MessageCorrelation both = new MessageCorrelation(UUID.randomUUID(), f, c, System.currentTimeMillis(), TransportType.Dummy, u);
//listen({to:"user"})
MessageCorrelation byuser = new MessageCorrelation(UUID.randomUUID(), f, null, System.currentTimeMillis(), TransportType.Dummy, u);
//listen({messageId:"foo"})
MessageCorrelation messageId = new MessageCorrelation(UUID.randomUUID(), null, c, System.currentTimeMillis(), TransportType.Dummy, u);
//listen()
MessageCorrelation byNull = new MessageCorrelation(UUID.randomUUID(), null, null, System.currentTimeMillis(), TransportType.Dummy, u);
MessageCorrelation byNullOtheruser = new MessageCorrelation(UUID.randomUUID(), null, null, System.currentTimeMillis(), TransportType.Dummy, u+r.nextInt());
datastore.registerMessageCorrelation(both);
datastore.registerMessageCorrelation(byuser);
datastore.registerMessageCorrelation(messageId);
datastore.registerMessageCorrelation(byNull);