GarmadonMessageFilters { public static GarmadonMessageFilter.HeaderFilter hasTag(Header.Tag tag) { return new GarmadonMessageFilter.HeaderFilter.TagFilter(tag); } protected  GarmadonMessageFilters(); static GarmadonMessageFilter.ANY any(); static GarmadonMessageFilter.NONE none(); static GarmadonMessageFilter.HeaderFilter hasTag(Header.Tag tag); static GarmadonMessageFilter.HeaderFilter hasContainerId(String id); static GarmadonMessageFilter.HeaderFilter hasFramework(String framework); static GarmadonMessageFilter.TypeFilter hasType(int type); static GarmadonMessageFilter.NotFilter not(GarmadonMessageFilter other);  }
@Test public void TagFilter_should_accept_only_header_with_correct_tag(){ GarmadonMessageFilter.HeaderFilter nodemanagerFilter = GarmadonMessageFilters.hasTag(Header.Tag.NODEMANAGER); GarmadonMessageFilter.HeaderFilter forwarderFilter = GarmadonMessageFilters.hasTag(Header.Tag.FORWARDER); EventHeaderProtos.Header noTag = EventHeaderProtos.Header.newBuilder().build(); EventHeaderProtos.Header tagForwarder = EventHeaderProtos.Header.newBuilder().addTags(Header.Tag.FORWARDER.toString()).build(); EventHeaderProtos.Header tagNodemanager = EventHeaderProtos.Header.newBuilder().addTags(Header.Tag.NODEMANAGER.toString()).build(); assertThat(nodemanagerFilter.accepts(random.nextInt(),noTag), is(false)); assertThat(nodemanagerFilter.accepts(random.nextInt(),tagForwarder), is(false)); assertThat(nodemanagerFilter.accepts(random.nextInt(),tagNodemanager), is(true)); assertThat(forwarderFilter.accepts(random.nextInt(),noTag), is(false)); assertThat(forwarderFilter.accepts(random.nextInt(),tagForwarder), is(true)); assertThat(forwarderFilter.accepts(random.nextInt(),tagNodemanager), is(false)); }
@Test public void TagFilter_should_accept_all_types(){ GarmadonMessageFilter.HeaderFilter filter = GarmadonMessageFilters.hasTag(Header.Tag.NODEMANAGER); IntStream.of(20).forEach(i -> assertThat(filter.accepts(random.nextInt()), is(true))); }