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));
}
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;
}
Aggregations