@Test public void testCreateRELPEvent() { final byte[] data = "this is an event".getBytes(StandardCharsets.UTF_8); final String sender = "sender1"; final long txnr = 1; final String command = "syslog"; final Map<String,String> metadata = new HashMap<>(); metadata.put(EventFactory.SENDER_KEY, sender); metadata.put(RELPMetadata.TXNR_KEY, String.valueOf(txnr)); metadata.put(RELPMetadata.COMMAND_KEY, command); final ChannelResponder responder = new SocketChannelResponder(null); final EventFactory<RELPEvent> factory = new RELPEventFactory(); final RELPEvent event = factory.create(data, metadata, responder); Assert.assertEquals(data, event.getData()); Assert.assertEquals(sender, event.getSender()); Assert.assertEquals(txnr, event.getTxnr()); Assert.assertEquals(command, event.getCommand()); Assert.assertEquals(responder, event.getResponder()); }
@Override public RELPEvent create(final byte[] data, final Map<String, String> metadata, final ChannelResponder responder) { final long txnr = Long.valueOf(metadata.get(RELPMetadata.TXNR_KEY)); final String command = metadata.get(RELPMetadata.COMMAND_KEY); final String sender = metadata.get(EventFactory.SENDER_KEY); return new RELPEvent(sender, data, responder, txnr, command); }
RELPEventFactory implements EventFactory<RELPEvent> { @Override public RELPEvent create(final byte[] data, final Map<String, String> metadata, final ChannelResponder responder) { final long txnr = Long.valueOf(metadata.get(RELPMetadata.TXNR_KEY)); final String command = metadata.get(RELPMetadata.COMMAND_KEY); final String sender = metadata.get(EventFactory.SENDER_KEY); return new RELPEvent(sender, data, responder, txnr, command); } }
RELPEventFactory implements EventFactory<RELPEvent> { @Override public RELPEvent create(final byte[] data, final Map<String, String> metadata, final ChannelResponder responder) { final long txnr = Long.valueOf(metadata.get(RELPMetadata.TXNR_KEY)); final String command = metadata.get(RELPMetadata.COMMAND_KEY); final String sender = metadata.get(EventFactory.SENDER_KEY); return new RELPEvent(sender, data, responder, txnr, command); }  }
RELPEventFactory implements EventFactory<RELPEvent> { @Override public RELPEvent create(final byte[] data, final Map<String, String> metadata, final ChannelResponder responder) { final long txnr = Long.valueOf(metadata.get(RELPMetadata.TXNR_KEY)); final String command = metadata.get(RELPMetadata.COMMAND_KEY); final String sender = metadata.get(EventFactory.SENDER_KEY); return new RELPEvent(sender, data, responder, txnr, command); }  @Override RELPEvent create(final byte[] data, final Map<String, String> metadata, final ChannelResponder responder); }
RELPEventFactory implements EventFactory<RELPEvent> { @Override public RELPEvent create(final byte[] data, final Map<String, String> metadata, final ChannelResponder responder) { final long txnr = Long.valueOf(metadata.get(RELPMetadata.TXNR_KEY)); final String command = metadata.get(RELPMetadata.COMMAND_KEY); final String sender = metadata.get(EventFactory.SENDER_KEY); return new RELPEvent(sender, data, responder, txnr, command); }  @Override RELPEvent create(final byte[] data, final Map<String, String> metadata, final ChannelResponder responder);  }