use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.
the class ElasticSearchTansportSerializerTest method testSerializeDateIndexName.
@Test
public void testSerializeDateIndexName() throws UnsupportedEncodingException, IOException {
ElasticSearchTransportSerializer serializer = new ElasticSearchTransportSerializer(false, "event", "log-", "yyyy-MM-dd", false);
KinesisEvent kevent = TestUtils.createEvent(this.getClass(), "basic_event.json");
String payload = new String(kevent.getRecords().get(0).getKinesis().getData().array());
InternalEvent record = new DummyEvent(payload, 1478737790000l);
String actual = new String(serializer.serialize(record));
String expected = TestUtils.getResourceString(this.getClass(), "datetime_output.txt");
assertEquals(expected, actual);
}
use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.
the class ElasticSearchTansportSerializerTest method testSerialize.
@Test
public void testSerialize() throws UnsupportedEncodingException, IOException {
ElasticSearchTransportSerializer serializer = new ElasticSearchTransportSerializer(false, "event", "log", false);
InternalEvent record = new DummyEvent("foo", 0);
record.setSerialized("foo");
String actual = new String(serializer.serialize(record));
String expected = TestUtils.getResourceString(this.getClass(), "basic_output.txt");
/*
* Verify build output does not contain hash
*/
assertEquals(expected, actual);
}
use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.
the class S3TransportBufferTest method testBz2.
@Test
public void testBz2() throws IOException, TransportException {
S3TransportSerializer serializer = mock(S3TransportSerializer.class);
doReturn("foo".getBytes()).when(serializer).serialize(any(InternalEvent.class));
S3TransportBuffer buffer = new S3TransportBuffer(100, true, serializer);
InternalEvent mockEvent = mock(InternalEvent.class);
buffer.add(mockEvent);
buffer.close();
byte[] actual = buffer.getInternalBuffer().toByteArray();
byte[] expected = { 66, 90, 104, 57, 49, 65, 89, 38, 83, 89, 73, -2, -60, -91, 0, 0, 0, 1, 0, 1, 0, -96, 0, 48, -128, 65, 22, 46, -28, -118, 112, -95, 32, -109, -3, -119, 74 };
assertArrayEquals(expected, actual);
}
use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.
the class S3TransportBufferTest method testAddBufferFull.
@Test(expected = IllegalStateException.class)
public void testAddBufferFull() throws IOException, TransportException {
S3TransportSerializer serializer = mock(S3TransportSerializer.class);
doReturn("foo".getBytes()).when(serializer).serialize(any(InternalEvent.class));
S3TransportBuffer buffer = new S3TransportBuffer(5, false, serializer);
InternalEvent mockEvent = mock(InternalEvent.class);
buffer.add(mockEvent);
buffer.add(mockEvent);
}
use of com.nextdoor.bender.InternalEvent in project bender by Nextdoor.
the class GenericTansportSerializerTest method testSerialize.
@Test
public void testSerialize() throws UnsupportedEncodingException, IOException {
GenericTransportSerializer serializer = new GenericTransportSerializer();
InternalEvent record = new DummyEvent("foo", 0);
record.setEventTime(1505927823123l);
record.setSerialized("foo");
String actual = new String(serializer.serialize(record));
String expected = TestUtils.getResourceString(this.getClass(), "basic_output.txt");
assertEquals(expected, actual);
}
Aggregations