DiskspaceDelegator extends BaseDelegator implements IDiskspaceDelegator { @Override public List<IDiskSpace> getDiskSpace(final List<String> filesystems) throws P4JavaException { String[] cmdArgs = null; if (nonNull(filesystems)) { cmdArgs = filesystems.toArray(new String[filesystems.size()]); } List<Map<String, Object>> resultMaps = execMapCmdList( DISKSPACE, cmdArgs, null); return buildNonNullObjectListFromCommandResultMaps( resultMaps, new Function<Map<String, Object>, IDiskSpace>() { @Override public IDiskSpace apply(Map<String, Object> map) { return new DiskSpace(map); } }); } DiskspaceDelegator(IOptionsServer server); @Override List<IDiskSpace> getDiskSpace(final List<String> filesystems);  }
@Test public void testGetDiskSpace() throws Exception { String[] cmdArgs = {"-f", "-s"}; List<String> filesystems = newArrayList(cmdArgs); when(server.execMapCmdList(eq(DISKSPACE.toString()), eq(cmdArgs), eq(null))).thenReturn( resultMaps); List<IDiskSpace> diskSpaces = diskspaceDelegator.getDiskSpace(filesystems); assertThat(diskSpaces.size(), is(1)); }