ScreenshotArgumentBuilder { public ScreenshotArgument build() { if (Strings.isNullOrEmpty(screenshotId)) { throw new IllegalStateException("screenshotId must not be empty"); } List<CompareTarget> compareTargets = Lists.transform(targets, new Function<TargetParamHolder, CompareTarget>() { @Override public CompareTarget apply(TargetParamHolder holder) { return new CompareTarget(holder.target, holder.excludes.toArray(new ScreenArea[holder.excludes.size()]), holder.moveTarget, holder.scrollTarget); } }); return new ScreenshotArgument(screenshotId, new ArrayList<CompareTarget>(compareTargets), new ArrayList<DomSelector>(hiddenElementSelectors)); } protected  ScreenshotArgumentBuilder(); protected  ScreenshotArgumentBuilder(String screenshotId); Action getLastAction(); ScreenshotArgument build(); ScreenshotArgumentBuilder screenshotId(String id); ScreenshotArgumentBuilder addNewTarget(); ScreenshotArgumentBuilder addNewTarget(CompareTarget target); ScreenshotArgumentBuilder addNewTarget(ScreenArea target); ScreenshotArgumentBuilder addNewTarget(SelectorType type, String value); ScreenshotArgumentBuilder addNewTargetById(String value); ScreenshotArgumentBuilder addNewTargetByClassName(String value); ScreenshotArgumentBuilder addNewTargetByCssSelector(String value); ScreenshotArgumentBuilder addNewTargetByLinkText(String value); ScreenshotArgumentBuilder addNewTargetByName(String value); ScreenshotArgumentBuilder addNewTargetByPartialLinkText(String value); ScreenshotArgumentBuilder addNewTargetByTagName(String value); ScreenshotArgumentBuilder addNewTargetByXPath(String value); ScreenshotArgumentBuilder addNewTarget(double x, double y, double width, double height); ScreenshotArgumentBuilder addExclude(SelectorType type, String value); ScreenshotArgumentBuilder addExclude(SelectorType type, String value, SelectorType frameSelectorType,
			String frameSelectorValue); ScreenshotArgumentBuilder addExcludeById(String value); ScreenshotArgumentBuilder addExcludeByClassName(String value); ScreenshotArgumentBuilder addExcludeByCssSelector(String value); ScreenshotArgumentBuilder addExcludeByLinkText(String value); ScreenshotArgumentBuilder addExcludeByName(String value); ScreenshotArgumentBuilder addExcludeByPartialLinkText(String value); ScreenshotArgumentBuilder addExcludeByTagName(String value); ScreenshotArgumentBuilder addExcludeByXPath(String value); ScreenshotArgumentBuilder addExclude(ScreenArea exclude); ScreenshotArgumentBuilder addExclude(double x, double y, double width, double height); ScreenshotArgumentBuilder addExcludes(Collection<ScreenArea> excludes); ScreenshotArgumentBuilder addExcludes(ScreenArea... excludes); ScreenshotArgumentBuilder moveTarget(boolean moveTarget); ScreenshotArgumentBuilder scrollTarget(boolean scrollTarget); ScreenshotArgumentBuilder addHiddenElementSelector(SelectorType type, String value); ScreenshotArgumentBuilder addHiddenElementSelector(SelectorType type, String value,
			SelectorType frameSelectorType, String frameSelectorValue); ScreenshotArgumentBuilder addHiddenElementsById(String value); ScreenshotArgumentBuilder addHiddenElementsByClassName(String value); ScreenshotArgumentBuilder addHiddenElementsByCssSelector(String value); ScreenshotArgumentBuilder addHiddenElementsByLinkText(String value); ScreenshotArgumentBuilder addHiddenElementsByName(String value); ScreenshotArgumentBuilder addHiddenElementsByPartialLinkText(String value); ScreenshotArgumentBuilder addHiddenElementsByTagName(String value); ScreenshotArgumentBuilder addHiddenElementsByXPath(String value); ScreenshotArgumentBuilder addHiddenElementSelectors(Collection<DomSelector> selectors); ScreenshotArgumentBuilder addHiddenElementSelectors(DomSelector... selectors); ScreenshotArgumentBuilder inFrame(SelectorType type, String value); ScreenshotArgumentBuilder inFrameById(String value); ScreenshotArgumentBuilder inFrameByClassName(String value); ScreenshotArgumentBuilder inFrameByCssSelector(String value); ScreenshotArgumentBuilder inFrameByLinkText(String value); ScreenshotArgumentBuilder inFrameByName(String value); ScreenshotArgumentBuilder inFrameByPartialLinkText(String value); ScreenshotArgumentBuilder inFrameByTagName(String value); ScreenshotArgumentBuilder inFrameByXPath(String value);  }
@Test public void constructor() throws Exception { ScreenshotArgumentBuilder builder = new ScreenshotArgumentBuilder(); expected.expect(IllegalStateException.class); expected.expectMessage(containsString("screenshotId")); builder.build(); }
@Test public void constructor_null() throws Exception { ScreenshotArgumentBuilder builder = new ScreenshotArgumentBuilder(null); expected.expect(IllegalStateException.class); expected.expectMessage(containsString("screenshotId")); builder.build(); }
@Test public void constructor_empty() throws Exception { ScreenshotArgumentBuilder builder = new ScreenshotArgumentBuilder(""); expected.expect(IllegalStateException.class); expected.expectMessage(containsString("screenshotId")); builder.build(); }
@Test public void constructor_ssid() throws Exception { ScreenshotArgument arg = new ScreenshotArgumentBuilder("ssid").build(); assertThat(arg.getScreenshotId(), is("ssid")); assertThat(arg.getTargets().isEmpty(), is(true)); assertThat(arg.getHiddenElementSelectors().isEmpty(), is(true)); }
@Test public void addNewTargetByXxx() throws Exception { Class<ScreenshotArgumentBuilder> clss = ScreenshotArgumentBuilder.class; for (Pair<String, SelectorType> mapping : TYPE_MAPPINGS) { Method method = clss.getMethod("addNewTargetBy" + mapping.getKey(), String.class); ScreenshotArgumentBuilder builder = new ScreenshotArgumentBuilder("ssid"); method.invoke(builder, "target"); ScreenshotArgument arg = builder.build(); assertThat(arg.getScreenshotId(), is("ssid")); assertThat(arg.getTargets().size(), is(1)); assertThat(arg.getHiddenElementSelectors().isEmpty(), is(true)); assertThat(arg.getTargets().get(0), is(new CompareTarget(ScreenArea.of(mapping.getValue(), "target")))); } }
@Test public void addHiddenElementsByXxx() throws Exception { for (Pair<String, SelectorType> mapping : TYPE_MAPPINGS) { ScreenshotArgumentBuilder builder = new ScreenshotArgumentBuilder("ssid"); ScreenshotArgumentBuilder.class.getMethod("addHiddenElementsBy" + mapping.getKey(), String.class).invoke( builder, "value"); ScreenshotArgument arg = builder.build(); assertThat(arg.getScreenshotId(), is("ssid")); assertThat(arg.getTargets().isEmpty(), is(true)); assertThat(arg.getHiddenElementSelectors().size(), is(1)); assertThat(arg.getHiddenElementSelectors().get(0), is(new DomSelector(mapping.getValue(), "value"))); } }