use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceIntegrationTest method testCreateConsumerVsDefaultServiceLevelForOwner.
@Test
@SuppressWarnings("checkstyle:indentation")
public void testCreateConsumerVsDefaultServiceLevelForOwner() {
ConsumerDTO toSubmit = createConsumerDTO(CONSUMER_NAME, USER_NAME, null, standardSystemTypeDTO);
ConsumerDTO submitted = consumerResource.create(toSubmit, new UserPrincipal(someuser.getUsername(), Arrays.asList(new Permission[] { new OwnerPermission(owner, Access.ALL) }), false), someuser.getUsername(), owner.getKey(), null, true);
assertEquals(DEFAULT_SERVICE_LEVEL, submitted.getServiceLevel());
}
use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceIntegrationTest method onlyOnePersonalConsumer.
@Test(expected = BadRequestException.class)
public void onlyOnePersonalConsumer() {
ConsumerDTO personal = createConsumerDTO(personTypeDTO, ownerDTO);
consumerResource.create(personal, principal, null, null, null, true);
personal = createConsumerDTO(personTypeDTO, ownerDTO);
consumerResource.create(personal, principal, null, null, null, true);
}
use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceIntegrationTest method testCreateConsumer.
@Test
@SuppressWarnings("checkstyle:indentation")
public void testCreateConsumer() {
ConsumerDTO toSubmit = createConsumerDTO(CONSUMER_NAME, USER_NAME, null, standardSystemTypeDTO);
toSubmit.setFact(METADATA_NAME, METADATA_VALUE);
ConsumerDTO submitted = consumerResource.create(toSubmit, new UserPrincipal(someuser.getUsername(), Arrays.asList(new Permission[] { new OwnerPermission(owner, Access.ALL) }), false), someuser.getUsername(), owner.getKey(), null, true);
assertNotNull(submitted);
assertNotNull(consumerCurator.find(submitted.getId()));
assertEquals(standardSystemType.getLabel(), submitted.getType().getLabel());
assertEquals(METADATA_VALUE, submitted.getFact(METADATA_NAME));
}
use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method ensureGuestEntitlementsAreNotRevokedWhenGuestIsRemovedFromHost.
@Test
public void ensureGuestEntitlementsAreNotRevokedWhenGuestIsRemovedFromHost() {
String uuid = "TEST_CONSUMER";
Consumer host = createConsumerWithGuests(createOwner(), "Guest 1", "Guest 2");
host.setUuid(uuid);
when(this.consumerCurator.verifyAndLookupConsumer(uuid)).thenReturn(host);
ConsumerDTO updatedHost = createConsumerDTOWithGuests("Guest 2");
updatedHost.setUuid(uuid);
Entitlement entitlement = TestUtil.createEntitlement();
entitlement.getPool().setAttribute(Product.Attributes.VIRT_ONLY, "1");
entitlement.getPool().setAttribute(Pool.Attributes.REQUIRES_HOST, uuid);
Consumer guest1 = new Consumer();
guest1.setUuid("Guest 1");
guest1.addEntitlement(entitlement);
when(this.consumerCurator.getGuestConsumersMap(any(String.class), any(Set.class))).thenReturn(mockVirtConsumerMap("Guest 1", guest1));
this.resource.updateConsumer(host.getUuid(), updatedHost, principal);
// verify(consumerCurator).findByVirtUuid(eq("Guest 1"));
verify(poolManager, never()).revokeEntitlement(eq(entitlement));
}
use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method setStatusOnUpdate.
@Test
public void setStatusOnUpdate() throws Exception {
Product productA = TestUtil.createProduct("Product A");
Product productB = TestUtil.createProduct("Product B");
Product productC = TestUtil.createProduct("Product C");
Consumer consumer = getFakeConsumer();
consumer.addInstalledProduct(new ConsumerInstalledProduct(consumer, productA));
consumer.addInstalledProduct(new ConsumerInstalledProduct(consumer, productB));
ConsumerDTO incoming = new ConsumerDTO();
incoming.addInstalledProduct(new ConsumerInstalledProductDTO(productB.getId(), productB.getName()));
incoming.addInstalledProduct(new ConsumerInstalledProductDTO(productC.getId(), productC.getName()));
this.resource.updateConsumer(consumer.getUuid(), incoming, principal);
verify(sink).queueEvent((Event) any());
verify(complianceRules).getStatus(eq(consumer), any(Date.class), any(Boolean.class), any(Boolean.class));
}
Aggregations