Search in sources :

Example 1 with CandlepinCommonTestConfig

use of org.candlepin.config.CandlepinCommonTestConfig 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 2 with CandlepinCommonTestConfig

use of org.candlepin.config.CandlepinCommonTestConfig 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 3 with CandlepinCommonTestConfig

use of org.candlepin.config.CandlepinCommonTestConfig in project candlepin by candlepin.

the class DatabaseTestFixture method init.

public void init(boolean beginTransaction) throws Exception {
    this.config = new CandlepinCommonTestConfig();
    Module testingModule = new TestingModules.StandardTest(this.config);
    this.injector = parentInjector.createChildInjector(Modules.override(testingModule).with(getGuiceOverrideModule()));
    locatorMap = this.injector.getInstance(ResourceLocatorMap.class);
    locatorMap.init();
    securityInterceptor = this.injector.getInstance(TestingInterceptor.class);
    cpRequestScope = injector.getInstance(CandlepinRequestScope.class);
    // Because all candlepin operations are running in the CandlepinRequestScope
    // we'll force the instance creations to be done inside the scope.
    // Exit the scope to make sure that it is clean before starting the test.
    cpRequestScope.exit();
    cpRequestScope.enter();
    this.injector.injectMembers(this);
    dateSource = (DateSourceForTesting) injector.getInstance(DateSource.class);
    dateSource.currentDate(TestDateUtil.date(2010, 1, 1));
    HttpServletRequest req = parentInjector.getInstance(HttpServletRequest.class);
    when(req.getAttribute("username")).thenReturn("mock_user");
    this.i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    if (beginTransaction) {
        this.beginTransaction();
    }
}
Also used : HttpServletRequest(javax.servlet.http.HttpServletRequest) CandlepinRequestScope(org.candlepin.guice.CandlepinRequestScope) CandlepinCommonTestConfig(org.candlepin.config.CandlepinCommonTestConfig) TestingInterceptor(org.candlepin.TestingInterceptor) Module(com.google.inject.Module) AbstractModule(com.google.inject.AbstractModule) ResourceLocatorMap(org.candlepin.resteasy.ResourceLocatorMap)

Example 4 with CandlepinCommonTestConfig

use of org.candlepin.config.CandlepinCommonTestConfig in project candlepin by candlepin.

the class SuspendModeTransitionerTest method setUp.

@Before
public void setUp() {
    when(candlepinCache.getStatusCache()).thenReturn(cache);
    CandlepinCommonTestConfig testConfig = new CandlepinCommonTestConfig();
    transitioner = new SuspendModeTransitioner(testConfig, execService, candlepinCache);
    transitioner.setModeManager(modeManager);
    transitioner.setQmf(qmf);
    transitioner.setQpidConnection(qpidConnection);
    startupModeChange = new CandlepinModeChange(new Date(), Mode.NORMAL, Reason.STARTUP);
    downModeChange = new CandlepinModeChange(new Date(), Mode.SUSPEND, Reason.QPID_DOWN);
    normalModeChange = new CandlepinModeChange(new Date(), Mode.NORMAL, Reason.QPID_UP);
}
Also used : CandlepinCommonTestConfig(org.candlepin.config.CandlepinCommonTestConfig) CandlepinModeChange(org.candlepin.model.CandlepinModeChange) Date(java.util.Date) Before(org.junit.Before)

Example 5 with CandlepinCommonTestConfig

use of org.candlepin.config.CandlepinCommonTestConfig in project candlepin by candlepin.

the class EventSinkImplTest method createEventSink.

/**
 * @return
 * @throws Exception
 */
private EventSinkImpl createEventSink(final ClientSessionFactory sessionFactory) throws Exception {
    EventSinkImpl sink = new EventSinkImpl(eventFilter, factory, mapper, new CandlepinCommonTestConfig(), mockModeManager) {

        @Override
        protected ClientSessionFactory createClientSessionFactory() {
            return sessionFactory;
        }
    };
    sink.initialize();
    return sink;
}
Also used : CandlepinCommonTestConfig(org.candlepin.config.CandlepinCommonTestConfig)

Aggregations

CandlepinCommonTestConfig (org.candlepin.config.CandlepinCommonTestConfig)14 Before (org.junit.Before)8 StandardTranslator (org.candlepin.dto.StandardTranslator)5 ConsumerType (org.candlepin.model.ConsumerType)5 GuestMigration (org.candlepin.resource.util.GuestMigration)4 Test (org.junit.Test)4 Date (java.util.Date)3 Target (org.candlepin.audit.Event.Target)3 Type (org.candlepin.audit.Event.Type)3 Configuration (org.candlepin.common.config.Configuration)3 Consumer (org.candlepin.model.Consumer)3 Owner (org.candlepin.model.Owner)3 FactValidator (org.candlepin.util.FactValidator)3 Access (org.candlepin.auth.Access)2 SubResource (org.candlepin.auth.SubResource)2 UserPrincipal (org.candlepin.auth.UserPrincipal)2 ConsumerDTO (org.candlepin.dto.api.v1.ConsumerDTO)2 ConsumerTypeDTO (org.candlepin.dto.api.v1.ConsumerTypeDTO)2 OwnerDTO (org.candlepin.dto.api.v1.OwnerDTO)2 ProductCachedSerializationModule (org.candlepin.jackson.ProductCachedSerializationModule)2