OpenedDelegator extends BaseDelegator implements IOpenedDelegator { @Override public List<IFileSpec> getOpenedFiles( final List<IFileSpec> fileSpecs, final boolean allClients, final String clientName, final int maxFiles, final int changeListId) throws ConnectionException, AccessException { try { OpenedFilesOptions openedFilesOptions = new OpenedFilesOptions( allClients, clientName, maxFiles, null, changeListId); return getOpenedFiles(fileSpecs, openedFilesOptions); } catch (final ConnectionException | AccessException exc) { throw exc; } catch (P4JavaException exc) { Log.warn("Unexpected exception in IServer.openedFiles: %s", exc); return Collections.emptyList(); } } OpenedDelegator(final IOptionsServer server); @Override List<IFileSpec> getOpenedFiles(
            final List<IFileSpec> fileSpecs,
            final boolean allClients,
            final String clientName,
            final int maxFiles,
            final int changeListId); @Override List<IFileSpec> getOpenedFiles(
            final List<IFileSpec> fileSpecs,
            final OpenedFilesOptions opts);  }
@Test(expected = AccessException.class) public void testOpenedOptAccessException() throws P4JavaException { setUpException(AccessException.AccessExceptionForTests.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); openedDelegator.getOpenedFiles(specs, new OpenedFilesOptions()); }
@Test(expected = AccessException.class) public void testOpenedAccessException() throws P4JavaException { setUpException(AccessException.AccessExceptionForTests.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); openedDelegator.getOpenedFiles(specs, false, "client", 1, 1); }
@Test public void testOpened() throws P4JavaException { when(server.execMapCmdList(eq(OPENED.toString()), argThat(SIMPLE_MATCHER), eq((Map<String, Object>)null))) .thenReturn(buildResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); List<IFileSpec> opened = openedDelegator.getOpenedFiles(specs, new OpenedFilesOptions()); verify(server).execMapCmdList(eq(OPENED.toString()), argThat(SIMPLE_MATCHER), eq((Map<String, Object>)null)); assertFileSpecs(opened); }
@Test public void testOpenedSetOptions() throws P4JavaException { OpenedFilesOptions options = new OpenedFilesOptions() .setChangelistId(Integer.valueOf(CHANGE).intValue()).setAllClients(true) .setClientName(CLIENT).setMaxFiles(1); when(server.execMapCmdList(eq(OPENED.toString()), argThat(OPTION_MATCHER), eq((Map<String, Object>)null))) .thenReturn(buildResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); List<IFileSpec> opened = openedDelegator.getOpenedFiles(specs, options); verify(server).execMapCmdList(eq(OPENED.toString()), argThat(OPTION_MATCHER), eq((Map<String, Object>)null)); assertFileSpecs(opened); }
@Test public void testOpenedParameters() throws P4JavaException { when(server.execMapCmdList(eq(OPENED.toString()), argThat(OPTION_MATCHER), eq((Map<String, Object>)null))) .thenReturn(buildResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); List<IFileSpec> opened = openedDelegator.getOpenedFiles(specs, true, CLIENT, 1, Integer.valueOf(CHANGE).intValue()); verify(server).execMapCmdList(eq(OPENED.toString()), argThat(OPTION_MATCHER), eq((Map<String, Object>)null)); assertFileSpecs(opened); }
@Test(expected = ConnectionException.class) public void testOpenedOptConnectionException() throws P4JavaException { setUpException(ConnectionException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); openedDelegator.getOpenedFiles(specs, new OpenedFilesOptions()); }
@Test(expected = AccessException.class) public void testOpenedOptAccessException() throws P4JavaException { setUpException(AccessException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); openedDelegator.getOpenedFiles(specs, new OpenedFilesOptions()); }
@Test(expected = RequestException.class) public void testOpenedOptRequestException() throws P4JavaException { setUpException(RequestException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); openedDelegator.getOpenedFiles(specs, new OpenedFilesOptions()); }
@Test(expected = P4JavaException.class) public void testOpenedOptP4JavaException() throws P4JavaException { setUpException(P4JavaException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); openedDelegator.getOpenedFiles(specs, new OpenedFilesOptions()); }
@Test(expected = ConnectionException.class) public void testOpenedConnectionException() throws P4JavaException { setUpException(ConnectionException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); openedDelegator.getOpenedFiles(specs, false, "client", 1, 1); }
@Test(expected = AccessException.class) public void testOpenedAccessException() throws P4JavaException { setUpException(AccessException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); openedDelegator.getOpenedFiles(specs, false, "client", 1, 1); }
@Test public void testOpenedRequestException() throws P4JavaException { setUpException(RequestException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); List<IFileSpec> opened = openedDelegator.getOpenedFiles(specs, false, "client", 1, 1); assertNotNull(opened); assertEquals(0, opened.size()); }
@Test public void testOpenedP4JavaException() throws P4JavaException { setUpException(P4JavaException.class); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); List<IFileSpec> opened = openedDelegator.getOpenedFiles(specs, false, "client", 1, 1); assertNotNull(opened); assertEquals(0, opened.size()); }
@SuppressWarnings({ "unchecked", "deprecation" }) @Test public void testOpened() throws P4JavaException { when(server.execMapCmdList(eq(OPENED.toString()), argThat(SIMPLE_MATCHER), eq(null))) .thenReturn(buildResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); List<IFileSpec> opened = openedDelegator.getOpenedFiles(specs, new OpenedFilesOptions()); verify(server).execMapCmdList(eq(OPENED.toString()), argThat(SIMPLE_MATCHER), eq(null)); assertFileSpecs(opened); }
@SuppressWarnings({ "unchecked", "deprecation" }) @Test public void testOpenedSetOptions() throws P4JavaException { OpenedFilesOptions options = new OpenedFilesOptions() .setChangelistId(Integer.valueOf(CHANGE).intValue()).setAllClients(true) .setClientName(CLIENT).setMaxFiles(1); when(server.execMapCmdList(eq(OPENED.toString()), argThat(OPTION_MATCHER), eq(null))) .thenReturn(buildResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); List<IFileSpec> opened = openedDelegator.getOpenedFiles(specs, options); verify(server).execMapCmdList(eq(OPENED.toString()), argThat(OPTION_MATCHER), eq(null)); assertFileSpecs(opened); }
@SuppressWarnings({ "unchecked", "deprecation" }) @Test public void testOpenedParameters() throws P4JavaException { when(server.execMapCmdList(eq(OPENED.toString()), argThat(OPTION_MATCHER), eq(null))) .thenReturn(buildResultMap()); List<IFileSpec> specs = FileSpecBuilder.makeFileSpecList(DEPOT_FILE); List<IFileSpec> opened = openedDelegator.getOpenedFiles(specs, true, CLIENT, 1, Integer.valueOf(CHANGE).intValue()); verify(server).execMapCmdList(eq(OPENED.toString()), argThat(OPTION_MATCHER), eq(null)); assertFileSpecs(opened); }