-
Notifications
You must be signed in to change notification settings - Fork 124
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created AsciidoctorAsserter to simplify tests
- Loading branch information
1 parent
ae4716a
commit 09d919b
Showing
4 changed files
with
108 additions
and
76 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
src/test/java/org/asciidoctor/maven/AsciidoctorAsserter.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
package org.asciidoctor.maven; | ||
|
||
import org.assertj.core.api.AbstractFileAssert; | ||
import org.assertj.core.api.AbstractStringAssert; | ||
import org.assertj.core.api.Assertions; | ||
|
||
import java.io.File; | ||
|
||
public class AsciidoctorAsserter { | ||
|
||
private final AbstractFileAssert<?> fileAssert; | ||
private final AbstractStringAssert<?> contentAssert; | ||
|
||
private AsciidoctorAsserter(File generatedFile) { | ||
this.fileAssert = Assertions.assertThat(generatedFile); | ||
this.contentAssert = Assertions.assertThat(TestUtils.readAsString(generatedFile)); | ||
} | ||
|
||
public static AsciidoctorAsserter assertThat(File file) { | ||
return new AsciidoctorAsserter(file); | ||
} | ||
|
||
public static AsciidoctorAsserter assertThat(File parentPath, String filename) { | ||
return new AsciidoctorAsserter(new File(parentPath, filename)); | ||
} | ||
|
||
public AsciidoctorAsserter isNotEmpty() { | ||
fileAssert.exists().isNotEmpty(); | ||
return this; | ||
} | ||
|
||
public AsciidoctorAsserter contains(String text) { | ||
contentAssert.contains(text); | ||
return this; | ||
} | ||
|
||
public AsciidoctorAsserter doesNotContain(String text) { | ||
contentAssert.doesNotContain(text); | ||
return this; | ||
} | ||
|
||
public AsciidoctorAsserter startsWith(String prefix) { | ||
contentAssert.startsWith(prefix); | ||
return this; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters