Parameters { private static String[] addUnannotatedFileSpecs(@Nonnull final List<String> args, @Nullable final List<IFileSpec> fileSpecs) { Validate.notNull(args); if (nonNull(fileSpecs)) { for (IFileSpec fileSpec : fileSpecs) { if (nonNull(fileSpec) && fileSpec.getOpStatus() == VALID) { args.add(fileSpec.getPreferredPathString()); } } } return args.toArray(new String[args.size()]); }  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 addUnannotatedFileSpecs() throws Exception { Parameters parameters = new Parameters(); Method addUnannotatedFileSpecs = getPrivateMethod(Parameters.class, "addUnannotatedFileSpecs", List.class, List.class); assertThrows(InvocationTargetException.class, () -> addUnannotatedFileSpecs.invoke(parameters, null, null)); List<String> args = Lists.newArrayList(); addUnannotatedFileSpecs.invoke(parameters, args, null); assertThat(args.size(), is(0)); args = Lists.newArrayList(); List<IFileSpec> fileSpecs = Lists.newArrayList(); IFileSpec fileSpec1 = mock(IFileSpec.class); when(fileSpec1.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec1.getPreferredPathString()).thenReturn(" fileSpecs.add(fileSpec1); IFileSpec fileSpec2 = mock(IFileSpec.class); when(fileSpec2.getOpStatus()).thenReturn(FileSpecOpStatus.UNKNOWN); fileSpecs.add(fileSpec2); fileSpecs.add(null); addUnannotatedFileSpecs.invoke(parameters, args, fileSpecs); assertThat(args.size(), is(1)); assertThat(args.get(0), is(" }
@Test public void addUnannotatedFileSpecs() throws Exception { Parameters parameters = new Parameters(); Method addUnannotatedFileSpecs = getPrivateMethod(Parameters.class, "addUnannotatedFileSpecs", List.class, List.class); try { addUnannotatedFileSpecs.invoke(parameters, null, null); fail("should have thown InvocationTargetException.class"); } catch (Throwable e) { assertEquals(InvocationTargetException.class, e.getClass()); } List<String> args = new ArrayList<String>(); addUnannotatedFileSpecs.invoke(parameters, args, null); assertThat(args.size(), is(0)); args = new ArrayList<String>(); List<IFileSpec> fileSpecs = new ArrayList<IFileSpec>(); IFileSpec fileSpec1 = mock(IFileSpec.class); when(fileSpec1.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec1.getPreferredPathString()).thenReturn(" fileSpecs.add(fileSpec1); IFileSpec fileSpec2 = mock(IFileSpec.class); when(fileSpec2.getOpStatus()).thenReturn(FileSpecOpStatus.UNKNOWN); fileSpecs.add(fileSpec2); fileSpecs.add(null); addUnannotatedFileSpecs.invoke(parameters, args, fileSpecs); assertThat(args.size(), is(1)); assertThat(args.get(0), is(" }
@Test public void addUnannotatedFileSpecs() throws Exception { Parameters parameters = new Parameters(); Method addUnannotatedFileSpecs = getPrivateMethod(Parameters.class, "addUnannotatedFileSpecs", List.class, List.class); expectThrows(InvocationTargetException.class, () -> addUnannotatedFileSpecs.invoke(parameters, null, null)); List<String> args = Lists.newArrayList(); addUnannotatedFileSpecs.invoke(parameters, args, null); assertThat(args.size(), is(0)); args = Lists.newArrayList(); List<IFileSpec> fileSpecs = Lists.newArrayList(); IFileSpec fileSpec1 = mock(IFileSpec.class); when(fileSpec1.getOpStatus()).thenReturn(FileSpecOpStatus.VALID); when(fileSpec1.getPreferredPathString()).thenReturn(" fileSpecs.add(fileSpec1); IFileSpec fileSpec2 = mock(IFileSpec.class); when(fileSpec2.getOpStatus()).thenReturn(FileSpecOpStatus.UNKNOWN); fileSpecs.add(fileSpec2); fileSpecs.add(null); addUnannotatedFileSpecs.invoke(parameters, args, fileSpecs); assertThat(args.size(), is(1)); assertThat(args.get(0), is(" }