org.springframework.hateoas.Links.of()

Here are the examples of the java api org.springframework.hateoas.Links.of() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

22 Examples 7

19 Source : JsonApiLinksDeserializer.java
with Apache License 2.0
from toedter

@Override
public Links deserialize(JsonParser jp, DeserializationContext ctxt) throws IOException {
    JavaType type = ctxt.getTypeFactory().constructMapType(HashMap.clreplaced, String.clreplaced, Object.clreplaced);
    List<Link> links = new ArrayList<>();
    Map<String, Object> jsonApiLinks = jp.getCodec().readValue(jp, type);
    jsonApiLinks.forEach((rel, object) -> {
        if (object instanceof List) {
            for (Object linkObject : (List<?>) object) {
                deserializeLink(links, rel, linkObject);
            }
        } else {
            deserializeLink(links, rel, object);
        }
    });
    return Links.of(links);
}

19 Source : WebFluxPersonController.java
with Apache License 2.0
from ingogriebsch

@GetMapping("/persons/{id}")
public Mono<EnreplacedyModel<Person>> findOne(@PathVariable Integer id) {
    WebFluxPersonController controller = methodOn(WebFluxPersonController.clreplaced);
    Mono<Link> selfLink = // 
    linkTo(controller.findOne(id)).withSelfRel().andAffordance(// 
    controller.update(id, null)).andAffordance(// 
    controller.patch(id, null)).toMono();
    Mono<Link> personsLink = // 
    linkTo(controller.findAll()).withRel("persons").toMono();
    return // 
    selfLink.zipWith(personsLink).map(// 
    function((left, right) -> Links.of(left, right))).map(links -> EnreplacedyModel.of(PERSONS.get(id), links));
}

19 Source : ResourceDeserializerTest.java
with Apache License 2.0
from BlackPepperSoftware

@Test
public void deserializeResolvesType() throws Exception {
    mapper.readValue("{\"_links\":{\"self\":{\"href\":\"http://x.com/1\"}}}", new TypeReference<EnreplacedyModel<DeclaredType>>() {
    });
    verify(typeResolver).resolveType(DeclaredType.clreplaced, Links.of(new Link("http://x.com/1", IreplacedinkRelations.SELF)), configuration);
}

19 Source : DefaultTypeResolverTest.java
with Apache License 2.0
from BlackPepperSoftware

@Test
public void resolveTypeWithSubtypesAndMatchingAbsoluteUriSubtypeReturnsSubtype() {
    Configuration config = Configuration.builder().setBaseUri("http://x.com").build();
    Clreplaced<?> type = resolver.resolveType(TypeWithSubtypes.clreplaced, Links.of(new Link("http://x.com/2/1", IreplacedinkRelations.SELF)), config);
    replacedertThat(type, Matchers.<Clreplaced<?>>equalTo(TypeWithSubtypesSubtype2.clreplaced));
}

19 Source : DefaultTypeResolverTest.java
with Apache License 2.0
from BlackPepperSoftware

@Test
public void resolveTypeWithNonRemoteResourceSubtypeThrowsException() {
    thrown.expect(ClientProxyException.clreplaced);
    thrown.expectMessage(TypeWithNonRemoteResourceSubtypeSubtype.clreplaced.getName() + " is not annotated with @RemoteResource");
    resolver.resolveType(TypeWithNonRemoteResourceSubtype.clreplaced, Links.of(new Link("/", IreplacedinkRelations.SELF)), Configuration.build());
}

19 Source : DefaultTypeResolverTest.java
with Apache License 2.0
from BlackPepperSoftware

@Test
public void resolveTypeWithNoResourceTypeInfoReturnsDeclaredType() {
    Clreplaced<?> type = resolver.resolveType(TypeWithoutInfo.clreplaced, Links.of(new Link("http://x", IreplacedinkRelations.SELF)), Configuration.build());
    replacedertThat(type, Matchers.<Clreplaced<?>>equalTo(TypeWithoutInfo.clreplaced));
}

19 Source : DefaultTypeResolverTest.java
with Apache License 2.0
from BlackPepperSoftware

@Test
public void resolveTypeWithResolverReturnsResolvedType() {
    Links links = Links.of(new Link("_"));
    Configuration config = Configuration.build();
    doReturn(TypeWithResolverSubtype.clreplaced).when(Resolver.mockResolver).resolveType(TypeWithResolver.clreplaced, links, config);
    Clreplaced<?> type = resolver.resolveType(TypeWithResolver.clreplaced, links, config);
    replacedertThat(type, Matchers.<Clreplaced<?>>equalTo(TypeWithResolverSubtype.clreplaced));
}

