MinPatternActionsModel implements Model { @Override public Set<APIUsagePattern> getPatterns() { return patterns; } MinPatternActionsModel(Model model, int minNumberOfCalls); @Override Set<APIUsagePattern> getPatterns();  }
@Test public void filtersPatternWithFewerActions() { APIUsagePattern pattern = somePattern(TestAUGBuilder.buildAUG().withActionNode("m()")); Set<APIUsagePattern> patterns = new MinPatternActionsModel(() -> asSet(pattern), 2).getPatterns(); assertThat(patterns, is(empty())); }
@Test public void considersCalls() { APIUsagePattern pattern = somePattern(TestAUGBuilder.buildAUG().withActionNodes("m()", "n()")); Set<APIUsagePattern> patterns = new MinPatternActionsModel(() -> asSet(pattern), 2).getPatterns(); assertThat(patterns, is(not(empty()))); }
@Test public void considersCatch() { APIUsagePattern pattern = somePattern(TestAUGBuilder.buildAUG() .withActionNodes("m()").withDataNode("SomeException") .withEdge("m()", THROW, "SomeException")); Set<APIUsagePattern> patterns = new MinPatternActionsModel(() -> asSet(pattern), 2).getPatterns(); assertThat(patterns, is(not(empty()))); }
@Test public void considersSynchronization() { APIUsagePattern pattern = somePattern(TestAUGBuilder.buildAUG() .withDataNode("Object").withActionNodes("m()") .withEdge("Object", SYNCHRONIZE, "m()")); Set<APIUsagePattern> patterns = new MinPatternActionsModel(() -> asSet(pattern), 2).getPatterns(); assertThat(patterns, is(not(empty()))); }