From 39e6117155ce044d26ad4cec8bd4cba41e3cb6ce Mon Sep 17 00:00:00 2001 From: pkupczyk <pkupczyk> Date: Mon, 4 Apr 2016 17:17:54 +0000 Subject: [PATCH] SSDM-3395 : V3 AS API - controlled vocabulary terms - more js-tests for vocabularies SVN: 36072 --- .../openbis-v3-api-test/html/test/common.js | 17 +++++++++++++ .../html/test/test-delete.js | 5 ++++ .../openbis-v3-api-test/html/test/test-map.js | 24 +++++++++++++++++++ 3 files changed, 46 insertions(+) diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js index 140f1c0569a..3a758cd222a 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/common.js @@ -167,6 +167,16 @@ define([ 'jquery', 'openbis', 'underscore', 'test/dtos' ], function($, openbis, }); }.bind(this); + this.createVocabularyTerm = function(facade) { + var c = this; + var creation = new dtos.VocabularyTermCreation(); + creation.setCode(c.generateId("VOCABULARY_TERM")); + creation.setVocabularyId(new c.VocabularyPermId("TEST-VOCABULARY")); + return facade.createVocabularyTerms([ creation ]).then(function(permIds) { + return permIds[0]; + }); + }.bind(this); + this.findSpace = function(facade, id) { var c = this; return facade.mapSpaces([ id ], c.createSpaceFetchOptions()).then(function(spaces) { @@ -257,6 +267,13 @@ define([ 'jquery', 'openbis', 'underscore', 'test/dtos' ], function($, openbis, options.setReason("test reason"); return facade.deleteMaterials([ id ], options); }.bind(this); + + this.deleteVocabularyTerm = function(facade, id) { + var c = this; + var options = new dtos.VocabularyTermDeletionOptions(); + options.setReason("test reason"); + return facade.deleteVocabularyTerms([ id ], options); + }.bind(this); this.getObjectProperty = function(object, propertyName) { var propertyNames = propertyName.split('.'); diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-delete.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-delete.js index 1c01a095cb1..527a0b2430c 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-delete.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-delete.js @@ -153,6 +153,11 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open var c = new common(assert); testDeleteWithoutTrash(c, c.createMaterial, c.findMaterial, c.deleteMaterial); }); + + QUnit.test("deleteVocabularyTerm()", function(assert) { + var c = new common(assert); + testDeleteWithoutTrash(c, c.createVocabularyTerm, c.findVocabularyTerm, c.deleteVocabularyTerm); + }); } }); diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-map.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-map.js index 4512ad42c8f..0833b8d1d5d 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-map.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-map.js @@ -269,5 +269,29 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open testMap(c, fCreate, fMap, fMapEmptyFetchOptions, fechOptionsTestConfig); }); + QUnit.test("mapVocabularyTerms()", function(assert) { + var c = new common(assert); + var fo = new c.VocabularyTermFetchOptions(); + var fechOptionsTestConfig = getConfigForFetchOptions(fo); + fechOptionsTestConfig.SortBy = null; + + var fCreate = function(facade) { + return $.when(c.createVocabularyTerm(facade), c.createVocabularyTerm(facade)).then(function(permId1, permId2) { + return [ permId1, permId2 ]; + }); + } + + var fMap = function(facade, permIds) { + testFetchOptionsAssignation(c, fo, fechOptionsTestConfig); + return facade.mapVocabularyTerms(permIds, fo); + } + + var fMapEmptyFetchOptions = function(facade, permIds) { + return facade.mapVocabularyTerms(permIds, new c.VocabularyTermFetchOptions()); + } + + testMap(c, fCreate, fMap, fMapEmptyFetchOptions, fechOptionsTestConfig); + }); + } }); -- GitLab