Package org.qzerver.model.domain.entities.job

Examples of org.qzerver.model.domain.entities.job.ScheduleGroup


    @Test
    public void testGroups() {
        // Create group

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        entityManager.flush();
        entityManager.clear();

        ScheduleGroup scheduleGroupModified;

        scheduleGroupModified = scheduleJobManagementService.findGroup(scheduleGroup.getId());
        Assert.assertNotNull(scheduleGroupModified);
        Assert.assertEquals(scheduleGroup, scheduleGroupModified);

        List<ScheduleGroup> scheduleGroups = scheduleJobManagementService.findAllGroups(Extraction.ALL);
        Assert.assertNotNull(scheduleGroups);
        Assert.assertTrue(scheduleGroups.size() > 0);
        Assert.assertTrue(Iterators.contains(scheduleGroups.iterator(), scheduleGroupModified));

        // Modify group

        scheduleGroupModified = scheduleJobManagementService.modifyGroup(scheduleGroup.getId(), "Name 2");
        Assert.assertNotNull(scheduleGroupModified);

        entityManager.flush();
        entityManager.clear();

        scheduleGroupModified = scheduleJobManagementService.findGroup(scheduleGroup.getId());
        Assert.assertNotNull(scheduleGroupModified);
        Assert.assertEquals("Name 2", scheduleGroupModified.getName());

        // Delete group

        scheduleJobManagementService.deleteGroup(scheduleGroup.getId());
View Full Code Here


    @Test
    public void testCreateJobWithoutCluster() throws Exception {
        String cron = "0 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(null);
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

        ScheduleJob scheduleJob = scheduleJobManagementService.createJob(jobParameters);
View Full Code Here

    @Test
    public void testCreateJobWithCluster() throws Exception {
        String cron = "0 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode1 = new ClusterNode();
        clusterNode1.setAddress("10.2.0.1");
        clusterNode1.setDescription("test node");
        clusterNode1.setEnabled(true);
        clusterNode1.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode1);

        ClusterNode clusterNode2 = new ClusterNode();
        clusterNode2.setAddress("10.2.0.2");
        clusterNode2.setDescription("test node");
        clusterNode2.setEnabled(true);
        clusterNode2.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode2);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

        ScheduleJob scheduleJob = scheduleJobManagementService.createJob(jobParameters);
View Full Code Here

    @Test
    public void testDeleteJob() throws Exception {
        String cron = "0 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        Capture<Long> idCapture1 = new Capture<Long>(CaptureType.ALL);
        Capture<Long> idCapture2 = new Capture<Long>(CaptureType.ALL);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.capture(idCapture1),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        quartzManagementService.deleteJob(
            EasyMock.capture(idCapture2)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

        ScheduleJob scheduleJob = scheduleJobManagementService.createJob(jobParameters);
View Full Code Here

    @Test
    public void testModifyJob() throws Exception {
        String cron = "0 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

        ScheduleJob scheduleJob = scheduleJobManagementService.createJob(jobParameters);
View Full Code Here

    @Test
    public void testToggleJob() throws Exception {
        String cron = "0 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        Capture<Long> idCapture1 = new Capture<Long>(CaptureType.ALL);
        Capture<Long> idCapture2 = new Capture<Long>(CaptureType.ALL);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        quartzManagementService.disableJob(
            EasyMock.capture(idCapture1)
        );

        quartzManagementService.enableJob(
            EasyMock.capture(idCapture2),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

        ScheduleJob scheduleJob = scheduleJobManagementService.createJob(jobParameters);
View Full Code Here

    @Test
    public void testRescheduleActiveJob() throws Exception {
        String cron1 = "0 0 0 * * ?";
        String cron2 = "1 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        Capture<Long> idCapture = new Capture<Long>(CaptureType.ALL);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron1),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        quartzManagementService.rescheduleJob(
            EasyMock.capture(idCapture),
            EasyMock.eq(cron2),
            EasyMock.eq(DEFAULT_TIMEZONE)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron1);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

        ScheduleJob scheduleJob = scheduleJobManagementService.createJob(jobParameters);
View Full Code Here

    @Test
    public void testChangeJobActionTest() throws Exception {
        String cron = "0 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

        ScheduleJob scheduleJob = scheduleJobManagementService.createJob(jobParameters);
View Full Code Here

    @Test
    public void testChangeJobGroupTest() throws Exception {
        String cron = "0 0 0 * * ?";

        ScheduleGroup scheduleGroup1 = scheduleJobManagementService.createGroup("test group 1");
        Assert.assertNotNull(scheduleGroup1);

        ScheduleGroup scheduleGroup2 = scheduleJobManagementService.createGroup("test group 2");
        Assert.assertNotNull(scheduleGroup2);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup2.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

        ScheduleJob scheduleJob = scheduleJobManagementService.createJob(jobParameters);
        Assert.assertNotNull(scheduleJob);

        ScheduleAction currentScheduleAction = scheduleJob.getAction();
        Assert.assertNotNull(currentScheduleAction);
        Assert.assertEquals("action.type", currentScheduleAction.getIdentifier());
        Assert.assertTrue(Arrays.equals("action.data".getBytes(), currentScheduleAction.getDefinition()));
        Assert.assertFalse(currentScheduleAction.isArchived());

        ScheduleJob scheduleJobModified = scheduleJobManagementService.changeJobGroup(scheduleJob.getId(), scheduleGroup2.getId());
        Assert.assertNotNull(scheduleJobModified);

        control.verify();

        entityManager.flush();
        entityManager.clear();

        scheduleJobModified = scheduleJobManagementService.findJob(scheduleJob.getId());
        Assert.assertNotNull(scheduleJobModified);
        Assert.assertEquals("test group 2", scheduleJobModified.getGroup().getName());

        ScheduleGroup scheduleGroupModified = scheduleJobManagementService.findGroup(scheduleGroup1.getId());
        Assert.assertNotNull(scheduleGroupModified);
        Assert.assertEquals(0, scheduleGroupModified.getJobs().size());
    }
View Full Code Here

    @Test
    public void testReschedulePassiveJob() throws Exception {
        String cron1 = "0 0 0 * * ?";
        String cron2 = "1 0 0 * * ?";

        ScheduleGroup scheduleGroup = scheduleJobManagementService.createGroup("test group");
        Assert.assertNotNull(scheduleGroup);

        ClusterGroup clusterGroup = new ClusterGroup();
        clusterGroup.setName("Test cluster group");
        businessEntityDao.save(clusterGroup);

        ClusterNode clusterNode = new ClusterNode();
        clusterNode.setAddress("10.2.0.1");
        clusterNode.setDescription("test node");
        clusterNode.setEnabled(true);
        clusterNode.setGroup(clusterGroup);
        clusterGroup.getNodes().add(clusterNode);

        Capture<Long> idCapture = new Capture<Long>(CaptureType.ALL);

        control.reset();

        quartzManagementService.createJob(
            EasyMock.anyLong(),
            EasyMock.eq(cron1),
            EasyMock.eq(DEFAULT_TIMEZONE),
            EasyMock.eq(true)
        );

        quartzManagementService.disableJob(
            EasyMock.capture(idCapture)
        );

        control.replay();

        ScheduleJobCreateParameters jobParameters = new ScheduleJobCreateParameters();
        jobParameters.setName("Test Job");
        jobParameters.setDescription("Nothing to do");
        jobParameters.setTimezone(DEFAULT_TIMEZONE);
        jobParameters.setCron(cron1);
        jobParameters.setEnabled(true);
        jobParameters.setClusterGroupId(clusterGroup.getId());
        jobParameters.setScheduleGroupId(scheduleGroup.getId());
        jobParameters.setStrategy(ScheduleExecutionStrategy.CIRCULAR);
        jobParameters.setActionIdentifier("action.type");
        jobParameters.setActionDefinition("action.data".getBytes());

        ScheduleJob scheduleJob = scheduleJobManagementService.createJob(jobParameters);
View Full Code Here

TOP

Related Classes of org.qzerver.model.domain.entities.job.ScheduleGroup

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.