@Override public List<String> getJobMessages(int idJob) { return getJob(idJob).getMessages(); }
@Override public List<String> getJobMessages(int idJob) { try { return getJob(idJob).getMessages(); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Test public void testSendMsg() throws Exception { boolean success = false; boolean success2 = false; boolean success3 = false; int i = JqmSimpleTest.create(cnx, "pyl.EngineApiSend3Msg").run(this); List<String> messages = Query.create().setJobInstanceId(i).run().get(0).getMessages(); for (String msg : messages) { if (msg.equals("Les marsus sont nos amis, il faut les aimer aussi!")) { success = true; } if (msg.equals("Les marsus sont nos amis, il faut les aimer aussi!2")) { success2 = true; } if (msg.equals("Les marsus sont nos amis, il faut les aimer aussi!3")) { success3 = true; } } Assert.assertEquals(true, success); Assert.assertEquals(true, success2); Assert.assertEquals(true, success3); }
while (msg.next()) res.get(msg.getInt(2)).getMessages().add(msg.getString(3));
@Test public void testMainTypeInjectWithFullApi() throws Exception { // Here, engine API + full API mix. int i = JqmSimpleTest.create(cnx, "pyl.EngineApiInject", "jqm-test-pyl-hibapi").setSessionId("123X").expectOk(3).run(this); Assert.assertEquals(1, JqmClientFactory.getClient().getJob(i).getMessages().size()); // 1 message per run created by payload Assert.assertEquals(100, (int) JqmClientFactory.getClient().getJob(i).getProgress()); } }
@Test public void testRmParameterCleanup() throws Exception { // Single thread available. int qId = Queue.create(cnx, "testqueue", " ", false); DeploymentParameter.create(cnx, TestHelpers.node.getId(), 2, 1, qId); // 2 slots Map<String, String> prms = new HashMap<>(1); prms.put("com.enioka.jqm.rm.quantity.thread.consumption", "2"); prms.put("whatever", "value"); CreationTools.createJobDef(null, true, "pyl.MessagePerParameter", prms, "jqm-tests/jqm-test-pyl/target/test.jar", qId, 42, "jqm-test-kill", null, "Franquin", "ModuleMachin", "other", "other", false, cnx); cnx.commit(); int i1 = JobRequest.create("jqm-test-kill", "test").setPriority(null).submit(); addAndStartEngine(); TestHelpers.waitFor(1, 60000, cnx); // Check only one of the two JI has started (asking for total 3 slots, only 2 available) Assert.assertEquals(1, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getQueueRunningCount(cnx)); Assert.assertEquals(0, TestHelpers.getQueueAllCount(cnx)); // Check the parameter wazs removed by the RM JobInstance ji = JqmClientFactory.getClient().getJob(i1); Assert.assertEquals(1, ji.getMessages().size()); }