use of org.candlepin.model.VirtConsumerMap 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.model.VirtConsumerMap in project candlepin by candlepin.
the class HypervisorUpdateJobTest method reporterIdOnCreateTest.
@Test
public void reporterIdOnCreateTest() throws JobExecutionException {
when(ownerCurator.lookupByKey(eq("joe"))).thenReturn(owner);
JobDetail detail = HypervisorUpdateJob.forOwner(owner, hypervisorJson, true, principal, "createReporterId");
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);
ArgumentCaptor<Consumer> argument = ArgumentCaptor.forClass(Consumer.class);
verify(consumerCurator).create(argument.capture(), eq(false));
assertEquals("createReporterId", argument.getValue().getHypervisorId().getReporterId());
}
use of org.candlepin.model.VirtConsumerMap in project candlepin by candlepin.
the class HypervisorUpdateJobTest method reporterIdOnUpdateTest.
@Test
public void reporterIdOnUpdateTest() throws JobExecutionException {
when(ownerCurator.lookupByKey(eq("joe"))).thenReturn(owner);
Consumer hypervisor = new Consumer();
String hypervisorId = "uuid_999";
hypervisor.setHypervisorId(new HypervisorId(hypervisorId));
VirtConsumerMap vcm = new VirtConsumerMap();
vcm.add(hypervisorId, hypervisor);
when(consumerCurator.getHostConsumersMap(eq(owner), any(Set.class))).thenReturn(vcm);
JobDetail detail = HypervisorUpdateJob.forOwner(owner, hypervisorJson, true, principal, "updateReporterId");
JobExecutionContext ctx = mock(JobExecutionContext.class);
when(ctx.getMergedJobDataMap()).thenReturn(detail.getJobDataMap());
HypervisorUpdateJob job = new HypervisorUpdateJob(ownerCurator, consumerCurator, consumerTypeCurator, consumerResource, i18n, subAdapter, complianceRules);
injector.injectMembers(job);
job.execute(ctx);
assertEquals("updateReporterId", hypervisor.getHypervisorId().getReporterId());
}
Aggregations