@Override public int getJobProgress(int idJob) { return getJob(idJob).getProgress(); }
@Override public int getJobProgress(int idJob) { try { return getJob(idJob).getProgress(); } catch (BadRequestException e) { throw new JqmInvalidRequestException(e.getResponse().readEntity(String.class), e); } catch (Exception e) { throw new JqmClientException(e); } }
@Test public void testSendProgress() throws Exception { JqmSimpleTest.create(cnx, "pyl.EngineApiProgress").addWaitMargin(10000).run(this); List<JobInstance> res = Query.create().run(); Assert.assertEquals((Integer) 50, res.get(0).getProgress()); }
@Test public void testRunnableInject() throws Exception { JqmSimpleTest.create(cnx, "pyl.EngineApiInjectThread").expectOk(3).run(this); Assert.assertEquals(3, (int) cnx.runSelectSingle("message_select_count_all", Integer.class)); Assert.assertEquals(100, (int) Query.create().addSortAsc(Sort.ID).run().get(0).getProgress()); }
@Test public void testMainTypeInject() throws Exception { JqmSimpleTest.create(cnx, "pyl.EngineApiInject").setSessionId("123X").expectOk(3).run(this); Assert.assertEquals(3, (int) cnx.runSelectSingle("message_select_count_all", Integer.class)); Assert.assertEquals(100, (int) Query.create().run().get(0).getProgress()); }
@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 testDisabledPayload() throws Exception { int jd = CreationTools.createJobDef(null, true, "App", null, "jqm-tests/jqm-test-datetimemaven/target/test.jar", TestHelpers.qVip, 42, "MarsuApplication", null, "Franquin", "ModuleMachin", "other", "other", true, cnx); cnx.runUpdate("jd_update_set_enabled_by_id", false, jd); cnx.commit(); JobRequest.create("MarsuApplication", "TestUser").submit(); addAndStartEngine(); TestHelpers.waitFor(1, 10000, cnx); Assert.assertEquals(1, TestHelpers.getOkCount(cnx)); Assert.assertEquals(0, TestHelpers.getNonOkCount(cnx)); Assert.assertEquals(-1, (int) Query.create().run().get(0).getProgress()); }