use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class PathBuilderTest method prepare.
@Before
public void prepare() {
CrnkBoot boot = new CrnkBoot();
boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
boot.boot();
pathBuilder = new PathBuilder(boot.getResourceRegistry());
RegistryEntry entry = boot.getResourceRegistry().findEntry(Task.class);
ResourceRepositoryInformation repositoryInformation = entry.getRepositoryInformation();
repositoryInformation.getActions().put("someRepositoryAction", Mockito.mock(RepositoryAction.class));
repositoryInformation.getActions().put("someResourceAction", Mockito.mock(RepositoryAction.class));
}
use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class ControllerRegistryTest method prepare.
@Before
public void prepare() {
CrnkBoot boot = new CrnkBoot();
boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
boot.boot();
resourceRegistry = boot.getResourceRegistry();
}
use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class AbstractJpaTest method setup.
@Before
public void setup() {
ModuleRegistry moduleRegistry = new ModuleRegistry();
moduleRegistry.getHttpRequestContextProvider().setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost:1234"));
resourceRegistry = new ResourceRegistryImpl(new DefaultResourceRegistryPart(), moduleRegistry);
module = JpaModule.newServerModule(emFactory, em, transactionRunner);
setupModule(module);
moduleRegistry.addModule(new JacksonModule(new ObjectMapper()));
moduleRegistry.addModule(new CoreModule());
moduleRegistry.addModule(module);
moduleRegistry.setServiceDiscovery(new EmptyServiceDiscovery());
moduleRegistry.init(new ObjectMapper());
queryFactory = createQueryFactory(em);
module.setQueryFactory(queryFactory);
clear();
for (int i = 0; i < numTestEntities; i++) {
TestEmbeddedIdEntity idEntity = new TestEmbeddedIdEntity();
idEntity.setId(new TestIdEmbeddable(i, "test" + i));
idEntity.setLongValue(100L + i);
em.persist(idEntity);
RelatedEntity related = new RelatedEntity();
related.setId(100L + i);
related.setStringValue("related" + i);
em.persist(related);
TestAnyType anyValue = new TestAnyType();
if (i == 0)
anyValue.setValue("first");
else
anyValue.setValue(i);
TestEmbeddable embValue = new TestEmbeddable();
embValue.setEmbIntValue(i);
embValue.setEmbStringValue("emb" + i);
embValue.setNestedValue(new TestNestedEmbeddable(i == 0));
embValue.setAnyValue(anyValue);
TestEntity test = new TestEntity();
test.setStringValue("test" + i);
test.setId((long) i);
test.setLongValue(i);
test.setEmbValue(embValue);
// left join sorting
if (i != numTestEntities - 1) {
test.setOneRelatedValue(related);
test.getMapValue().put("a", "a" + i);
test.getMapValue().put("b", "b" + i);
test.getMapValue().put("c", "c" + i);
}
em.persist(test);
// inheritance
SingleTableBaseEntity singleTableBase = new SingleTableBaseEntity();
singleTableBase.setId((long) i);
singleTableBase.setStringValue("base" + i);
em.persist(singleTableBase);
SingleTableChildEntity singleTableChild = new SingleTableChildEntity();
singleTableChild.setId((long) i + numTestEntities);
singleTableChild.setStringValue("child" + i);
singleTableChild.setIntValue(i);
em.persist(singleTableChild);
JoinedTableBaseEntity joinedTableBase = new JoinedTableBaseEntity();
joinedTableBase.setId((long) i);
joinedTableBase.setStringValue("base" + i);
em.persist(joinedTableBase);
JoinedTableChildEntity joinedTableChild = new JoinedTableChildEntity();
joinedTableChild.setId((long) i + numTestEntities);
joinedTableChild.setStringValue("child" + i);
joinedTableChild.setIntValue(i);
em.persist(joinedTableChild);
TablePerClassBaseEntity tablePerClassBase = new TablePerClassBaseEntity();
tablePerClassBase.setId((long) i);
tablePerClassBase.setStringValue("base" + i);
em.persist(tablePerClassBase);
TablePerClassChildEntity tablePerClassChild = new TablePerClassChildEntity();
tablePerClassChild.setId((long) i + numTestEntities);
tablePerClassChild.setStringValue("child" + i);
tablePerClassChild.setIntValue(i);
em.persist(tablePerClassChild);
}
em.flush();
em.clear();
queryFactory = createQueryFactory(em);
module.setQueryFactory(queryFactory);
}
use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class ValidationMetaProviderTest method setup.
private void setup(boolean addValidationProvider) {
CrnkBoot boot = new CrnkBoot();
boot.addModule(new JaxrsModule(null));
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost"));
boot.setServiceDiscovery(new ReflectionsServiceDiscovery("io.crnk.validation.mock", new SampleJsonServiceLocator()));
boot.boot();
resourceMetaProvider = new ResourceMetaProvider();
lookup = new MetaLookup();
lookup.setModuleContext(boot.getModuleRegistry().getContext());
lookup.addProvider(resourceMetaProvider);
if (addValidationProvider) {
lookup.addProvider(new ValidationMetaProvider());
}
lookup.initialize();
}
use of io.crnk.core.engine.url.ConstantServiceUrlProvider in project crnk-framework by crnk-project.
the class AbstractQuerySpecTest method setup.
@Before
public void setup() {
ResourceInformationProvider resourceInformationProvider = new DefaultResourceInformationProvider(new NullPropertiesProvider(), ImmutableList.of(new OffsetLimitPagingBehavior(), new CustomOffsetLimitPagingBehavior()), new DefaultResourceFieldInformationProvider(), new JacksonResourceFieldInformationProvider()) {
@Override
protected List<ResourceField> getResourceFields(Class<?> resourceClass) {
List<ResourceField> fields = super.getResourceFields(resourceClass);
if (resourceClass == Task.class) {
// add additional field that is not defined on the class
String name = "computedAttribute";
ResourceFieldAccess access = new ResourceFieldAccess(true, true, true, true, true);
InformationBuilder informationBuilder = new DefaultInformationBuilder(new TypeParser());
InformationBuilder.Field fieldBuilder = informationBuilder.createResourceField();
fieldBuilder.type(Integer.class);
fieldBuilder.jsonName(name);
fieldBuilder.underlyingName(name);
fieldBuilder.access(access);
fieldBuilder.accessor(new ResourceFieldAccessor() {
public Object getValue(Object resource) {
return 13;
}
public void setValue(Object resource, Object fieldValue) {
}
});
fields.add(fieldBuilder.build());
}
return fields;
}
};
SimpleModule testModule = new SimpleModule("test");
testModule.addResourceInformationProvider(resourceInformationProvider);
CrnkBoot boot = new CrnkBoot();
boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://127.0.0.1"));
boot.addModule(testModule);
boot.setServiceDiscovery(new ReflectionsServiceDiscovery(getResourceSearchPackage()));
boot.boot();
moduleRegistry = boot.getModuleRegistry();
querySpecConverter = new DefaultQuerySpecConverter(moduleRegistry);
resourceRegistry = boot.getResourceRegistry();
}
Aggregations