Skip to content

Commit

Permalink
fixed unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
jnguyenx committed Dec 9, 2016
1 parent 82c9da5 commit 61bddab
Showing 1 changed file with 31 additions and 26 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,31 +17,36 @@

public class MatchResourceTest {

MatchResource match;

@Before
public void setup() {
match = new MatchResource();
ProfileMatcher matcher = mock(ProfileMatcher.class);
NegationAwareProfileMatcher negatedMatcher = mock(NegationAwareProfileMatcher.class);
match.matchers = new HashMap<>();
match.matchers.put("foo", matcher);
match.matchers.put("notfoo", negatedMatcher);
}

@Test(expected=UnknownMatcherException.class)
public void testUnkownMatcher() throws UnknownFilterException, IncoherentStateException {
match.getMatches("unknown", Collections.<String>emptySet(), Collections.<String>emptySet(), null, null);
}

@Test(expected=NonNegatedMatcherException.class)
public void testNegatedIdsWithNonNegatedMatcher() throws UnknownFilterException, IncoherentStateException {
match.getMatches("foo", Collections.<String>emptySet(), newHashSet("not me"), null, null);
}

@Test
public void testNegatedIdsWithNegatedMatcher() throws UnknownFilterException, IncoherentStateException {
match.getMatches("notfoo", Collections.<String>emptySet(), newHashSet("not me"), null, null);
}
MatchResource match;

@Before
public void setup() {
match = new MatchResource();
ProfileMatcher matcher = mock(ProfileMatcher.class);
NegationAwareProfileMatcher negatedMatcher = mock(NegationAwareProfileMatcher.class);
match.matchers = new HashMap<>();
match.matchers.put("foo", matcher);
match.matchers.put("notfoo", negatedMatcher);
}

@Test(expected = UnknownMatcherException.class)
public void testUnkownMatcher() throws UnknownFilterException, IncoherentStateException {
match.getMatches("unknown", Collections.<String>emptySet(), Collections.<String>emptySet(),
Collections.<String>emptySet(), null, null);
}

@Test(expected = NonNegatedMatcherException.class)
public void testNegatedIdsWithNonNegatedMatcher()
throws UnknownFilterException, IncoherentStateException {
match.getMatches("foo", Collections.<String>emptySet(),
newHashSet("not me"), Collections.<String>emptySet(), null, null);
}

@Test
public void testNegatedIdsWithNegatedMatcher()
throws UnknownFilterException, IncoherentStateException {
match.getMatches("notfoo", Collections.<String>emptySet(), Collections.<String>emptySet(),
newHashSet("not me"), null, null);
}

}

0 comments on commit 61bddab

Please sign in to comment.