Search in sources :

Example 1 with StandardTranslator

use of org.candlepin.dto.StandardTranslator in project candlepin by candlepin.

the class InstalledProductStatusCalculatorTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    translator = new StandardTranslator(this.consumerTypeCurator, this.environmentCurator, this.ownerCurator);
    // Load the default production rules:
    InputStream is = this.getClass().getResourceAsStream(RulesCurator.DEFAULT_RULES_FILE);
    Rules rules = new Rules(Util.readFile(is));
    Locale locale = new Locale("en_US");
    when(rulesCuratorMock.getUpdated()).thenReturn(new Date());
    when(rulesCuratorMock.getRules()).thenReturn(rules);
    when(cacheProvider.get()).thenReturn(cache);
    this.provider = new JsRunnerProvider(rulesCuratorMock, cacheProvider);
    i18n = I18nFactory.getI18n(getClass(), "org.candlepin.i18n.Messages", locale, I18nFactory.FALLBACK);
    RulesObjectMapper objectMapper = new RulesObjectMapper(new ProductCachedSerializationModule(productCurator));
    this.complianceRules = new ComplianceRules(provider.get(), this.entCurator, new StatusReasonMessageGenerator(i18n), eventSink, this.consumerCurator, this.consumerTypeCurator, objectMapper, translator);
    this.consumerEnricher = new ConsumerEnricher(this.complianceRules, this.ownerProductCurator);
}
Also used : Locale(java.util.Locale) ProductCachedSerializationModule(org.candlepin.jackson.ProductCachedSerializationModule) InputStream(java.io.InputStream) JsRunnerProvider(org.candlepin.policy.js.JsRunnerProvider) RulesObjectMapper(org.candlepin.policy.js.RulesObjectMapper) StatusReasonMessageGenerator(org.candlepin.policy.js.compliance.StatusReasonMessageGenerator) ComplianceRules(org.candlepin.policy.js.compliance.ComplianceRules) StandardTranslator(org.candlepin.dto.StandardTranslator) Rules(org.candlepin.model.Rules) ComplianceRules(org.candlepin.policy.js.compliance.ComplianceRules) Date(java.util.Date) Before(org.junit.Before)

Example 2 with StandardTranslator

use of org.candlepin.dto.StandardTranslator in project candlepin by candlepin.

the class ImporterTest method init.

@Before
public void init() throws URISyntaxException, IOException {
    mapper = TestSyncUtils.getTestSyncUtils(new MapConfiguration(new HashMap<String, String>() {

        {
            put(ConfigProperties.FAIL_ON_UNKNOWN_IMPORT_PROPERTIES, "false");
        }
    }));
    i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    config = new CandlepinCommonTestConfig();
    pc = Mockito.mock(ProductCurator.class);
    ec = Mockito.mock(EntitlementCurator.class);
    this.environmentCurator = Mockito.mock(EnvironmentCurator.class);
    ProductCachedSerializationModule productCachedModule = new ProductCachedSerializationModule(pc);
    su = new SyncUtils(config, productCachedModule);
    PrintStream ps = new PrintStream(new File(this.getClass().getClassLoader().getResource("version.properties").toURI()));
    ps.println("version=0.0.3");
    ps.println("release=1");
    ps.close();
    mockJsPath = new File(folder.getRoot(), "empty.js").getPath();
    this.mockSubReconciler = Mockito.mock(SubscriptionReconciler.class);
    this.consumerTypeCurator = Mockito.mock(ConsumerTypeCurator.class);
    oc = mock(OwnerCurator.class);
    this.translator = new StandardTranslator(this.consumerTypeCurator, this.environmentCurator, this.oc);
}
Also used : EntitlementCurator(org.candlepin.model.EntitlementCurator) PrintStream(java.io.PrintStream) ConsumerTypeCurator(org.candlepin.model.ConsumerTypeCurator) MapConfiguration(org.candlepin.common.config.MapConfiguration) StandardTranslator(org.candlepin.dto.StandardTranslator) ProductCachedSerializationModule(org.candlepin.jackson.ProductCachedSerializationModule) OwnerCurator(org.candlepin.model.OwnerCurator) CandlepinCommonTestConfig(org.candlepin.config.CandlepinCommonTestConfig) ProductCurator(org.candlepin.model.ProductCurator) EnvironmentCurator(org.candlepin.model.EnvironmentCurator) ImportFile(org.candlepin.sync.Importer.ImportFile) File(java.io.File) Before(org.junit.Before)

