Tabnine Logo
LinkDescriptor.description
Code IndexAdd Tabnine to your IDE (free)

How to use
description
method
in
org.springframework.restdocs.hypermedia.LinkDescriptor

Best Java code snippets using org.springframework.restdocs.hypermedia.LinkDescriptor.description (Showing top 20 results out of 315)

origin: spring-projects/spring-restdocs

private LinkDescriptor createDescriptor(String description, LinkDescriptor source) {
  LinkDescriptor newDescriptor = new LinkDescriptor(source.getRel())
      .description(description);
  if (source.isOptional()) {
    newDescriptor.optional();
  }
  if (source.isIgnored()) {
    newDescriptor.ignored();
  }
  return newDescriptor;
}
origin: spring-projects/spring-restdocs

public void documentation() throws Exception {
  // tag::use[]
  RestAssured.given(this.spec)
    .accept("application/json")
    .filter(document("example", this.pagingLinks.and( // <1>
        linkWithRel("alpha").description("Link to the alpha resource"),
        linkWithRel("bravo").description("Link to the bravo resource"))))
    .get("/").then().assertThat().statusCode(is(200));
  // end::use[]
}
origin: spring-projects/spring-restdocs

public void defaultExtractor() throws Exception {
  // tag::links[]
  RestAssured.given(this.spec)
    .accept("application/json")
    .filter(document("index", links( // <1>
        linkWithRel("alpha").description("Link to the alpha resource"), // <2>
        linkWithRel("bravo").description("Link to the bravo resource")))) // <3>
    .get("/").then().assertThat().statusCode(is(200));
  // end::links[]
}
origin: spring-projects/spring-restdocs

public void explicitExtractor() throws Exception {
  RestAssured.given(this.spec)
  .accept("application/json")
  // tag::explicit-extractor[]
  .filter(document("index", links(halLinks(), // <1>
      linkWithRel("alpha").description("Link to the alpha resource"),
      linkWithRel("bravo").description("Link to the bravo resource"))))
  // end::explicit-extractor[]
  .get("/").then().assertThat().statusCode(is(200));
}
origin: spring-projects/spring-restdocs

@Test
public void missingLink() throws IOException {
  this.thrown.expect(SnippetException.class);
  this.thrown.expectMessage(equalTo("Links with the following relations were not"
      + " found in the response: [foo]"));
  new LinksSnippet(new StubLinkExtractor(),
      Arrays.asList(new LinkDescriptor("foo").description("bar")))
          .document(this.operationBuilder.build());
}
origin: spring-projects/spring-restdocs

public void documentation() throws Exception {
  // tag::use[]
  this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON))
    .andExpect(status().isOk())
    .andDo(document("example", this.pagingLinks.and( // <1>
        linkWithRel("alpha").description("Link to the alpha resource"),
        linkWithRel("bravo").description("Link to the bravo resource"))));
  // end::use[]
}
origin: spring-projects/spring-restdocs

public void defaultExtractor() throws Exception {
  // tag::links[]
  this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON))
    .andExpect(status().isOk())
    .andDo(document("index", links( // <1>
        linkWithRel("alpha").description("Link to the alpha resource"), // <2>
        linkWithRel("bravo").description("Link to the bravo resource")))); // <3>
  // end::links[]
}
origin: spring-projects/spring-restdocs

public void defaultExtractor() throws Exception {
  // tag::links[]
  this.webTestClient.get().uri("/").accept(MediaType.APPLICATION_JSON).exchange()
    .expectStatus().isOk().expectBody()
    .consumeWith(document("index",links( // <1>
        linkWithRel("alpha").description("Link to the alpha resource"), // <2>
        linkWithRel("bravo").description("Link to the bravo resource")))); // <3>
  // end::links[]
}
origin: spring-projects/spring-restdocs

public void documentation() throws Exception {
  // tag::use[]
  this.webTestClient.get().uri("/").accept(MediaType.APPLICATION_JSON).exchange()
    .expectStatus().isOk().expectBody()
    .consumeWith(document("example", this.pagingLinks.and( // <1>
      linkWithRel("alpha").description("Link to the alpha resource"),
      linkWithRel("bravo").description("Link to the bravo resource"))));
  // end::use[]
}
origin: spring-projects/spring-restdocs

public void explicitExtractor() throws Exception {
  this.mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON))
    .andExpect(status().isOk())
    //tag::explicit-extractor[]
    .andDo(document("index", links(halLinks(), // <1>
        linkWithRel("alpha").description("Link to the alpha resource"),
        linkWithRel("bravo").description("Link to the bravo resource"))));
    // end::explicit-extractor[]
}
origin: spring-projects/spring-restdocs

@Test
public void additionalDescriptors() throws IOException {
  HypermediaDocumentation
      .links(new StubLinkExtractor().withLinks(new Link("a", "alpha"),
          new Link("b", "bravo")),
          new LinkDescriptor("a").description("one"))
      .and(new LinkDescriptor("b").description("two"))
      .document(this.operationBuilder.build());
  assertThat(this.generatedSnippets.links())
      .is(tableWithHeader("Relation", "Description").row("`a`", "one")
          .row("`b`", "two"));
}
origin: spring-projects/spring-restdocs

@Test
public void documentedLinks() throws IOException {
  new LinksSnippet(
      new StubLinkExtractor().withLinks(new Link("a", "alpha"),
          new Link("b", "bravo")),
      Arrays.asList(new LinkDescriptor("a").description("one"),
          new LinkDescriptor("b").description("two")))
              .document(this.operationBuilder.build());
  assertThat(this.generatedSnippets.links())
      .is(tableWithHeader("Relation", "Description").row("`a`", "one")
          .row("`b`", "two"));
}
origin: spring-projects/spring-restdocs

