use of org.candlepin.model.OwnerCurator 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.OwnerCurator in project candlepin by candlepin.
the class OwnerResourceTest method testActivationKeyNameUnique.
@Test(expected = BadRequestException.class)
public void testActivationKeyNameUnique() {
ActivationKeyDTO ak = mock(ActivationKeyDTO.class);
ActivationKey akOld = mock(ActivationKey.class);
ActivationKeyCurator akc = mock(ActivationKeyCurator.class);
Owner o = mock(Owner.class);
OwnerCurator oc = mock(OwnerCurator.class);
ProductCurator pc = mock(ProductCurator.class);
when(ak.getName()).thenReturn("testKey");
when(akc.lookupForOwner(eq("testKey"), eq(o))).thenReturn(akOld);
when(oc.lookupByKey(eq("testOwner"))).thenReturn(o);
OwnerResource ownerres = new OwnerResource(oc, pc, akc, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, contentOverrideValidator, null, null, null, null, null, null, this.modelTranslator);
ownerres.createActivationKey("testOwner", ak);
}
use of org.candlepin.model.OwnerCurator in project candlepin by candlepin.
the class OwnerResourceTest method upstreamConsumers.
@Test
public void upstreamConsumers() {
Principal p = mock(Principal.class);
OwnerCurator oc = mock(OwnerCurator.class);
ProductCurator pc = mock(ProductCurator.class);
UpstreamConsumer upstream = mock(UpstreamConsumer.class);
Owner owner = mock(Owner.class);
OwnerResource ownerres = new OwnerResource(oc, pc, null, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, contentOverrideValidator, serviceLevelValidator, null, null, null, null, null, this.modelTranslator);
when(oc.lookupByKey(eq("admin"))).thenReturn(owner);
when(owner.getUpstreamConsumer()).thenReturn(upstream);
List<UpstreamConsumerDTO> results = ownerres.getUpstreamConsumers(p, "admin");
assertNotNull(results);
assertEquals(1, results.size());
}
use of org.candlepin.model.OwnerCurator in project candlepin by candlepin.
the class HypervisorUpdateJobTest method init.
@Before
public void init() {
super.init();
i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.READ_PROPERTIES | I18nFactory.FALLBACK);
owner = mock(Owner.class);
principal = mock(Principal.class);
ownerCurator = mock(OwnerCurator.class);
consumerCurator = mock(ConsumerCurator.class);
consumerResource = mock(ConsumerResource.class);
consumerTypeCurator = mock(ConsumerTypeCurator.class);
subAdapter = mock(SubscriptionServiceAdapter.class);
complianceRules = mock(ComplianceRules.class);
when(owner.getId()).thenReturn("joe");
ConsumerType ctype = new ConsumerType(ConsumerTypeEnum.HYPERVISOR);
ctype.setId("test-ctype");
when(consumerTypeCurator.lookupByLabel(eq(ConsumerTypeEnum.HYPERVISOR.getLabel()))).thenReturn(ctype);
when(consumerTypeCurator.lookupByLabel(eq(ConsumerTypeEnum.HYPERVISOR.getLabel()), anyBoolean())).thenReturn(ctype);
when(owner.getKey()).thenReturn("joe");
when(principal.getUsername()).thenReturn("joe user");
testMigration = new GuestMigration(consumerCurator);
migrationProvider = Providers.of(testMigration);
hypervisorJson = "{\"hypervisors\":" + "[{" + "\"name\" : \"hypervisor_999\"," + "\"hypervisorId\" : {\"hypervisorId\":\"uuid_999\"}," + "\"guestIds\" : [{\"guestId\" : \"guestId_1_999\"}]" + "}]}";
}
use of org.candlepin.model.OwnerCurator in project candlepin by candlepin.
the class OwnerResourceTest method testActivationKeyTooLongRelease.
@Test(expected = BadRequestException.class)
public void testActivationKeyTooLongRelease() {
OwnerCurator oc = mock(OwnerCurator.class);
ProductCurator pc = mock(ProductCurator.class);
Owner o = new Owner();
o.setKey("owner-key");
OwnerResource ownerres = new OwnerResource(oc, pc, null, null, i18n, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null, this.modelTranslator);
when(oc.lookupByKey(anyString())).thenReturn(o);
ActivationKeyDTO key = new ActivationKeyDTO();
key.setReleaseVersion(TestUtil.getStringOfSize(256));
key = ownerres.createActivationKey(owner.getKey(), key);
}
Aggregations