Filter { public boolean match(Filter f) { if (this.to != null) { if (!Arrays.equals(this.to, f.getTo())) { return false; } } if (this.from != null) { if (!Arrays.equals(this.from, f.getFrom())) { return false; } } if (this.filterTopics != null) { Topic[] topics = new Topic[f.getTopics().size()]; f.getTopics().toArray(topics); return this.filterTopics.matches(topics); } return true; } Filter(byte[] to, byte[] from, TopicMatcher filterTopics);  Filter(Message m, Topic[] topics); byte[] getTo(); void setTo(byte[] to); byte[] getFrom(); void setFrom(byte[] from); TopicMatcher getFilterTopics(); void setFilterTopics(TopicMatcher filterTopics); List<Topic> getTopics(); boolean match(Filter f); void trigger();  }
@Test public void test1() { Filter matcher = new Filter(null, null, new TopicMatcher(new String[]{})); Filter message = new Filter(to, from, new TopicMatcher(topics)); assertTrue(matcher.match(message)); }
@Test public void test2() { Filter matcher = new Filter(to, null, new TopicMatcher(new String[]{})); Filter message = new Filter(to, from, new TopicMatcher(topics)); assertTrue(matcher.match(message)); }
@Test public void test3() { Filter matcher = new Filter(to, null, new TopicMatcher(new String[]{})); Filter message = new Filter(null, from, new TopicMatcher(topics)); assertTrue(!matcher.match(message)); }
@Test public void test4() { Filter matcher = new Filter(null, from, new TopicMatcher(new String[]{})); Filter message = new Filter(to, from, new TopicMatcher(topics)); assertTrue(matcher.match(message)); }
@Test public void test5() { Filter matcher = new Filter(null, from, new TopicMatcher(new String[]{})); Filter message = new Filter(to, null, new TopicMatcher(topics)); assertTrue(!matcher.match(message)); }
@Test public void test6() { Filter matcher = new Filter(null, from, new TopicMatcher(topics)); Filter message = new Filter(to, from, new TopicMatcher(topics)); assertTrue(matcher.match(message)); }
@Test public void test7() { Filter matcher = new Filter(null, null, new TopicMatcher(topics)); Filter message = new Filter(to, from, new TopicMatcher(new String[]{})); assertTrue(!matcher.match(message)); }