JournalWaitDelegator extends BaseDelegator implements IJournalWaitDelegator { @Override public void journalWait(final JournalWaitOptions opts) throws P4JavaException { List<Map<String, Object>> resultMaps = execMapCmdList(JOURNALWAIT, processParameters(opts, server), null); if (nonNull(resultMaps)) { for (Map<String, Object> map : resultMaps) { String errStr = ResultMapParser.getErrorStr(map); throwRequestExceptionIfConditionFails(isBlank(errStr), parseCode0ErrorString(map), errStr); } } } JournalWaitDelegator(final IOptionsServer server); @Override void journalWait(final JournalWaitOptions opts);  }
@Test(expected = ConnectionException.class) public void testWaitConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq((Map<String, Object>)null))) .thenThrow(ConnectionException.class); journalWaitDelegator.journalWait(new JournalWaitOptions()); }
@Test(expected = AccessException.class) public void testWaitAccessException() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq((Map<String, Object>)null))) .thenThrow(AccessException.class); journalWaitDelegator.journalWait(new JournalWaitOptions()); }
@Test(expected = RequestException.class) public void testWaitRequestException() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq((Map<String, Object>)null))) .thenThrow(RequestException.class); journalWaitDelegator.journalWait(new JournalWaitOptions()); }
@Test(expected = P4JavaException.class) public void testWaitP4JavaException() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq((Map<String, Object>)null))) .thenThrow(P4JavaException.class); journalWaitDelegator.journalWait(new JournalWaitOptions()); }
@Test public void testWait() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq((Map<String, Object>)null))) .thenReturn(new ArrayList<Map<String, Object>>()); journalWaitDelegator.journalWait(new JournalWaitOptions()); verify(server).execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq((Map<String, Object>)null)); }
@Test public void testNoWait() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(NO_WAIT_MATCHER), eq((Map<String, Object>)null))) .thenReturn(new ArrayList<Map<String, Object>>()); journalWaitDelegator.journalWait(new JournalWaitOptions().setNoWait(true)); verify(server).execMapCmdList(eq(JOURNALWAIT.toString()), argThat(NO_WAIT_MATCHER), eq((Map<String, Object>)null)); }
@Test public void testNullOptions() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq((Map<String, Object>)null))) .thenReturn(new ArrayList<Map<String, Object>>()); journalWaitDelegator.journalWait(null); verify(server).execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq((Map<String, Object>)null)); }
@Test public void testNullOptionsNullReturn() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq((Map<String, Object>)null))) .thenReturn(null); journalWaitDelegator.journalWait(null); verify(server).execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq((Map<String, Object>)null)); }
@Test public void testError() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq((Map<String, Object>)null))) .thenReturn(buildErrorResultMap()); try { journalWaitDelegator.journalWait(null); } catch (RequestException e) { assertTrue(e.getMessage().startsWith(ERROR)); } }
@Test(expected = ConnectionException.class) public void testWaitConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq(null))) .thenThrow(ConnectionException.class); journalWaitDelegator.journalWait(new JournalWaitOptions()); }
@Test(expected = AccessException.class) public void testWaitAccessException() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq(null))) .thenThrow(AccessException.class); journalWaitDelegator.journalWait(new JournalWaitOptions()); }
@Test(expected = RequestException.class) public void testWaitRequestException() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq(null))) .thenThrow(RequestException.class); journalWaitDelegator.journalWait(new JournalWaitOptions()); }
@Test(expected = P4JavaException.class) public void testWaitP4JavaException() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq(null))) .thenThrow(P4JavaException.class); journalWaitDelegator.journalWait(new JournalWaitOptions()); }
@Test public void testWait() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq(null))) .thenReturn(new ArrayList<>()); journalWaitDelegator.journalWait(new JournalWaitOptions()); verify(server).execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq(null)); }
@Test public void testNoWait() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(NO_WAIT_MATCHER), eq(null))) .thenReturn(new ArrayList<>()); journalWaitDelegator.journalWait(new JournalWaitOptions().setNoWait(true)); verify(server).execMapCmdList(eq(JOURNALWAIT.toString()), argThat(NO_WAIT_MATCHER), eq(null)); }
@Test public void testNullOptions() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq(null))) .thenReturn(new ArrayList<>()); journalWaitDelegator.journalWait(null); verify(server).execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq(null)); }
@Test public void testNullOptionsNullReturn() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq(null))) .thenReturn(null); journalWaitDelegator.journalWait(null); verify(server).execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq(null)); }
@Test public void testError() throws P4JavaException { when(server.execMapCmdList(eq(JOURNALWAIT.toString()), argThat(WAIT_MATCHER), eq(null))) .thenReturn(buildErrorResultMap()); try { journalWaitDelegator.journalWait(null); } catch (RequestException e) { assertTrue(e.getMessage().startsWith(ERROR)); } }