use of org.candlepin.model.Owner in project candlepin by candlepin.
the class ImporterTest method testImportNoConsumer.
@Test
public void testImportNoConsumer() throws IOException, ImporterException {
OwnerCurator oc = mock(OwnerCurator.class);
Importer i = new Importer(null, null, null, oc, null, null, null, null, config, null, null, null, i18n, null, null, su, null, this.mockSubReconciler, this.ec, this.translator);
Owner owner = mock(Owner.class);
ConflictOverrides co = mock(ConflictOverrides.class);
Map<String, File> importFiles = getTestImportFiles();
importFiles.put(ImportFile.CONSUMER.fileName(), null);
String m = i18n.tr("The archive does not contain the required consumer.json file");
ee.expect(ImporterException.class);
ee.expectMessage(m);
i.importObjects(owner, importFiles, co);
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class ProductCertCreationTest method validProduct.
@Test
public void validProduct() {
Owner owner = TestUtil.createOwner("Example-Corporation");
Product product = this.createProduct("50", "Test Product", "Standard", "1", "x86_64", "Base");
ProductCertificate cert = this.createCert(owner, product);
Assert.assertEquals(product, cert.getProduct());
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class ConsumerImporterTest method importConsumerWithSameUuidOnOwnerShouldDoNothing.
@Test
public void importConsumerWithSameUuidOnOwnerShouldDoNothing() throws ImporterException {
Owner owner = mock(Owner.class);
OwnerDTO ownerDTO = mock(OwnerDTO.class);
ConsumerDTO consumer = mock(ConsumerDTO.class);
ConsumerTypeDTO type = mock(ConsumerTypeDTO.class);
when(owner.getUpstreamUuid()).thenReturn("test-uuid");
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 didn't change
// arg.getValue() returns the Owner being stored
ArgumentCaptor<Owner> arg = ArgumentCaptor.forClass(Owner.class);
verify(curator).merge(arg.capture());
assertEquals("test-uuid", arg.getValue().getUpstreamUuid());
}
use of org.candlepin.model.Owner in project candlepin by candlepin.
the class ConsumerImporterTest method importConsumerWithNullIdCertShouldNotFail.
/*
* BZ#966860
*/
@Test
public void importConsumerWithNullIdCertShouldNotFail() throws ImporterException {
Owner owner = mock(Owner.class);
OwnerDTO ownerDTO = mock(OwnerDTO.class);
ConsumerDTO consumer = mock(ConsumerDTO.class);
ConsumerTypeDTO type = mock(ConsumerTypeDTO.class);
when(owner.getUpstreamUuid()).thenReturn("test-uuid");
when(consumer.getUuid()).thenReturn("test-uuid");
when(consumer.getOwner()).thenReturn(ownerDTO);
when(consumer.getType()).thenReturn(type);
importer.store(owner, consumer, new ConflictOverrides(), null);
// 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.model.Owner in project candlepin by candlepin.
the class ConsumerImporterTest method importConsumerWithNullUuidOnConsumerShouldThrowException.
@Test(expected = ImporterException.class)
public void importConsumerWithNullUuidOnConsumerShouldThrowException() throws ImporterException {
Owner owner = new Owner();
ConsumerDTO consumer = new ConsumerDTO();
consumer.setUuid(null);
importer.store(owner, consumer, new ConflictOverrides(), null);
}
Aggregations