Package org.candlepin.pinsetter.core.model

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


        JobDetail detail = mock(JobDetail.class);
        when(detail.getKey()).thenReturn(jobKey("name", "group"));
        when(detail.getJobDataMap()).thenReturn(map);

        JobStatus status = new JobStatus(detail);

        // store a merge so we can find it in the test run
        curator.merge(status);

        JobExecutionContext ctx = mock(JobExecutionContext.class);
        when(ctx.getMergedJobDataMap()).thenReturn(map);
        when(ctx.getJobDetail()).thenReturn(detail);

        // thing to be tested
        listener.jobWasExecuted(ctx, e);

        // verify the message stored is a substring of the long message
        JobStatus verify = curator.find("name");
        assertEquals(longstr.substring(0, JobStatus.RESULT_COL_LENGTH),
            verify.getResult());
    }
View Full Code Here


    @Test
    public void tobeExecuted() {
        Principal principal = mock(Principal.class);
        JobDataMap map = new JobDataMap();
        JobDetail detail = mock(JobDetail.class);
        JobStatus status = mock(JobStatus.class);

        map.put(PinsetterJobListener.PRINCIPAL_KEY, principal);

        when(ctx.getMergedJobDataMap()).thenReturn(map);
        when(detail.getKey()).thenReturn(jobKey("foo"));
View Full Code Here

    }

    @Test
    public void executed() {
        JobDetail detail = mock(JobDetail.class);
        JobStatus status = mock(JobStatus.class);

        when(detail.getKey()).thenReturn(jobKey("foo"));
        when(ctx.getJobDetail()).thenReturn(detail);
        when(jcurator.find(eq("foo"))).thenReturn(status);
View Full Code Here

    @Test
    public void executedNullStatus() {
        JobExecutionException e = mock(JobExecutionException.class);
        JobDetail detail = mock(JobDetail.class);
        JobStatus status = mock(JobStatus.class);

        when(detail.getKey()).thenReturn(jobKey("foo"));
        when(ctx.getJobDetail()).thenReturn(detail);
        when(jcurator.find(eq("foo"))).thenReturn(null);
View Full Code Here

    @Test
    public void tobeExecutedNull() {
        Principal principal = mock(Principal.class);
        JobDataMap map = new JobDataMap();
        JobDetail detail = mock(JobDetail.class);
        JobStatus status = mock(JobStatus.class);

        map.put(PinsetterJobListener.PRINCIPAL_KEY, principal);

        when(ctx.getMergedJobDataMap()).thenReturn(map);
        when(detail.getKey()).thenReturn(jobKey("foo"));
View Full Code Here

        verify(jcurator, never()).merge(eq(status));
    }

    @Test
    public void handleNullException() {
        JobStatus status = mock(JobStatus.class);
        JobDetail detail = mock(JobDetail.class);

        when(detail.getKey()).thenReturn(jobKey("foo"));
        when(ctx.getJobDetail()).thenReturn(detail);
        when(jcurator.find(eq("foo"))).thenReturn(status);
View Full Code Here

    @Test
    public void handleException() {
        JobExecutionException e = mock(JobExecutionException.class);
        JobDetail detail = mock(JobDetail.class);
        JobStatus status = mock(JobStatus.class);

        when(detail.getKey()).thenReturn(jobKey("foo"));
        when(ctx.getJobDetail()).thenReturn(detail);
        when(jcurator.find(eq("foo"))).thenReturn(status);
        when(e.getMessage()).thenReturn("job errored");
View Full Code Here

    @Test
    public void ensureProperLengthOfResult() {
        JobExecutionException e = mock(JobExecutionException.class);
        JobDetail detail = mock(JobDetail.class);
        JobStatus status = mock(JobStatus.class);

        when(detail.getKey()).thenReturn(jobKey("foo"));
        when(ctx.getJobDetail()).thenReturn(detail);
        when(jcurator.find(eq("foo"))).thenReturn(status);
        String longstr = RandomStringUtils.randomAlphanumeric(
View Full Code Here

        when(detail.getKey()).thenReturn(jobKey("name", "group"));
        when(detail.getJobDataMap()).thenReturn(map);
        when(ctx.getJobDetail()).thenReturn(detail);

        JobStatus status = new JobStatus(detail);
        when(jcurator.find(eq("name"))).thenReturn(status);

        String longstr = RandomStringUtils.randomAlphanumeric(300);
        when(e.getMessage()).thenReturn(longstr);

        listener.jobWasExecuted(ctx, e);

        assertEquals(longstr.substring(0, JobStatus.RESULT_COL_LENGTH), status.getResult());
        assertEquals(JobState.FAILED, status.getState());
        verify(jcurator).merge(eq(status));
    }
View Full Code Here

        assertEquals(0, this.curator.listAll().size());
    }

    @Test
    public void findByPrincipalName() {
        JobStatus job = newJobStatus().principalName("donald").owner("ducks").create();
        List<JobStatus> jobs = this.curator.findByPrincipalName("donald");
        assertNotNull(jobs);
        assertEquals("donald", job.getPrincipalName());
        assertEquals(job, jobs.get(0));
    }
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.