// Path: netsecurity/src/main/java/com/commonsware/cwac/netsecurity/DomainMatchRule.java
// public static DomainMatchRule allOf(DomainMatchRule... rules) {
//   return(new Composite(false, rules));
// }
// 
// Path: netsecurity/src/main/java/com/commonsware/cwac/netsecurity/DomainMatchRule.java
// public static DomainMatchRule anyOf(DomainMatchRule... rules) {
//   return(new Composite(true, rules));
// }
// 
// Path: netsecurity/src/main/java/com/commonsware/cwac/netsecurity/DomainMatchRule.java
// public static DomainMatchRule blacklist(String... globs) {
//   List<DomainMatchRule> rules=new ArrayList<>();
// 
//   for (String glob : globs) {
//     rules.add(not(is(glob)));
//   }
// 
//   return(allOf(rules));
// }
// 
// Path: netsecurity/src/main/java/com/commonsware/cwac/netsecurity/DomainMatchRule.java
// public static DomainMatchRule is(Pattern pattern) {
//   return(new Regex(pattern));
// }
// 
// Path: netsecurity/src/main/java/com/commonsware/cwac/netsecurity/DomainMatchRule.java
// public static DomainMatchRule not(DomainMatchRule rule) {
//   return(new Not(rule));
// }
// 
// Path: netsecurity/src/main/java/com/commonsware/cwac/netsecurity/DomainMatchRule.java
// public static DomainMatchRule whitelist(String... globs) {
//   List<DomainMatchRule> rules=new ArrayList<>();
// 
//   for (String glob : globs) {
//     rules.add(is(glob));
//   }
// 
//   return(anyOf(rules));
// }


