@Override public void transmit(@Nonnull final NessEvent event) { eventDispatcher.dispatch(event); } }
/** * Enqueue an event into the messaging system. */ public void enqueue(@Nonnull NessEvent event) { for (NessEventTransmitter transport : eventTransmitters) { transport.transmit(event); } } }
public void testNullUserOk() { final NessEvent event = NessEvent.createEvent(null, TIMESTAMP, ID, TYPE, PAYLOAD); Assert.assertNull(event.getUser()); Assert.assertEquals(TIMESTAMP, event.getTimestamp()); Assert.assertEquals(ID, event.getId()); Assert.assertEquals(TYPE, event.getType()); Assert.assertEquals(PAYLOAD, event.getPayload()); }
@Test public void testDeserialize() throws IOException { NessEvent event = mapper.readValue(loadJson("/serializedEvent.json"), NessEvent.class); Assert.assertEquals(payload, event.getPayload()); Assert.assertEquals(EVENT_ID, event.getId()); Assert.assertEquals(ENTRY_TIMESTAMP, event.getTimestamp()); Assert.assertEquals(NessEventTypes.SEARCH, event.getType()); Assert.assertEquals(USER, event.getUser()); }
public void testNullFactory() { final NessEventType eventType = NessEventType.getForName(null); Assert.assertEquals("", eventType.getName()); } }
@Test public void testSimple() { final NessEventType eventType = new NessEventType("FOO"); Assert.assertEquals("FOO", eventType.getName()); }
@Test(expected = IllegalArgumentException.class) @SuppressWarnings("NP_NONNULL_PARAM_VIOLATION") public void testTypeRequired() { NessEvent.createEvent(null, TIMESTAMP, ID, null, PAYLOAD); } }
@Override public void configure(final Binder binder) { NessEventModule.bindEventReceiver(binder).toInstance(testEventReceiver1); NessEventModule.bindEventReceiver(binder).toInstance(testEventReceiver2); binder.disableCircularProxies(); binder.requireExplicitBindings(); }}, new NessEventModule());
@Test public void testSerialize() throws IOException { NessEvent e = NessEvent.createEvent(USER, ENTRY_TIMESTAMP, EVENT_ID, NessEventTypes.SEARCH, payload); String serialized = mapper.writeValueAsString(e); Assert.assertEquals(mapper.readValue(loadJson("/serializedEvent.json"), TreeMap.class), mapper.readValue(serialized, TreeMap.class)); }
@Override public void run() { for (int i = 0; i < maxCount; i++) { sender.enqueue(TEST_EVENT); } } };
@Override public void transmit(final NessEvent event) { eventDispatcher.dispatch(event); count.incrementAndGet(); }
@Test(expected=IllegalArgumentException.class) @SuppressWarnings({"NP_NONNULL_PARAM_VIOLATION"}) public void testNullCtor() { new NessEventType(null); }
@Test public void testSimpleFactory() { final NessEventType eventType = NessEventType.getForName("FOO"); Assert.assertEquals("FOO", eventType.getName()); }
@Test public void testToUpper() { final NessEventType eventType = new NessEventType("foo"); Assert.assertEquals("FOO", eventType.getName()); }
public void testNullTimestampIsOk() { final NessEvent event = NessEvent.createEvent(null, null, ID, TYPE, PAYLOAD); Assert.assertNotNull(event); }
@Override public void configure(final Binder binder) { NessEventModule.bindEventReceiver(binder).toInstance(testEventReceiver1); NessEventModule.bindEventReceiver(binder).toInstance(testEventReceiver2); binder.disableCircularProxies(); binder.requireExplicitBindings(); }}, new NessEventModule());
@Test(expected = IllegalArgumentException.class) @SuppressWarnings("NP_NONNULL_PARAM_VIOLATION") public void testIdRequired() { NessEvent.createEvent(null, TIMESTAMP, null, TYPE, PAYLOAD); }
@Override public void configure(final Binder binder) { NessEventModule.bindEventReceiver(binder).toInstance(testEventReceiver1); NessEventModule.bindEventReceiver(binder).toInstance(testEventReceiver2); binder.disableCircularProxies(); binder.requireExplicitBindings(); }}, new NessEventModule());