Search in sources :

Example 1 with TaskRepository

use of io.crnk.test.mock.repository.TaskRepository in project crnk-framework by crnk-project.

the class ControllerTest method setup.

@Before
public void setup() {
    TaskRepository repo = new TaskRepository();
    Task task = new Task();
    task.setName("test value");
    task.setId(1L);
    repo.save(task);
}
Also used : Task(io.crnk.test.mock.models.Task) TaskRepository(io.crnk.test.mock.repository.TaskRepository) Before(org.junit.Before)

Example 2 with TaskRepository

use of io.crnk.test.mock.repository.TaskRepository in project crnk-framework by crnk-project.

the class BasicSpringBootTest method testRelationshipInclusion.

@Test
public void testRelationshipInclusion() {
    Project project = new Project();
    ProjectRepository projectRepository = new ProjectRepository();
    projectRepository.save(project);
    Task task = new Task();
    task.setProject(project);
    TaskRepository taskRepository = new TaskRepository();
    taskRepository.save(task);
    RestTemplate testRestTemplate = new RestTemplate();
    ResponseEntity<String> response = testRestTemplate.getForEntity("http://localhost:" + this.port + "/api/tasks?include[tasks]=schedule%2Cproject", String.class);
    assertEquals(HttpStatus.OK, response.getStatusCode());
    JsonFluentAssert included = assertThatJson(response.getBody()).node("included");
    included.isArray().ofLength(1);
}
Also used : JsonFluentAssert(net.javacrumbs.jsonunit.fluent.JsonFluentAssert) Project(io.crnk.test.mock.models.Project) Task(io.crnk.test.mock.models.Task) ProjectRepository(io.crnk.test.mock.repository.ProjectRepository) TaskRepository(io.crnk.test.mock.repository.TaskRepository) RestTemplate(org.springframework.web.client.RestTemplate) Test(org.junit.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with TaskRepository

use of io.crnk.test.mock.repository.TaskRepository in project crnk-framework by crnk-project.

the class UriInfoServiceUrlProviderTest method setup.

@Before
public void setup() {
    TaskRepository repo = new TaskRepository();
    Task task = new Task();
    task.setName("test");
    task.setId(1L);
    repo.save(task);
}
Also used : Task(io.crnk.test.mock.models.Task) TaskRepository(io.crnk.test.mock.repository.TaskRepository) Before(org.junit.Before)

Example 4 with TaskRepository

use of io.crnk.test.mock.repository.TaskRepository in project crnk-framework by crnk-project.

the class MetaModuleProducer method createRepositoryModule.

@Produces
@ApplicationScoped
public Module createRepositoryModule() {
    SimpleModule module = new SimpleModule("mock");
    module.addRepository(new ScheduleRepositoryImpl());
    module.addRepository(new ProjectRepository());
    module.addRepository(new TaskRepository());
    module.addRepository(new ProjectToTaskRepository());
    module.addRepository(new ScheduleToTaskRepository());
    module.addRepository(new TaskSubtypeRepository());
    module.addRepository(new TaskToProjectRepository());
    module.addRepository(new TaskToScheduleRepo());
    return module;
}
Also used : ScheduleRepositoryImpl(io.crnk.test.mock.repository.ScheduleRepositoryImpl) ProjectRepository(io.crnk.test.mock.repository.ProjectRepository) TaskToProjectRepository(io.crnk.test.mock.repository.TaskToProjectRepository) TaskSubtypeRepository(io.crnk.test.mock.repository.TaskSubtypeRepository) ProjectToTaskRepository(io.crnk.test.mock.repository.ProjectToTaskRepository) TaskToProjectRepository(io.crnk.test.mock.repository.TaskToProjectRepository) TaskToScheduleRepo(io.crnk.test.mock.repository.TaskToScheduleRepo) TaskRepository(io.crnk.test.mock.repository.TaskRepository) ProjectToTaskRepository(io.crnk.test.mock.repository.ProjectToTaskRepository) ScheduleToTaskRepository(io.crnk.test.mock.repository.ScheduleToTaskRepository) ScheduleToTaskRepository(io.crnk.test.mock.repository.ScheduleToTaskRepository) SimpleModule(io.crnk.core.module.SimpleModule) Produces(javax.enterprise.inject.Produces) ApplicationScoped(javax.enterprise.context.ApplicationScoped)

Example 5 with TaskRepository

use of io.crnk.test.mock.repository.TaskRepository in project crnk-framework by crnk-project.

the class MetaModuleTest method createRegistryEntry.

private RegistryEntry createRegistryEntry() {
    ModuleRegistry moduleRegistry = boot.getModuleRegistry();
    RegistryEntryBuilder entryBuilder = moduleRegistry.getContext().newRegistryEntryBuilder();
    entryBuilder.resource().resourceClass(Task.class).resourceType("someNewTask");
    entryBuilder.resourceRepository().instance(new TaskRepository());
    return entryBuilder.build();
}
Also used : Task(io.crnk.test.mock.models.Task) RegistryEntryBuilder(io.crnk.core.engine.registry.RegistryEntryBuilder) TaskRepository(io.crnk.test.mock.repository.TaskRepository) ModuleRegistry(io.crnk.core.module.ModuleRegistry)

Aggregations

TaskRepository (io.crnk.test.mock.repository.TaskRepository)5 Task (io.crnk.test.mock.models.Task)4 ProjectRepository (io.crnk.test.mock.repository.ProjectRepository)2 Before (org.junit.Before)2 RegistryEntryBuilder (io.crnk.core.engine.registry.RegistryEntryBuilder)1 ModuleRegistry (io.crnk.core.module.ModuleRegistry)1 SimpleModule (io.crnk.core.module.SimpleModule)1 Project (io.crnk.test.mock.models.Project)1 ProjectToTaskRepository (io.crnk.test.mock.repository.ProjectToTaskRepository)1 ScheduleRepositoryImpl (io.crnk.test.mock.repository.ScheduleRepositoryImpl)1 ScheduleToTaskRepository (io.crnk.test.mock.repository.ScheduleToTaskRepository)1 TaskSubtypeRepository (io.crnk.test.mock.repository.TaskSubtypeRepository)1 TaskToProjectRepository (io.crnk.test.mock.repository.TaskToProjectRepository)1 TaskToScheduleRepo (io.crnk.test.mock.repository.TaskToScheduleRepo)1 ApplicationScoped (javax.enterprise.context.ApplicationScoped)1 Produces (javax.enterprise.inject.Produces)1 JsonFluentAssert (net.javacrumbs.jsonunit.fluent.JsonFluentAssert)1 Test (org.junit.Test)1 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)1 RestTemplate (org.springframework.web.client.RestTemplate)1