Package org.candlepin.pinsetter.core.model

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


    @Test
    public void cancel() {
        String jobid = newJobStatus().owner("ducks")
            .startTime(Util.yesterday()).create().getId();
        JobStatus job = curator.cancel(jobid);
        assertNotNull(job);
        assertEquals(jobid, job.getId());
        assertEquals(JobStatus.JobState.CANCELED, job.getState());
    }
View Full Code Here


        JobExecutionContext ctx = mock(JobExecutionContext.class);
        when(ctx.getFireTime()).thenReturn(new Date());
        when(ctx.getJobRunTime()).thenReturn(1000L);
        when(ctx.getResult()).thenReturn(longstr);

        JobStatus status = newJobStatus().owner("terps").create();
        status.update(ctx);
        curator.merge(status);
    }
View Full Code Here

     */
    @DELETE
    @Path("/{job_id}")
    @Produces(MediaType.APPLICATION_JSON)
    public JobStatus cancel(@PathParam("job_id") String jobId) {
        JobStatus j = curator.find(jobId);
        if (j.getState().equals(JobState.CANCELED)) {
            throw new BadRequestException(i18n.tr("job already canceled"));
        }
        if (j.isDone()) {
            throw new BadRequestException(i18n.tr("cannot cancel a job that " +
                "is in a finished state"));
        }
        return curator.cancel(jobId);
    }
View Full Code Here

     */
    @POST
    @Path("/{job_id}")
    @Produces(MediaType.APPLICATION_JSON)
    public JobStatus getStatusAndDeleteIfFinished(@PathParam("job_id") String jobId) {
        JobStatus status = curator.find(jobId);

        if (status != null && status.getState() == JobState.FINISHED) {
            curator.delete(status);
        }

        return status;
    }
View Full Code Here

    }

    @Test
    public void getStatusAndDeleteIfFinishedTest() {
        //nothing to delete..
        when(jobCurator.find("bogus_id")).thenReturn(new JobStatus());
        jobResource.getStatusAndDeleteIfFinished("foobar");
        verify(jobCurator, never()).delete(any(JobStatus.class));

        //now lets make a deletable JobStatus
        JobStatus finishedJobStatus = new JobStatus();
        finishedJobStatus.setState(JobState.FINISHED);
        when(jobCurator.find("deletable_id")).thenReturn(finishedJobStatus);
        jobResource.getStatusAndDeleteIfFinished("deletable_id");
        verify(jobCurator, atLeastOnce()).delete(finishedJobStatus);
    }
View Full Code Here

    }

    @Test
    public void cancelJob() {
        //we are just testing that the cancellation gets into the db
        JobStatus createdJobStatus = new JobStatus();
        createdJobStatus.setState(JobState.CREATED);
        JobStatus canceledJobStatus = new JobStatus();
        canceledJobStatus.setState(JobState.CANCELED);

        when(jobCurator.find("cancel_id")).thenReturn(createdJobStatus);
        when(jobCurator.cancel("cancel_id")).thenReturn(canceledJobStatus);
        jobResource.cancel("cancel_id");
        verify(jobCurator, atLeastOnce()).cancel("cancel_id");
View Full Code Here

    }

    @Test
    public void getStatusesByPrincipal() {
        List<JobStatus> statuses = new ArrayList<JobStatus>();
        JobStatus status = new JobStatus();
        statuses.add(status);
        when(jobCurator.findByPrincipalName(eq("admin"))).thenReturn(statuses);
        Collection<JobStatus> real = jobResource.getStatuses(null, null, "admin");
        assertNotNull(real);
        assertEquals(1, real.size());
View Full Code Here

    }

    @Test
    public void getStatusesByOwner() {
        List<JobStatus> statuses = new ArrayList<JobStatus>();
        JobStatus status = new JobStatus();
        statuses.add(status);
        when(jobCurator.findByOwnerKey(eq("admin"))).thenReturn(statuses);
        Collection<JobStatus> real = jobResource.getStatuses("admin", null, null);
        assertNotNull(real);
        assertEquals(1, real.size());
View Full Code Here

    }

    @Test
    public void getStatusesByUuid() {
        List<JobStatus> statuses = new ArrayList<JobStatus>();
        JobStatus status = new JobStatus();
        statuses.add(status);
        when(jobCurator.findByConsumerUuid(eq("abcd"))).thenReturn(statuses);
        Collection<JobStatus> real = jobResource.getStatuses(null, "abcd", null);
        assertNotNull(real);
        assertEquals(1, real.size());
View Full Code Here

    }

    @Test
    public void emptyStringIsAlsoValid() {
        List<JobStatus> statuses = new ArrayList<JobStatus>();
        JobStatus status = new JobStatus();
        statuses.add(status);
        when(jobCurator.findByPrincipalName(eq("foo"))).thenReturn(statuses);
        jobResource.getStatuses(null, "", "foo");
    }
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.