### Question:
BooleanOptionFieldAdapter extends ValueOptionFieldAdapter<BooleanOption> { public static Builder builder() { return new Builder(); } BooleanOptionFieldAdapter(
            String nullFormat,
            Predicate<? super CharSequence> trueTester, Predicate<? super CharSequence> falseTester,
            String trueFormat, String falseFormat); static Builder builder(); static final String DEFAULT_TRUE_FORMAT; static final String DEFAULT_FALSE_FORMAT; }### Answer:
@Test public void parse() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder().build(); checkParse(adapter, true, new BooleanOption(true)); checkParse(adapter, false, new BooleanOption(false)); }
@Test public void parse_null() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder().build(); checkParse(adapter, null, new BooleanOption()); }
@Test public void parse_empty() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder().build(); checkMalformed(adapter, "", new BooleanOption()); }
@Test public void parse_null_formatted() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder() .withNullFormat("") .build(); checkParse(adapter, "", new BooleanOption()); }
@Test public void parse_format() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder() .withTrueFormat("1") .withFalseFormat("0") .build(); checkParse(adapter, 1, new BooleanOption(true)); checkParse(adapter, 0, new BooleanOption(false)); }
@Test public void parse_predicate() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder() .withTrueFormat("T", s -> s.length() > 0 && "F".contentEquals(s) == false) .withFalseFormat("F", s -> s.length() == 0 || "F".contentEquals(s)) .build(); checkParse(adapter, "F", new BooleanOption(false)); checkParse(adapter, "T", new BooleanOption(true)); checkParse(adapter, "", new BooleanOption(false)); checkParse(adapter, "abc", new BooleanOption(true)); checkParse(adapter, "true", new BooleanOption(true)); checkParse(adapter, "false", new BooleanOption(true)); }
@Test public void emit() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder().build(); checkEmit(adapter, new BooleanOption(true), true); checkEmit(adapter, new BooleanOption(false), false); }
@Test public void emit_null() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder().build(); checkEmit(adapter, new BooleanOption(), null); }
@Test public void emit_null_formatted() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder() .withNullFormat("") .build(); checkEmit(adapter, new BooleanOption(), ""); }
@Test public void emit_format() { BooleanOptionFieldAdapter adapter = BooleanOptionFieldAdapter.builder() .withTrueFormat("1") .withFalseFormat("0") .build(); checkEmit(adapter, new BooleanOption(true), "1"); checkEmit(adapter, new BooleanOption(false), "0"); }