Search in sources :

Example 11 with CandlepinCommonTestConfig

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

the class HypervisorResourceTest method setupTest.

@Before
public void setupTest() {
    Configuration config = new CandlepinCommonTestConfig();
    testMigration = new GuestMigration(consumerCurator);
    migrationProvider = Providers.of(testMigration);
    this.i18n = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    this.hypervisorType = new ConsumerType(ConsumerTypeEnum.HYPERVISOR);
    this.hypervisorType.setId("test-hypervisor-ctype");
    this.mockConsumerType(this.hypervisorType);
    this.modelTranslator = new StandardTranslator(this.consumerTypeCurator, this.environmentCurator, this.ownerCurator);
    this.consumerResource = 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, null, null, this.ownerCurator, this.activationKeyCurator, null, this.complianceRules, this.deletedConsumerCurator, null, null, config, null, null, null, this.consumerBindUtil, null, null, new FactValidator(config, this.i18n), null, consumerEnricher, migrationProvider, modelTranslator);
    this.guestIdResource = new GuestIdResource(this.guestIdCurator, this.consumerCurator, this.consumerTypeCurator, this.consumerResource, this.i18n, this.eventFactory, this.sink, migrationProvider, modelTranslator);
    this.hypervisorResource = new HypervisorResource(consumerResource, consumerCurator, consumerTypeCurator, i18n, ownerCurator, migrationProvider, modelTranslator, guestIdResource);
    // Ensure that we get the consumer that was passed in back from the create call.
    when(consumerCurator.create(any(Consumer.class))).thenAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return invocation.getArguments()[0];
        }
    });
    when(consumerCurator.create(any(Consumer.class), any(Boolean.class))).thenAnswer(new Answer<Object>() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            return invocation.getArguments()[0];
        }
    });
    when(complianceRules.getStatus(any(Consumer.class), any(Date.class), any(Boolean.class))).thenReturn(new ComplianceStatus(new Date()));
    when(ownerCurator.lookupByKey(any(String.class))).thenReturn(new Owner());
    when(eventFactory.getEventBuilder(any(Target.class), any(Type.class))).thenReturn(consumerEventBuilder);
    when(consumerEventBuilder.setEventData(any(Consumer.class))).thenReturn(consumerEventBuilder);
}
Also used : FactValidator(org.candlepin.util.FactValidator) Owner(org.candlepin.model.Owner) 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) InvocationOnMock(org.mockito.invocation.InvocationOnMock) ConsumerType(org.candlepin.model.ConsumerType) Before(org.junit.Before)

Example 12 with CandlepinCommonTestConfig

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

the class EventSinkImplTest method init.

@Before
public void init() throws Exception {
    this.factory = new EventFactory(mockPrincipalProvider);
    this.principal = TestUtil.createOwnerPrincipal();
    eventFilter = new EventFilter(new CandlepinCommonTestConfig());
    when(mockPrincipalProvider.get()).thenReturn(this.principal);
    when(mockSessionFactory.createTransactedSession()).thenReturn(mockClientSession);
    when(mockClientSession.createProducer(anyString())).thenReturn(mockClientProducer);
    when(mockClientSession.createMessage(anyBoolean())).thenReturn(mockClientMessage);
    when(mockClientMessage.getBodyBuffer()).thenReturn(ActiveMQBuffers.fixedBuffer(2000));
    when(mockSessionFactory.getServerLocator()).thenReturn(mockLocator);
    this.mapper = spy(new ObjectMapper());
    this.eventSinkImpl = createEventSink(mockSessionFactory);
    o = new Owner("test owner");
}
Also used : Owner(org.candlepin.model.Owner) CandlepinCommonTestConfig(org.candlepin.config.CandlepinCommonTestConfig) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) Before(org.junit.Before)

Example 13 with CandlepinCommonTestConfig

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

the class ModeManagerTest method setUp.

@Before
public void setUp() {
    I18n mockedi18 = I18nFactory.getI18n(getClass(), Locale.US, I18nFactory.FALLBACK);
    modeManager = new ModeManagerImpl(new CandlepinCommonTestConfig(), mockedi18);
    testReason = Reason.STARTUP;
    modeChanged = false;
}
Also used : CandlepinCommonTestConfig(org.candlepin.config.CandlepinCommonTestConfig) I18n(org.xnap.commons.i18n.I18n) Before(org.junit.Before)

Example 14 with CandlepinCommonTestConfig

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

the class QpidQmfTest method liveTest.

@Ignore("This test requires running qpid broker and is useful only for development")
@Test
public void liveTest() throws URISyntaxException, JMSException, InterruptedException {
    Configuration config = new CandlepinCommonTestConfig();
    config.setProperty("trust_store", "/etc/candlepin/certs/amqp/candlepin.truststore");
    config.setProperty("trust_store_password", "password");
    config.setProperty("key_store", "/etc/candlepin/certs/amqp/candlepin.jks");
    config.setProperty("key_store_password", "password");
    config.setProperty("retries", "0");
    config.setProperty("connectdelay", "1");
// QpidConnection connection = new QpidConnection(new QpidConfigBuilder(config));
// QpidQmf qmf = new QpidQmf(connection, config);
// System.out.println(qmf.getStatus());
}
Also used : Configuration(org.candlepin.common.config.Configuration) CandlepinCommonTestConfig(org.candlepin.config.CandlepinCommonTestConfig) Ignore(org.junit.Ignore) Test(org.junit.Test)

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