.thenReturn(consumerEventBuilder);
}
@Test
public void hypervisorCheckInCreatesNewConsumer() throws Exception {
Owner owner = new Owner("admin");
Map<String, List<GuestId>> hostGuestMap = new HashMap<String, List<GuestId>>();
hostGuestMap.put("test-host", Arrays.asList(new GuestId("GUEST_A"),
new GuestId("GUEST_B")));
when(ownerCurator.lookupByKey(eq(owner.getKey()))).thenReturn(owner);
when(consumerCurator.getHypervisor(eq("test-host"), eq(owner))).thenReturn(null);
when(ownerCurator.lookupByKey(eq(owner.getKey()))).thenReturn(owner);
when(principal.canAccess(eq(owner), eq(SubResource.CONSUMERS), eq(Access.CREATE))).
thenReturn(true);
when(consumerTypeCurator.lookupByLabel(
eq(ConsumerTypeEnum.HYPERVISOR.getLabel()))).thenReturn(hypervisorType);
when(idCertService.generateIdentityCert(any(Consumer.class)))
.thenReturn(new IdentityCertificate());
HypervisorCheckInResult result = hypervisorResource.hypervisorCheckIn(hostGuestMap,
principal, owner.getKey(), true);
Set<Consumer> created = result.getCreated();
assertEquals(1, created.size());
Consumer c1 = created.iterator().next();