Search in sources :

Example 6 with OwnerCurator

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);
}
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 7 with OwnerCurator

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);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ActivationKeyDTO(org.candlepin.dto.api.v1.ActivationKeyDTO) ActivationKeyCurator(org.candlepin.model.activationkeys.ActivationKeyCurator) ProductCurator(org.candlepin.model.ProductCurator) ActivationKey(org.candlepin.model.activationkeys.ActivationKey) Test(org.junit.Test)

Example 8 with OwnerCurator

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());
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) UpstreamConsumerDTO(org.candlepin.dto.api.v1.UpstreamConsumerDTO) ProductCurator(org.candlepin.model.ProductCurator) UpstreamConsumer(org.candlepin.model.UpstreamConsumer) ConsumerPrincipal(org.candlepin.auth.ConsumerPrincipal) UserPrincipal(org.candlepin.auth.UserPrincipal) Principal(org.candlepin.auth.Principal) Test(org.junit.Test)

Example 9 with OwnerCurator

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\"}]" + "}]}";
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) GuestMigration(org.candlepin.resource.util.GuestMigration) Owner(org.candlepin.model.Owner) ConsumerTypeCurator(org.candlepin.model.ConsumerTypeCurator) ConsumerResource(org.candlepin.resource.ConsumerResource) ComplianceRules(org.candlepin.policy.js.compliance.ComplianceRules) ConsumerType(org.candlepin.model.ConsumerType) Principal(org.candlepin.auth.Principal) ConsumerCurator(org.candlepin.model.ConsumerCurator) SubscriptionServiceAdapter(org.candlepin.service.SubscriptionServiceAdapter) Before(org.junit.Before)

Example 10 with OwnerCurator

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);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ActivationKeyDTO(org.candlepin.dto.api.v1.ActivationKeyDTO) ProductCurator(org.candlepin.model.ProductCurator) Test(org.junit.Test)

Aggregations

OwnerCurator (org.candlepin.model.OwnerCurator)21 Owner (org.candlepin.model.Owner)20 Test (org.junit.Test)19 ProductCurator (org.candlepin.model.ProductCurator)9 File (java.io.File)8 ImportFile (org.candlepin.sync.Importer.ImportFile)8 Principal (org.candlepin.auth.Principal)4 Date (java.util.Date)3 ConsumerPrincipal (org.candlepin.auth.ConsumerPrincipal)3 UserPrincipal (org.candlepin.auth.UserPrincipal)3 CandlepinPoolManager (org.candlepin.controller.CandlepinPoolManager)3 ActivationKeyDTO (org.candlepin.dto.api.v1.ActivationKeyDTO)3 ConsumerCurator (org.candlepin.model.ConsumerCurator)3 ConsumerType (org.candlepin.model.ConsumerType)3 ConsumerTypeCurator (org.candlepin.model.ConsumerTypeCurator)3 Product (org.candlepin.model.Product)3 Reader (java.io.Reader)2 HashMap (java.util.HashMap)2 StandardTranslator (org.candlepin.dto.StandardTranslator)2 ConsumerDTO (org.candlepin.dto.manifest.v1.ConsumerDTO)2