import org.junit.Test;
import java.util.regex.Pattern;
import static com.commonsware.cwac.netsecurity.DomainMatchRule.allOf;
import static com.commonsware.cwac.netsecurity.DomainMatchRule.anyOf;
import static com.commonsware.cwac.netsecurity.DomainMatchRule.blacklist;
import static com.commonsware.cwac.netsecurity.DomainMatchRule.is;
import static com.commonsware.cwac.netsecurity.DomainMatchRule.not;
import static com.commonsware.cwac.netsecurity.DomainMatchRule.whitelist;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;
    assertTrue(allOf(is("foo.com")).matches("foo.com"));
    assertFalse(allOf(is("*.foo.com")).matches("foo.com"));
    assertTrue(allOf(is("*.foo.com")).matches("www.foo.com"));

    assertFalse(allOf(is("foo.com"), is("bar.com")).matches("foo.com"));
    assertFalse(allOf(is("*.foo.com"), is("bar.com")).matches("foo.com"));
    assertFalse(allOf(is("*.foo.com"), is("bar.com")).matches("www.foo.com"));

    assertFalse(allOf(is("goo.com"), is("foo.com"), is("bar.com")).matches("foo.com"));
    assertFalse(allOf(is("goo.com"), is("*.foo.com"), is("bar.com")).matches("foo.com"));
    assertFalse(allOf(is("goo.com"), is("*.foo.com"), is("bar.com")).matches("www.foo.com"));
  }

  @Test
  public void _whitelist() {
    assertTrue(whitelist("foo.com").matches("foo.com"));
    assertFalse(whitelist("*.foo.com").matches("foo.com"));
    assertTrue(whitelist("*.foo.com").matches("www.foo.com"));

    assertTrue(whitelist("foo.com", "bar.com").matches("foo.com"));
    assertFalse(whitelist("*.foo.com", "bar.com").matches("foo.com"));
    assertTrue(whitelist("*.foo.com", "bar.com").matches("www.foo.com"));

    assertTrue(whitelist("goo.com", "foo.com", "bar.com").matches("foo.com"));
    assertFalse(whitelist("goo.com", "*.foo.com", "bar.com").matches("foo.com"));
    assertTrue(whitelist("goo.com", "*.foo.com", "bar.com").matches("www.foo.com"));
  }

  @Test
  public void _blacklist() {
// Path: netsecurity/src/main/java/com/commonsware/cwac/netsecurity/DomainMatchRule.java
// public static DomainMatchRule allOf(DomainMatchRule... rules) {
//   return(new Composite(false, rules));
// }
// 
// Path: netsecurity/src/main/java/com/commonsware/cwac/netsecurity/DomainMatchRule.java
// public static DomainMatchRule anyOf(DomainMatchRule... rules) {
//   return(new Composite(true, rules));
// }
// 
// Path: netsecurity/src/main/java/com/commonsware/cwac/netsecurity/DomainMatchRule.java
// public static DomainMatchRule blacklist(String... globs) {
//   List<DomainMatchRule> rules=new ArrayList<>();
// 
//   for (String glob : globs) {
//     rules.add(not(is(glob)));
//   }
// 
//   return(allOf(rules));
// }
// 
// Path: netsecurity/src/main/java/com/commonsware/cwac/netsecurity/DomainMatchRule.java
// public static DomainMatchRule is(Pattern pattern) {
//   return(new Regex(pattern));
// }
// 
// Path: netsecurity/src/main/java/com/commonsware/cwac/netsecurity/DomainMatchRule.java
// public static DomainMatchRule not(DomainMatchRule rule) {
//   return(new Not(rule));
// }
// 
// Path: netsecurity/src/main/java/com/commonsware/cwac/netsecurity/DomainMatchRule.java
// public static DomainMatchRule whitelist(String... globs) {
//   List<DomainMatchRule> rules=new ArrayList<>();
// 
//   for (String glob : globs) {
//     rules.add(is(glob));
//   }
// 
//   return(anyOf(rules));
// }


// Path: netsecurity/src/test/java/com/commonsware/cwac/netsecurity/test/DomainMatchRuleTests.java
import org.junit.Test;
import java.util.regex.Pattern;
import static com.commonsware.cwac.netsecurity.DomainMatchRule.allOf;
import static com.commonsware.cwac.netsecurity.DomainMatchRule.anyOf;
import static com.commonsware.cwac.netsecurity.DomainMatchRule.blacklist;
import static com.commonsware.cwac.netsecurity.DomainMatchRule.is;
import static com.commonsware.cwac.netsecurity.DomainMatchRule.not;
import static com.commonsware.cwac.netsecurity.DomainMatchRule.whitelist;
import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

    assertTrue(allOf(is("foo.com")).matches("foo.com"));
    assertFalse(allOf(is("*.foo.com")).matches("foo.com"));
    assertTrue(allOf(is("*.foo.com")).matches("www.foo.com"));

    assertFalse(allOf(is("foo.com"), is("bar.com")).matches("foo.com"));
    assertFalse(allOf(is("*.foo.com"), is("bar.com")).matches("foo.com"));
    assertFalse(allOf(is("*.foo.com"), is("bar.com")).matches("www.foo.com"));

    assertFalse(allOf(is("goo.com"), is("foo.com"), is("bar.com")).matches("foo.com"));
    assertFalse(allOf(is("goo.com"), is("*.foo.com"), is("bar.com")).matches("foo.com"));
    assertFalse(allOf(is("goo.com"), is("*.foo.com"), is("bar.com")).matches("www.foo.com"));
  }

  @Test
  public void _whitelist() {
    assertTrue(whitelist("foo.com").matches("foo.com"));
    assertFalse(whitelist("*.foo.com").matches("foo.com"));
    assertTrue(whitelist("*.foo.com").matches("www.foo.com"));

    assertTrue(whitelist("foo.com", "bar.com").matches("foo.com"));
    assertFalse(whitelist("*.foo.com", "bar.com").matches("foo.com"));
    assertTrue(whitelist("*.foo.com", "bar.com").matches("www.foo.com"));

    assertTrue(whitelist("goo.com", "foo.com", "bar.com").matches("foo.com"));
    assertFalse(whitelist("goo.com", "*.foo.com", "bar.com").matches("foo.com"));
    assertTrue(whitelist("goo.com", "*.foo.com", "bar.com").matches("www.foo.com"));
  }

  @Test
  public void _blacklist() {
    assertFalse(blacklist("foo.com").matches("foo.com"));