Search in sources :

Example 21 with ReflectionsServiceDiscovery

use of io.crnk.core.module.discovery.ReflectionsServiceDiscovery in project crnk-framework by crnk-project.

the class OppositeFowardingRelationshipRepositoryTest method setup.

@Before
public void setup() {
    MockRepositoryUtil.clear();
    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();
    testRepository = (RelationIdTestRepository) resourceRegistry.getEntry(RelationIdTestResource.class).getResourceRepository().getResourceRepository();
    RelationshipMatcher relMatcher = new RelationshipMatcher().rule().source(RelationIdTestResource.class).target(RelationIdTestResource.class).add();
    relRepository = new ForwardingRelationshipRepository(RelationIdTestResource.class, relMatcher, ForwardingDirection.OPPOSITE, ForwardingDirection.OPPOSITE);
    relRepository.setResourceRegistry(resourceRegistry);
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ForwardingRelationshipRepository(io.crnk.core.repository.foward.ForwardingRelationshipRepository) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) RelationshipMatcher(io.crnk.core.repository.RelationshipMatcher) RelationIdTestResource(io.crnk.core.mock.models.RelationIdTestResource) Before(org.junit.Before)

Example 22 with ReflectionsServiceDiscovery

use of io.crnk.core.module.discovery.ReflectionsServiceDiscovery in project crnk-framework by crnk-project.

the class HttpRequestContextAwareTest method check.

@Test
public void check() throws IOException {
    HttTestModule testModule = Mockito.mock(HttTestModule.class);
    CrnkBoot boot = new CrnkBoot();
    boot.setServiceUrlProvider(new ConstantServiceUrlProvider("http://localhost:8080"));
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
    boot.addModule(testModule);
    boot.boot();
    Mockito.verify(testModule, Mockito.times(1)).setHttpRequestContextProvider(Mockito.any(HttpRequestContextProvider.class));
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) Test(org.junit.Test)

Example 23 with ReflectionsServiceDiscovery

use of io.crnk.core.module.discovery.ReflectionsServiceDiscovery 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));
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ResourceRepositoryInformation(io.crnk.core.engine.information.repository.ResourceRepositoryInformation) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) RepositoryAction(io.crnk.core.engine.information.repository.RepositoryAction) RegistryEntry(io.crnk.core.engine.registry.RegistryEntry) Before(org.junit.Before)

Example 24 with ReflectionsServiceDiscovery

use of io.crnk.core.module.discovery.ReflectionsServiceDiscovery 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();
}
Also used : CrnkBoot(io.crnk.core.boot.CrnkBoot) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ConstantServiceUrlProvider(io.crnk.core.engine.url.ConstantServiceUrlProvider) Before(org.junit.Before)

Example 25 with ReflectionsServiceDiscovery

use of io.crnk.core.module.discovery.ReflectionsServiceDiscovery in project crnk-framework by crnk-project.

the class ConstraintViolationImplTest method setup.

@Before
public void setup() {
    boot = new CrnkBoot();
    boot.addModule(ValidationModule.create());
    boot.setServiceDiscovery(new ReflectionsServiceDiscovery("io.crnk.validation.mock.repository"));
    boot.boot();
    errorData = Mockito.spy(new ErrorDataBuilder().setDetail("testMessage").addMetaField(ConstraintViolationExceptionMapper.META_RESOURCE_TYPE, "tasks").setSourcePointer("name").build());
    ResourceRegistry resourceRegistry = boot.getResourceRegistry();
    violation = ConstraintViolationImpl.fromError(resourceRegistry, errorData);
}
Also used : ErrorDataBuilder(io.crnk.core.engine.document.ErrorDataBuilder) CrnkBoot(io.crnk.core.boot.CrnkBoot) ReflectionsServiceDiscovery(io.crnk.core.module.discovery.ReflectionsServiceDiscovery) ResourceRegistry(io.crnk.core.engine.registry.ResourceRegistry) Before(org.junit.Before)

Aggregations

ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)30 CrnkBoot (io.crnk.core.boot.CrnkBoot)28 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)25 Before (org.junit.Before)22 Test (org.junit.Test)7 JsonApiUrlBuilder (io.crnk.core.engine.internal.utils.JsonApiUrlBuilder)6 RegistryEntry (io.crnk.core.engine.registry.RegistryEntry)5 Task (io.crnk.core.mock.models.Task)5 SimpleModule (io.crnk.core.module.SimpleModule)4 RelationIdTestResource (io.crnk.core.mock.models.RelationIdTestResource)3 PathBuilder (io.crnk.core.engine.internal.dispatcher.path.PathBuilder)2 PropertiesProvider (io.crnk.core.engine.properties.PropertiesProvider)2 ResourceRegistry (io.crnk.core.engine.registry.ResourceRegistry)2 Project (io.crnk.core.mock.models.Project)2 Schedule (io.crnk.core.mock.models.Schedule)2 User (io.crnk.core.mock.models.User)2 ProjectRepository (io.crnk.core.mock.repository.ProjectRepository)2 ScheduleRepositoryImpl (io.crnk.core.mock.repository.ScheduleRepositoryImpl)2 TaskRepository (io.crnk.core.mock.repository.TaskRepository)2 Module (io.crnk.core.module.Module)2