Package org.springframework.data.rest.webmvc.jpa

Examples of org.springframework.data.rest.webmvc.jpa.Person


  @Test
  public void setsExpandedSelfUriInLocationHeader() throws Exception {

    RootResourceInformation information = getResourceInformation(Order.class);

    PersistentEntityResource persistentEntityResource = PersistentEntityResource.build(new Order(new Person()),
        entities.getPersistentEntity(Order.class)).build();

    ResponseEntity<?> entity = controller.putItemResource(information, persistentEntityResource, 1L, assembler);

    assertThat(entity.getHeaders().getLocation().toString(), not(endsWith("{?projection}")));
View Full Code Here


  }

  @Test
  public void deserializesPersonEntity() throws IOException {

    Person p = mapper.readValue(PERSON_JSON_IN, Person.class);

    assertThat(p.getFirstName(), is("John"));
    assertThat(p.getLastName(), is("Doe"));
    assertThat(p.getSiblings(), is(Collections.EMPTY_LIST));
  }
View Full Code Here

        + "      \"href\" : \"http://localhost/people/4/siblings\"\n" + "    },\n" + "    \"father\" : {\n"
        + "      \"href\" : \"http://localhost/people/4/father\"\n" + "    }\n" + "  },\n"
        + "  \"firstName\" : \"Bilbo\",\n" + "  \"lastName\" : \"Baggins\",\n"
        + "  \"created\" : \"2014-01-31T21:07:45.574+0000\"\n" + "}\n";

    Person p = mapper.readValue(bilbo, Person.class);
    assertThat(p.getFirstName(), equalTo("Bilbo"));
    assertThat(p.getLastName(), equalTo("Baggins"));
  }
View Full Code Here

   */
  @Test
  public void serializesPersonEntity() throws IOException, InterruptedException {

    PersistentEntity<?, ?> persistentEntity = repositories.getPersistentEntity(Person.class);
    Person person = people.save(new Person("John", "Doe"));

    PersistentEntityResource resource = PersistentEntityResource.build(person, persistentEntity).//
        withLink(new Link("/person/" + person.getId())).build();

    StringWriter writer = new StringWriter();
    mapper.writeValue(writer, resource);

    String s = writer.toString();

    Link fatherLink = linkDiscoverer.findLinkWithRel("father", s);
    assertThat(fatherLink.getHref(), endsWith(new UriTemplate("/{id}/father").expand(person.getId()).toString()));

    Link siblingLink = linkDiscoverer.findLinkWithRel("siblings", s);
    assertThat(siblingLink.getHref(), endsWith(new UriTemplate("/{id}/siblings").expand(person.getId()).toString()));
  }
View Full Code Here

   * @see DATAREST-248
   */
  @Test
  public void deserializesPersonWithLinkToOtherPersonCorrectly() throws Exception {

    Person father = people.save(new Person("John", "Doe"));

    String child = String.format("{ \"firstName\" : \"Bilbo\", \"father\" : \"/persons/%s\"}", father.getId());
    Person result = mapper.readValue(child, Person.class);

    assertThat(result.getFather(), is(father));
  }
View Full Code Here

   * @see DATAREST-248
   */
  @Test
  public void deserializesPersonWithLinkToOtherPersonsCorrectly() throws Exception {

    Person firstSibling = people.save(new Person("John", "Doe"));
    Person secondSibling = people.save(new Person("Dave", "Doe"));

    String child = String.format("{ \"firstName\" : \"Bilbo\", \"siblings\" : [\"/persons/%s\", \"/persons/%s\"]}",
        firstSibling.getId(), secondSibling.getId());
    Person result = mapper.readValue(child, Person.class);

    assertThat(result.getSiblings(), hasItems(firstSibling, secondSibling));
  }
View Full Code Here

   * @see DATAREST-250
   */
  @Test
  public void serializesReferencesWithinPagedResourceCorrectly() throws Exception {

    Person creator = new Person("Dave", "Matthews");

    Order order = new Order(creator);
    order.add(new LineItem("first"));
    order.add(new LineItem("second"));

View Full Code Here

TOP

Related Classes of org.springframework.data.rest.webmvc.jpa.Person

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.