use of io.crnk.core.mock.repository.UserRepository in project crnk-framework by crnk-project.
the class RepositoryFilterTest method prepare.
@Before
public void prepare() {
boot = new CrnkBoot();
boot.setServiceDiscovery(new ReflectionsServiceDiscovery(MockConstants.TEST_MODELS_PACKAGE));
boot.setServiceUrlProvider(new ConstantServiceUrlProvider(ResourceRegistryTest.TEST_MODELS_URL));
SimpleModule filterModule = new SimpleModule("filter");
filterModule.addRepositoryFilter(filter);
boot.addModule(filterModule);
boot.boot();
resourceRegistry = boot.getResourceRegistry();
querySpec = new QuerySpec(User.class);
querySpec.setPagingSpec(new OffsetLimitPagingSpec());
queryAdapter = new QuerySpecAdapter(querySpec, resourceRegistry);
scheduleInfo = resourceRegistry.getEntry(Schedule.class).getResourceInformation();
RegistryEntry userEntry = resourceRegistry.getEntry(User.class);
resourceAdapter = userEntry.getResourceRepository(null);
projectRelationAdapter = userEntry.getRelationshipRepository("assignedProjects", null);
taskRelationAdapter = userEntry.getRelationshipRepository("assignedTasks", null);
userInfo = userEntry.getResourceInformation();
UserRepository resourceRepository = (UserRepository) resourceAdapter.getResourceRepository();
user1 = new User();
user1.setId(1L);
resourceRepository.save(user1);
user2 = new User();
user2.setId(2L);
resourceRepository.save(user2);
UserToProjectRepository userProjectRepository = (UserToProjectRepository) ((AnnotatedRelationshipRepositoryAdapter<?, ?, ?, ?>) projectRelationAdapter.getRelationshipRepository()).getImplementationObject();
userProjectRepository.setRelation(user1, 11L, "assignedProjects");
UserToTaskRepository userTaskRepository = new UserToTaskRepository();
userTaskRepository.addRelations(user1, Arrays.asList(21L), "assignedTasks");
userTaskRepository.addRelations(user2, Arrays.asList(22L), "assignedTasks");
assignedTasksField = resourceRegistry.getEntry(User.class).getResourceInformation().findRelationshipFieldByName("assignedTasks");
assignedProjectsField = resourceRegistry.getEntry(User.class).getResourceInformation().findRelationshipFieldByName("assignedProjects");
}
Aggregations