### Question:
OriginMatchUtil { public boolean matches(String origin) { if(Objects.isNull(origin) || Objects.equals("", origin)) { return false; } Predicate<String> subdomainMatch = s -> origin.toLowerCase().matches(s); Predicate<String> matchingCritera = wildcardMatch.or(subdomainMatch); return tokens.stream().anyMatch(matchingCritera); } OriginMatchUtil(List<String> tokens); boolean matches(String origin);  }### Answer:
@Test public void matchWildCard() { List<String> tokens = Arrays.asList("*"); String origin = "http: OriginMatchUtil matcher = new OriginMatchUtil(tokens); assertThat(matcher.matches(origin)).isTrue(); }
@Test public void exactMatch() { List<String> tokens = Arrays.asList("http: String origin = "http: OriginMatchUtil matcher = new OriginMatchUtil(tokens); assertThat(matcher.matches(origin)).isTrue(); }
@Test public void withSubDomain() { List<String> tokens = Arrays.asList("http: String origin = "http: OriginMatchUtil matcher = new OriginMatchUtil(tokens); assertThat(matcher.matches(origin)).isTrue(); }
@Test public void withBadSubDomain() { List<String> tokens = Arrays.asList("http: String origin = "http: OriginMatchUtil matcher = new OriginMatchUtil(tokens); assertThat(matcher.matches(origin)).isFalse(); }
@Test public void withNullOrigin() { List<String> tokens = Arrays.asList("http: OriginMatchUtil matcher = new OriginMatchUtil(tokens); assertThat(matcher.matches(null)).isFalse(); }
@Test public void withEmptyOrigin() { List<String> tokens = Arrays.asList("http: OriginMatchUtil matcher = new OriginMatchUtil(tokens); assertThat(matcher.matches("")).isFalse(); }
@Test public void withSubDomainWithPort() { List<String> tokens = Arrays.asList("http: String origin = "http: OriginMatchUtil matcher = new OriginMatchUtil(tokens); assertThat(matcher.matches(origin)).isFalse(); }
@Test public void withDifferentScheme() { List<String> tokens = Arrays.asList("https: String origin = "http: OriginMatchUtil matcher = new OriginMatchUtil(tokens); assertThat(matcher.matches(origin)).isFalse(); }
@Test public void withSamePorts() { List<String> tokens = Arrays.asList("http: String origin = "http: OriginMatchUtil matcher = new OriginMatchUtil(tokens); assertThat(matcher.matches(origin)).isTrue(); }
@Test public void withDifferentCases() { List<String> tokens = Arrays.asList("HTTP: String origin = "http: OriginMatchUtil matcher = new OriginMatchUtil(tokens); assertThat(matcher.matches(origin)).isTrue(); }
@Test public void withDifferentCases2() { List<String> tokens = Arrays.asList("http: String origin = "HTTP: OriginMatchUtil matcher = new OriginMatchUtil(tokens); assertThat(matcher.matches(origin)).isTrue(); }