ProtectsDelegator extends BaseDelegator implements IProtectsDelegator { @Override public List<IProtectionEntry> getProtectionEntries( final boolean allUsers, final String hostName, final String userName, final String groupName, final List<IFileSpec> fileList) throws ConnectionException, RequestException, AccessException { try { GetProtectionEntriesOptions opts = new GetProtectionEntriesOptions() .setAllUsers(allUsers) .setHostName(hostName) .setUserName(userName) .setGroupName(groupName); return getProtectionEntries(fileList, opts); } catch (final ConnectionException | AccessException | RequestException exc) { throw exc; } catch (P4JavaException exc) { throw new RequestException(exc.getMessage(), exc); } } ProtectsDelegator(IOptionsServer server); @Override List<IProtectionEntry> getProtectionEntries(
            final boolean allUsers,
            final String hostName,
            final String userName,
            final String groupName,
            final List<IFileSpec> fileList); @Override List<IProtectionEntry> getProtectionEntries(
            final List<IFileSpec> fileList,
            final GetProtectionEntriesOptions opts);  }
@Test public void testGetProtectionEntriesShouldReturnNonEmptyList() throws Exception { when(server.execMapCmdList(eq(PROTECTS.toString()), eq(cmdArguments), eq((Map<String, Object>)null))) .thenReturn(resultMaps); List<IProtectionEntry> protectionEntries = protectsDelegator.getProtectionEntries( allUsers, hostName, userName, groupName, fileSpecs); assertThat(protectionEntries.size(), is(2)); assertThat(protectionEntries.get(0).getOrder(), is(0)); assertThat(protectionEntries.get(1).getOrder(), is(1)); }
@Test public void testGetProtectionEntriesByOptionsShouldReturnNonEmptyList() throws Exception { when(server.execMapCmdList(eq(PROTECTS.toString()), eq(cmdArguments), eq((Map<String, Object>)null))) .thenReturn(resultMaps); List<IProtectionEntry> protectionEntries = protectsDelegator.getProtectionEntries( fileSpecs, opts); assertThat(protectionEntries.size(), is(2)); assertThat(protectionEntries.get(0).getOrder(), is(0)); assertThat(protectionEntries.get(1).getOrder(), is(1)); }
@Test public void testGetProtectionEntriesShouldReturnNonEmptyList() throws Exception { when(server.execMapCmdList(eq(PROTECTS.toString()), eq(cmdArguments), eq(null))) .thenReturn(resultMaps); List<IProtectionEntry> protectionEntries = protectsDelegator.getProtectionEntries( allUsers, hostName, userName, groupName, fileSpecs); assertThat(protectionEntries.size(), is(2)); assertThat(protectionEntries.get(0).getOrder(), is(0)); assertThat(protectionEntries.get(1).getOrder(), is(1)); }
@Test public void testGetProtectionEntriesByOptionsShouldReturnNonEmptyList() throws Exception { when(server.execMapCmdList(eq(PROTECTS.toString()), eq(cmdArguments), eq(null))) .thenReturn(resultMaps); List<IProtectionEntry> protectionEntries = protectsDelegator.getProtectionEntries( fileSpecs, opts); assertThat(protectionEntries.size(), is(2)); assertThat(protectionEntries.get(0).getOrder(), is(0)); assertThat(protectionEntries.get(1).getOrder(), is(1)); }