Search in sources :

Example 6 with User

use of io.crnk.core.mock.models.User in project crnk-framework by crnk-project.

the class UserToTaskRepository method findManyTargets.

@JsonApiFindManyTargets
public ResourceList<Task> findManyTargets(Long sourceId, String fieldName, QuerySpec querySpec) {
    ResourceList<Task> projects = new DefaultResourceList<>();
    for (Relation<User> relation : THREAD_LOCAL_REPOSITORY.keySet()) {
        if (relation.getSource().getId().equals(sourceId) && relation.getFieldName().equals(fieldName)) {
            Task project = new Task();
            project.setId((Long) relation.getTargetId());
            projects.add(project);
        }
    }
    return projects;
}
Also used : Task(io.crnk.core.mock.models.Task) User(io.crnk.core.mock.models.User) DefaultResourceList(io.crnk.core.resource.list.DefaultResourceList) JsonApiFindManyTargets(io.crnk.legacy.repository.annotations.JsonApiFindManyTargets)

Example 7 with User

use of io.crnk.core.mock.models.User in project crnk-framework by crnk-project.

the class UserToProjectRepository method findOneTarget.

@JsonApiFindOneTarget
public Project findOneTarget(Long sourceId, String fieldName, QuerySpec querySpec) {
    for (Relation<User> relation : THREAD_LOCAL_REPOSITORY.keySet()) {
        if (relation.getSource().getId().equals(sourceId) && relation.getFieldName().equals(fieldName)) {
            Project project = new Project();
            project.setId((Long) relation.getTargetId());
            return project;
        }
    }
    return null;
}
Also used : Project(io.crnk.core.mock.models.Project) User(io.crnk.core.mock.models.User)

Example 8 with User

use of io.crnk.core.mock.models.User in project crnk-framework by crnk-project.

the class UserToProjectRepository method findManyTargets.

@JsonApiFindManyTargets
public Iterable<Project> findManyTargets(Long sourceId, String fieldName, QuerySpec querySpec) {
    List<Project> projects = new LinkedList<>();
    for (Relation<User> relation : THREAD_LOCAL_REPOSITORY.keySet()) {
        if (relation.getSource().getId().equals(sourceId) && relation.getFieldName().equals(fieldName)) {
            Project project = new Project();
            project.setId((Long) relation.getTargetId());
            projects.add(project);
        }
    }
    return projects;
}
Also used : Project(io.crnk.core.mock.models.Project) User(io.crnk.core.mock.models.User) LinkedList(java.util.LinkedList)

Example 9 with User

use of io.crnk.core.mock.models.User in project crnk-framework by crnk-project.

the class RegistryEntryFacadeTest method checkCreate.

@Test
public void checkCreate() {
    User updatedUser = new User();
    updatedUser.setName("updated");
    facade.save(updatedUser);
    ResourceList<User> list = facade.findAll(new QuerySpec(User.class));
    Assert.assertEquals(3, list.size());
}
Also used : User(io.crnk.core.mock.models.User) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Example 10 with User

use of io.crnk.core.mock.models.User in project crnk-framework by crnk-project.

the class RegistryEntryFacadeTest method checkSave.

@Test
public void checkSave() {
    User updatedUser = new User();
    updatedUser.setId(user1.getId());
    updatedUser.setName("updated");
    facade.save(updatedUser);
    User facadeUser = facade.findOne(user1.getId(), new QuerySpec(User.class));
    Assert.assertSame(updatedUser, facadeUser);
}
Also used : User(io.crnk.core.mock.models.User) QuerySpec(io.crnk.core.queryspec.QuerySpec) Test(org.junit.Test)

Aggregations

User (io.crnk.core.mock.models.User)16 Test (org.junit.Test)10 QuerySpec (io.crnk.core.queryspec.QuerySpec)8 Project (io.crnk.core.mock.models.Project)3 Task (io.crnk.core.mock.models.Task)3 CrnkBoot (io.crnk.core.boot.CrnkBoot)2 RepositoryRequestSpec (io.crnk.core.engine.dispatcher.RepositoryRequestSpec)2 ConstantServiceUrlProvider (io.crnk.core.engine.url.ConstantServiceUrlProvider)2 ReflectionsServiceDiscovery (io.crnk.core.module.discovery.ReflectionsServiceDiscovery)2 ResourceRegistryTest (io.crnk.core.resource.registry.ResourceRegistryTest)2 Before (org.junit.Before)2 Response (io.crnk.core.engine.dispatcher.Response)1 Relationship (io.crnk.core.engine.document.Relationship)1 Resource (io.crnk.core.engine.document.Resource)1 ResourceField (io.crnk.core.engine.information.resource.ResourceField)1 ResourceInformation (io.crnk.core.engine.information.resource.ResourceInformation)1 BaseControllerTest (io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest)1 FieldResourceGet (io.crnk.core.engine.internal.dispatcher.controller.FieldResourceGet)1 JsonPath (io.crnk.core.engine.internal.dispatcher.path.JsonPath)1 RelationshipRepositoryAdapter (io.crnk.core.engine.internal.repository.RelationshipRepositoryAdapter)1