use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method ensureEventIsNotFiredWhenNoChangeWasMadeToConsumerGuestIds.
@Test
public void ensureEventIsNotFiredWhenNoChangeWasMadeToConsumerGuestIds() {
String uuid = "TEST_CONSUMER";
Consumer existing = createConsumerWithGuests(createOwner(), "Guest 1", "Guest 2");
existing.setUuid(uuid);
when(this.consumerCurator.verifyAndLookupConsumer(uuid)).thenReturn(existing);
ConsumerDTO updated = createConsumerDTOWithGuests("Guest 1", "Guest 2");
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 ConsumerResourceUpdateTest method throwsAnExceptionWhenEnvironmentNotFound.
@Test(expected = NotFoundException.class)
public void throwsAnExceptionWhenEnvironmentNotFound() {
String uuid = "A Consumer";
EnvironmentDTO changedEnvironment = new EnvironmentDTO().setId("42").setName("environment");
ConsumerDTO updated = new ConsumerDTO();
updated.setUuid(uuid);
updated.setEnvironment(changedEnvironment);
Consumer existing = getFakeConsumer();
existing.setUuid(updated.getUuid());
when(consumerCurator.verifyAndLookupConsumer(existing.getUuid())).thenReturn(existing);
when(environmentCurator.find(changedEnvironment.getId())).thenReturn(null);
resource.updateConsumer(existing.getUuid(), updated, principal);
}
use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method testUpdateConsumerUpdatesGuestIds.
@Test
public void testUpdateConsumerUpdatesGuestIds() {
String uuid = "TEST_CONSUMER";
String[] existingGuests = new String[] { "Guest 1", "Guest 2", "Guest 3" };
Consumer existing = createConsumerWithGuests(createOwner(), existingGuests);
existing.setUuid(uuid);
when(this.consumerCurator.verifyAndLookupConsumer(uuid)).thenReturn(existing);
ConsumerDTO updated = new ConsumerDTO();
updated.setUuid(uuid);
GuestIdDTO expectedGuestId = TestUtil.createGuestIdDTO("Guest 2");
updated.addGuestId(expectedGuestId);
when(this.consumerCurator.getGuestConsumersMap(any(String.class), any(Set.class))).thenReturn(new VirtConsumerMap());
this.resource.updateConsumer(existing.getUuid(), updated, principal);
assertEquals(1, existing.getGuestIds().size());
GuestId actualGID = existing.getGuestIds().iterator().next();
assertNotNull(actualGID);
assertEquals(actualGID.getGuestId(), expectedGuestId.getGuestId());
assertEquals(actualGID.getAttributes(), expectedGuestId.getAttributes());
}
use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method nullReleaseVer.
@Test
public void nullReleaseVer() {
ConsumerDTO consumer = getFakeConsumerDTO();
consumer.setReleaseVersion(null);
ConsumerDTO incoming = new ConsumerDTO();
incoming.setReleaseVersion("not null");
this.resource.updateConsumer(consumer.getUuid(), incoming, principal);
ConsumerDTO consumer2 = getFakeConsumerDTO();
consumer2.setReleaseVersion("foo");
ConsumerDTO incoming2 = new ConsumerDTO();
incoming2.setReleaseVersion(null);
this.resource.updateConsumer(consumer2.getUuid(), incoming2, principal);
}
use of org.candlepin.dto.manifest.v1.ConsumerDTO in project candlepin by candlepin.
the class ConsumerResourceUpdateTest method sameNameDoesntRegenIdCert.
@Test
public void sameNameDoesntRegenIdCert() {
ConsumerDTO consumer = getFakeConsumerDTO();
consumer.setName("old name");
ConsumerDTO updated = new ConsumerDTO();
updated.setName("old name");
resource.updateConsumer(consumer.getUuid(), updated, principal);
assertEquals(updated.getName(), consumer.getName());
assertNull(consumer.getIdCert());
}
Aggregations