Search in sources :

Example 1 with MetadataSubstitution

use of com.nextdoor.bender.operation.substitution.metadata.MetadataSubstitution in project bender by Nextdoor.

the class MetadataSubstitutionTest method testIncludeMetadata.

@Test
public void testIncludeMetadata() throws FieldNotFoundException {
    ArrayList<Substitution> substitutions = new ArrayList<Substitution>();
    substitutions.add(new MetadataSubstitution("foo", Arrays.asList("eventSha1Hash"), Collections.emptyList(), true));
    DummpyMapEvent devent = new DummpyMapEvent();
    InternalEvent ievent = new InternalEvent("", null, 10);
    ievent.setEventObj(devent);
    ievent.setEventTime(20);
    SubstitutionOperation op = new SubstitutionOperation(substitutions);
    op.perform(ievent);
    Map<String, Object> expected = new HashMap<String, Object>() {

        {
            put("eventSha1Hash", "da39a3ee5e6b4b0d3255bfef95601890afd80709");
        }
    };
    assertEquals(expected, devent.getField("foo"));
}
Also used : MetadataSubstitution(com.nextdoor.bender.operation.substitution.metadata.MetadataSubstitution) MetadataSubstitution(com.nextdoor.bender.operation.substitution.metadata.MetadataSubstitution) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DummpyMapEvent(com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent) InternalEvent(com.nextdoor.bender.InternalEvent) Test(org.junit.Test)

Example 2 with MetadataSubstitution

use of com.nextdoor.bender.operation.substitution.metadata.MetadataSubstitution in project bender by Nextdoor.

the class MetadataSubstitutionTest method testExcludeMetadata.

@Test
public void testExcludeMetadata() throws FieldNotFoundException {
    ArrayList<Substitution> substitutions = new ArrayList<Substitution>();
    substitutions.add(new MetadataSubstitution("foo", Collections.emptyList(), Arrays.asList("sourceLagMs"), true));
    DummpyMapEvent devent = new DummpyMapEvent();
    InternalEvent ievent = new InternalEvent("", null, 10);
    ievent.setEventObj(devent);
    ievent.setEventTime(20);
    SubstitutionOperation op = new SubstitutionOperation(substitutions);
    op.perform(ievent);
    Map<String, Object> expected = new HashMap<String, Object>() {

        {
            put("arrivalEpochMs", new Long(10));
            put("eventSha1Hash", "da39a3ee5e6b4b0d3255bfef95601890afd80709");
            put("eventEpochMs", new Long(20));
        }
    };
    assertEquals(expected, devent.getField("foo"));
}
Also used : MetadataSubstitution(com.nextdoor.bender.operation.substitution.metadata.MetadataSubstitution) MetadataSubstitution(com.nextdoor.bender.operation.substitution.metadata.MetadataSubstitution) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DummpyMapEvent(com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent) InternalEvent(com.nextdoor.bender.InternalEvent) Test(org.junit.Test)

Aggregations

InternalEvent (com.nextdoor.bender.InternalEvent)2 MetadataSubstitution (com.nextdoor.bender.operation.substitution.metadata.MetadataSubstitution)2 DummpyMapEvent (com.nextdoor.bender.testutils.DummyDeserializerHelper.DummpyMapEvent)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Test (org.junit.Test)2