FilesDelegator extends BaseDelegator implements IFilesDelegator { @Override public List<IFileSpec> getDepotFiles(@Nonnull final List<IFileSpec> fileSpecs, final boolean allRevs) throws ConnectionException, AccessException { List<IFileSpec> depotFileSpecs = new ArrayList<>(); try { depotFileSpecs = getDepotFiles(fileSpecs, new GetDepotFilesOptions().setAllRevs(allRevs)); } catch (final ConnectionException | AccessException exc) { throw exc; } catch (P4JavaException exc) { Log.warn("Unexpected exception in IServer.getDepotFiles: %s", exc); } return depotFileSpecs; } FilesDelegator(final IOptionsServer server); @Override List<IFileSpec> getDepotFiles(@Nonnull final List<IFileSpec> fileSpecs,
            final boolean allRevs); @Override List<IFileSpec> getDepotFiles(@Nonnull final List<IFileSpec> fileSpecs,
            final GetDepotFilesOptions opts);  }
@Test(expected = AccessException.class) public void testGetFilesOptAccessException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_FS_MATCHER), eq(null))) .thenThrow(AccessException.AccessExceptionForTests.class); filesDelegator.getDepotFiles(specs, new GetDepotFilesOptions()); }
@Test(expected = AccessException.class) public void testGetFilesAccessException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_ALL_FS_MATCHER), eq(null))) .thenThrow(AccessException.AccessExceptionForTests.class); filesDelegator.getDepotFiles(specs, true); }
@Test public void testGetFilesOpt() throws P4JavaException { List<Map<String, Object>> serverResults = buildDevPathMap(); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_FS_MATCHER), eq((Map<String, Object>)null))) .thenReturn(serverResults); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFileSpec> files = filesDelegator.getDepotFiles(specs, new GetDepotFilesOptions()); assertFileSpecs(files); }
@Test public void testGetFiles() throws P4JavaException { List<Map<String, Object>> serverResults = buildDevPathMap(); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_ALL_FS_MATCHER), eq((Map<String, Object>)null))) .thenReturn(serverResults); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFileSpec> files = filesDelegator.getDepotFiles(specs, true); assertFileSpecs(files); }
@Test public void testGetFilesNotAll() throws P4JavaException { List<Map<String, Object>> serverResults = buildDevPathMap(); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_FS_MATCHER), eq((Map<String, Object>)null))) .thenReturn(serverResults); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFileSpec> files = filesDelegator.getDepotFiles(specs, false); assertFileSpecs(files); }
@Test(expected = ConnectionException.class) public void testGetFilesOptConnectionException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_FS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(ConnectionException.class); filesDelegator.getDepotFiles(specs, new GetDepotFilesOptions()); }
@Test(expected = ConnectionException.class) public void testGetFilesConnectionException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_ALL_FS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(ConnectionException.class); filesDelegator.getDepotFiles(specs, true); }
@Test(expected = AccessException.class) public void testGetFilesOptAccessException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_FS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(AccessException.class); filesDelegator.getDepotFiles(specs, new GetDepotFilesOptions()); }
@Test(expected = AccessException.class) public void testGetFilesAccessException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_ALL_FS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(AccessException.class); filesDelegator.getDepotFiles(specs, true); }
@Test(expected = RequestException.class) public void testGetFilesOptRequestException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_FS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(RequestException.class); filesDelegator.getDepotFiles(specs, new GetDepotFilesOptions()); }
@Test public void testGetFilesRequestException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_ALL_FS_MATCHER), eq((Map<String, Object>)null))) .thenThrow(RequestException.class); List<IFileSpec> results = filesDelegator.getDepotFiles(specs, true); assertNotNull(results); assertEquals(0, results.size()); }
@Test public void testGetDirectoriesOptError() throws P4JavaException { List<Map<String, Object>> serverResults = buildDevPathMapError(); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_FS_MATCHER), eq((Map<String, Object>)null))) .thenReturn(serverResults); List<IFileSpec> dirs = filesDelegator.getDepotFiles(specs, new GetDepotFilesOptions()); assertFileSpecsError(dirs); }
@Test public void testGetDirectoriesError() throws P4JavaException { List<Map<String, Object>> serverResults = buildDevPathMapError(); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_ALL_FS_MATCHER), eq((Map<String, Object>)null))) .thenReturn(serverResults); List<IFileSpec> dirs = filesDelegator.getDepotFiles(specs, true); assertFileSpecsError(dirs); }
@Test public void testGetFilesOpt() throws P4JavaException { List<Map<String, Object>> serverResults = buildDevPathMap(); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_FS_MATCHER), eq(null))) .thenReturn(serverResults); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFileSpec> files = filesDelegator.getDepotFiles(specs, new GetDepotFilesOptions()); assertFileSpecs(files); }
@Test public void testGetFiles() throws P4JavaException { List<Map<String, Object>> serverResults = buildDevPathMap(); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_ALL_FS_MATCHER), eq(null))) .thenReturn(serverResults); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFileSpec> files = filesDelegator.getDepotFiles(specs, true); assertFileSpecs(files); }
@Test public void testGetFilesNotAll() throws P4JavaException { List<Map<String, Object>> serverResults = buildDevPathMap(); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_FS_MATCHER), eq(null))) .thenReturn(serverResults); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); List<IFileSpec> files = filesDelegator.getDepotFiles(specs, false); assertFileSpecs(files); }
@Test(expected = ConnectionException.class) public void testGetFilesOptConnectionException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_FS_MATCHER), eq(null))) .thenThrow(ConnectionException.class); filesDelegator.getDepotFiles(specs, new GetDepotFilesOptions()); }
@Test(expected = ConnectionException.class) public void testGetFilesConnectionException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_ALL_FS_MATCHER), eq(null))) .thenThrow(ConnectionException.class); filesDelegator.getDepotFiles(specs, true); }
@Test(expected = AccessException.class) public void testGetFilesOptAccessException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_FS_MATCHER), eq(null))) .thenThrow(AccessException.class); filesDelegator.getDepotFiles(specs, new GetDepotFilesOptions()); }
@Test(expected = AccessException.class) public void testGetFilesAccessException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_ALL_FS_MATCHER), eq(null))) .thenThrow(AccessException.class); filesDelegator.getDepotFiles(specs, true); }
@Test(expected = RequestException.class) public void testGetFilesOptRequestException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_FS_MATCHER), eq(null))) .thenThrow(RequestException.class); filesDelegator.getDepotFiles(specs, new GetDepotFilesOptions()); }
@Test public void testGetFilesRequestException() throws P4JavaException { List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_ALL_FS_MATCHER), eq(null))) .thenThrow(RequestException.class); List<IFileSpec> results = filesDelegator.getDepotFiles(specs, true); assertNotNull(results); assertEquals(0, results.size()); }
@Test public void testGetDirectoriesOptError() throws P4JavaException { List<Map<String, Object>> serverResults = buildDevPathMapError(); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_FS_MATCHER), eq(null))) .thenReturn(serverResults); List<IFileSpec> dirs = filesDelegator.getDepotFiles(specs, new GetDepotFilesOptions()); assertFileSpecsError(dirs); }
@Test public void testGetDirectoriesError() throws P4JavaException { List<Map<String, Object>> serverResults = buildDevPathMapError(); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_DEV_PATH); when(server.execMapCmdList(eq(FILES.toString()), argThat(DEV_ALL_FS_MATCHER), eq(null))) .thenReturn(serverResults); List<IFileSpec> dirs = filesDelegator.getDepotFiles(specs, true); assertFileSpecsError(dirs); }