Skip to content
This repository has been archived by the owner on May 26, 2020. It is now read-only.

Commit

Permalink
Fix mojo tests for Windows'
Browse files Browse the repository at this point in the history
  • Loading branch information
purple52 committed Mar 10, 2016
1 parent b3c598d commit 15f677d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,14 @@
import uk.gov.justice.raml.core.Generator;

import javax.json.Json;
import javax.json.JsonArrayBuilder;
import javax.json.JsonWriter;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.Paths;
import java.util.Arrays;
import java.util.Set;

/**
Expand All @@ -27,8 +29,12 @@ public Set<String> run(Raml raml, GeneratorConfig generatorConfig) {
Files.createDirectories(outputPath.getParent());
OutputStream outputStream = Files.newOutputStream(outputPath);
JsonWriter writer = Json.createWriter(outputStream);
JsonArrayBuilder jsonArrayBuilder = Json.createArrayBuilder();
for(String line : Arrays.asList(new RamlEmitter().dump(raml).split("\n"))) {
jsonArrayBuilder = jsonArrayBuilder.add(line);
}
writer.writeObject(Json.createObjectBuilder()
.add("raml", new RamlEmitter().dump(raml))
.add("raml", jsonArrayBuilder)
.add("configuration", Json.createObjectBuilder()
.add("basePackageName", generatorConfig.getBasePackageName())
.add("sourceDirectory", generatorConfig.getSourceDirectory().toString())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,8 @@ public void testShouldGenerateFromValidRaml() throws Exception {

Path expectedSourceDirectory = Paths.get(project.getBasedir().toString(), "src", "raml");
Path expectedOutputDirectory = Paths.get(project.getBasedir().toString(), "target", "generated-sources");
assertThat(output.getString("raml"), equalTo("#%RAML 0.8" + System.getProperty("line.separator")));
assertThat(output.getJsonArray("raml").getString(0), equalTo("#%RAML 0.8"));
assertThat(output.getJsonArray("raml").size(), equalTo(1));
assertThat(output.getJsonObject("configuration").getString("sourceDirectory"), equalTo(expectedSourceDirectory.toString()));
assertThat(output.getJsonObject("configuration").getString("outputDirectory"), equalTo(expectedOutputDirectory.toString()));
assertThat(output.getJsonObject("configuration").getString("basePackageName"), equalTo("uk.gov.justice.api"));
Expand Down

0 comments on commit 15f677d

Please sign in to comment.