19 Source : DefaultTypeResolverTest.java
with Apache License 2.0
from BlackPepperSoftware

@Test
public void resolveTypeWithIllegalSubtypeThrowsException() {
    thrown.expect(ClientProxyException.clreplaced);
    thrown.expectMessage(TypeWithIllegalSubtypeSubtype.clreplaced.getName() + " is not a subtype of " + TypeWithIllegalSubtype.clreplaced.getName());
    resolver.resolveType(TypeWithIllegalSubtype.clreplaced, Links.of(new Link("/x/1", IreplacedinkRelations.SELF)), Configuration.build());
}

19 Source : DefaultTypeResolverTest.java
with Apache License 2.0
from BlackPepperSoftware

@Test
public void resolveTypeWithSubtypesAndNoMatchingSubtypeReturnsDeclaredType() {
    Clreplaced<?> type = resolver.resolveType(TypeWithSubtypes.clreplaced, Links.of(new Link("http://x", IreplacedinkRelations.SELF)), Configuration.build());
    replacedertThat(type, Matchers.<Clreplaced<?>>equalTo(TypeWithSubtypes.clreplaced));
}

19 Source : DefaultTypeResolverTest.java
with Apache License 2.0
from BlackPepperSoftware

@Test
public void resolveTypeWithSubtypesAndNoSelfLinkReturnsDeclaredType() {
    Clreplaced<?> type = resolver.resolveType(TypeWithSubtypes.clreplaced, Links.of(), Configuration.build());
    replacedertThat(type, Matchers.<Clreplaced<?>>equalTo(TypeWithSubtypes.clreplaced));
}

19 Source : DefaultTypeResolverTest.java
with Apache License 2.0
from BlackPepperSoftware

@Test
public void resolveTypeWithOverspecifiedResourceTypeInfoThrowsException() {
    thrown.expect(ClientProxyException.clreplaced);
    thrown.expectMessage("one of subtypes or typeResolver must be specified");
    resolver.resolveType(TypeWithOverspecifiedInfo.clreplaced, Links.of(), Configuration.build());
}

19 Source : DefaultTypeResolverTest.java
with Apache License 2.0
from BlackPepperSoftware

@Test
public void resolveTypeWithSubtypesAndMatchingAbsolutePathReferenceUriSubtypeReturnsSubtype() {
    Configuration config = Configuration.builder().setBaseUri("http://x.com").build();
    Clreplaced<?> type = resolver.resolveType(TypeWithSubtypes.clreplaced, Links.of(new Link("/2/1", IreplacedinkRelations.SELF)), config);
    replacedertThat(type, Matchers.<Clreplaced<?>>equalTo(TypeWithSubtypesSubtype2.clreplaced));
}

19 Source : DefaultTypeResolverTest.java
with Apache License 2.0
from BlackPepperSoftware

@Test
public void resolveTypeWithUnderspecifiedResourceTypeInfoThrowsException() {
    thrown.expect(ClientProxyException.clreplaced);
    thrown.expectMessage("one of subtypes or typeResolver must be specified");
    resolver.resolveType(TypeWithUnderspecifiedInfo.clreplaced, Links.of(), Configuration.build());
}

19 Source : ResourceDeserializer.java
with Apache License 2.0
from BlackPepperSoftware

@Override
public EnreplacedyModel<?> deserialize(JsonParser p, DeserializationContext ctxt) throws IOException {
    ObjectNode node = p.readValueAs(ObjectNode.clreplaced);
    ObjectMapper mapper = (ObjectMapper) p.getCodec();
    RepresentationModel resource = mapper.convertValue(node, RepresentationModel.clreplaced);
    Links links = Links.of(resource.getLinks());
    Object content = mapper.convertValue(node, getResourceDeserializationType(links));
    return new EnreplacedyModel<>(content, links);
}

18 Source : Event.java
with Apache License 2.0
from kbastani

@Override
@SuppressWarnings("unchecked")
public Links getLinks() {
    List<Link> links = super.getLinks().stream().collect(Collectors.toList());
    links.add(getId());
    Clreplaced<T> clazz = (Clreplaced<T>) ((ParameterizedTypeImpl) this.getClreplaced().getGenericSuperclreplaced()).getActualTypeArguments()[0];
    links.add(getEnreplacedy().getId().withRel(new EvoInflectorLinkRelationProvider().gereplacedemResourceRelFor(clazz)));
    return Links.of(links);
}

