@Test public void ableToCreateSimpleUrl() { HelpUrlBuilder builder = createBuilder().key("key").alt("alt").title("title").url("url"); final HelpUrlMatcher matcher = new HelpUrlMatcher().url("url").key("key").alt("alt").title("title"); assertThat(builder.build(), matcher); assertThat(builder.build(), matcher); builder.title("newtitle"); matcher.title("newtitle"); assertThat(builder.build(), matcher); builder.alt("newalt"); matcher.alt("newalt"); assertThat(builder.build(), matcher); builder.key("newKey"); matcher.key("newKey"); assertThat(builder.build(), matcher); builder.url("newUrl"); matcher.url("newUrl"); assertThat(builder.build(), matcher); builder.local(true); matcher.local(true); assertThat(builder.build(), matcher); }
@Test public void blanksInterpretedAsBlanks() { HelpUrlBuilder builder = createBuilder().key("key"); HelpUrlMatcher matcher = new HelpUrlMatcher().key("key"); assertThat(builder.build(), matcher); List<String> emptys = Lists.newArrayList(null, "", " ", "\t\r\n"); for (String empty : emptys) { builder.title(empty); matcher.title(empty); assertThat(builder.build(), matcher); } for (String empty : emptys) { builder.alt(empty); matcher.alt(empty); assertThat(builder.build(), matcher); } for (String empty : emptys) { builder.url(empty); matcher.url(empty); assertThat(builder.build(), matcher); } }
@Test public void ableToCopyBuilderClonesBuilderAndIsIndependent() { HelpUrlBuilder builder = createBuilder().key("key").alt("alt").title("title").url("url"); final HelpUrlMatcher matcher = new HelpUrlMatcher().url("url").key("key").alt("alt").title("title"); final HelpUrlBuilder builderCopy = builder.copy(); final HelpUrlMatcher matcherCopy = matcher.copy(); assertThat(builder.build(), matcher); assertThat(builderCopy.build(), matcher); builder.title("newtitle"); matcher.title("newtitle"); assertThat(builder.build(), matcher); assertThat(builderCopy.build(), matcherCopy); builder.alt("newalt"); matcher.alt("newalt"); assertThat(builder.build(), matcher); assertThat(builderCopy.build(), matcherCopy); builder.key("newKey"); matcher.key("newKey"); assertThat(builder.build(), matcher); assertThat(builderCopy.build(), matcherCopy); builder.url("newUrl"); matcher.url("newUrl"); assertThat(builder.build(), matcher); assertThat(builderCopy.build(), matcherCopy); builder.local(true); matcher.local(true); assertThat(builder.build(), matcher); assertThat(builderCopy.build(), matcherCopy); builderCopy.url("url2").title("title2").local(false); matcherCopy.url("url2").title("title2").local(false); assertThat(builder.build(), matcher); assertThat(builderCopy.build(), matcherCopy); }