DirsDelegator extends BaseDelegator implements IDirsDelegator { @Override public List<IFileSpec> getDirectories(@Nonnull final List<IFileSpec> fileSpecs, final boolean clientOnly, final boolean deletedOnly, final boolean haveListOnly) throws ConnectionException, AccessException { Validate.notNull(fileSpecs); try { GetDirectoriesOptions directoriesOptions = new GetDirectoriesOptions() .setClientOnly(clientOnly).setDeletedOnly(deletedOnly) .setHaveListOnly(haveListOnly); return getDirectories(fileSpecs, directoriesOptions); } catch (final ConnectionException | AccessException exc) { throw exc; } catch (P4JavaException exc) { Log.warn("Unexpected exception in IServer.getDirectories: %s", exc); return Collections.emptyList(); } } DirsDelegator(final IOptionsServer server); @Override List<IFileSpec> getDirectories(@Nonnull final List<IFileSpec> fileSpecs,
            final boolean clientOnly, final boolean deletedOnly, final boolean haveListOnly); @Override List<IFileSpec> getDirectories(final List<IFileSpec> fileSpecs,
            final GetDirectoriesOptions opts);  }
@Test(expected = AccessException.class) public void testGetDirectoriesAccessException() throws P4JavaException { when(server.execMapCmdList(eq(DIRS.toString()), argThat(DEV_FS_MATCHER), eq(IN_MAP))) .thenThrow(AccessException.AccessExceptionForTests.class); dirsDelegator.getDirectories(FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH), false, false, false); }
@Test(expected = AccessException.class) public void testGetDirectoriesOptAccessException() throws P4JavaException { when(server.execMapCmdList(eq(DIRS.toString()), argThat(DEV_FS_MATCHER), eq(IN_MAP))) .thenThrow(AccessException.AccessExceptionForTests.class); dirsDelegator.getDirectories(FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH), new GetDirectoriesOptions()); }
@Test public void testGetDirectoriesOpt() throws P4JavaException { when(server.execMapCmdList(eq(DIRS.toString()), argThat(DEV_FS_MATCHER), eq(IN_MAP))) .thenReturn(buildDevPathMap()); List<IFileSpec> dirs = dirsDelegator.getDirectories( FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH), new GetDirectoriesOptions()); assertFileSpecs(dirs); }
@Test public void testGetDirectoriesOptWithDir() throws P4JavaException { when(server.execMapCmdList(eq(DIRS.toString()), argThat(DEV_FS_MATCHER), eq(IN_MAP))) .thenReturn(buildDevPathMap("dir")); List<IFileSpec> dirs = dirsDelegator.getDirectories( FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH), new GetDirectoriesOptions()); assertFileSpecs(dirs); }
@Test public void testGetDirectoriesOptError() throws P4JavaException { when(server.execMapCmdList(eq(DIRS.toString()), argThat(DEV_FS_MATCHER), eq(IN_MAP))) .thenReturn(buildDevPathMapError()); List<IFileSpec> dirs = dirsDelegator.getDirectories( FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH), new GetDirectoriesOptions()); assertFileSpecsError(dirs); }
@Test public void testGetDirectoriesError() throws P4JavaException { when(server.execMapCmdList(eq(DIRS.toString()), argThat(DEV_FS_MATCHER), eq(IN_MAP))) .thenReturn(buildDevPathMapError()); List<IFileSpec> dirs = dirsDelegator.getDirectories( FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH), false, false, false); assertFileSpecsError(dirs); }
@Test public void testGetDirectories() throws P4JavaException { when(server.execMapCmdList(eq(DIRS.toString()), argThat(DEV_FS_MATCHER), eq(IN_MAP))) .thenReturn(buildDevPathMap()); List<IFileSpec> dirs = dirsDelegator.getDirectories( FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH), false, false, false); assertFileSpecs(dirs); }
@Test(expected = ConnectionException.class) public void testGetDirectoriesConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(DIRS.toString()), argThat(DEV_FS_MATCHER), eq(IN_MAP))) .thenThrow(ConnectionException.class); dirsDelegator.getDirectories(FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH), false, false, false); }
@Test(expected = ConnectionException.class) public void testGetDirectoriesOptConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(DIRS.toString()), argThat(DEV_FS_MATCHER), eq(IN_MAP))) .thenThrow(ConnectionException.class); dirsDelegator.getDirectories(FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH), new GetDirectoriesOptions()); }
@Test(expected = AccessException.class) public void testGetDirectoriesAccessException() throws P4JavaException { when(server.execMapCmdList(eq(DIRS.toString()), argThat(DEV_FS_MATCHER), eq(IN_MAP))) .thenThrow(AccessException.class); dirsDelegator.getDirectories(FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH), false, false, false); }
@Test(expected = AccessException.class) public void testGetDirectoriesOptAccessException() throws P4JavaException { when(server.execMapCmdList(eq(DIRS.toString()), argThat(DEV_FS_MATCHER), eq(IN_MAP))) .thenThrow(AccessException.class); dirsDelegator.getDirectories(FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH), new GetDirectoriesOptions()); }
@Test(expected = RequestException.class) public void testGetDirectoriesOptRequestException() throws P4JavaException { when(server.execMapCmdList(eq(DIRS.toString()), argThat(DEV_FS_MATCHER), eq(IN_MAP))) .thenThrow(RequestException.class); dirsDelegator.getDirectories(FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH), new GetDirectoriesOptions()); }
@Test public void testGetDirectoriesRequestException() throws P4JavaException { when(server.execMapCmdList(eq(DIRS.toString()), argThat(DEV_FS_MATCHER), eq(IN_MAP))) .thenThrow(RequestException.class); List<IFileSpec> dirs = dirsDelegator.getDirectories( FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH), false, false, false); assertNotNull(dirs); assertEquals(0, dirs.size()); }