Parameters { public static String[] processParameters(final Options opts, final IServer server) throws P4JavaException { return processParameters(opts, null, null, true, 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 processParameters_opts_fileSpecs_stringParams_server() throws Exception { Options opts = createMockOptions(); List<IFileSpec> fileSpecs = null; String[] stringParams = null; String[] processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s"})); fileSpecs = new ArrayList<IFileSpec>(); IFileSpec fileSpec1 = mock(IFileSpec.class); when(fileSpec1.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec1.getAnnotatedPreferredPathString()).thenReturn(" fileSpecs.add(fileSpec1); IFileSpec fileSpec2 = mock(IFileSpec.class); when(fileSpec2.getOpStatus()).thenReturn(FileSpecOpStatus.UNKNOWN); fileSpecs.add(fileSpec2); processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", " stringParams = new String[] {"-o"}; processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", "-o", " processParameters = Parameters.processParameters(opts, fileSpecs, "-o", null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", "-o", " processParameters = Parameters.processParameters(opts, fileSpecs, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", " processParameters = Parameters.processParameters(opts, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s"})); }
@Test public void processParameters_opts_fileSpecs_stringParams_annotateFiles_server() throws Exception { Options opts = createMockOptions(); List<IFileSpec> fileSpecs = null; String[] stringParams = null; String[] processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, true, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s"})); fileSpecs = new ArrayList<IFileSpec>(); IFileSpec fileSpec1 = mock(IFileSpec.class); when(fileSpec1.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec1.getAnnotatedPreferredPathString()).thenReturn(" when(fileSpec1.getPreferredPathString()).thenReturn(" fileSpecs.add(fileSpec1); IFileSpec fileSpec2 = mock(IFileSpec.class); when(fileSpec2.getOpStatus()).thenReturn(FileSpecOpStatus.UNKNOWN); fileSpecs.add(fileSpec2); processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, true, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", " processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, false, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", " stringParams = new String[] {"-o"}; processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, false, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", "-o", " processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, true, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", "-o", " }
@Test public void processParameters_opts_fromFileSpec_toFileSpec_stringParams_server() throws P4JavaException { Options opts = createMockOptions(); List<IFileSpec> toFileSpecs = null; String[] stringParams = null; String[] processParameters = Parameters.processParameters(opts, mock(IFileSpec.class), toFileSpecs, stringParams, mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-s"})); toFileSpecs = new ArrayList<IFileSpec>(); IFileSpec fileSpec1 = mock(IFileSpec.class); when(fileSpec1.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec1.getAnnotatedPreferredPathString()).thenReturn(" toFileSpecs.add(fileSpec1); IFileSpec fileSpec2 = mock(IFileSpec.class); when(fileSpec2.getOpStatus()).thenReturn(FileSpecOpStatus.UNKNOWN); toFileSpecs.add(fileSpec2); processParameters = Parameters.processParameters(opts, mock(IFileSpec.class), toFileSpecs, stringParams, mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", " stringParams = new String[]{" processParameters = Parameters.processParameters(opts, mock(IFileSpec.class), toFileSpecs, stringParams, mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", " }
@Test public void processParameters_opts_fromFileSpec_toFileSpecs_branchSpec_server() throws P4JavaException { Options opts = mock(Options.class); ArrayList<String> optionsStrings = new ArrayList<String>(); optionsStrings.add("-a"); optionsStrings.add("-f"); when(opts.isImmutable()).thenReturn(true); when(opts.getOptions()).thenReturn(optionsStrings); IFileSpec fromFile = mock(IFileSpec.class); when(fromFile.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fromFile.getAnnotatedPreferredPathString()).thenReturn(" IFileSpec toFile = mock(IFileSpec.class); when(toFile.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(toFile.getAnnotatedPreferredPathString()).thenReturn(" String[] processParameters = Parameters.processParameters(opts, fromFile, toFile, "myBranch", mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-b", "myBranch", " reset(toFile); when(toFile.getOpStatus()).thenReturn(FileSpecOpStatus.ERROR); processParameters = Parameters.processParameters(opts, fromFile, toFile, "myBranch", mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-b", "myBranch", " reset(fromFile); when(fromFile.getOpStatus()).thenReturn(FileSpecOpStatus.ERROR); processParameters = Parameters.processParameters(opts, fromFile, toFile, "myBranch", mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-b", "myBranch"})); }
@Test public void processParameters_opts_formFile_toFile_branchSpec_server() throws Exception { Options opts = createMockOptions(); List<IFileSpec> fromFiles = null; List<IFileSpec> toFiles = null; String[] processParameters = Parameters.processParameters(opts, fromFiles, toFiles, "myBranch", mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-b", "myBranch", "-s"})); processParameters = Parameters.processParameters(opts, fromFiles, toFiles, null, mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-s"})); processParameters = Parameters.processParameters(opts, fromFiles, toFiles, EMPTY, mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-s"})); reset(opts); ArrayList<String> optionsStrings = new ArrayList<String>(); optionsStrings.add("-a"); optionsStrings.add("-f"); when(opts.isImmutable()).thenReturn(true); when(opts.getOptions()).thenReturn(optionsStrings); processParameters = Parameters.processParameters(opts, fromFiles, toFiles, "myBranch", mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-b", "myBranch"})); fromFiles = new ArrayList<IFileSpec>(); IFileSpec fileSpec1 = mock(IFileSpec.class); when(fileSpec1.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec1.getAnnotatedPreferredPathString()).thenReturn(" fromFiles.add(fileSpec1); IFileSpec fileSpec2 = mock(IFileSpec.class); when(fileSpec2.getOpStatus()).thenReturn(FileSpecOpStatus.ERROR); when(fileSpec2.getAnnotatedPreferredPathString()).thenReturn(" fromFiles.add(fileSpec2); toFiles = new ArrayList<IFileSpec>(); IFileSpec fileSpec3 = mock(IFileSpec.class); when(fileSpec3.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec3.getAnnotatedPreferredPathString()).thenReturn(" toFiles.add(fileSpec3); IFileSpec fileSpec4 = mock(IFileSpec.class); when(fileSpec4.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec4.getAnnotatedPreferredPathString()).thenReturn(" toFiles.add(fileSpec4); processParameters = Parameters.processParameters(opts, fromFiles, toFiles, "myBranch", mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-b", "myBranch", " }
@Test public void processParameters_opts_fileSpecs_stringParams_server() throws Exception { Options opts = createMockOptions(); List<IFileSpec> fileSpecs = null; String[] stringParams = null; String[] processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s"})); fileSpecs = Lists.newArrayList(); IFileSpec fileSpec1 = mock(IFileSpec.class); when(fileSpec1.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec1.getAnnotatedPreferredPathString()).thenReturn(" fileSpecs.add(fileSpec1); IFileSpec fileSpec2 = mock(IFileSpec.class); when(fileSpec2.getOpStatus()).thenReturn(FileSpecOpStatus.UNKNOWN); fileSpecs.add(fileSpec2); processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", " stringParams = new String[] {"-o"}; processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", "-o", " processParameters = Parameters.processParameters(opts, fileSpecs, "-o", null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", "-o", " processParameters = Parameters.processParameters(opts, fileSpecs, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", " processParameters = Parameters.processParameters(opts, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s"})); }
@Test public void processParameters_opts_fileSpecs_stringParams_annotateFiles_server() throws Exception { Options opts = createMockOptions(); List<IFileSpec> fileSpecs = null; String[] stringParams = null; String[] processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, true, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s"})); fileSpecs = Lists.newArrayList(); IFileSpec fileSpec1 = mock(IFileSpec.class); when(fileSpec1.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec1.getAnnotatedPreferredPathString()).thenReturn(" when(fileSpec1.getPreferredPathString()).thenReturn(" fileSpecs.add(fileSpec1); IFileSpec fileSpec2 = mock(IFileSpec.class); when(fileSpec2.getOpStatus()).thenReturn(FileSpecOpStatus.UNKNOWN); fileSpecs.add(fileSpec2); processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, true, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", " processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, false, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", " stringParams = new String[] {"-o"}; processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, false, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", "-o", " processParameters = Parameters.processParameters(opts, fileSpecs, stringParams, true, null); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", "-o", " }
@Test public void processParameters_opts_fromFileSpec_toFileSpec_stringParams_server() throws P4JavaException { Options opts = createMockOptions(); List<IFileSpec> toFileSpecs = null; String[] stringParams = null; String[] processParameters = Parameters.processParameters(opts, mock(IFileSpec.class), toFileSpecs, stringParams, mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-s"})); toFileSpecs = Lists.newArrayList(); IFileSpec fileSpec1 = mock(IFileSpec.class); when(fileSpec1.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec1.getAnnotatedPreferredPathString()).thenReturn(" toFileSpecs.add(fileSpec1); IFileSpec fileSpec2 = mock(IFileSpec.class); when(fileSpec2.getOpStatus()).thenReturn(FileSpecOpStatus.UNKNOWN); toFileSpecs.add(fileSpec2); processParameters = Parameters.processParameters(opts, mock(IFileSpec.class), toFileSpecs, stringParams, mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", " stringParams = new String[]{" processParameters = Parameters.processParameters(opts, mock(IFileSpec.class), toFileSpecs, stringParams, mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-s", " }
@Test public void processParameters_opts_fromFileSpec_toFileSpecs_branchSpec_server() throws P4JavaException { Options opts = mock(Options.class); when(opts.isImmutable()).thenReturn(true); when(opts.getOptions()).thenReturn(Lists.newArrayList("-a", "-f")); IFileSpec fromFile = mock(IFileSpec.class); when(fromFile.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fromFile.getAnnotatedPreferredPathString()).thenReturn(" IFileSpec toFile = mock(IFileSpec.class); when(toFile.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(toFile.getAnnotatedPreferredPathString()).thenReturn(" String[] processParameters = Parameters.processParameters(opts, fromFile, toFile, "myBranch", mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-b", "myBranch", " reset(toFile); when(toFile.getOpStatus()).thenReturn(FileSpecOpStatus.ERROR); processParameters = Parameters.processParameters(opts, fromFile, toFile, "myBranch", mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-b", "myBranch", " reset(fromFile); when(fromFile.getOpStatus()).thenReturn(FileSpecOpStatus.ERROR); processParameters = Parameters.processParameters(opts, fromFile, toFile, "myBranch", mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-b", "myBranch"})); }
@Test public void processParameters_opts_formFile_toFile_branchSpec_server() throws Exception { Options opts = createMockOptions(); List<IFileSpec> fromFiles = null; List<IFileSpec> toFiles = null; String[] processParameters = Parameters.processParameters(opts, fromFiles, toFiles, "myBranch", mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-b", "myBranch", "-s"})); processParameters = Parameters.processParameters(opts, fromFiles, toFiles, null, mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-s"})); processParameters = Parameters.processParameters(opts, fromFiles, toFiles, EMPTY, mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-s"})); reset(opts); when(opts.isImmutable()).thenReturn(true); when(opts.getOptions()).thenReturn(Lists.newArrayList("-a", "-f")); processParameters = Parameters.processParameters(opts, fromFiles, toFiles, "myBranch", mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-b", "myBranch"})); fromFiles = Lists.newArrayList(); IFileSpec fileSpec1 = mock(IFileSpec.class); when(fileSpec1.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec1.getAnnotatedPreferredPathString()).thenReturn(" fromFiles.add(fileSpec1); IFileSpec fileSpec2 = mock(IFileSpec.class); when(fileSpec2.getOpStatus()).thenReturn(FileSpecOpStatus.ERROR); when(fileSpec2.getAnnotatedPreferredPathString()).thenReturn(" fromFiles.add(fileSpec2); toFiles = Lists.newArrayList(); IFileSpec fileSpec3 = mock(IFileSpec.class); when(fileSpec3.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec3.getAnnotatedPreferredPathString()).thenReturn(" toFiles.add(fileSpec3); IFileSpec fileSpec4 = mock(IFileSpec.class); when(fileSpec4.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec4.getAnnotatedPreferredPathString()).thenReturn(" toFiles.add(fileSpec4); processParameters = Parameters.processParameters(opts, fromFiles, toFiles, "myBranch", mock(IServer.class)); assertThat(processParameters, is(new String[]{"-a", "-f", "-b", "myBranch", " }