use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method updatingToNullNameIgnoresName.
@Test
public void updatingToNullNameIgnoresName() {
ConsumerDTO consumer = getFakeConsumerDTO();
consumer.setName("old name");
ConsumerDTO updated = new ConsumerDTO();
updated.setName(null);
resource.updateConsumer(consumer.getUuid(), updated, principal);
assertEquals("old name", consumer.getName());
}
use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method guestEntitlementsNotRemovedIfEntitlementIsVirtOnlyButRequiresHostNotSet.
@Test
public void guestEntitlementsNotRemovedIfEntitlementIsVirtOnlyButRequiresHostNotSet() {
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 1");
updatedHost.setUuid(uuid);
Entitlement entitlement = TestUtil.createEntitlement();
entitlement.getPool().setAttribute(Product.Attributes.VIRT_ONLY, "1");
Consumer guest1 = new Consumer();
guest1.setUuid("Guest 1");
guest1.addEntitlement(entitlement);
guest1.setAutoheal(true);
when(this.consumerCurator.getGuestConsumersMap(any(String.class), any(Set.class))).thenReturn(mockVirtConsumerMap("Guest 1", guest1));
when(this.consumerCurator.find(eq(guest1.getId()))).thenReturn(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 updatingToInvalidCharacterNameNotAllowed.
@Test(expected = BadRequestException.class)
public void updatingToInvalidCharacterNameNotAllowed() {
ConsumerDTO consumer = getFakeConsumerDTO();
consumer.setName("old name");
ConsumerDTO updated = new ConsumerDTO();
updated.setName("#a name");
resource.updateConsumer(consumer.getUuid(), updated, principal);
}
use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method ensureEventIsNotFiredWhenGuestIDCaseChanges.
@Test
public void ensureEventIsNotFiredWhenGuestIDCaseChanges() {
String uuid = "TEST_CONSUMER";
Consumer existing = createConsumerWithGuests(createOwner(), "aaa123", "bbb123");
existing.setUuid(uuid);
when(this.consumerCurator.verifyAndLookupConsumer(uuid)).thenReturn(existing);
// flip case on one ID, should be treated as no change
ConsumerDTO updated = createConsumerDTOWithGuests("aaa123", "BBB123");
updated.setUuid(uuid);
when(this.consumerCurator.getGuestConsumersMap(any(String.class), any(Set.class))).thenReturn(new VirtConsumerMap());
this.resource.updateConsumer(existing.getUuid(), updated, principal);
verify(sink, never()).queueEvent(any(Event.class));
}
use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceTest method testFetchAllConsumersForOwner.
public void testFetchAllConsumersForOwner() {
ConsumerResource cr = new ConsumerResource(mockConsumerCurator, mockConsumerTypeCurator, null, null, null, null, null, null, i18n, null, null, null, null, null, null, null, mockOwnerCurator, null, null, null, null, null, null, this.config, null, null, null, null, null, null, this.factValidator, null, consumerEnricher, migrationProvider, translator);
ArrayList<Consumer> consumers = new ArrayList<>();
CandlepinQuery cqmock = mock(CandlepinQuery.class);
when(cqmock.list()).thenReturn(consumers);
when(cqmock.iterator()).thenReturn(consumers.iterator());
when(mockOwnerCurator.lookupByKey(eq("taylorOwner"))).thenReturn(new Owner());
when(mockConsumerCurator.searchOwnerConsumers(any(Owner.class), anyString(), (java.util.Collection<ConsumerType>) any(Collection.class), any(List.class), any(List.class), any(List.class), any(List.class), any(List.class), any(List.class))).thenReturn(cqmock);
List<ConsumerDTO> result = cr.list(null, null, "taylorOwner", null, null, null, null).list();
assertEquals(consumers, result);
}
Aggregations