public boolean matches(Message<? extends T> message) { for (MessageMatcher<T> matcher : getMessageMatchers()) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Trying to match using " + matcher); } if (!matcher.matches(message)) { LOGGER.debug("Did not match"); return false; } } LOGGER.debug("All messageMatchers returned true"); return true; } }
@SuppressWarnings("unchecked") @Test(expected = IllegalArgumentException.class) public void constructorEmptyArray() { new AndMessageMatcher<>((MessageMatcher<Object>[]) new MessageMatcher[0]); }
@Test(expected = NullPointerException.class) public void constructorNullArray() { new AndMessageMatcher<>((MessageMatcher<Object>[]) null); }
public boolean matches(Message<? extends T> message) { for (MessageMatcher<T> matcher : getMessageMatchers()) { if (LOGGER.isDebugEnabled()) { LOGGER.debug("Trying to match using " + matcher); } if (!matcher.matches(message)) { LOGGER.debug("Did not match"); return false; } } LOGGER.debug("All messageMatchers returned true"); return true; } }
@Test(expected = IllegalArgumentException.class) public void constructorNullList() { new AndMessageMatcher<>((List<MessageMatcher<Object>>) null); }
@Test(expected = IllegalArgumentException.class) public void constructorListContainsNull() { new AndMessageMatcher<>(Arrays.asList((MessageMatcher<Object>) null)); }
@Test(expected = IllegalArgumentException.class) public void constructorArrayContainsNull() { new AndMessageMatcher<>((MessageMatcher<Object>) null); }
@Test(expected = IllegalArgumentException.class) public void constructorEmptyList() { new AndMessageMatcher<>(Collections.emptyList()); }
@Test public void matchesMultiBothFalse() { when(delegate.matches(message)).thenReturn(false); matcher = new AndMessageMatcher<>(delegate, delegate2); assertThat(matcher.matches(message)).isFalse(); }
@Test public void matchesSingleFalse() { when(delegate.matches(message)).thenReturn(false); matcher = new AndMessageMatcher<>(delegate); assertThat(matcher.matches(message)).isFalse(); }
@Test public void matchesSingleTrue() { when(delegate.matches(message)).thenReturn(true); matcher = new AndMessageMatcher<>(delegate); assertThat(matcher.matches(message)).isTrue(); }
@Test public void matchesMultiTrue() { when(delegate.matches(message)).thenReturn(true); when(delegate2.matches(message)).thenReturn(true); matcher = new AndMessageMatcher<>(delegate, delegate2); assertThat(matcher.matches(message)).isTrue(); }
@Test public void matchesMultiSingleFalse() { when(delegate.matches(message)).thenReturn(true); when(delegate2.matches(message)).thenReturn(false); matcher = new AndMessageMatcher<>(delegate, delegate2); assertThat(matcher.matches(message)).isFalse(); } }