Tabnine Logo
LinkDescriptor.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.springframework.restdocs.hypermedia.LinkDescriptor
constructor

Best Java code snippets using org.springframework.restdocs.hypermedia.LinkDescriptor.<init> (Showing top 15 results out of 315)

origin: spring-projects/spring-restdocs

/**
 * Creates a {@code LinkDescriptor} that describes a link with the given {@code rel}.
 * @param rel the rel of the link
 * @return a {@code LinkDescriptor} ready for further configuration
 */
public static LinkDescriptor linkWithRel(String rel) {
  return new LinkDescriptor(rel);
}
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

@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

@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 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 linkWithNoDescription() throws IOException {
  this.thrown.expect(SnippetException.class);
  this.thrown.expectMessage(
      equalTo("No description was provided for the link with rel 'foo' and no"
          + " title was available from the link in the payload"));
  new LinksSnippet(new StubLinkExtractor().withLinks(new Link("foo", "bar")),
      Arrays.asList(new LinkDescriptor("foo")))
          .document(this.operationBuilder.build());
}
origin: spring-projects/spring-restdocs

@Test
public void undocumentedLinkAndMissingLink() throws IOException {
  this.thrown.expect(SnippetException.class);
  this.thrown.expectMessage(equalTo("Links with the following relations were not"
      + " documented: [a]. Links with the following relations were not"
      + " found in the response: [foo]"));
  new LinksSnippet(new StubLinkExtractor().withLinks(new Link("a", "alpha")),
      Arrays.asList(new LinkDescriptor("foo").description("bar")))
          .document(this.operationBuilder.build());
}
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 linksWithCustomAttributes() throws IOException {
  TemplateResourceResolver resolver = mock(TemplateResourceResolver.class);
  given(resolver.resolveTemplateResource("links"))
      .willReturn(snippetResource("links-with-title"));
  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")),
      attributes(key("title").value("Title for the links")))
          .document(
              this.operationBuilder
                  .attribute(TemplateEngine.class.getName(),
                      new MustacheTemplateEngine(resolver))
                  .build());
  assertThat(this.generatedSnippets.links()).contains("Title for the links");
}
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

@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 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 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 linksWithCustomDescriptorAttributes() throws IOException {
  TemplateResourceResolver resolver = mock(TemplateResourceResolver.class);
  given(resolver.resolveTemplateResource("links"))
      .willReturn(snippetResource("links-with-extra-column"));
  new LinksSnippet(
      new StubLinkExtractor().withLinks(new Link("a", "alpha"),
          new Link("b", "bravo")),
      Arrays.asList(
          new LinkDescriptor("a").description("one")
              .attributes(key("foo").value("alpha")),
          new LinkDescriptor("b").description("two")
              .attributes(key("foo").value("bravo"))))
                  .document(this.operationBuilder.attribute(
                      TemplateEngine.class.getName(),
                      new MustacheTemplateEngine(resolver))
                      .build());
  assertThat(this.generatedSnippets.links())
      .is(tableWithHeader("Relation", "Description", "Foo")
          .row("a", "one", "alpha").row("b", "two", "bravo"));
}
org.springframework.restdocs.hypermediaLinkDescriptor<init>

Javadoc

Creates a new LinkDescriptor describing a link with the given rel.

Popular methods of LinkDescriptor

  • description
  • ignored
  • optional
    Marks the link as optional.
  • 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

  • Running tasks concurrently on multiple threads
  • getApplicationContext (Context)
  • requestLocationUpdates (LocationManager)
  • startActivity (Activity)
  • GridBagLayout (java.awt)
    The GridBagLayout class is a flexible layout manager that aligns components vertically and horizonta
  • PrintStream (java.io)
    Fake signature of an existing Java class.
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • SortedSet (java.util)
    SortedSet is a Set which iterates over its elements in a sorted order. The order is determined eithe
  • CountDownLatch (java.util.concurrent)
    A synchronization aid that allows one or more threads to wait until a set of operations being perfor
  • Options (org.apache.commons.cli)
    Main entry-point into the library. Options represents a collection of Option objects, which describ
  • Top PhpStorm plugins
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