Skip to content

Commit

Permalink
Drop ContentContainingCondition in favor of Assertions.contentOf
Browse files Browse the repository at this point in the history
  • Loading branch information
dreis2211 authored and snicoll committed Dec 20, 2018
1 parent 0d67f7a commit 3544ed0
Show file tree
Hide file tree
Showing 7 changed files with 28 additions and 106 deletions.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.io.File;

import org.assertj.core.api.Condition;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -37,6 +36,7 @@
import org.springframework.util.FileSystemUtils;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.linkWithRel;
import static org.springframework.restdocs.hypermedia.HypermediaDocumentation.links;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
Expand Down Expand Up @@ -77,16 +77,12 @@ public void snippetGeneration() throws Exception {
linkWithRel("self").description("Canonical location of this resource"))));
File defaultSnippetsDir = new File(this.generatedSnippets, "snippet-generation");
assertThat(defaultSnippetsDir).exists();
assertThat(new File(defaultSnippetsDir, "curl-request.md"))
.has(contentContaining("'http://localhost:8080/'"));
assertThat(contentOf(new File(defaultSnippetsDir, "curl-request.md")))
.contains("'http://localhost:8080/'");
assertThat(new File(defaultSnippetsDir, "links.md")).isFile();
assertThat(new File(defaultSnippetsDir, "response-fields.md")).isFile();
}

private Condition<File> contentContaining(String toContain) {
return new ContentContainingCondition(toContain);
}

@TestConfiguration
public static class CustomizationConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.io.File;

import org.assertj.core.api.Condition;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -31,6 +30,7 @@
import org.springframework.util.FileSystemUtils;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf;
import static org.springframework.restdocs.mockmvc.MockMvcRestDocumentation.document;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;

Expand Down Expand Up @@ -61,15 +61,11 @@ public void defaultSnippetsAreWritten() throws Exception {
this.mvc.perform(get("/")).andDo(document("default-snippets"));
File defaultSnippetsDir = new File(this.generatedSnippets, "default-snippets");
assertThat(defaultSnippetsDir).exists();
assertThat(new File(defaultSnippetsDir, "curl-request.adoc"))
.has(contentContaining("'https://api.example.com/'"));
assertThat(new File(defaultSnippetsDir, "http-request.adoc"))
.has(contentContaining("api.example.com"));
assertThat(contentOf(new File(defaultSnippetsDir, "curl-request.adoc")))
.contains("'https://api.example.com/'");
assertThat(contentOf(new File(defaultSnippetsDir, "http-request.adoc")))
.contains("api.example.com");
assertThat(new File(defaultSnippetsDir, "http-response.adoc")).isFile();
}