@Test
public void missingOptionalLink() throws IOException {
  new LinksSnippet(new StubLinkExtractor(),
      Arrays.asList(new LinkDescriptor("foo").description("bar").optional()))
          .document(this.operationBuilder.build());
  assertThat(this.generatedSnippets.links())
      .is(tableWithHeader("Relation", "Description").row("`foo`", "bar"));
}
origin: spring-projects/spring-restdocs

@Test
public void presentOptionalLink() throws IOException {
  new LinksSnippet(new StubLinkExtractor().withLinks(new Link("foo", "blah")),
      Arrays.asList(new LinkDescriptor("foo").description("bar").optional()))
          .document(this.operationBuilder.build());
  assertThat(this.generatedSnippets.links())
      .is(tableWithHeader("Relation", "Description").row("`foo`", "bar"));
}
origin: spring-projects/spring-restdocs

public void use() throws Exception {
  // tag::use[]
  this.mockMvc.perform(get("/"))
      .andExpect(status().isOk())
      .andDo(document("index",
          links(linkWithRel("self").description("Canonical self link"))
      ));
  // end::use[]
}
origin: spring-projects/spring-restdocs

@Test
public void allUndocumentedLinksCanBeIgnored() throws IOException {
  new LinksSnippet(
      new StubLinkExtractor().withLinks(new Link("a", "alpha"),
          new Link("b", "bravo")),
      Arrays.asList(new LinkDescriptor("b").description("Link b")), true)
          .document(this.operationBuilder.build());
  assertThat(this.generatedSnippets.links())
      .is(tableWithHeader("Relation", "Description").row("`b`", "Link b"));
}
origin: spring-projects/spring-restdocs

@Test
public void tableCellContentIsEscapedWhenNecessary() throws IOException {
  new LinksSnippet(new StubLinkExtractor().withLinks(new Link("Foo|Bar", "foo")),
      Arrays.asList(new LinkDescriptor("Foo|Bar").description("one|two")))
          .document(this.operationBuilder.build());
  assertThat(this.generatedSnippets.links())
      .is(tableWithHeader("Relation", "Description").row(
          escapeIfNecessary("`Foo|Bar`"), escapeIfNecessary("one|two")));
}
origin: spring-projects/spring-restdocs

@Test
public void ignoredLink() throws IOException {
  new LinksSnippet(
      new StubLinkExtractor().withLinks(new Link("a", "alpha"),
          new Link("b", "bravo")),
      Arrays.asList(new LinkDescriptor("a").ignored(),
          new LinkDescriptor("b").description("Link b")))
              .document(this.operationBuilder.build());
  assertThat(this.generatedSnippets.links())
      .is(tableWithHeader("Relation", "Description").row("`b`", "Link b"));
}
origin: spring-projects/spring-restdocs

@Test
public void linkDescriptionFromTitleInPayload() throws IOException {
  new LinksSnippet(
      new StubLinkExtractor().withLinks(new Link("a", "alpha", "Link a"),
          new Link("b", "bravo", "Link b")),
      Arrays.asList(new LinkDescriptor("a").description("one"),
          new LinkDescriptor("b"))).document(this.operationBuilder.build());
  assertThat(this.generatedSnippets.links())
      .is(tableWithHeader("Relation", "Description").row("`a`", "one")
          .row("`b`", "Link b"));
}
origin: spring-projects/spring-restdocs

@Test
public void linksSnippet() throws Exception {
  MockMvc mockMvc = MockMvcBuilders.webAppContextSetup(this.context)
      .apply(documentationConfiguration(this.restDocumentation)).build();
  mockMvc.perform(get("/").accept(MediaType.APPLICATION_JSON))
      .andExpect(status().isOk()).andDo(document("links",
          links(linkWithRel("rel").description("The description"))));
  assertExpectedSnippetFilesExist(new File("build/generated-snippets/links"),
      "http-request.adoc", "http-response.adoc", "curl-request.adoc",
      "links.adoc");
}
org.springframework.restdocs.hypermediaLinkDescriptordescription

Popular methods of LinkDescriptor

  • ignored
  • optional
    Marks the link as optional.
  • <init>
    Creates a new LinkDescriptor describing a link with the given rel.
  • attributes
  • getAttributes
  • getDescription
  • getRel
    Returns the rel of the link described by this descriptor.
  • isIgnored
  • isOptional
    Returns true if the described link is optional, otherwise false.

Popular in Java

  • Updating database using SQL prepared statement
  • getContentResolver (Context)
  • getApplicationContext (Context)
  • getSystemService (Context)
  • InputStream (java.io)
    A readable source of bytes.Most clients will use input streams that read data from the file system (
  • Hashtable (java.util)
    A plug-in replacement for JDK1.5 java.util.Hashtable. This version is based on org.cliffc.high_scale
  • NoSuchElementException (java.util)
    Thrown when trying to retrieve an element past the end of an Enumeration or Iterator.
  • Collectors (java.util.stream)
  • DataSource (javax.sql)
    An interface for the creation of Connection objects which represent a connection to a database. This
  • Scheduler (org.quartz)
    This is the main interface of a Quartz Scheduler. A Scheduler maintains a registry of org.quartz.Job
  • Top 12 Jupyter Notebook extensions
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now