Search in sources :

Example 1 with ConsumerTypeCurator

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

the class ConsumerTypeImporterTest method testSingleConsumerTypeInDbAndListCausesNoChange.

@Test
public void testSingleConsumerTypeInDbAndListCausesNoChange() {
    final ConsumerType testType = new ConsumerType();
    testType.setLabel("prosumer");
    ConsumerTypeCurator curator = mock(ConsumerTypeCurator.class);
    when(curator.lookupByLabel("prosumer")).thenReturn(testType);
    ConsumerTypeImporter importer = new ConsumerTypeImporter(curator);
    importer.store(new HashSet<ConsumerType>() {

        {
            add(testType);
        }
    });
    verify(curator, never()).create(testType);
    verify(curator, never()).merge(testType);
}
Also used : ConsumerTypeCurator(org.candlepin.model.ConsumerTypeCurator) ConsumerType(org.candlepin.model.ConsumerType) Test(org.junit.Test)

Example 2 with ConsumerTypeCurator

use of org.candlepin.model.ConsumerTypeCurator 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 3 with ConsumerTypeCurator

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

the class ProductExporterTest method testProductExport.

@Test
public void testProductExport() throws IOException {
    ObjectMapper mapper = TestSyncUtils.getTestSyncUtils(new MapConfiguration(new HashMap<String, String>() {

        {
            put(ConfigProperties.FAIL_ON_UNKNOWN_IMPORT_PROPERTIES, "false");
        }
    }));
    ProductExporter exporter = new ProductExporter(new StandardTranslator(new ConsumerTypeCurator(), new EnvironmentCurator(), new OwnerCurator()));
    StringWriter writer = new StringWriter();
    Owner owner = TestUtil.createOwner("Example-Corporation");
    Product product = TestUtil.createProduct("my-id", "product name");
    exporter.export(mapper, writer, product);
    String s = writer.toString();
    assertTrue(s.contains("\"name\":\"product name\""));
    assertTrue(s.contains("\"id\":\"my-id\""));
    assertTrue(s.contains("\"productContent\":[]"));
    assertTrue(s.contains("\"attributes\":[]"));
    assertTrue(s.contains("\"multiplier\":1"));
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ConsumerTypeCurator(org.candlepin.model.ConsumerTypeCurator) StringWriter(java.io.StringWriter) HashMap(java.util.HashMap) MapConfiguration(org.candlepin.common.config.MapConfiguration) Product(org.candlepin.model.Product) EnvironmentCurator(org.candlepin.model.EnvironmentCurator) StandardTranslator(org.candlepin.dto.StandardTranslator) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Test(org.junit.Test)

Example 4 with ConsumerTypeCurator

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

the class SubscriptionReconcilerTest method init.

@Before
public void init() {
    this.owner = new Owner();
    this.reconciler = new SubscriptionReconciler(this.poolCurator);
    this.translator = new StandardTranslator(new ConsumerTypeCurator(), new EnvironmentCurator(), new OwnerCurator());
    i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    this.importer = new EntitlementImporter(certSerialCurator, cdnCurator, i18n, pc, ec, translator);
}
Also used : OwnerCurator(org.candlepin.model.OwnerCurator) Owner(org.candlepin.model.Owner) ConsumerTypeCurator(org.candlepin.model.ConsumerTypeCurator) EnvironmentCurator(org.candlepin.model.EnvironmentCurator) StandardTranslator(org.candlepin.dto.StandardTranslator) Before(org.junit.Before)

Example 5 with ConsumerTypeCurator

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

the class ConsumerTypeImporterTest method testSingleConsumerTypeInListEmptyDbCausesInsert.

@Test
public void testSingleConsumerTypeInListEmptyDbCausesInsert() {
    final ConsumerType testType = new ConsumerType();
    testType.setLabel("prosumer");
    ConsumerTypeCurator curator = mock(ConsumerTypeCurator.class);
    when(curator.lookupByLabel("prosumer")).thenReturn(null);
    ConsumerTypeImporter importer = new ConsumerTypeImporter(curator);
    importer.store(new HashSet<ConsumerType>() {

        {
            add(testType);
        }
    });
    verify(curator).create(testType);
    verify(curator, never()).merge(testType);
}
Also used : ConsumerTypeCurator(org.candlepin.model.ConsumerTypeCurator) ConsumerType(org.candlepin.model.ConsumerType) Test(org.junit.Test)

Aggregations

ConsumerTypeCurator (org.candlepin.model.ConsumerTypeCurator)5 ConsumerType (org.candlepin.model.ConsumerType)3 Owner (org.candlepin.model.Owner)3 OwnerCurator (org.candlepin.model.OwnerCurator)3 Test (org.junit.Test)3 StandardTranslator (org.candlepin.dto.StandardTranslator)2 EnvironmentCurator (org.candlepin.model.EnvironmentCurator)2 Before (org.junit.Before)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 StringWriter (java.io.StringWriter)1 HashMap (java.util.HashMap)1 Principal (org.candlepin.auth.Principal)1 MapConfiguration (org.candlepin.common.config.MapConfiguration)1 ConsumerCurator (org.candlepin.model.ConsumerCurator)1 Product (org.candlepin.model.Product)1 ComplianceRules (org.candlepin.policy.js.compliance.ComplianceRules)1 ConsumerResource (org.candlepin.resource.ConsumerResource)1 GuestMigration (org.candlepin.resource.util.GuestMigration)1 SubscriptionServiceAdapter (org.candlepin.service.SubscriptionServiceAdapter)1