GarmadonMessageFilters { public static GarmadonMessageFilter.ANY any() { return GarmadonMessageFilter.ANY.INSTANCE; } 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 Disjunction_should_accept_either_left_true_or_right_true(){ GarmadonMessageFilter.Junction left = newMockableJunction(); GarmadonMessageFilter.Junction right = newMockableJunction(); GarmadonMessageFilter.Junction filter = left.or(right); when(left.accepts(anyInt(), any())).thenReturn(true); when(right.accepts(anyInt(), any())).thenReturn(true); assertThat(filter.accepts(random.nextInt(), EventHeaderProtos.Header.getDefaultInstance()), is(true)); when(left.accepts(anyInt(), any())).thenReturn(true); when(right.accepts(anyInt(), any())).thenReturn(false); assertThat(filter.accepts(random.nextInt(), EventHeaderProtos.Header.getDefaultInstance()), is(true)); when(left.accepts(anyInt(), any())).thenReturn(false); when(right.accepts(anyInt(), any())).thenReturn(true); assertThat(filter.accepts(random.nextInt(), EventHeaderProtos.Header.getDefaultInstance()), is(true)); when(left.accepts(anyInt(), any())).thenReturn(false); when(right.accepts(anyInt(), any())).thenReturn(false); assertThat(filter.accepts(random.nextInt(), EventHeaderProtos.Header.getDefaultInstance()), is(false)); }
@Test public void Disjunction_should_not_evaluate_right_unless_left_is_false(){ GarmadonMessageFilter.Junction left = newMockableJunction(); GarmadonMessageFilter.Junction right = newMockableJunction(); GarmadonMessageFilter.Junction filter = left.or(right); when(left.accepts(anyInt(), any())).thenReturn(true); filter.accepts(random.nextInt(), EventHeaderProtos.Header.getDefaultInstance()); verify(right, never()).accepts(anyInt(), any()); when(left.accepts(anyInt(), any())).thenReturn(false); filter.accepts(random.nextInt(),EventHeaderProtos.Header.getDefaultInstance()); verify(right).accepts(anyInt(), any()); }
@Test public void Conjunction_should_accept_left_true_and_right_true_only(){ GarmadonMessageFilter.Junction left = newMockableJunction(); GarmadonMessageFilter.Junction right = newMockableJunction(); GarmadonMessageFilter.Junction filter = left.and(right); when(left.accepts(anyInt(), any())).thenReturn(true); when(right.accepts(anyInt(), any())).thenReturn(true); assertThat(filter.accepts(random.nextInt(),EventHeaderProtos.Header.getDefaultInstance()), is(true)); when(left.accepts(anyInt(), any())).thenReturn(true); when(right.accepts(anyInt(), any())).thenReturn(false); assertThat(filter.accepts(random.nextInt(),EventHeaderProtos.Header.getDefaultInstance()), is(false)); when(left.accepts(anyInt(), any())).thenReturn(false); when(right.accepts(anyInt(), any())).thenReturn(true); assertThat(filter.accepts(random.nextInt(),EventHeaderProtos.Header.getDefaultInstance()), is(false)); when(left.accepts(anyInt(), any())).thenReturn(false); when(right.accepts(anyInt(), any())).thenReturn(false); assertThat(filter.accepts(random.nextInt(),EventHeaderProtos.Header.getDefaultInstance()), is(false)); }
@Test public void Conjunction_should_evaluate_all_operands(){ GarmadonMessageFilter.Junction left = newMockableJunction(); GarmadonMessageFilter.Junction right = newMockableJunction(); GarmadonMessageFilter.Junction filter = left.and(right); when(left.accepts(anyInt(), any())).thenReturn(true); filter.accepts(random.nextInt(),EventHeaderProtos.Header.getDefaultInstance()); verify(right).accepts(anyInt(), any()); when(left.accepts(anyInt(), any())).thenReturn(false); filter.accepts(random.nextInt(),EventHeaderProtos.Header.getDefaultInstance()); verify(right).accepts(anyInt(), any()); }