JobDelegator extends BaseDelegator implements IJobDelegator { @Override public String updateJob(@Nonnull final IJob job) throws ConnectionException, RequestException, AccessException { Validate.notNull(job); List<Map<String, Object>> resultMaps = execMapCmdList(JOB, new String[] { "-i" }, job.getRawFields()); return ResultMapParser.parseCommandResultMapIfIsInfoMessageAsString(resultMaps); } JobDelegator(final IOptionsServer server); @Override IJob createJob(@Nonnull final Map<String, Object> fieldMap); @Override String deleteJob(final String jobId); @SuppressWarnings("unchecked") @Override IJob getJob(final String jobId); @Override String updateJob(@Nonnull final IJob job);  }
@Test(expected = AccessException.class) public void testJobUpdateAccessException() throws P4JavaException { when(server.execMapCmdList(eq(JOB.toString()), argThat(UPDATE_MATCHER), eq(UPDATE_FIELD_MAP))).thenThrow(AccessException.AccessExceptionForTests.class); jobDelegator.updateJob(updateJob); }
@Test(expected = NullPointerException.class) public void testJobUpdateNull() throws P4JavaException { jobDelegator.updateJob(null); }
@Test(expected = ConnectionException.class) public void testJobUpdateConnectionException() throws P4JavaException { when(server.execMapCmdList(eq(JOB.toString()), argThat(UPDATE_MATCHER), eq(UPDATE_FIELD_MAP))).thenThrow(ConnectionException.class); jobDelegator.updateJob(updateJob); }
@Test(expected = AccessException.class) public void testJobUpdateAccessException() throws P4JavaException { when(server.execMapCmdList(eq(JOB.toString()), argThat(UPDATE_MATCHER), eq(UPDATE_FIELD_MAP))).thenThrow(AccessException.class); jobDelegator.updateJob(updateJob); }
@Test(expected = RequestException.class) public void testJobUpdateRequestException() throws P4JavaException { when(server.execMapCmdList(eq(JOB.toString()), argThat(UPDATE_MATCHER), eq(UPDATE_FIELD_MAP))).thenThrow(RequestException.class); jobDelegator.updateJob(updateJob); }
@Test(expected = P4JavaException.class) public void testJobUpdateP4JavaException() throws P4JavaException { when(server.execMapCmdList(eq(JOB.toString()), argThat(UPDATE_MATCHER), eq(UPDATE_FIELD_MAP))).thenThrow(P4JavaException.class); jobDelegator.updateJob(updateJob); }