use of org.candlepin.dto.manifest.v1.ConsumerTypeDTO in project candlepin by candlepin.
the class ConsumerResourceTest method testValidateShareConsumerRequiresRecipientFact.
@Test
public void testValidateShareConsumerRequiresRecipientFact() {
ConsumerType share = this.mockConsumerType(new ConsumerType(ConsumerTypeEnum.SHARE));
ConsumerTypeDTO shareDto = this.translator.translate(share, ConsumerTypeDTO.class);
OwnerDTO ownerDto = new OwnerDTO().setDisplayName("Test Owner");
ConsumerDTO c = createConsumerDTO("test-consumer", "test-user", ownerDto, shareDto);
ConsumerResource consumerResource = new ConsumerResource(mockConsumerCurator, mockConsumerTypeCurator, null, null, null, mockEntitlementCurator, null, mockEntitlementCertServiceAdapter, i18n, null, null, null, null, null, mockPoolManager, null, mockOwnerCurator, null, null, null, null, null, null, new CandlepinCommonTestConfig(), null, null, null, consumerBindUtil, null, null, factValidator, null, consumerEnricher, migrationProvider, translator);
UserPrincipal uap = mock(UserPrincipal.class);
when(uap.canAccess(any(Object.class), any(SubResource.class), any(Access.class))).thenReturn(Boolean.TRUE);
Owner o = mock(Owner.class);
when(mockOwnerCurator.lookupByKey(any(String.class))).thenReturn(o);
c.setFact("foo", "bar");
thrown.expect(BadRequestException.class);
thrown.expectMessage("must specify a recipient org");
consumerResource.create(c, uap, "test-user", "test-owner", null, false);
}
use of org.candlepin.dto.manifest.v1.ConsumerTypeDTO in project candlepin by candlepin.
the class ConsumerImporterTest method importConsumerWithNullUuidOnOwnerShouldSetUuid.
@Test
public void importConsumerWithNullUuidOnOwnerShouldSetUuid() throws ImporterException {
OwnerDTO ownerDTO = mock(OwnerDTO.class);
Owner owner = mock(Owner.class);
ConsumerDTO consumer = mock(ConsumerDTO.class);
ConsumerTypeDTO type = mock(ConsumerTypeDTO.class);
when(ownerDTO.getId()).thenReturn("test-owner-id");
when(consumer.getUuid()).thenReturn("test-uuid");
when(consumer.getOwner()).thenReturn(ownerDTO);
when(consumer.getType()).thenReturn(type);
IdentityCertificate idCert = new IdentityCertificate();
idCert.setSerial(new CertificateSerial());
importer.store(owner, consumer, new ConflictOverrides(), idCert);
// now verify that the owner has the upstream consumer set
ArgumentCaptor<UpstreamConsumer> arg = ArgumentCaptor.forClass(UpstreamConsumer.class);
verify(owner).setUpstreamConsumer(arg.capture());
assertEquals("test-uuid", arg.getValue().getUuid());
verify(curator).merge(owner);
}
use of org.candlepin.dto.manifest.v1.ConsumerTypeDTO in project candlepin by candlepin.
the class ConsumerTypeResourceTest method testUpdateTypeWithNullId.
@Test(expected = NotFoundException.class)
public void testUpdateTypeWithNullId() {
ConsumerTypeDTO dto = new ConsumerTypeDTO();
dto.setId(null);
ConsumerTypeDTO output = this.consumerTypeResource.update(dto);
}
use of org.candlepin.dto.manifest.v1.ConsumerTypeDTO in project candlepin by candlepin.
the class ConsumerTypeResourceTest method testUpdateTypeWithBadId.
@Test(expected = NotFoundException.class)
public void testUpdateTypeWithBadId() {
ConsumerTypeDTO dto = new ConsumerTypeDTO();
dto.setId("some bad id");
ConsumerTypeDTO output = this.consumerTypeResource.update(dto);
}
use of org.candlepin.dto.manifest.v1.ConsumerTypeDTO in project candlepin by candlepin.
the class ConsumerTypeResourceTest method testUpdateTypeUpdatesManifestButNotLabel.
@Test
public void testUpdateTypeUpdatesManifestButNotLabel() {
String label = this.testType.getLabel();
boolean manifest = !this.testType.isManifest();
ConsumerTypeDTO dto = new ConsumerTypeDTO();
dto.setId(this.testType.getId());
dto.setManifest(manifest);
// Update the type with our DTO
ConsumerTypeDTO output = this.consumerTypeResource.update(dto);
assertNotNull(output);
assertEquals(label, output.getLabel());
assertEquals(dto.isManifest(), output.isManifest());
// Flush & clear DB state
this.consumerTypeCurator.flush();
this.consumerTypeCurator.clear();
// Ensure the update actually hit the DB
ConsumerType existing = this.consumerTypeCurator.find(this.testType.getId());
assertNotNull(existing);
assertEquals(label, existing.getLabel());
assertEquals(dto.isManifest(), existing.isManifest());
}
Aggregations