Search in sources :

Example 46 with Owner

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);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ImportFile(org.candlepin.sync.Importer.ImportFile) File(java.io.File) Test(org.junit.Test)

Example 47 with Owner

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());
}
Also used : Owner(org.candlepin.model.Owner) ProductCertificate(org.candlepin.model.ProductCertificate) Product(org.candlepin.model.Product) Test(org.junit.Test)

Example 48 with Owner

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());
}
Also used : Owner(org.candlepin.model.Owner) ConsumerDTO(org.candlepin.dto.manifest.v1.ConsumerDTO) OwnerDTO(org.candlepin.dto.manifest.v1.OwnerDTO) CertificateSerial(org.candlepin.model.CertificateSerial) ConsumerTypeDTO(org.candlepin.dto.manifest.v1.ConsumerTypeDTO) IdentityCertificate(org.candlepin.model.IdentityCertificate) Test(org.junit.Test)

Example 49 with Owner

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);
}
Also used : Owner(org.candlepin.model.Owner) ConsumerDTO(org.candlepin.dto.manifest.v1.ConsumerDTO) OwnerDTO(org.candlepin.dto.manifest.v1.OwnerDTO) UpstreamConsumer(org.candlepin.model.UpstreamConsumer) ConsumerTypeDTO(org.candlepin.dto.manifest.v1.ConsumerTypeDTO) Test(org.junit.Test)

Example 50 with 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);
}
Also used : Owner(org.candlepin.model.Owner) ConsumerDTO(org.candlepin.dto.manifest.v1.ConsumerDTO) Test(org.junit.Test)

Aggregations

Owner (org.candlepin.model.Owner)405 Test (org.junit.Test)254 Product (org.candlepin.model.Product)153 Consumer (org.candlepin.model.Consumer)127 Pool (org.candlepin.model.Pool)79 Date (java.util.Date)72 ConsumerInstalledProduct (org.candlepin.model.ConsumerInstalledProduct)71 ArrayList (java.util.ArrayList)58 Produces (javax.ws.rs.Produces)52 ConsumerType (org.candlepin.model.ConsumerType)52 ApiOperation (io.swagger.annotations.ApiOperation)50 HashSet (java.util.HashSet)44 Entitlement (org.candlepin.model.Entitlement)44 Path (javax.ws.rs.Path)42 HashMap (java.util.HashMap)41 ApiResponses (io.swagger.annotations.ApiResponses)40 Content (org.candlepin.model.Content)39 BadRequestException (org.candlepin.common.exceptions.BadRequestException)37 Subscription (org.candlepin.model.dto.Subscription)32 List (java.util.List)29