Search in sources :

Example 1 with MockResourceServiceBroker

use of org.onehippo.cms7.crisp.mock.broker.MockResourceServiceBroker in project hippo by NHS-digital-website.

the class SubscriptionResourceTest method setUp.

@Before
public void setUp() {
    final Map<String, ResourceResolver> resourceResolverMap = new HashMap<>();
    resourceResolverMap.put("govDeliveryApi", new MockJdomResourceResolverAdapter() {

        @Override
        public Resource resolve(String absPath, Map<String, Object> pathVariables, ExchangeHint exchangeHint) throws ResourceException {
            return urlToResource(SubscriptionResourceTest.class.getResource("/subscriber-output.xml"));
        }
    });
    final ResourceServiceBroker mockBroker = new MockResourceServiceBroker(resourceResolverMap);
    MockCrispHstServices.setDefaultResourceServiceBroker(mockBroker);
}
Also used : MockJdomResourceResolverAdapter(org.onehippo.cms7.crisp.mock.resource.MockJdomResourceResolverAdapter) MockResourceServiceBroker(org.onehippo.cms7.crisp.mock.broker.MockResourceServiceBroker) HashMap(java.util.HashMap) Resource(org.onehippo.cms7.crisp.api.resource.Resource) MockResourceServiceBroker(org.onehippo.cms7.crisp.mock.broker.MockResourceServiceBroker) ResourceServiceBroker(org.onehippo.cms7.crisp.api.broker.ResourceServiceBroker) ExchangeHint(org.onehippo.cms7.crisp.api.exchange.ExchangeHint) ResourceResolver(org.onehippo.cms7.crisp.api.resource.ResourceResolver) ResourceException(org.onehippo.cms7.crisp.api.resource.ResourceException) Before(org.junit.Before)

Example 2 with MockResourceServiceBroker

use of org.onehippo.cms7.crisp.mock.broker.MockResourceServiceBroker in project hippo by NHS-digital-website.

the class RemoteContentServiceTest method before.

@Before
public void before() {
    Map<String, ResourceResolver> resourceResolverMap = new HashMap<>();
    resourceResolverMap.put("testResourceResolver", testResourceResolver);
    ResourceServiceBroker mockBroker = new MockResourceServiceBroker(resourceResolverMap);
    MockCrispHstServices.setDefaultResourceServiceBroker(mockBroker);
}
Also used : MockResourceServiceBroker(org.onehippo.cms7.crisp.mock.broker.MockResourceServiceBroker) HashMap(java.util.HashMap) ResourceResolver(org.onehippo.cms7.crisp.api.resource.ResourceResolver) SimpleJacksonRestTemplateResourceResolver(org.onehippo.cms7.crisp.core.resource.jackson.SimpleJacksonRestTemplateResourceResolver) MockResourceServiceBroker(org.onehippo.cms7.crisp.mock.broker.MockResourceServiceBroker) ResourceServiceBroker(org.onehippo.cms7.crisp.api.broker.ResourceServiceBroker) Before(org.junit.Before)

Example 3 with MockResourceServiceBroker

use of org.onehippo.cms7.crisp.mock.broker.MockResourceServiceBroker in project hippo by NHS-digital-website.

the class ApiSpecSyncFromApigeeJobIntegrationTest method crispApiConfiguredForOAuth2.

private void crispApiConfiguredForOAuth2() {
    crispApiSpringApplicationContextEnvironment = new MockEnvironment().withProperty(PARAM_APIGEE_RESOURCES_SPECS_ALL_URL, apigeeAllSpecsUrl).withProperty(PARAM_APIGEE_OAUTH_TOKEN_URL, oauthTokenUrl).withProperty(PARAM_APIGEE_RESOURCES_SPECS_INDIVIDUAL_URL, apigeeSingleSpecUrlTemplate).withProperty(PARAM_APIGEE_OAUTH_USERNAME, OAUTH_USERNAME).withProperty(PARAM_APIGEE_OAUTH_PASSWORD, OAUTH_PASSWORD).withProperty(PARAM_APIGEE_OAUTH_BASICAUTHTOKEN, OAUTH_BASIC_AUTH_TOKEN).withProperty(PARAM_APIGEE_OAUTH_OTPKEY, OAUTH_OTP_KEY);
    // See https://documentation.bloomreach.com/14/library/concepts/crisp-api/unit-testing.html
    final ClassPathXmlApplicationContext crispApiSpringApplicationContext = new ClassPathXmlApplicationContext();
    crispApiSpringApplicationContext.setEnvironment(crispApiSpringApplicationContextEnvironment);
    crispApiSpringApplicationContext.setConfigLocations(testDataFileLocation("crisp-spring-context-properties-support.xml"), "/META-INF/hst-assembly/addon/crisp/overrides/custom-resource-resolvers.xml");
    crispApiSpringApplicationContext.refresh();
    final String apigeeManagementApiCrispApiNamespace = "apigeeManagementApi";
    final SimpleJacksonRestTemplateResourceResolver simpleJacksonRestTemplateResourceResolver = crispApiSpringApplicationContext.getBean(apigeeManagementApiCrispApiNamespace, SimpleJacksonRestTemplateResourceResolver.class);
    final ImmutableMap<String, ResourceResolver> resourceResolverMap = ImmutableMap.<String, ResourceResolver>builder().put(apigeeManagementApiCrispApiNamespace, simpleJacksonRestTemplateResourceResolver).build();
    final MockResourceServiceBroker mockResourceServiceBroker = new MockResourceServiceBroker(resourceResolverMap);
    MockCrispHstServices.setDefaultResourceServiceBroker(mockResourceServiceBroker);
}
Also used : SimpleJacksonRestTemplateResourceResolver(org.onehippo.cms7.crisp.core.resource.jackson.SimpleJacksonRestTemplateResourceResolver) MockResourceServiceBroker(org.onehippo.cms7.crisp.mock.broker.MockResourceServiceBroker) ClassPathXmlApplicationContext(org.springframework.context.support.ClassPathXmlApplicationContext) MockEnvironment(org.springframework.mock.env.MockEnvironment) ResourceResolver(org.onehippo.cms7.crisp.api.resource.ResourceResolver) SimpleJacksonRestTemplateResourceResolver(org.onehippo.cms7.crisp.core.resource.jackson.SimpleJacksonRestTemplateResourceResolver)

Aggregations

ResourceResolver (org.onehippo.cms7.crisp.api.resource.ResourceResolver)3 MockResourceServiceBroker (org.onehippo.cms7.crisp.mock.broker.MockResourceServiceBroker)3 HashMap (java.util.HashMap)2 Before (org.junit.Before)2 ResourceServiceBroker (org.onehippo.cms7.crisp.api.broker.ResourceServiceBroker)2 SimpleJacksonRestTemplateResourceResolver (org.onehippo.cms7.crisp.core.resource.jackson.SimpleJacksonRestTemplateResourceResolver)2 ExchangeHint (org.onehippo.cms7.crisp.api.exchange.ExchangeHint)1 Resource (org.onehippo.cms7.crisp.api.resource.Resource)1 ResourceException (org.onehippo.cms7.crisp.api.resource.ResourceException)1 MockJdomResourceResolverAdapter (org.onehippo.cms7.crisp.mock.resource.MockJdomResourceResolverAdapter)1 ClassPathXmlApplicationContext (org.springframework.context.support.ClassPathXmlApplicationContext)1 MockEnvironment (org.springframework.mock.env.MockEnvironment)1