### Question:
BoolVar extends AbstractVarType<Boolean> { public static BoolVar boolVar(String id) { return new BoolVar(id); } private  BoolVar(String id); private  BoolVar(String id, String regex); static BoolVar boolVar(String id); static BoolVar boolVar(String id, String regex); @Override Boolean convert(String value);  }### Answer:
@Test public void whenValueIsTrueThenIsCorrectlyParsed() { RestParser parser = parser("/users?active={}", boolVar("isActive")); RestUrl url = parser.parse("http: assertThat(url, isValid()); assertThat((Boolean) url.variable("isActive"), is(true)); }
@Test public void whenVariableIsEmptyThenValueIsFalse() { RestParser parser = parser("/users?active={}", boolVar("isActive")); RestUrl url = parser.parse("http: assertThat(url, isValid()); assertThat((Boolean) url.variable("isActive"), is(false)); }
@Test public void whenValueIsFalseThenIsCorrectlyParsed() { RestParser parser = parser("/users?active={}", boolVar("isActive")); RestUrl url = parser.parse("http: assertThat(url, isValid()); assertThat((Boolean) url.variable("isActive"), is(false)); }
@Test public void whenValueIsIncorrectThenVariableIsFalse() { RestParser parser = parser("/users?active={}", boolVar("isActive")); RestUrl url = parser.parse("http: assertThat(url, isValid()); assertThat((Boolean) url.variable("isActive"), is(false)); }
@Test public void whenValueIsOptionalAndMissingThenVariableIsNull() { RestParser parser = parser("/users?active={}", opt(boolVar("isActive"))); RestUrl url = parser.parse("http: assertThat(url, isValid()); assertThat(url.variable("isActive"), nullValue()); }