forked from allegro/json-avro-converter
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'allegro:master' into master
- Loading branch information
Showing
7 changed files
with
143 additions
and
18 deletions.
There are no files selected for viewing
26 changes: 26 additions & 0 deletions
26
validator/src/main/java/tech/allegro/schema/json2avro/validator/FileValidationOutput.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,26 @@ | ||
package tech.allegro.schema.json2avro.validator; | ||
|
||
import tech.allegro.schema.json2avro.validator.schema.ValidationOutput; | ||
import tech.allegro.schema.json2avro.validator.schema.ValidatorException; | ||
|
||
import java.io.IOException; | ||
import java.nio.file.Files; | ||
import java.nio.file.Path; | ||
|
||
class FileValidationOutput implements ValidationOutput { | ||
|
||
private final Path outputPath; | ||
|
||
FileValidationOutput(Path outputPath) { | ||
this.outputPath = outputPath; | ||
} | ||
|
||
@Override | ||
public void write(byte[] output) { | ||
try { | ||
Files.write(outputPath, output); | ||
} catch (IOException e) { | ||
throw new ValidatorException("Error occurred when writing the output", e); | ||
} | ||
} | ||
} |
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
8 changes: 8 additions & 0 deletions
8
validator/src/main/java/tech/allegro/schema/json2avro/validator/schema/ValidationOutput.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,8 @@ | ||
package tech.allegro.schema.json2avro.validator.schema; | ||
|
||
public interface ValidationOutput { | ||
|
||
ValidationOutput NO_OUTPUT = output -> {}; | ||
|
||
void write(byte[] output); | ||
} |
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
9 changes: 5 additions & 4 deletions
9
validator/src/test/groovy/tech/allegro/schema/json2avro/validator/test/ResourceUtils.groovy
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,18 +1,19 @@ | ||
package tech.allegro.schema.json2avro.validator.test | ||
|
||
import java.nio.file.Files | ||
import java.nio.file.Path | ||
import java.nio.file.Paths | ||
|
||
class ResourceUtils { | ||
|
||
static String resource(String path) { | ||
static Path resource(String path) { | ||
|
||
new File(ResourceUtils.classLoader.getResource(path).toURI()).getAbsolutePath() | ||
Paths.get(ResourceUtils.classLoader.getResource(path).toURI()) | ||
} | ||
|
||
static byte[] readResource(String path) { | ||
|
||
String filePath = resource(path) | ||
return Files.readAllBytes(Paths.get(filePath)) | ||
Path filePath = resource(path) | ||
return Files.readAllBytes(filePath) | ||
} | ||
} |