private Condition<File> contentContaining(String toContain) {
return new ContentContainingCondition(toContain);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.io.File;

import io.restassured.specification.RequestSpecification;
import org.assertj.core.api.Condition;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -39,6 +38,7 @@

import static io.restassured.RestAssured.given;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf;
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyUris;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
Expand Down Expand Up @@ -81,18 +81,14 @@ public void snippetGeneration() {
.when().port(this.port).get("/").then().assertThat().statusCode(is(200));
File defaultSnippetsDir = new File(this.generatedSnippets, "default-snippets");
assertThat(defaultSnippetsDir).exists();
assertThat(new File(defaultSnippetsDir, "curl-request.md"))
.has(contentContaining("'https://api.example.com/'"));
assertThat(new File(defaultSnippetsDir, "http-request.md"))
.has(contentContaining("api.example.com"));
assertThat(contentOf(new File(defaultSnippetsDir, "curl-request.md")))
.contains("'https://api.example.com/'");
assertThat(contentOf(new File(defaultSnippetsDir, "http-request.md")))
.contains("api.example.com");
assertThat(new File(defaultSnippetsDir, "http-response.md")).isFile();
assertThat(new File(defaultSnippetsDir, "response-fields.md")).isFile();
}

private Condition<File> contentContaining(String toContain) {
return new ContentContainingCondition(toContain);
}

@TestConfiguration
public static class CustomizationConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import java.io.File;

import io.restassured.specification.RequestSpecification;
import org.assertj.core.api.Condition;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -34,6 +33,7 @@

import static io.restassured.RestAssured.given;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf;
import static org.hamcrest.CoreMatchers.is;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.modifyUris;
import static org.springframework.restdocs.operation.preprocess.Preprocessors.preprocessRequest;
Expand Down Expand Up @@ -73,15 +73,11 @@ public void defaultSnippetsAreWritten() {
.when().port(this.port).get("/").then().assertThat().statusCode(is(200));
File defaultSnippetsDir = new File(this.generatedSnippets, "default-snippets");
assertThat(defaultSnippetsDir).exists();
assertThat(new File(defaultSnippetsDir, "curl-request.adoc"))
.has(contentContaining("'https://api.example.com/'"));
assertThat(new File(defaultSnippetsDir, "http-request.adoc"))
.has(contentContaining("api.example.com"));
assertThat(contentOf(new File(defaultSnippetsDir, "curl-request.adoc")))
.contains("'https://api.example.com/'");
assertThat(contentOf(new File(defaultSnippetsDir, "http-request.adoc")))
.contains("api.example.com");
assertThat(new File(defaultSnippetsDir, "http-response.adoc")).isFile();
}

private Condition<File> contentContaining(String toContain) {
return new ContentContainingCondition(toContain);
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.io.File;

import org.assertj.core.api.Condition;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -37,6 +36,7 @@
import org.springframework.util.FileSystemUtils;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf;
import static org.springframework.restdocs.payload.PayloadDocumentation.fieldWithPath;
import static org.springframework.restdocs.payload.PayloadDocumentation.responseFields;
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document;
Expand Down Expand Up @@ -70,18 +70,14 @@ public void defaultSnippetsAreWritten() throws Exception {
.expectBody().consumeWith(document("default-snippets"));
File defaultSnippetsDir = new File(this.generatedSnippets, "default-snippets");
assertThat(defaultSnippetsDir).exists();
assertThat(new File(defaultSnippetsDir, "curl-request.md"))
.has(contentContaining("'https://api.example.com/'"));
assertThat(new File(defaultSnippetsDir, "http-request.md"))
.has(contentContaining("api.example.com"));
assertThat(contentOf(new File(defaultSnippetsDir, "curl-request.md")))
.contains("'https://api.example.com/'");
assertThat(contentOf(new File(defaultSnippetsDir, "http-request.md")))
.contains("api.example.com");
assertThat(new File(defaultSnippetsDir, "http-response.md")).isFile();
assertThat(new File(defaultSnippetsDir, "response-fields.md")).isFile();
}

private Condition<File> contentContaining(String toContain) {
return new ContentContainingCondition(toContain);
}

@TestConfiguration
public static class CustomizationConfiguration {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@

import java.io.File;

import org.assertj.core.api.Condition;
import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
Expand All @@ -32,6 +31,7 @@
import org.springframework.util.FileSystemUtils;

import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.contentOf;
import static org.springframework.restdocs.webtestclient.WebTestClientRestDocumentation.document;

/**
Expand Down Expand Up @@ -63,15 +63,11 @@ public void defaultSnippetsAreWritten() throws Exception {
.expectBody().consumeWith(document("default-snippets"));
File defaultSnippetsDir = new File(this.generatedSnippets, "default-snippets");
assertThat(defaultSnippetsDir).exists();
assertThat(new File(defaultSnippetsDir, "curl-request.adoc"))
.has(contentContaining("'https://api.example.com/'"));
assertThat(new File(defaultSnippetsDir, "http-request.adoc"))
.has(contentContaining("api.example.com"));
assertThat(contentOf(new File(defaultSnippetsDir, "curl-request.adoc")))
.contains("'https://api.example.com/'");
assertThat(contentOf(new File(defaultSnippetsDir, "http-request.adoc")))
.contains("api.example.com");
assertThat(new File(defaultSnippetsDir, "http-response.adoc")).isFile();
}

private Condition<File> contentContaining(String toContain) {
return new ContentContainingCondition(toContain);
}

}

0 comments on commit 3544ed0

Please sign in to comment.