Example 3 with StandardTranslator

use of org.candlepin.dto.StandardTranslator in project candlepin by candlepin.

the class ExporterTest method setUp.

@Before
public void setUp() {
    ctc = mock(ConsumerTypeCurator.class);
    mockEnvironmentCurator = mock(EnvironmentCurator.class);
    oc = mock(OwnerCurator.class);
    me = new MetaExporter();
    translator = new StandardTranslator(ctc, mockEnvironmentCurator, oc);
    ce = new ConsumerExporter(translator);
    cte = new ConsumerTypeExporter(translator);
    rc = mock(RulesCurator.class);
    re = new RulesExporter(rc);
    ece = new EntitlementCertExporter();
    ecsa = mock(EntitlementCertServiceAdapter.class);
    pe = new ProductExporter(translator);
    psa = mock(ProductServiceAdapter.class);
    pce = new ProductCertExporter();
    ec = mock(EntitlementCurator.class);
    ee = new EntitlementExporter(translator);
    pki = mock(PKIUtility.class);
    config = new CandlepinCommonTestConfig();
    exportRules = mock(ExportRules.class);
    pprov = mock(PrincipalProvider.class);
    dvc = mock(DistributorVersionCurator.class);
    dve = new DistributorVersionExporter();
    cdnc = mock(CdnCurator.class);
    cdne = new CdnExporter();
    pc = mock(ProductCurator.class);
    ProductCachedSerializationModule productCachedModule = new ProductCachedSerializationModule(pc);
    su = new SyncUtils(config, productCachedModule);
    exportExtensionAdapter = mock(ExportExtensionAdapter.class);
    when(exportRules.canExport(any(Entitlement.class))).thenReturn(Boolean.TRUE);
}
Also used : PrincipalProvider(org.candlepin.guice.PrincipalProvider) ConsumerTypeCurator(org.candlepin.model.ConsumerTypeCurator) PKIUtility(org.candlepin.pki.PKIUtility) OwnerCurator(org.candlepin.model.OwnerCurator) RulesCurator(org.candlepin.model.RulesCurator) ExportRules(org.candlepin.policy.js.export.ExportRules) DistributorVersionCurator(org.candlepin.model.DistributorVersionCurator) CdnCurator(org.candlepin.model.CdnCurator) EntitlementCurator(org.candlepin.model.EntitlementCurator) EntitlementCertServiceAdapter(org.candlepin.service.EntitlementCertServiceAdapter) StandardTranslator(org.candlepin.dto.StandardTranslator) ProductServiceAdapter(org.candlepin.service.ProductServiceAdapter) ProductCachedSerializationModule(org.candlepin.jackson.ProductCachedSerializationModule) CandlepinCommonTestConfig(org.candlepin.config.CandlepinCommonTestConfig) ProductCurator(org.candlepin.model.ProductCurator) EnvironmentCurator(org.candlepin.model.EnvironmentCurator) Entitlement(org.candlepin.model.Entitlement) ExportExtensionAdapter(org.candlepin.service.ExportExtensionAdapter) Before(org.junit.Before)

Example 4 with StandardTranslator

use of org.candlepin.dto.StandardTranslator in project candlepin by candlepin.

the class ConsumerResourceUpdateTest method init.

