forked from asciidoctor/asciidoctorj
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request asciidoctor#1170 from abelsromero/issue-1169-remov…
…e-AsciidoctorUtils-class Remove AsciidoctorUtils class
- Loading branch information
Showing
6 changed files
with
30 additions
and
202 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
59 changes: 21 additions & 38 deletions
59
asciidoctorj-cli/src/test/java/org/asciidoctor/cli/WhenAsciidoctorAPICallIsCalled.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 |
---|---|---|
@@ -1,58 +1,41 @@ | ||
package org.asciidoctor.cli; | ||
|
||
import com.beust.jcommander.JCommander; | ||
import org.asciidoctor.Attributes; | ||
import org.asciidoctor.Options; | ||
import org.asciidoctor.OptionsBuilder; | ||
import org.asciidoctor.SafeMode; | ||
import org.asciidoctor.jruby.internal.AsciidoctorUtils; | ||
import org.junit.Test; | ||
|
||
import java.io.File; | ||
import java.util.List; | ||
import java.nio.file.Path; | ||
|
||
import static org.hamcrest.CoreMatchers.is; | ||
import static org.hamcrest.MatcherAssert.assertThat; | ||
import static org.hamcrest.collection.IsIterableContainingInAnyOrder.containsInAnyOrder; | ||
import static org.hamcrest.collection.IsMapContaining.hasEntry; | ||
import static org.hamcrest.collection.IsMapContaining.hasKey; | ||
import static org.assertj.core.api.Assertions.assertThat; | ||
|
||
public class WhenAsciidoctorAPICallIsCalled { | ||
|
||
@Test | ||
public void api_parameters_should_be_transformed_to_cli_command() { | ||
|
||
Attributes attributes = Attributes.builder() | ||
.attribute("myAtribute", "myValue") | ||
.sectionNumbers(true) | ||
.copyCss(false) | ||
.build(); | ||
|
||
OptionsBuilder optionsBuilder = Options.builder() | ||
.backend("docbook") | ||
.templateDirs(new File("a"), new File("b")) | ||
.safe(SafeMode.UNSAFE) | ||
.attributes(attributes); | ||
|
||
List<String> command = AsciidoctorUtils.toAsciidoctorCommand( | ||
optionsBuilder.asMap(), "file.adoc"); | ||
|
||
String currentDirectory = new File("").getAbsolutePath() + File.separator; | ||
|
||
String[] parameters = command.subList(1, command.size()).toArray(new String[0]); | ||
final String currentDirectory = new File("").getAbsolutePath() + File.separator; | ||
var parameters = new String[]{ | ||
"-T", Path.of(currentDirectory, "a").toAbsolutePath().toString(), | ||
"-T", Path.of(currentDirectory, "b").toAbsolutePath().toString(), | ||
"-S", "UNSAFE", | ||
"-b", "docbook", | ||
"-a", "myAttribute=myValue", | ||
"-a", "sectnums", | ||
"-a", "copycss!", | ||
"file.adoc" | ||
}; | ||
|
||
final AsciidoctorCliOptions asciidoctorCliOptions = new AsciidoctorCliOptions(); | ||
final JCommander jCommander = new JCommander(asciidoctorCliOptions); | ||
jCommander.parse(parameters); | ||
|
||
assertThat(asciidoctorCliOptions.getTemplateDir(), containsInAnyOrder(currentDirectory + "a", currentDirectory + "b")); | ||
assertThat(asciidoctorCliOptions.getSafeMode(), is(SafeMode.UNSAFE)); | ||
assertThat(asciidoctorCliOptions.getBackend(), is("docbook")); | ||
assertThat(asciidoctorCliOptions.getParameters(), containsInAnyOrder("file.adoc")); | ||
|
||
assertThat(asciidoctorCliOptions.getAttributes(), hasEntry("myAtribute", "myValue")); | ||
assertThat(asciidoctorCliOptions.getAttributes(), hasKey("sectnums")); | ||
assertThat(asciidoctorCliOptions.getAttributes(), hasKey("copycss!")); | ||
assertThat(asciidoctorCliOptions.getTemplateDir()).containsExactlyInAnyOrder(currentDirectory + "a", currentDirectory + "b"); | ||
assertThat(asciidoctorCliOptions.getSafeMode()).isEqualTo(SafeMode.UNSAFE); | ||
assertThat(asciidoctorCliOptions.getBackend()).isEqualTo("docbook"); | ||
assertThat(asciidoctorCliOptions.getParameters()).containsExactly("file.adoc"); | ||
assertThat(asciidoctorCliOptions.getAttributes()) | ||
.containsEntry("myAttribute", "myValue") | ||
.containsEntry("sectnums", "") | ||
.containsEntry("copycss!", ""); | ||
} | ||
|
||
} |
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
158 changes: 0 additions & 158 deletions
158
asciidoctorj-core/src/main/java/org/asciidoctor/jruby/internal/AsciidoctorUtils.java
This file was deleted.
Oops, something went wrong.
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