use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method testUpdateConsumerClearsGuestListWhenRequestGuestListIsEmptyButNotNull.
@Test
public void testUpdateConsumerClearsGuestListWhenRequestGuestListIsEmptyButNotNull() {
String uuid = "TEST_CONSUMER";
String[] guests = new String[] { "Guest 1", "Guest 2" };
Consumer existing = createConsumerWithGuests(createOwner(), guests);
existing.setUuid(uuid);
when(this.consumerCurator.verifyAndLookupConsumer(uuid)).thenReturn(existing);
ConsumerDTO updated = new ConsumerDTO();
updated.setGuestIds(new ArrayList<>());
this.resource.updateConsumer(existing.getUuid(), updated, principal);
assertTrue(existing.getGuestIds().isEmpty());
}
use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method consumerCapabilityUpdate.
@Test
public void consumerCapabilityUpdate() {
ConsumerType ct = new ConsumerType(ConsumerType.ConsumerTypeEnum.CANDLEPIN);
this.mockConsumerType(ct);
Consumer c = getFakeConsumer();
Set<ConsumerCapability> caps = new HashSet<>();
ConsumerCapability cca = new ConsumerCapability(c, "capability_a");
ConsumerCapability ccb = new ConsumerCapability(c, "capability_b");
ConsumerCapability ccc = new ConsumerCapability(c, "capability_c");
caps.add(cca);
caps.add(ccb);
caps.add(ccc);
c.setCapabilities(caps);
c.setType(ct);
assertEquals(3, c.getCapabilities().size());
// no capability list in update object does not change existing
// also shows that setCapabilites can accept null and not error
ConsumerDTO updated = new ConsumerDTO();
updated.setCapabilities(null);
resource.updateConsumer(c.getUuid(), updated, principal);
assertEquals(3, c.getCapabilities().size());
// empty capability list in update object does change existing
updated = new ConsumerDTO();
updated.setCapabilities(new HashSet<>());
resource.updateConsumer(c.getUuid(), updated, principal);
assertEquals(0, c.getCapabilities().size());
}
use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method nothingChanged.
@Test
public void nothingChanged() throws Exception {
ConsumerDTO consumer = getFakeConsumerDTO();
this.resource.updateConsumer(consumer.getUuid(), consumer, principal);
verify(sink, never()).queueEvent((Event) any());
}
use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method testUpdatesOnContentTagChanges.
@Test
public void testUpdatesOnContentTagChanges() {
HashSet<String> originalTags = new HashSet<>(Arrays.asList(new String[] { "hello", "world" }));
HashSet<String> changedTags = new HashSet<>(Arrays.asList(new String[] { "x", "y" }));
ConsumerDTO c = getFakeConsumerDTO();
c.setContentTags(originalTags);
ConsumerDTO incoming = new ConsumerDTO();
incoming.setContentTags(changedTags);
ArgumentCaptor<Consumer> consumerCaptor = ArgumentCaptor.forClass(Consumer.class);
resource.updateConsumer(c.getUuid(), incoming, principal);
verify(consumerCurator, times(1)).update(consumerCaptor.capture());
Consumer mergedConsumer = consumerCaptor.getValue();
assertEquals(changedTags, mergedConsumer.getContentTags());
}
Aggregations