LocationNameMatcher { public boolean matches(String name, Language lang, String className, String methodName, boolean strictNameMatch) { if (matchers.isEmpty()) { return matchesName(name, strictNameMatch); } for (final LocationMatcher matcher : matchers) { if (matches(matcher, name, lang, className, methodName, strictNameMatch)) { return true; } } return false; } LocationNameMatcher(List<Location> locs, List<String> names); boolean matches(String name, Language lang, String className, String methodName, boolean strictNameMatch); @Override String toString();  }
@Test void basic() { final LocationNameMatcher m = new LocationNameMatcher( asList(Location.of("A"), Location.of("a.B"), Location.of("Y#c")), asList("c", "d")); assertTrue(m.matches("c", null, "A", null, true)); assertTrue(m.matches("d", null, "a.B", null, true)); assertTrue(m.matches("d", null, "Y", "c", true)); assertTrue(m.matches("d", null, "A", "x", true)); assertFalse(m.matches("e", null, "Y", "c", true)); assertFalse(m.matches("d", null, "Y", "d", true)); }
@Test void emptyLocs() { final LocationNameMatcher m = new LocationNameMatcher(emptyList(), asList("c", "d")); assertTrue(m.matches("c", null, "X", null, true)); assertTrue(m.matches("c", null, null, "#e", true)); assertFalse(m.matches("e", null, "X", null, true)); }
@Test void emptyNames() { final LocationNameMatcher m = new LocationNameMatcher( asList(Location.of("A"), Location.of("a.B"), Location.of("x.Y#c")), emptyList()); assertTrue(m.matches("c", null, "A", null, true)); assertFalse(m.matches("c", null, "B", null, true)); }
@Test void nonStrictNames() { final LocationNameMatcher m = new LocationNameMatcher(emptyList(), asList("cat")); assertTrue(m.matches("cat", null, null, null, false)); assertTrue(m.matches("xcat", null, null, null, false)); assertTrue(m.matches("catx", null, null, null, false)); assertTrue(m.matches("xcatx", null, null, null, false)); assertFalse(m.matches("ca", null, null, null, false)); }
@Test void language() { final LocationNameMatcher m = new LocationNameMatcher( asList(Location.of("java:A"), Location.of("kotlin:")), asList("c")); assertTrue(m.matches("c", null, "A", null, true)); assertTrue(m.matches("c", JAVA, "A", null, true)); assertTrue(m.matches("c", KOTLIN, "B", null, true)); assertFalse(m.matches("c", SCALA, "A", null, true)); }