Search in sources :

Example 6 with Project

use of io.crnk.test.mock.models.Project in project crnk-framework by crnk-project.

the class InformationClientTest method testMeta.

@Test
public void testMeta() {
    QuerySpec querySpec = new QuerySpec(Project.class);
    ResourceList<Project> list = projectRepo.findAll(querySpec);
    ProjectsMetaInformation metaInformation = list.getMeta(ProjectsMetaInformation.class);
    Assert.assertEquals("testMeta", metaInformation.getMetaValue());
    Project project = list.get(0);
    ProjectMeta projectMeta = project.getMeta();
    Assert.assertNotNull(projectMeta);
    Assert.assertEquals("someMetaValue", projectMeta.getValue());
}
Also used : Project(io.crnk.test.mock.models.Project) QuerySpec(io.crnk.core.queryspec.QuerySpec) ProjectsMetaInformation(io.crnk.test.mock.repository.ProjectRepository.ProjectsMetaInformation) ProjectMeta(io.crnk.test.mock.models.Project.ProjectMeta) Test(org.junit.Test)

Example 7 with Project

use of io.crnk.test.mock.models.Project in project crnk-framework by crnk-project.

the class InformationClientTest method setup.

@Before
public void setup() {
    super.setup();
    taskRepo = client.getQuerySpecRepository(Task.class);
    projectRepo = client.getQuerySpecRepository(Project.class);
    Project project = new Project();
    project.setId(14L);
    projectRepo.create(project);
}
Also used : Project(io.crnk.test.mock.models.Project) Task(io.crnk.test.mock.models.Task) Before(org.junit.Before)

Example 8 with Project

use of io.crnk.test.mock.models.Project in project crnk-framework by crnk-project.

the class QueryParamsClientTest method testAddSetRemoveRelations.

@Test
public void testAddSetRemoveRelations() {
    Project project0 = new Project();
    project0.setId(1L);
    project0.setName("project0");
    projectRepo.create(project0);
    Project project1 = new Project();
    project1.setId(2L);
    project1.setName("project1");
    projectRepo.create(project1);
    Task task = new Task();
    task.setId(3L);
    task.setName("test");
    taskRepo.create(task);
    relRepo.addRelations(task, Arrays.asList(project0.getId(), project1.getId()), "projects");
    List<Project> relProjects = relRepo.findManyTargets(task.getId(), "projects", new QueryParams());
    Assert.assertEquals(2, relProjects.size());
    relRepo.setRelations(task, Arrays.asList(project1.getId()), "projects");
    relProjects = relRepo.findManyTargets(task.getId(), "projects", new QueryParams());
    Assert.assertEquals(1, relProjects.size());
    Assert.assertEquals(project1.getId(), relProjects.get(0).getId());
// FIXME HTTP DELETE method with payload not supported? at least in
// Jersey
// relRepo.removeRelations(task, Arrays.asList(project1.getId()),
// "projects");
// relProjects = relRepo.findManyTargets(task.getId(), "projects", new
// QueryParams());
// Assert.assertEquals(0, relProjects.size());
}
Also used : Project(io.crnk.test.mock.models.Project) Task(io.crnk.test.mock.models.Task) QueryParams(io.crnk.legacy.queryParams.QueryParams) Test(org.junit.Test)

Example 9 with Project

use of io.crnk.test.mock.models.Project in project crnk-framework by crnk-project.

the class QueryParamsClientTest method testSetRelation.

@Test
public void testSetRelation() {
    Project project = new Project();
    project.setId(1L);
    project.setName("project");
    projectRepo.create(project);
    Task task = new Task();
    task.setId(2L);
    task.setName("test");
    taskRepo.create(task);
    relRepo.setRelation(task, project.getId(), "project");
    Project relProject = relRepo.findOneTarget(task.getId(), "project", new QueryParams());
    Assert.assertNotNull(relProject);
    Assert.assertEquals(project.getId(), relProject.getId());
}
Also used : Project(io.crnk.test.mock.models.Project) Task(io.crnk.test.mock.models.Task) QueryParams(io.crnk.legacy.queryParams.QueryParams) Test(org.junit.Test)

Example 10 with Project

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

Aggregations

Project (io.crnk.test.mock.models.Project)17 Task (io.crnk.test.mock.models.Task)12 Test (org.junit.Test)7 QuerySpec (io.crnk.core.queryspec.QuerySpec)6 Schedule (io.crnk.test.mock.models.Schedule)3 DefaultResourceList (io.crnk.core.resource.list.DefaultResourceList)2 QueryParams (io.crnk.legacy.queryParams.QueryParams)2 Before (org.junit.Before)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 ObjectProxy (io.crnk.client.internal.proxy.ObjectProxy)1 ProjectLinks (io.crnk.test.mock.models.Project.ProjectLinks)1 ProjectMeta (io.crnk.test.mock.models.Project.ProjectMeta)1 TaskSubType (io.crnk.test.mock.models.TaskSubType)1 ProjectRepository (io.crnk.test.mock.repository.ProjectRepository)1 ProjectsLinksInformation (io.crnk.test.mock.repository.ProjectRepository.ProjectsLinksInformation)1 ProjectsMetaInformation (io.crnk.test.mock.repository.ProjectRepository.ProjectsMetaInformation)1 TaskRepository (io.crnk.test.mock.repository.TaskRepository)1 Serializable (java.io.Serializable)1 JsonFluentAssert (net.javacrumbs.jsonunit.fluent.JsonFluentAssert)1 Span (org.springframework.cloud.sleuth.Span)1