From d21f20bd82ee9449116abad98ada6808607e84de Mon Sep 17 00:00:00 2001 From: vkovtun <viktor.kovtun@id.ethz.ch> Date: Tue, 5 Dec 2023 14:47:52 +0100 Subject: [PATCH] BIS-772: Writing JS tests. --- .../as/dto/exporter/data/ExportablePermId.js | 4 +++- .../as/dto/exporter/options/ExportOptions.js | 6 ++++- .../systemtest/asapi/v3/ExportTest.java | 13 ---------- .../html/test/test-import-export.js | 24 +++++++++++++++++++ 4 files changed, 32 insertions(+), 15 deletions(-) diff --git a/api-openbis-javascript/src/v3/as/dto/exporter/data/ExportablePermId.js b/api-openbis-javascript/src/v3/as/dto/exporter/data/ExportablePermId.js index df6affab0fa..4a0569dca3d 100644 --- a/api-openbis-javascript/src/v3/as/dto/exporter/data/ExportablePermId.js +++ b/api-openbis-javascript/src/v3/as/dto/exporter/data/ExportablePermId.js @@ -16,7 +16,9 @@ */ define(["stjs"], function (stjs) { - var ExportablePermId = function() { + var ExportablePermId = function(exportableKind, permId) { + this.exportableKind = exportableKind; + this.permId = permId; } stjs.extend( diff --git a/api-openbis-javascript/src/v3/as/dto/exporter/options/ExportOptions.js b/api-openbis-javascript/src/v3/as/dto/exporter/options/ExportOptions.js index 005f53ddb45..586119a7948 100644 --- a/api-openbis-javascript/src/v3/as/dto/exporter/options/ExportOptions.js +++ b/api-openbis-javascript/src/v3/as/dto/exporter/options/ExportOptions.js @@ -16,7 +16,11 @@ */ define(["stjs"], function (stjs) { - var ExportOptions = function() { + var ExportOptions = function(formats, xlsTextFormat, withReferredTypes, withImportCompatibility) { + this.formats = formats; + this.xlsTextFormat = xlsTextFormat; + this.withReferredTypes = withReferredTypes; + this.withImportCompatibility = withImportCompatibility; } stjs.extend( diff --git a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/ExportTest.java b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/ExportTest.java index 6cde131c55f..2627a2e07b8 100644 --- a/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/ExportTest.java +++ b/server-application-server/sourceTest/java/ch/ethz/sis/openbis/systemtest/asapi/v3/ExportTest.java @@ -346,19 +346,6 @@ public class ExportTest extends AbstractTest } } - private static ObjectInputStream objectToStream(final Object object) throws IOException - { - final ByteArrayOutputStream baos = new ByteArrayOutputStream(); - try (final ObjectOutputStream oos = new ObjectOutputStream(baos)) - { - oos.writeObject(object); - } - final byte[] objectBytes = baos.toByteArray(); - - final ByteArrayInputStream bais = new ByteArrayInputStream(objectBytes); - return new ObjectInputStream(bais); - } - /** * Searches for ExportablePermIds with null perm IDs, which should indicate that it should be replaced with {@link #samplePermId}. * diff --git a/test-api-openbis-javascript/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-import-export.js b/test-api-openbis-javascript/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-import-export.js index 2c60f834252..e97858ba8cf 100644 --- a/test-api-openbis-javascript/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-import-export.js +++ b/test-api-openbis-javascript/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-import-export.js @@ -151,6 +151,30 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' testAction(c, fAction, fCheck); }); + + QUnit.test("executeExport()", function(assert) { + var c = new common(assert, dtos); + + var fAction = function(facade) { + var exportablePermId = new ExportablePermId( + ExportableKind.SAMPLE, new SamplePermId("200902091225616-1027")); + var exportData = new dtos.ExportData(exportablePermId, + new AllFields()); + + var exportOptions = new dtos.ExportOptions( + [ExportFormat.XLSX, ExportFormat.HTML, ExportFormat.PDF, ExportFormat.DATA], + XlsTextFormat.RICH, true, false); + + return facade.executeExport(exportData, exportOptions); + } + + var fCheck = function(facade, result) { + // Simple smoke test in this case. + c.assertNotNull(result); + } + + testAction(c, fAction, fCheck); + }); } return function() { -- GitLab