@Before
public void init() throws Exception {
    Configuration config = new CandlepinCommonTestConfig();
    this.i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    testMigration = new GuestMigration(consumerCurator);
    migrationProvider = Providers.of(testMigration);
    this.translator = new StandardTranslator(this.consumerTypeCurator, this.environmentCurator, this.ownerCurator);
    this.resource = new ConsumerResource(this.consumerCurator, this.consumerTypeCurator, null, this.subscriptionService, this.ownerService, null, this.idCertService, null, this.i18n, this.sink, this.eventFactory, null, null, this.userService, poolManager, null, null, this.activationKeyCurator, this.entitler, this.complianceRules, this.deletedConsumerCurator, this.environmentCurator, null, config, null, null, null, this.consumerBindUtil, null, null, new FactValidator(config, this.i18n), null, consumerEnricher, migrationProvider, this.translator);
    when(complianceRules.getStatus(any(Consumer.class), any(Date.class), any(Boolean.class), any(Boolean.class))).thenReturn(new ComplianceStatus(new Date()));
    when(idCertService.regenerateIdentityCert(any(Consumer.class))).thenReturn(new IdentityCertificate());
    when(consumerEventBuilder.setEventData(any(Consumer.class))).thenReturn(consumerEventBuilder);
    when(eventFactory.getEventBuilder(any(Target.class), any(Type.class))).thenReturn(consumerEventBuilder);
}
Also used : FactValidator(org.candlepin.util.FactValidator) Configuration(org.candlepin.common.config.Configuration) ComplianceStatus(org.candlepin.policy.js.compliance.ComplianceStatus) StandardTranslator(org.candlepin.dto.StandardTranslator) Date(java.util.Date) GuestMigration(org.candlepin.resource.util.GuestMigration) Target(org.candlepin.audit.Event.Target) Type(org.candlepin.audit.Event.Type) ConsumerType(org.candlepin.model.ConsumerType) Consumer(org.candlepin.model.Consumer) CandlepinCommonTestConfig(org.candlepin.config.CandlepinCommonTestConfig) Mockito.anyBoolean(org.mockito.Mockito.anyBoolean) IdentityCertificate(org.candlepin.model.IdentityCertificate) Before(org.junit.Before)

Example 5 with StandardTranslator

use of org.candlepin.dto.StandardTranslator in project candlepin by candlepin.

the class ActivationKeyRulesTest method setUp.

@Before
public void setUp() {
    MockitoAnnotations.initMocks(this);
    Locale locale = new Locale("en_US");
    i18n = I18nFactory.getI18n(getClass(), "org.candlepin.i18n.Messages", locale, I18nFactory.FALLBACK);
    // Load the default production rules:
    InputStream is = this.getClass().getResourceAsStream(RulesCurator.DEFAULT_RULES_FILE);
    Rules rules = new Rules(Util.readFile(is));
    when(rulesCuratorMock.getUpdated()).thenReturn(new Date());
    when(rulesCuratorMock.getRules()).thenReturn(rules);
    when(cacheProvider.get()).thenReturn(cache);
    provider = new JsRunnerProvider(rulesCuratorMock, cacheProvider);
    ProductCurator productCurator = mock(ProductCurator.class);
    translator = new StandardTranslator(mockConsumerTypeCurator, environmentCurator, mockOwnerCurator);
    actKeyRules = new ActivationKeyRules(provider.get(), i18n, new RulesObjectMapper(new ProductCachedSerializationModule(productCurator)), translator);
}
Also used : Locale(java.util.Locale) ProductCachedSerializationModule(org.candlepin.jackson.ProductCachedSerializationModule) InputStream(java.io.InputStream) ProductCurator(org.candlepin.model.ProductCurator) JsRunnerProvider(org.candlepin.policy.js.JsRunnerProvider) RulesObjectMapper(org.candlepin.policy.js.RulesObjectMapper) Rules(org.candlepin.model.Rules) StandardTranslator(org.candlepin.dto.StandardTranslator) Date(java.util.Date) Before(org.junit.Before)

Aggregations

StandardTranslator (org.candlepin.dto.StandardTranslator)20 Before (org.junit.Before)17 Owner (org.candlepin.model.Owner)10 ProductCachedSerializationModule (org.candlepin.jackson.ProductCachedSerializationModule)9 ConsumerType (org.candlepin.model.ConsumerType)9 Consumer (org.candlepin.model.Consumer)8 Date (java.util.Date)7 Rules (org.candlepin.model.Rules)7 JsRunnerProvider (org.candlepin.policy.js.JsRunnerProvider)7 RulesObjectMapper (org.candlepin.policy.js.RulesObjectMapper)7 InputStream (java.io.InputStream)6 CandlepinCommonTestConfig (org.candlepin.config.CandlepinCommonTestConfig)5 GuestMigration (org.candlepin.resource.util.GuestMigration)5 MapConfiguration (org.candlepin.common.config.MapConfiguration)4 ConsumerTypeCurator (org.candlepin.model.ConsumerTypeCurator)4 EnvironmentCurator (org.candlepin.model.EnvironmentCurator)4 OwnerCurator (org.candlepin.model.OwnerCurator)4 ComplianceStatus (org.candlepin.policy.js.compliance.ComplianceStatus)4 FactValidator (org.candlepin.util.FactValidator)4 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)3