Skip to content

Commit fc26d83

Browse files
NIAD-3142 Refactored run method within TransformJsonToXml class
1 parent fb4bbde commit fc26d83

File tree

1 file changed

+10
-5
lines changed

1 file changed

+10
-5
lines changed

service/src/main/java/uk/nhs/adaptors/gp2gp/transformjsontoxmltool/TransformJsonToXml.java

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -65,17 +65,22 @@ public static void main(String[] args) {
6565
@Override
6666
public void run(String... args) {
6767
try {
68-
getFiles().forEach(file -> {
69-
String xmlResult = mapJsonToXml(file.getJsonFileInput());
70-
writeToFile(xmlResult, file.getJsonFileName());
71-
xmlSchemaValidator.validateOutputToXmlSchema(file.getJsonFileName(), xmlResult);
72-
});
68+
getFiles().forEach(this::processAndValidateFile);
7369
} catch (NHSNumberNotFound | UnreadableJsonFileException | NoJsonFileFound | Hl7TranslatedResponseError e) {
7470
LOGGER.error("error: " + e.getMessage());
7571
}
72+
7673
LOGGER.info("end");
7774
}
7875

76+
private void processAndValidateFile(InputFile file) {
77+
String xmlResult = mapJsonToXml(file.getJsonFileInput());
78+
79+
writeToFile(xmlResult, file.getJsonFileName());
80+
81+
xmlSchemaValidator.validateOutputToXmlSchema(file.getJsonFileName(), xmlResult);
82+
}
83+
7984
private List<InputFile> getFiles() throws UnreadableJsonFileException, NoJsonFileFound {
8085
File[] files = new File(JSON_FILE_INPUT_PATH).listFiles();
8186
List<String> jsonStringInputs = new ArrayList<>();

0 commit comments

Comments
 (0)