use of io.crnk.core.queryspec.QuerySpecDeserializer in project crnk-framework by crnk-project.
the class CrnkFeatureTest method testQuerySpecConstructor.
@Test
public void testQuerySpecConstructor() {
ObjectMapper objectMapper = new ObjectMapper();
QuerySpecDeserializer querySpecDeserializer = new DefaultQuerySpecDeserializer();
SampleJsonServiceLocator serviceLocator = new SampleJsonServiceLocator();
CrnkFeature feature = new CrnkFeature(objectMapper, querySpecDeserializer, serviceLocator);
Assert.assertSame(objectMapper, feature.getObjectMapper());
Assert.assertSame(querySpecDeserializer, feature.getBoot().getQuerySpecDeserializer());
}
use of io.crnk.core.queryspec.QuerySpecDeserializer in project crnk-framework by crnk-project.
the class CrnkBootTest method testDiscoverDeserializer.
@Test
public void testDiscoverDeserializer() {
CrnkBoot boot = new CrnkBoot();
boot.setServiceDiscovery(serviceDiscovery);
DefaultQuerySpecDeserializer instance = new DefaultQuerySpecDeserializer();
Mockito.when(serviceDiscovery.getInstancesByType(eq(QuerySpecDeserializer.class))).thenReturn(Arrays.<QuerySpecDeserializer>asList(instance));
boot.boot();
Assert.assertSame(instance, boot.getQuerySpecDeserializer());
}
use of io.crnk.core.queryspec.QuerySpecDeserializer in project crnk-framework by crnk-project.
the class CrnkBoot method setupQuerySpecDeserializer.
private void setupQuerySpecDeserializer() {
if (querySpecDeserializer == null) {
setupServiceDiscovery();
List<QuerySpecDeserializer> list = serviceDiscovery.getInstancesByType(QuerySpecDeserializer.class);
if (list.isEmpty()) {
querySpecDeserializer = new DefaultQuerySpecDeserializer();
} else {
querySpecDeserializer = list.get(0);
}
}
if (querySpecDeserializer instanceof DefaultQuerySpecDeserializer) {
if (allowUnknownAttributes == null) {
String strAllow = propertiesProvider.getProperty(CrnkProperties.ALLOW_UNKNOWN_ATTRIBUTES);
if (strAllow != null) {
allowUnknownAttributes = Boolean.parseBoolean(strAllow);
}
}
if (allowUnknownAttributes != null) {
((DefaultQuerySpecDeserializer) this.querySpecDeserializer).setAllowUnknownAttributes(allowUnknownAttributes);
}
if (allowUnknownParameters == null) {
String strAllow = propertiesProvider.getProperty(CrnkProperties.ALLOW_UNKNOWN_PARAMETERS);
if (strAllow != null) {
allowUnknownParameters = Boolean.parseBoolean(strAllow);
}
}
if (allowUnknownParameters != null) {
((DefaultQuerySpecDeserializer) this.querySpecDeserializer).setAllowUnknownParameters(allowUnknownParameters);
}
}
}
use of io.crnk.core.queryspec.QuerySpecDeserializer in project crnk-framework by crnk-project.
the class CrnkBootTest method setQuerySpecDeserializer.
@Test
public void setQuerySpecDeserializer() {
CrnkBoot boot = new CrnkBoot();
boot.setServiceDiscoveryFactory(serviceDiscoveryFactory);
boot.setDefaultServiceUrlProvider(mock(ServiceUrlProvider.class));
QuerySpecDeserializer deserializer = Mockito.mock(QuerySpecDeserializer.class);
boot.setQuerySpecDeserializer(deserializer);
Assert.assertSame(deserializer, boot.getQuerySpecDeserializer());
boot.boot();
HttpRequestProcessorImpl requestDispatcher = boot.getRequestDispatcher();
QueryAdapterBuilder queryAdapterBuilder = requestDispatcher.getQueryAdapterBuilder();
Assert.assertTrue(queryAdapterBuilder instanceof QuerySpecAdapterBuilder);
}
Aggregations