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