use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class JobStatusTest method knownPrincipalName.
@Test
public void knownPrincipalName() {
Principal p = mock(Principal.class);
when(p.getPrincipalName()).thenReturn("admin");
JobDetail detail = mock(JobDetail.class);
JobDataMap map = new JobDataMap();
map.put(PinsetterJobListener.PRINCIPAL_KEY, p);
when(detail.getKey()).thenReturn(JobKey.jobKey("name", "group"));
when(detail.getJobDataMap()).thenReturn(map);
status = new JobStatus(detail);
assertEquals("admin", status.getPrincipalName());
}
use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class HypervisorUpdateJobTest method hypervisorUpdateExecCreateNoHypervisorId.
@Test
public void hypervisorUpdateExecCreateNoHypervisorId() throws JobExecutionException {
when(ownerCurator.lookupByKey(eq("joe"))).thenReturn(owner);
hypervisorJson = "{\"hypervisors\":" + "[{" + "\"name\" : \"hypervisor_999\"," + "\"guestIds\" : [{\"guestId\" : \"guestId_1_999\"}]" + "}]}";
JobDetail detail = HypervisorUpdateJob.forOwner(owner, hypervisorJson, true, principal, null);
JobExecutionContext ctx = mock(JobExecutionContext.class);
when(ctx.getMergedJobDataMap()).thenReturn(detail.getJobDataMap());
when(consumerCurator.getHostConsumersMap(eq(owner), any(Set.class))).thenReturn(new VirtConsumerMap());
HypervisorUpdateJob job = new HypervisorUpdateJob(ownerCurator, consumerCurator, consumerTypeCurator, consumerResource, i18n, subAdapter, complianceRules);
injector.injectMembers(job);
job.execute(ctx);
verify(consumerResource, never()).createConsumerFromDTO(any(ConsumerDTO.class), any(ConsumerType.class), any(Principal.class), anyString(), anyString(), anyString(), eq(false));
}
use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class PinsetterJobListenerTest method tobeExecuted.
@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"));
when(ctx.getJobDetail()).thenReturn(detail);
when(jcurator.find(eq("foo"))).thenReturn(status);
listener.jobToBeExecuted(ctx);
verify(status).update(eq(ctx));
verify(jcurator).merge(eq(status));
}
use of org.candlepin.auth.Principal in project candlepin by candlepin.
the class PinsetterJobListenerTest method tobeExecutedNull.
@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"));
when(ctx.getJobDetail()).thenReturn(detail);
when(jcurator.find(eq("foo"))).thenReturn(null);
listener.jobToBeExecuted(ctx);
verifyZeroInteractions(status);
verify(jcurator, never()).merge(eq(status));
}
Aggregations