14 Source : Jackson2JsonApiIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_serialize_movies_with_long_id() throws Exception {
    MovieWithLongId movie = new MovieWithLongId(1, "Star Wars", "long-movies");
    EnreplacedyModel<MovieWithLongId> enreplacedyModel = EnreplacedyModel.of(movie).add(Links.of(Link.of("http://localhost/movies/1").withSelfRel()));
    String movieJson = mapper.writeValuereplacedtring(enreplacedyModel);
    compareWithFile(movieJson, "movieEnreplacedyModelWithLongId.json");
}

14 Source : Jackson2JsonApiIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_serialize_movie_with_complex_link() throws Exception {
    MovieWithLongId movie = new MovieWithLongId(1, "Star Wars", "long-movies");
    EnreplacedyModel<MovieWithLongId> enreplacedyModel = EnreplacedyModel.of(movie).add(Links.of(Link.of("http://localhost/movies/1").withRel("related").withName("link name").withreplacedle("link replacedle")));
    String movieJson = mapper.writeValuereplacedtring(enreplacedyModel);
    compareWithFile(movieJson, "movieEnreplacedyModelWithComplexLink.json");
}

14 Source : Jackson2JsonApiIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_serialize_movie_with_templated_link() throws Exception {
    Movie movie = new Movie("1", "Star Wars");
    EnreplacedyModel<Movie> enreplacedyModel = EnreplacedyModel.of(movie).add(Links.of(Link.of("http://localhost/directors?{page,size}").withRel("directors")));
    final String movieJson = mapper.writeValuereplacedtring(enreplacedyModel);
    compareWithFile(movieJson, "movieEnreplacedyModelWithTemplatedLink.json");
}

14 Source : Jackson2JsonApiIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_serialize_single_movie_enreplacedy_model() throws Exception {
    Movie movie = new Movie("1", "Star Wars");
    EnreplacedyModel<Movie> enreplacedyModel = EnreplacedyModel.of(movie).add(Links.of(Link.of("http://localhost/movies/1").withSelfRel()));
    String movieJson = mapper.writeValuereplacedtring(enreplacedyModel);
    compareWithFile(movieJson, "movieEnreplacedyModelWithLinks.json");
}

13 Source : Jackson2JsonApiIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_not_serialize_movie_without_id_and_link() {
    replacedertions.replacedertThrows(JsonMappingException.clreplaced, () -> {
        Movie movie = new Movie(null, "Star Wars");
        EnreplacedyModel<Movie> enreplacedyModel = EnreplacedyModel.of(movie).add(Links.of(Link.of("http://localhost/movies/1").withSelfRel()));
        mapper.writeValuereplacedtring(enreplacedyModel);
    });
}

11 Source : Jackson2JsonApiIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_serialize_movie_collection_model() throws Exception {
    Movie movie1 = new Movie("1", "Star Wars");
    Movie movie2 = new Movie("2", "Avengers");
    List<Movie> movies = new ArrayList<>();
    movies.add(movie1);
    movies.add(movie2);
    CollectionModel<Movie> collectionModel = CollectionModel.of(movies).add(Links.of(Link.of("http://localhost/movies").withSelfRel()));
    String moviesJson = mapper.writeValuereplacedtring(collectionModel);
    compareWithFile(moviesJson, "moviesCollectionModelFromResources.json");
}

9 Source : Jackson2JsonApiIntegrationTest.java
with Apache License 2.0
from toedter

@Test
void should_serialize_movie_collection_model_with_enreplacedy_models() throws Exception {
    Movie movie1 = new Movie("1", "Star Wars");
    EnreplacedyModel<Movie> movie1Model = EnreplacedyModel.of(movie1);
    movie1Model.add(Link.of("http://localhost/movies/1").withSelfRel());
    Movie movie2 = new Movie("2", "Avengers");
    EnreplacedyModel<Movie> movie2Model = EnreplacedyModel.of(movie2);
    movie2Model.add(Link.of("http://localhost/movies/2").withSelfRel());
    List<EnreplacedyModel<Movie>> movies = new ArrayList<>();
    movies.add(movie1Model);
    movies.add(movie2Model);
    CollectionModel<EnreplacedyModel<Movie>> collectionModel = CollectionModel.of(movies).add(Links.of(Link.of("http://localhost/movies").withSelfRel()));
    String moviesJson = mapper.writeValuereplacedtring(collectionModel);
    compareWithFile(moviesJson, "moviesCollectionModel.json");
}