Parameters { private static void addOpts(@Nonnull List<String> args, @Nullable Options opts, IServer server) throws P4JavaException { if (nonNull(opts)) { if (opts.isImmutable() && nonNull(opts.getOptions())) { args.addAll(opts.getOptions()); } else { args.addAll(opts.processOptions(server)); } } }  static String[] processParameters(final Options opts, final IServer server); static String[] processParameters(final Options opts, final List<IFileSpec> fileSpecs,
                                             final IServer server); static String[] processParameters(final Options opts, final List<IFileSpec> fileSpecs,
                                             final String[] stringParams, final IServer server); static String[] processParameters(final Options opts, final List<IFileSpec> fileSpecs,
                                             final String stringParam, final IServer server); static String[] processParameters(final Options opts, final List<IFileSpec> fileSpecs,
                                             final @Nullable String[] stringParams, final boolean annotateFiles,
                                             final IServer server); static String[] processParameters(final Options opts, final IFileSpec fromFileSpec,
                                             final List<IFileSpec> toFileSpecs, final String[] stringParams, final IServer server); static String[] processParameters(final Options opts, @Nullable final IFileSpec fromFile,
                                             @Nullable final IFileSpec toFile, final String branchSpec, final IServer server); static String[] processParameters(final Options opts,
                                             @Nullable final List<IFileSpec> fromFiles, @Nullable final List<IFileSpec> toFiles,
                                             final String branchSpec, final IServer server);  }
@Test public void addOpts() throws Exception { Parameters parameters = new Parameters(); Method addOpts = getPrivateMethod(Parameters.class, "addOpts", List.class, Options.class, IServer.class); List<String> args = new ArrayList<String>(); addOpts.invoke(parameters, args, null, null); assertThat(args.size(), is(0)); Options opts = mock(Options.class); when(opts.isImmutable()).thenReturn(true); ArrayList<String> optionsStrings = new ArrayList<String>(); optionsStrings.add("-a"); optionsStrings.add("-f"); optionsStrings.add("-s"); when(opts.getOptions()).thenReturn(optionsStrings); args = new ArrayList<String>(); addOpts.invoke(parameters, args, opts, mock(IServer.class)); assertEquals(optionsStrings, args); reset(opts); IServer server = mock(IServer.class); when(opts.isImmutable()).thenReturn(false); when(opts.processOptions(server)).thenReturn(optionsStrings); args = new ArrayList<String>(); addOpts.invoke(parameters, args, opts, server); assertEquals(optionsStrings, args); }
@Test public void addOpts() throws Exception { Parameters parameters = new Parameters(); Method addOpts = getPrivateMethod(Parameters.class, "addOpts", List.class, Options.class, IServer.class); List<String> args = Lists.newArrayList(); addOpts.invoke(parameters, args, null, null); assertThat(args.size(), is(0)); Options opts = mock(Options.class); when(opts.isImmutable()).thenReturn(true); ArrayList<String> optionsStrings = Lists.newArrayList("-a", "-f", "-s"); when(opts.getOptions()).thenReturn(optionsStrings); args = Lists.newArrayList(); addOpts.invoke(parameters, args, opts, mock(IServer.class)); assertThat(args, is(optionsStrings)); reset(opts); IServer server = mock(IServer.class); when(opts.isImmutable()).thenReturn(false); when(opts.processOptions(server)).thenReturn(optionsStrings); args = Lists.newArrayList(); addOpts.invoke(parameters, args, opts, server); assertThat(args, is(optionsStrings)); }