@@ -38,6 +38,8 @@ public class CroissantExporterTest {
3838 static ExportDataProvider dataProviderCars ;
3939 static OutputStream outputStreamJunk ;
4040 static ExportDataProvider dataProviderJunk ;
41+ static OutputStream outputStreamDraft ;
42+ static ExportDataProvider dataProviderDraft ;
4143
4244 @ BeforeAll
4345 public static void setUp () {
@@ -285,6 +287,67 @@ public String getDataCiteXml() {
285287 }
286288 }
287289 };
290+
291+ outputStreamDraft = new ByteArrayOutputStream ();
292+ dataProviderDraft =
293+ new ExportDataProvider () {
294+ @ Override
295+ public JsonObject getDatasetJson () {
296+ String pathToJsonFile = "src/test/resources/draft/in/datasetJson.json" ;
297+ try (JsonReader jsonReader =
298+ Json .createReader (new FileReader (pathToJsonFile ))) {
299+ return jsonReader .readObject ();
300+ } catch (FileNotFoundException ex ) {
301+ return null ;
302+ }
303+ }
304+
305+ @ Override
306+ public JsonObject getDatasetORE () {
307+ String pathToJsonFile = "src/test/resources/draft/in/datasetORE.json" ;
308+ try (JsonReader jsonReader =
309+ Json .createReader (new FileReader (pathToJsonFile ))) {
310+ return jsonReader .readObject ();
311+ } catch (FileNotFoundException ex ) {
312+ return null ;
313+ }
314+ }
315+
316+ @ Override
317+ public JsonArray getDatasetFileDetails () {
318+ String pathToJsonFile =
319+ "src/test/resources/draft/in/datasetFileDetails.json" ;
320+ try (JsonReader jsonReader =
321+ Json .createReader (new FileReader (pathToJsonFile ))) {
322+ return jsonReader .readArray ();
323+ } catch (FileNotFoundException ex ) {
324+ return null ;
325+ }
326+ }
327+
328+ @ Override
329+ public JsonObject getDatasetSchemaDotOrg () {
330+ String pathToJsonFile =
331+ "src/test/resources/draft/in/datasetSchemaDotOrg.json" ;
332+ try (JsonReader jsonReader =
333+ Json .createReader (new FileReader (pathToJsonFile ))) {
334+ return jsonReader .readObject ();
335+ } catch (FileNotFoundException ex ) {
336+ return null ;
337+ }
338+ }
339+
340+ @ Override
341+ public String getDataCiteXml () {
342+ try {
343+ return Files .readString (
344+ Paths .get ("src/test/resources/draft/in/dataCiteXml.xml" ),
345+ StandardCharsets .UTF_8 );
346+ } catch (IOException ex ) {
347+ return null ;
348+ }
349+ }
350+ };
288351 }
289352
290353 @ Test
@@ -394,6 +457,19 @@ public void testExportDatasetJunk() throws Exception {
394457 assertEquals (prettyPrint (expected ), prettyPrint (outputStreamJunk .toString ()));
395458 }
396459
460+ @ Test
461+ public void testExportDatasetDraft () throws Exception {
462+ exporter .exportDataset (dataProviderDraft , outputStreamDraft );
463+ String actual = outputStreamDraft .toString ();
464+ writeCroissantFile (actual , "draft" );
465+ String expected =
466+ Files .readString (
467+ Paths .get ("src/test/resources/draft/expected/draft-croissant.json" ),
468+ StandardCharsets .UTF_8 );
469+ JSONAssert .assertEquals (expected , actual , true );
470+ assertEquals (prettyPrint (expected ), prettyPrint (outputStreamDraft .toString ()));
471+ }
472+
397473 private void writeCroissantFile (String actual , String name ) throws IOException {
398474 Path dir = Files .createDirectories (Paths .get ("src/test/resources/" + name + "/out" ));
399475 Path out = Paths .get (dir + "/croissant.json" );
0 commit comments