From 1148b0a53b6aedeb0a05d707d36ed882dc38b5cc Mon Sep 17 00:00:00 2001 From: felmer <felmer> Date: Wed, 29 Nov 2017 10:17:45 +0000 Subject: [PATCH] SSDM-5721: JS tests for getting and creating persons SVN: 38979 --- .../openbis-v3-api-test/html/test/common.js | 18 +++++++++++++++ .../openbis-v3-api-test/html/test/dtos.js | 3 +++ .../html/test/openbis-execute-operations.js | 4 ++++ .../html/test/test-create.js | 19 +++++++++++++++ .../openbis-v3-api-test/html/test/test-get.js | 23 +++++++++++++++++++ 5 files changed, 67 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 eb27feb39e8..93eb1884087 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 @@ -31,6 +31,7 @@ define([ 'jquery', 'openbis', 'underscore', 'test/dtos' ], function($, defaultOp this.TagCreation = dtos.TagCreation; this.AuthorizationGroupCreation = dtos.AuthorizationGroupCreation; this.RoleAssignmentCreation = dtos.RoleAssignmentCreation; + this.PersonCreation = dtos.PersonCreation; this.Role = require('as/dto/roleassignment/Role'); this.SemanticAnnotationCreation = dtos.SemanticAnnotationCreation; this.DataSetCreation = dtos.DataSetCreation; @@ -181,6 +182,7 @@ define([ 'jquery', 'openbis', 'underscore', 'test/dtos' ], function($, defaultOp this.CreateTagsOperation = dtos.CreateTagsOperation; this.CreateAuthorizationGroupsOperation = dtos.CreateAuthorizationGroupsOperation; this.CreateRoleAssignmentsOperation = dtos.CreateRoleAssignmentsOperation; + this.CreatePersonsOperation = dtos.CreatePersonsOperation; this.CreateSemanticAnnotationsOperation = dtos.CreateSemanticAnnotationsOperation; this.CreateExternalDmsOperation = dtos.CreateExternalDmsOperation; @@ -455,6 +457,15 @@ define([ 'jquery', 'openbis', 'underscore', 'test/dtos' ], function($, defaultOp }); }.bind(this); + this.createPerson = function(facade) { + var c = this; + var creation = new dtos.PersonCreation(); + creation.setUserId(c.generateId("USER")); + return facade.createPersons([ creation ]).then(function(permIds) { + return permIds[0]; + }); + }.bind(this); + this.createSemanticAnnotation = function(facade) { var c = this; var creation = new dtos.SemanticAnnotationCreation(); @@ -586,6 +597,13 @@ define([ 'jquery', 'openbis', 'underscore', 'test/dtos' ], function($, defaultOp }); }.bind(this); + this.findPerson = function(facade, id) { + var c = this; + return facade.getPersons([ id ], c.createPersonFetchOptions()).then(function(persons) { + return persons[id]; + }); + }.bind(this); + this.findSemanticAnnotation = function(facade, id) { var c = this; return facade.getSemanticAnnotations([ id ], c.createSemanticAnnotationFetchOptions()).then(function(annotations) { diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/dtos.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/dtos.js index 0d938f92802..292cd2d2567 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/dtos.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/dtos.js @@ -369,6 +369,9 @@ var sources = [ 'as/dto/person/fetchoptions/PersonFetchOptions', 'as/dto/person/fetchoptions/PersonSortOptions', + 'as/dto/person/create/PersonCreation', + 'as/dto/person/create/CreatePersonsOperation', + 'as/dto/person/create/CreatePersonsOperationResult', 'as/dto/person/get/GetPersonsOperation', 'as/dto/person/get/GetPersonsOperationResult', 'as/dto/person/id/PersonPermId', diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/openbis-execute-operations.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/openbis-execute-operations.js index 286e79bc447..7be7b42a82f 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/openbis-execute-operations.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/openbis-execute-operations.js @@ -145,6 +145,10 @@ define([ 'jquery', 'openbis', 'test/common' ], function($, openbis, common) { return this._executeCreateOperation(new c.CreateRoleAssignmentsOperation(creations)); } + this.createPersons = function(creations) { + return this._executeCreateOperation(new c.CreatePersonsOperation(creations)); + } + this.createSemanticAnnotations = function(creations) { return this._executeCreateOperation(new c.CreateSemanticAnnotationsOperation(creations)); } diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-create.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-create.js index fe8e5c51e82..f85ba563e2a 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-create.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-create.js @@ -540,6 +540,25 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' testCreate(c, fCreate, c.findTag, fCheck); }); + QUnit.test("createPersons()", function(assert) { + var c = new common(assert, openbis); + var userId = c.generateId("user"); + + var fCreate = function(facade) { + var personCreation = new c.PersonCreation(); + personCreation.setUserId(userId); + return facade.createPersons([ personCreation ]); + } + + var fCheck = function(person) { + c.assertEqual(person.getUserId(), userId, "User id"); + c.assertEqual(person.getRegistrator().getUserId(), "openbis_test_js", "Registrator"); + c.assertEqual(person.isActive(), true, "User active"); + } + + testCreate(c, fCreate, c.findPerson, fCheck); + }); + var createSemanticAnnotationCreation = function(c) { var creation = new c.SemanticAnnotationCreation(); creation.setPredicateOntologyId("jsPredicateOntologyId"); diff --git a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-get.js b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-get.js index 768c7d48ae6..6f56a254c74 100644 --- a/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-get.js +++ b/js-test/servers/common/core-plugins/tests/1/as/webapps/openbis-v3-api-test/html/test/test-get.js @@ -430,6 +430,29 @@ define([ 'jquery', 'underscore', 'openbis', 'test/openbis-execute-operations', ' testGet(c, fCreate, fGet, fGetEmptyFetchOptions, fechOptionsTestConfig); }); + QUnit.test("getPersons()", function(assert) { + var c = new common(assert, openbis); + var fo = new c.PersonFetchOptions(); + var fechOptionsTestConfig = getConfigForFetchOptions(fo); + + var fCreate = function(facade) { + return $.when(c.createPerson(facade), c.createPerson(facade)).then(function(permId1, permId2) { + return [ permId1, permId2 ]; + }); + } + + var fGet = function(facade, permIds) { + testFetchOptionsAssignation(c, fo, fechOptionsTestConfig); + return facade.getPersons(permIds, fo); + } + + var fGetEmptyFetchOptions = function(facade, permIds) { + return facade.getPersons(permIds, new c.PersonFetchOptions()); + } + + testGet(c, fCreate, fGet, fGetEmptyFetchOptions, fechOptionsTestConfig); + }); + QUnit.test("getOperationExecutions()", function(assert) { var c = new common(assert, openbis); var fo = new c.OperationExecutionFetchOptions(); -- GitLab