Search in sources :

Example 1 with SpringServiceDiscovery

use of io.crnk.spring.internal.SpringServiceDiscovery in project crnk-framework by crnk-project.

the class CrnkConfigV3Test method checkProperties.

@Test
public void checkProperties() {
    ApplicationContext applicationContext = Mockito.mock(ApplicationContext.class);
    Mockito.when(applicationContext.getEnvironment()).thenReturn(Mockito.mock(Environment.class));
    CrnkSpringBootProperties properties = new CrnkSpringBootProperties();
    properties.setDomainName("testDomain");
    properties.setDefaultPageLimit(12L);
    properties.setMaxPageLimit(20L);
    properties.setPathPrefix("prefix");
    properties.setAllowUnknownAttributes(true);
    properties.setReturn404OnNull(true);
    properties.setResourcePackage("ch.something");
    ObjectMapper objectMapper = new ObjectMapper();
    CrnkConfigV3 config = new CrnkConfigV3(properties, objectMapper);
    config.setApplicationContext(applicationContext);
    SpringServiceDiscovery serviceDiscovery = Mockito.mock(SpringServiceDiscovery.class);
    CrnkBoot boot = config.crnkBoot(serviceDiscovery);
    PropertiesProvider propertiesProvider = boot.getPropertiesProvider();
    Assert.assertEquals("testDomain", propertiesProvider.getProperty(CrnkProperties.RESOURCE_DEFAULT_DOMAIN));
    Assert.assertEquals("ch.something", propertiesProvider.getProperty(CrnkProperties.RESOURCE_SEARCH_PACKAGE));
    Assert.assertEquals("prefix", propertiesProvider.getProperty(CrnkProperties.WEB_PATH_PREFIX));
    Assert.assertEquals("true", propertiesProvider.getProperty(CrnkProperties.ALLOW_UNKNOWN_ATTRIBUTES));
    Assert.assertEquals("true", propertiesProvider.getProperty(CrnkProperties.RETURN_404_ON_NULL));
    DefaultQuerySpecDeserializer deserializer = (DefaultQuerySpecDeserializer) boot.getQuerySpecDeserializer();
    Assert.assertTrue(deserializer.getAllowUnknownAttributes());
    ConstantServiceUrlProvider constantServiceUrlProvider = (ConstantServiceUrlProvider) boot.getServiceUrlProvider();
    Assert.assertEquals("testDomainprefix", constantServiceUrlProvider.getUrl());
    Assert.assertSame(objectMapper, boot.getObjectMapper());
    Assert.assertNotNull(boot.getModuleRegistry().getSecurityProvider());
}
Also used : PropertiesProvider(io.crnk.core.engine.properties.PropertiesProvider) ApplicationContext(org.springframework.context.ApplicationContext) CrnkBoot(io.crnk.core.boot.CrnkBoot) DefaultQuerySpecDeserializer(io.crnk.core.queryspec.DefaultQuerySpecDeserializer) Environment(org.springframework.core.env.Environment) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) CrnkSpringBootProperties(io.crnk.spring.boot.CrnkSpringBootProperties) ObjectMapper(com.fasterxml.jackson.databind.ObjectMapper) CrnkConfigV3(io.crnk.spring.boot.v3.CrnkConfigV3) SpringServiceDiscovery(io.crnk.spring.internal.SpringServiceDiscovery) Test(org.junit.Test)

Aggregations

ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 CrnkBoot (io.crnk.core.boot.CrnkBoot)1 PropertiesProvider (io.crnk.core.engine.properties.PropertiesProvider)1 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)1 DefaultQuerySpecDeserializer (io.crnk.core.queryspec.DefaultQuerySpecDeserializer)1 CrnkSpringBootProperties (io.crnk.spring.boot.CrnkSpringBootProperties)1 CrnkConfigV3 (io.crnk.spring.boot.v3.CrnkConfigV3)1 SpringServiceDiscovery (io.crnk.spring.internal.SpringServiceDiscovery)1 Test (org.junit.Test)1 ApplicationContext (org.springframework.context.ApplicationContext)1 Environment (org.springframework.core.env.Environment)1