Search in sources :

Example 1 with ImportUpstreamConsumer

use of org.candlepin.model.ImportUpstreamConsumer in project candlepin by candlepin.

the class ImporterTest method testRecordImportSetsUpstreamConsumerFromOwner.

@Test
public void testRecordImportSetsUpstreamConsumerFromOwner() {
    String expectedOwnerKey = "TEST_OWNER";
    Owner owner = new Owner(expectedOwnerKey);
    UpstreamConsumer uc = new UpstreamConsumer("uc", owner, new ConsumerType(ConsumerType.ConsumerTypeEnum.CANDLEPIN), "uuid");
    uc.setContentAccessMode("mode");
    owner.setUpstreamConsumer(uc);
    EventSink eventSinkMock = mock(EventSink.class);
    ImportRecordCurator importRecordCurator = mock(ImportRecordCurator.class);
    Importer importer = new Importer(null, null, null, null, null, null, null, null, config, null, null, eventSinkMock, i18n, null, null, su, importRecordCurator, this.mockSubReconciler, this.ec, this.translator);
    Meta meta = new Meta("1.0", new Date(), "test-user", "candlepin", "testcdn");
    Map<String, Object> data = new HashMap<>();
    data.put("meta", meta);
    data.put("subscriptions", new ArrayList<Subscription>());
    ImportRecord record = importer.recordImportSuccess(owner, data, new ConflictOverrides(), "test.zip");
    ImportUpstreamConsumer iuc = record.getUpstreamConsumer();
    assertNotNull(iuc);
    assertEquals(uc.getOwnerId(), iuc.getOwnerId());
    assertEquals(uc.getName(), iuc.getName());
    assertEquals(uc.getUuid(), iuc.getUuid());
    assertEquals(uc.getType(), iuc.getType());
    assertEquals(uc.getWebUrl(), iuc.getWebUrl());
    assertEquals(uc.getApiUrl(), iuc.getApiUrl());
    assertEquals(uc.getContentAccessMode(), iuc.getContentAccessMode());
    verify(importRecordCurator).create(eq(record));
}
Also used : Owner(org.candlepin.model.Owner) HashMap(java.util.HashMap) ImportUpstreamConsumer(org.candlepin.model.ImportUpstreamConsumer) UpstreamConsumer(org.candlepin.model.UpstreamConsumer) ImportUpstreamConsumer(org.candlepin.model.ImportUpstreamConsumer) ImportRecord(org.candlepin.model.ImportRecord) Date(java.util.Date) ImportRecordCurator(org.candlepin.model.ImportRecordCurator) ConsumerType(org.candlepin.model.ConsumerType) EventSink(org.candlepin.audit.EventSink) Subscription(org.candlepin.model.dto.Subscription) Test(org.junit.Test)

Example 2 with ImportUpstreamConsumer

use of org.candlepin.model.ImportUpstreamConsumer in project candlepin by candlepin.

the class UndoImportsJob method createImportUpstreamConsumer.

private ImportUpstreamConsumer createImportUpstreamConsumer(Owner owner, UpstreamConsumer uc) {
    ImportUpstreamConsumer iup = null;
    if (uc == null) {
        uc = owner.getUpstreamConsumer();
    }
    if (uc != null) {
        iup = new ImportUpstreamConsumer();
        iup.setOwnerId(uc.getOwnerId());
        iup.setName(uc.getName());
        iup.setUuid(uc.getUuid());
        iup.setType(uc.getType());
        iup.setWebUrl(uc.getWebUrl());
        iup.setApiUrl(uc.getApiUrl());
    }
    return iup;
}
Also used : ImportUpstreamConsumer(org.candlepin.model.ImportUpstreamConsumer)

Aggregations

ImportUpstreamConsumer (org.candlepin.model.ImportUpstreamConsumer)2 Date (java.util.Date)1 HashMap (java.util.HashMap)1 EventSink (org.candlepin.audit.EventSink)1 ConsumerType (org.candlepin.model.ConsumerType)1 ImportRecord (org.candlepin.model.ImportRecord)1 ImportRecordCurator (org.candlepin.model.ImportRecordCurator)1 Owner (org.candlepin.model.Owner)1 UpstreamConsumer (org.candlepin.model.UpstreamConsumer)1 Subscription (org.candlepin.model.dto.Subscription)1 Test (org.junit.Test)1