@Test public void test() { String name = "TestName"; int count = 10; MetricContext context = new MetricContext.Builder("name").build(); CountEventBuilder countEventBuilder = new CountEventBuilder(name, count); context.addNotificationTarget(new com.google.common.base.Function<Notification, Void>() { @Nullable @Override public Void apply(@Nullable Notification input) { if (input instanceof EventNotification) { GobblinTrackingEvent event = ((EventNotification) input).getEvent(); Map<String, String> metadata = event.getMetadata(); Assert.assertEquals(metadata.containsKey(GobblinEventBuilder.EVENT_TYPE), true); Assert.assertEquals(metadata.containsKey(CountEventBuilder.COUNT_KEY), true); Assert.assertEquals(metadata.get(GobblinEventBuilder.EVENT_TYPE), CountEventBuilder.COUNT_EVENT_TYPE); Assert.assertEquals(event.getName(), name); Assert.assertEquals(event.getNamespace(), GobblinEventBuilder.NAMESPACE); Assert.assertEquals(Integer.parseInt(metadata.get(CountEventBuilder.COUNT_KEY)), count); } return null; } }); EventSubmitter.submit(context, countEventBuilder); }
@Override public GobblinTrackingEvent build() { this.metadata.put(COUNT_KEY, Long.toString(count)); return super.build(); }
CountEventBuilder extends GobblinEventBuilder { @Override public GobblinTrackingEvent build() { this.metadata.put(COUNT_KEY, Long.toString(count)); return super.build(); } }
CountEventBuilder extends GobblinEventBuilder { @Override public GobblinTrackingEvent build() { this.metadata.put(COUNT_KEY, Long.toString(count)); return super.build(); } CountEventBuilder(String name, long count);  CountEventBuilder(String name, String namespace, long count); }
CountEventBuilder extends GobblinEventBuilder { @Override public GobblinTrackingEvent build() { this.metadata.put(COUNT_KEY, Long.toString(count)); return super.build(); } CountEventBuilder(String name, long count);  CountEventBuilder(String name, String namespace, long count); @Override GobblinTrackingEvent build(); static boolean isCountEvent(GobblinTrackingEvent event); static CountEventBuilder fromEvent(GobblinTrackingEvent event); }
CountEventBuilder extends GobblinEventBuilder { @Override public GobblinTrackingEvent build() { this.metadata.put(COUNT_KEY, Long.toString(count)); return super.build(); } CountEventBuilder(String name, long count);  CountEventBuilder(String name, String namespace, long count); @Override GobblinTrackingEvent build(); static boolean isCountEvent(GobblinTrackingEvent event); static CountEventBuilder fromEvent(GobblinTrackingEvent event); static final String COUNT_EVENT_TYPE; static final String COUNT_KEY; }