Package org.candlepin.pinsetter.core.model

Examples of org.candlepin.pinsetter.core.model.JobStatus


    public void unPauseTest() throws JobExecutionException, PinsetterException {
        JobDetail jd = newJob(KingpinJob.class)
            .withIdentity("Kayfabe", "Deluxe")
            .build();

        JobStatus js = new JobStatus(jd, true);
        List<JobStatus> jl = new ArrayList<JobStatus>();
        jl.add(js);
        when(j.findWaitingJobs()).thenReturn(jl);
        unpauseJob.execute(ctx);
        try {
View Full Code Here


    }

    @Test
    public void jobStatusSet() throws PinsetterException {
        JobDetail detail = newJob().build();
        JobStatus status = new JobStatus();

        when(response.getEntity()).thenReturn(detail);
        when(this.pinsetterKernel.scheduleSingleJob(detail)).thenReturn(status);

        this.interceptor.postProcess(response);
View Full Code Here

        if (entity instanceof JobDetail) {
            JobDetail jobDetail = (JobDetail) entity;
            setJobPrincipal(jobDetail);

            JobStatus status = this.scheduleJob(jobDetail);
            response.setEntity(status);
            response.setStatus(HttpResponseCodes.SC_ACCEPTED);
        }
        else if (entity instanceof JobDetail[]) {
            JobDetail[] details = (JobDetail[]) entity;
            JobStatus[] statuses = new JobStatus[details.length];

            int i = 0;
            for (JobDetail jobDetail : details) {
                setJobPrincipal(jobDetail);
                JobStatus status = this.scheduleJob(jobDetail);
                statuses[i++] = status;
            }

            response.setEntity(statuses);
            response.setStatus(HttpResponseCodes.SC_ACCEPTED);
View Full Code Here

        curator.merge(status);
    }

    @Test
    public void findWaitingJobsTest() {
        JobStatus waitingJob1 = newJobStatus().state(JobStatus.JobState.WAITING)
            .startTime(Util.yesterday()).create();
        JobStatus waitingJob2 = newJobStatus().state(JobStatus.JobState.WAITING)
            .startTime(Util.yesterday()).create();
        JobStatus createdJob = newJobStatus().state(JobStatus.JobState.CREATED)
            .startTime(Util.yesterday()).create();
        JobStatus finishedJob = newJobStatus().state(JobStatus.JobState.FINISHED)
            .startTime(Util.yesterday()).create();
        List<JobStatus> waitingList = curator.findWaitingJobs();
        assertTrue(waitingList.contains(waitingJob1));
        assertTrue(waitingList.contains(waitingJob2));
        assertFalse(waitingList.contains(createdJob));
View Full Code Here

            .owner("my_owner")
            .jobClass(HealEntireOrgJob.class).create();
        newJobStatus().state(JobStatus.JobState.RUNNING)
            .owner("my_owner")
            .jobClass(HealEntireOrgJob.class).create();
        JobStatus expected = newJobStatus().state(JobStatus.JobState.CREATED)
            .jobClass(HealEntireOrgJob.class)
            .owner("my_owner").create();

        // Would be chosen if the job class was correct
        newJobStatus().state(JobStatus.JobState.WAITING)
            .owner("my_owner")
            .jobClass(RefreshPoolsJob.class).create();
        // Would be chosen if the owner was correct
        newJobStatus().state(JobStatus.JobState.WAITING)
            .owner("some_owner")
            .jobClass(HealEntireOrgJob.class).create();
        // Would be chosen if the jobstate wasn't done
        newJobStatus().state(JobStatus.JobState.FINISHED)
            .jobClass(HealEntireOrgJob.class)
            .owner("my_owner").create();
        JobStatus result = curator.getByClassAndOwner("my_owner",
            HealEntireOrgJob.class);
        assertEquals(expected, result);
    }
View Full Code Here

        assertEquals(expected, result);
    }

    @Test
    public void cancelOrphanedJobs() throws InterruptedException {
        JobStatus status1 = newJobStatus().state(JobStatus.JobState.WAITING)
            .id("1").create();
        JobStatus status2 = newJobStatus().state(JobStatus.JobState.WAITING)
            .id("2").create();
        JobStatus status3 = newJobStatus().state(JobStatus.JobState.RUNNING)
            .id("3").create();
        JobStatus status4 = newJobStatus().state(JobStatus.JobState.CREATED)
            .id("4").create();
        JobStatus status5 = newJobStatus().state(JobStatus.JobState.RUNNING)
            .id("5").create();
        List<String> activeIds = new LinkedList<String>();
        activeIds.add(status1.getId());
        activeIds.add(status3.getId());
        activeIds.add(status4.getId());
        int updated = curator.cancelOrphanedJobs(activeIds, 0L);
        assertEquals(2, updated);
        curator.refresh(status1);
        curator.refresh(status2);
        curator.refresh(status3);
        curator.refresh(status4);
        curator.refresh(status5);
        assertEquals(JobStatus.JobState.WAITING, status1.getState());
        assertEquals(JobStatus.JobState.CANCELED, status2.getState());
        assertEquals(JobStatus.JobState.RUNNING, status3.getState());
        assertEquals(JobStatus.JobState.CREATED, status4.getState());
        assertEquals(JobStatus.JobState.CANCELED, status5.getState());
    }
View Full Code Here

            when(p.getPrincipalName()).thenReturn(principalName);

            map.put(PinsetterJobListener.PRINCIPAL_KEY, p);
            map.put(JobStatus.TARGET_TYPE, JobStatus.TargetType.OWNER);
            map.put(JobStatus.TARGET_ID, ownerkey);
            JobStatus status = new JobStatus(
                newJob(jobClass).withIdentity(id, PinsetterKernel.SINGLE_JOB_GROUP)
                .usingJobData(map).build());
            JobExecutionContext context = mock(JobExecutionContext.class);
            when(context.getFireTime()).thenReturn(startDt);
            long time = -1;
            if (endDt != null && startDt != null) {
                time = endDt.getTime() - startDt.getTime();
            }
            when(context.getJobRunTime()).thenReturn(time);
            when(context.getResult()).thenReturn(result);
            status.update(context);
            if (state != null) {
                status.setState(state);
            }
            return curator.create(status);
        }
