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());
}
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);
}
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());
}
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());
}
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);
}
Aggregations