StatDelegator extends BaseDelegator implements IStatDelegator { @Override public IStreamIntegrationStatus getStreamIntegrationStatus(final String stream, final StreamIntegrationStatusOptions opts) throws P4JavaException { List<Map<String, Object>> resultMaps = execMapCmdList(ISTAT, processParameters(opts, null, new String[]{stream}, server), null); return ResultListBuilder.buildNullableObjectFromNonInfoMessageCommandResultMaps( resultMaps, new Function<Map, IStreamIntegrationStatus>() { @Override public IStreamIntegrationStatus apply(Map map) { return new StreamIntegrationStatus(map); } } ); } StatDelegator(final IOptionsServer server); @Override IStreamIntegrationStatus getStreamIntegrationStatus(final String stream,
                                                               final StreamIntegrationStatusOptions opts);  }
@Test(expected = ConnectionException.class) public void testStatConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(ISTAT.toString()), argThat(STAT_MATCHER), eq((Map<String, Object>)null))) .thenThrow(ConnectionException.class); iStatDelegator.getStreamIntegrationStatus(STREAM, new StreamIntegrationStatusOptions()); }
@Test(expected = AccessException.class) public void testStatAccessException() throws P4JavaException { when(server.execMapCmdList(eq(ISTAT.toString()), argThat(STAT_MATCHER), eq((Map<String, Object>)null))) .thenThrow(AccessException.class); iStatDelegator.getStreamIntegrationStatus(STREAM, new StreamIntegrationStatusOptions()); }
@Test(expected = RequestException.class) public void testStatRequestException() throws P4JavaException { when(server.execMapCmdList(eq(ISTAT.toString()), argThat(STAT_MATCHER), eq((Map<String, Object>)null))) .thenThrow(RequestException.class); iStatDelegator.getStreamIntegrationStatus(STREAM, new StreamIntegrationStatusOptions()); }
@Test(expected = P4JavaException.class) public void testStatP4JavaException() throws P4JavaException { when(server.execMapCmdList(eq(ISTAT.toString()), argThat(STAT_MATCHER), eq((Map<String, Object>)null))) .thenThrow(P4JavaException.class); iStatDelegator.getStreamIntegrationStatus(STREAM, new StreamIntegrationStatusOptions()); }
@Test public void testStatNoOptions() throws P4JavaException { when(server.execMapCmdList(eq(ISTAT.toString()), argThat(STAT_MATCHER), eq((Map<String, Object>)null))) .thenReturn(buildValidResultMap()); assertStatus(iStatDelegator.getStreamIntegrationStatus(STREAM, new StreamIntegrationStatusOptions())); verify(server).execMapCmdList(eq(ISTAT.toString()), argThat(STAT_MATCHER), eq((Map<String, Object>)null)); }
@Test public void testStatOptions() throws P4JavaException { when(server.execMapCmdList(eq(ISTAT.toString()), argThat(STAT_OPT_MATCHER), eq((Map<String, Object>)null))) .thenReturn(buildValidResultMap()); StreamIntegrationStatusOptions options = new StreamIntegrationStatusOptions(); options.setNoRefresh(true); options.setBidirectional(true); options.setForceUpdate(true); assertStatus(iStatDelegator.getStreamIntegrationStatus(STREAM, options)); verify(server).execMapCmdList(eq(ISTAT.toString()), argThat(STAT_OPT_MATCHER), eq((Map<String, Object>)null)); }
@Test(expected = ConnectionException.class) public void testStatConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(ISTAT.toString()), argThat(STAT_MATCHER), eq(null))) .thenThrow(ConnectionException.class); iStatDelegator.getStreamIntegrationStatus(STREAM, new StreamIntegrationStatusOptions()); }
@Test(expected = AccessException.class) public void testStatAccessException() throws P4JavaException { when(server.execMapCmdList(eq(ISTAT.toString()), argThat(STAT_MATCHER), eq(null))) .thenThrow(AccessException.class); iStatDelegator.getStreamIntegrationStatus(STREAM, new StreamIntegrationStatusOptions()); }
@Test(expected = RequestException.class) public void testStatRequestException() throws P4JavaException { when(server.execMapCmdList(eq(ISTAT.toString()), argThat(STAT_MATCHER), eq(null))) .thenThrow(RequestException.class); iStatDelegator.getStreamIntegrationStatus(STREAM, new StreamIntegrationStatusOptions()); }
@Test(expected = P4JavaException.class) public void testStatP4JavaException() throws P4JavaException { when(server.execMapCmdList(eq(ISTAT.toString()), argThat(STAT_MATCHER), eq(null))) .thenThrow(P4JavaException.class); iStatDelegator.getStreamIntegrationStatus(STREAM, new StreamIntegrationStatusOptions()); }
@Test public void testStatNoOptions() throws P4JavaException { when(server.execMapCmdList(eq(ISTAT.toString()), argThat(STAT_MATCHER), eq(null))) .thenReturn(buildValidResultMap()); assertStatus(iStatDelegator.getStreamIntegrationStatus(STREAM, new StreamIntegrationStatusOptions())); verify(server).execMapCmdList(eq(ISTAT.toString()), argThat(STAT_MATCHER), eq(null)); }
@Test public void testStatOptions() throws P4JavaException { when(server.execMapCmdList(eq(ISTAT.toString()), argThat(STAT_OPT_MATCHER), eq(null))) .thenReturn(buildValidResultMap()); StreamIntegrationStatusOptions options = new StreamIntegrationStatusOptions(); options.setNoRefresh(true); options.setBidirectional(true); options.setForceUpdate(true); assertStatus(iStatDelegator.getStreamIntegrationStatus(STREAM, options)); verify(server).execMapCmdList(eq(ISTAT.toString()), argThat(STAT_OPT_MATCHER), eq(null)); }