View Full Code Here

        pk = new PinsetterKernel(config, jfactory, jlistener, jcurator, sfactory);
        pk.startup();
        verify(sched).start();
        ArgumentCaptor<JobStatus> arg = ArgumentCaptor.forClass(JobStatus.class);
        verify(jcurator, atMost(1)).create(arg.capture());
        JobStatus stat = arg.getValue();
        assertTrue(stat.getId().startsWith(Util.getClassName(CancelJobJob.class)));
        verify(sched, atMost(1)).scheduleJob(any(JobDetail.class), any(Trigger.class));
    }
View Full Code Here

    }

    @Test
    public void handleExistingJobStatus() throws Exception {
        pk = new PinsetterKernel(config, jfactory, jlistener, jcurator, sfactory);
        JobStatus status = mock(JobStatus.class);
        when(jcurator.find(startsWith(
            Util.getClassName(JobCleaner.class)))).thenReturn(status);
        when(jcurator.create(any(JobStatus.class))).thenThrow(new EntityExistsException());
        pk.startup();
        verify(sched).start();
View Full Code Here

    public void cancelTest() throws JobExecutionException, PinsetterException {
        JobDetail jd = newJob(Job.class)
            .withIdentity("Kayfabe", "Deluxe")
            .build();

        JobStatus js = new JobStatus(jd);
        List<JobStatus> jl = new ArrayList<JobStatus>();
        jl.add(js);
        when(j.findCanceledJobs(any(Set.class))).thenReturn(jl);
        cancelJobJob.execute(ctx);
        verify(pk, atLeastOnce()).cancelJob((Serializable) "Kayfabe", "Deluxe");
View Full Code Here

TOP

Related Classes of org.candlepin.pinsetter.core.model.JobStatus

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.