Search in sources :

Example 66 with Project

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

the class RepositoryAdapterTest method onClassWithGetMetaInformationShouldInvokeMethod.

@Test
public void onClassWithGetMetaInformationShouldInvokeMethod() throws Exception {
    // GIVEN
    ResourceRepositoryWithGetMetaInformation repo = spy(ResourceRepositoryWithGetMetaInformation.class);
    AnnotatedResourceRepositoryAdapter<Project, Long> sut = new AnnotatedResourceRepositoryAdapter<>(repo, parameterFactory);
    List<Project> resources = Collections.singletonList(new Project());
    // WHEN
    sut.getMetaInformation(resources, queryAdapter);
    // THEN
    verify(repo).getMetaInformation(resources, queryParams, "");
}
Also used : Project(io.crnk.core.mock.models.Project) AnnotatedResourceRepositoryAdapter(io.crnk.legacy.internal.AnnotatedResourceRepositoryAdapter) Test(org.junit.Test)

Example 67 with Project

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

the class TaskToProjectRepository method findOneTarget.

@Override
public Project findOneTarget(Long sourceId, String fieldName, QueryParams queryParams) {
    Map<Relation<Task>, Integer> repo = getRepo();
    for (Relation<Task> relation : repo.keySet()) {
        if (relation.getSource().getId().equals(sourceId) && relation.getFieldName().equals(fieldName)) {
            Project project = new Project();
            if (relation.getTargetId().equals(ProjectRepository.FANCY_PROJECT_ID)) {
                project = new FancyProject();
            }
            project.setId((Long) relation.getTargetId());
            return project;
        }
    }
    return null;
}
Also used : FancyProject(io.crnk.core.mock.models.FancyProject) Project(io.crnk.core.mock.models.Project) Relation(io.crnk.core.mock.repository.util.Relation) Task(io.crnk.core.mock.models.Task) FancyProject(io.crnk.core.mock.models.FancyProject)

Example 68 with Project

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

the class AnnotatedResourceRepositoryAdapterTest method onClassWithoutSaveShouldThrowException.

@Test(expected = RepositoryAnnotationNotFoundException.class)
public void onClassWithoutSaveShouldThrowException() throws Exception {
    // GIVEN
    ResourceRepositoryWithoutAnyMethods repo = new ResourceRepositoryWithoutAnyMethods();
    AnnotatedResourceRepositoryAdapter<Project, Long> sut = new AnnotatedResourceRepositoryAdapter<>(repo, parameterProvider);
    // WHEN
    sut.save(new Project());
}
Also used : Project(io.crnk.core.mock.models.Project) AnnotatedResourceRepositoryAdapter(io.crnk.legacy.internal.AnnotatedResourceRepositoryAdapter) Test(org.junit.Test)

Aggregations

Project (io.crnk.core.mock.models.Project)68 Test (org.junit.Test)54 Task (io.crnk.core.mock.models.Task)44 Document (io.crnk.core.engine.document.Document)27 QuerySpec (io.crnk.core.queryspec.QuerySpec)25 Resource (io.crnk.core.engine.document.Resource)24 Response (io.crnk.core.engine.dispatcher.Response)15 Relationship (io.crnk.core.engine.document.Relationship)14 JsonPath (io.crnk.core.engine.internal.dispatcher.path.JsonPath)14 BaseControllerTest (io.crnk.core.engine.internal.dispatcher.controller.BaseControllerTest)12 AnnotatedRelationshipRepositoryAdapter (io.crnk.legacy.internal.AnnotatedRelationshipRepositoryAdapter)12 ResourcePost (io.crnk.core.engine.internal.dispatcher.controller.ResourcePost)11 LazyTask (io.crnk.core.mock.models.LazyTask)11 ResourceRegistryTest (io.crnk.core.resource.registry.ResourceRegistryTest)10 ResourceIdentifier (io.crnk.core.engine.document.ResourceIdentifier)8 TaskToProjectRepository (io.crnk.core.mock.repository.TaskToProjectRepository)8 ProjectRepository (io.crnk.core.mock.repository.ProjectRepository)7 TaskRepository (io.crnk.core.mock.repository.TaskRepository)7 QueryParams (io.crnk.legacy.queryParams.QueryParams)7 ResourceField (io.crnk.core.engine.information.resource.ResourceField)6