Search in sources :

Example 1 with ProjectRepository

use of io.crnk.test.mock.repository.ProjectRepository 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 2 with ProjectRepository

use of io.crnk.test.mock.repository.ProjectRepository 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)

Aggregations

ProjectRepository (io.crnk.test.mock.repository.ProjectRepository)2 TaskRepository (io.crnk.test.mock.repository.TaskRepository)2 SimpleModule (io.crnk.core.module.SimpleModule)1 Project (io.crnk.test.mock.models.Project)1 Task (io.crnk.test.mock.models.Task)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