List of usage examples for org.springframework.data.rest.core.support DefaultSelfLinkProvider DefaultSelfLinkProvider
public DefaultSelfLinkProvider(PersistentEntities entities, EntityLinks entityLinks, List<? extends EntityLookup<?>> lookups)
From source file:org.springframework.data.rest.webmvc.PersistentEntityResourceAssemblerIntegrationTests.java
/** * @see DATAREST-609// w ww . j a v a2 s .co m */ @Test public void addsSelfAndSingleResourceLinkToResourceByDefault() throws Exception { Projector projector = mock(Projector.class); when(projector.projectExcerpt(anyObject())).thenAnswer(new ReturnsArgumentAt(0)); PersistentEntityResourceAssembler assembler = new PersistentEntityResourceAssembler(entities, projector, associations, new DefaultSelfLinkProvider(entities, entityLinks, Collections.<EntityLookup<?>>emptyList())); User user = new User(); user.id = BigInteger.valueOf(4711); PersistentEntityResource resource = assembler.toResource(user); Links links = new Links(resource.getLinks()); assertThat(links, is(Matchers.<Link>iterableWithSize(2))); assertThat(links.getLink("self").getVariables(), is(Matchers.empty())); assertThat(links.getLink("user").getVariableNames(), is(hasItem("projection"))); }
From source file:org.springframework.data.rest.tests.RepositoryTestsConfig.java
@Bean public Module persistentEntityModule() { RepositoryResourceMappings mappings = new RepositoryResourceMappings(repositories(), persistentEntities(), config().getRepositoryDetectionStrategy()); EntityLinks entityLinks = new RepositoryEntityLinks(repositories(), mappings, config(), mock(PagingAndSortingTemplateVariables.class), OrderAwarePluginRegistry .<Class<?>, BackendIdConverter>create(Arrays.asList(DefaultIdConverter.INSTANCE))); SelfLinkProvider selfLinkProvider = new DefaultSelfLinkProvider(persistentEntities(), entityLinks, Collections.<EntityLookup<?>>emptyList()); DefaultRepositoryInvokerFactory invokerFactory = new DefaultRepositoryInvokerFactory(repositories()); UriToEntityConverter uriToEntityConverter = new UriToEntityConverter(persistentEntities(), invokerFactory, repositories());/*w w w . j a va 2s .c o m*/ Associations associations = new Associations(mappings, config()); LinkCollector collector = new LinkCollector(persistentEntities(), selfLinkProvider, associations); NestedEntitySerializer nestedEntitySerializer = new NestedEntitySerializer(persistentEntities(), new EmbeddedResourcesAssembler(persistentEntities(), associations, mock(ExcerptProjector.class)), new ResourceProcessorInvoker(Collections.<ResourceProcessor<?>>emptyList())); return new PersistentEntityJackson2Module(associations, persistentEntities(), uriToEntityConverter, collector, invokerFactory, nestedEntitySerializer, mock(LookupObjectSerializer.class)); }
From source file:org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration.java
@Bean public SelfLinkProvider selfLinkProvider() { return new DefaultSelfLinkProvider(persistentEntities(), entityLinks(), getEntityLookups()); }