use of org.candlepin.pinsetter.core.model.JobStatus in project candlepin by candlepin.
the class PinsetterJobListenerTest method handleException.
@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");
listener.jobWasExecuted(ctx, e);
verify(status).setState(eq(JobState.FAILED));
verify(status).setResult(eq("job errored"));
verify(status, never()).update(eq(ctx));
verify(jcurator).merge(eq(status));
}
use of org.candlepin.pinsetter.core.model.JobStatus in project candlepin by candlepin.
the class PinsetterTriggerListenerTest method triggerMisfireDontRunAgain.
@Test
public void triggerMisfireDontRunAgain() {
PinsetterTriggerListener ptl = new PinsetterTriggerListener(modeManager, jobCurator);
Trigger trigger = mock(Trigger.class);
JobStatus jobStatus = new JobStatus();
JobKey jobKey = new JobKey("mockName");
when(trigger.mayFireAgain()).thenReturn(false);
when(trigger.getJobKey()).thenReturn(jobKey);
when(jobCurator.find(Matchers.anyString())).thenReturn(jobStatus);
ptl.triggerMisfired(trigger);
assert (jobStatus.getResult().startsWith("Failed run. Will not attempt again."));
assert (jobStatus.getState().equals(JobStatus.JobState.FAILED));
}
use of org.candlepin.pinsetter.core.model.JobStatus in project candlepin by candlepin.
the class JobCuratorTest method correlationIdOnStatus.
@Test
public void correlationIdOnStatus() {
JobStatus job = newJobStatus().principalName("donald").owner("ducks").create();
assertEquals("test-csid", job.getCorrelationId());
}
use of org.candlepin.pinsetter.core.model.JobStatus in project candlepin by candlepin.
the class JobCuratorTest method findByConsumerUuidRestrictsByOwnerWhenRequestedByBasicUser.
@Test
public void findByConsumerUuidRestrictsByOwnerWhenRequestedByBasicUser() {
newJobStatus().principalName("p1").consumer("c1", "owner1").create();
newJobStatus().principalName("p4").owner("owner2").create();
JobStatus job = newJobStatus().principalName("p3").consumer("c2", "owner1").create();
// Technically this case should not happen since a consumer
// can belong to one org, but adding just to make sure that
// it gets filtered.
newJobStatus().principalName("p2").consumer("c2", "owner2").create();
setupPrincipal("goofy", new Owner("owner1"), Access.READ_ONLY);
List<JobStatus> found = curator.findByConsumerUuid("c2").list();
assertEquals(1, found.size());
assertEquals(job, found.get(0));
}
use of org.candlepin.pinsetter.core.model.JobStatus in project candlepin by candlepin.
the class JobCuratorTest method findByUserFiltersByOwnerAccessAndUUIDWhenRequestedByConsumer.
@Test
public void findByUserFiltersByOwnerAccessAndUUIDWhenRequestedByConsumer() {
Owner owner = new Owner("testowner");
owner.setId(TestUtil.randomString());
Consumer consumer = TestUtil.createConsumer(owner);
JobStatus job = newJobStatus().principalName(consumer.getUuid()).owner(owner.getKey()).create();
newJobStatus().principalName("p1").owner("owner1").create();
newJobStatus().principalName("p2").owner("owner1").create();
newJobStatus().principalName("p3").owner("owner2").create();
setupPrincipal(new ConsumerPrincipal(consumer, owner));
assertTrue(this.curator.findByOwnerKey("owner1").list().isEmpty());
assertTrue(this.curator.findByOwnerKey("owner2").list().isEmpty());
List<JobStatus> found = this.curator.findByOwnerKey("testowner").list();
assertEquals(1, found.size());
assertEquals(job, found.get(0));
}
Aggregations