Skip to content
Snippets Groups Projects
Commit 70394b9c authored by felmer's avatar felmer
Browse files

SSDM-2718: Javascript: Bugs fixed and new tests (test-custom-services) in js-test

SVN: 35610
parent 61f187f9
No related branches found
No related tags found
No related merge requests found
Showing
with 99 additions and 5 deletions
class = ch.ethz.sis.openbis.generic.server.asapi.v3.helper.service.JythonBasedCustomASServiceExecutor
script-path = script.py
def process(context, parameters):
return "hello A"
class = ch.ethz.sis.openbis.generic.server.asapi.v3.helper.service.JythonBasedCustomASServiceExecutor
script-path = script.py
def process(context, parameters):
return "hello B"
class = ch.ethz.sis.openbis.generic.server.asapi.v3.helper.service.JythonBasedCustomASServiceExecutor
description = a simple service
script-path = script.py
from ch.ethz.sis.openbis.generic.asapi.v3.dto.space.fetchoptions import SpaceFetchOptions
from ch.ethz.sis.openbis.generic.asapi.v3.dto.space.search import SpaceSearchCriteria
def process(context, parameters):
spaceCode = parameters.get("space-code")
searchCriteria = SpaceSearchCriteria()
searchCriteria.withCode().thatEquals(spaceCode)
result = context.applicationService.searchSpaces(context.sessionToken, searchCriteria, SpaceFetchOptions())
return result
......@@ -7,13 +7,17 @@ define([ 'jquery', 'openbis', 'as/dto/space/create/SpaceCreation', 'as/dto/proje
'as/dto/dataset/id/FileFormatTypePermId', 'as/dto/material/id/MaterialPermId', 'as/dto/tag/id/TagCode', 'as/dto/space/search/SpaceSearchCriteria', 'as/dto/project/search/ProjectSearchCriteria',
'as/dto/experiment/search/ExperimentSearchCriteria', 'as/dto/sample/search/SampleSearchCriteria', 'as/dto/dataset/search/DataSetSearchCriteria', 'as/dto/material/search/MaterialSearchCriteria',
'as/dto/space/fetchoptions/SpaceFetchOptions', 'as/dto/project/fetchoptions/ProjectFetchOptions', 'as/dto/experiment/fetchoptions/ExperimentFetchOptions', 'as/dto/sample/fetchoptions/SampleFetchOptions',
'as/dto/dataset/fetchoptions/DataSetFetchOptions', 'as/dto/material/fetchoptions/MaterialFetchOptions', 'as/dto/deletion/fetchoptions/DeletionFetchOptions', 'as/dto/deletion/search/DeletionSearchCriteria'
'as/dto/dataset/fetchoptions/DataSetFetchOptions', 'as/dto/material/fetchoptions/MaterialFetchOptions', 'as/dto/deletion/fetchoptions/DeletionFetchOptions', 'as/dto/deletion/search/DeletionSearchCriteria',
'as/dto/service/search/CustomASServiceSearchCriteria', 'as/dto/service/fetchoptions/CustomASServiceFetchOptions',
'as/dto/service/id/CustomASServiceCode', 'as/dto/service/CustomASServiceExecutionOptions'
], function($, openbis, SpaceCreation,
ProjectCreation, ExperimentCreation, SampleCreation, MaterialCreation, AttachmentCreation, SpaceUpdate, ProjectUpdate, ExperimentUpdate, SampleUpdate, DataSetUpdate, PhysicalDataUpdate,
MaterialUpdate, SpaceDeletionOptions, ProjectDeletionOptions, ExperimentDeletionOptions, SampleDeletionOptions, DataSetDeletionOptions, MaterialDeletionOptions, EntityTypePermId, SpacePermId,
ProjectPermId, ProjectIdentifier, ExperimentPermId, ExperimentIdentifier, SamplePermId, DataSetPermId, FileFormatTypePermId, MaterialPermId, TagCode, SpaceSearchCriteria,
ProjectSearchCriteria, ExperimentSearchCriteria, SampleSearchCriteria, DataSetSearchCriteria, MaterialSearchCriteria, SpaceFetchOptions, ProjectFetchOptions, ExperimentFetchOptions,
SampleFetchOptions, DataSetFetchOptions, MaterialFetchOptions, DeletionFetchOptions, DeletionSearchCriteria) {
SampleFetchOptions, DataSetFetchOptions, MaterialFetchOptions, DeletionFetchOptions, DeletionSearchCriteria,
CustomASServiceSearchCriteria, CustomASServiceFetchOptions,
CustomASServiceCode, CustomASServiceExecutionOptions) {
/*
* These tests should be run against openBIS instance with screening sprint
......@@ -76,6 +80,10 @@ define([ 'jquery', 'openbis', 'as/dto/space/create/SpaceCreation', 'as/dto/proje
this.MaterialFetchOptions = MaterialFetchOptions;
this.DeletionFetchOptions = DeletionFetchOptions;
this.DeletionSearchCriteria = DeletionSearchCriteria;
this.CustomASServiceSearchCriteria = CustomASServiceSearchCriteria;
this.CustomASServiceFetchOptions = CustomASServiceFetchOptions;
this.CustomASServiceCode = CustomASServiceCode;
this.CustomASServiceExecutionOptions = CustomASServiceExecutionOptions;
this.generateId = function(base) {
var date = new Date();
......
define([ 'test/test-login', 'test/test-jsVSjava', 'test/test-create', 'test/test-update', 'test/test-search', 'test/test-map', 'test/test-delete', 'test/test-dto' ], function() {
define([ 'test/test-login', 'test/test-jsVSjava', 'test/test-create', 'test/test-update', 'test/test-search',
'test/test-map', 'test/test-delete', 'test/test-dto', 'test/test-custom-services' ], function() {
var testSuites = arguments;
return function() {
for (var i = 0; i < testSuites.length; i++) {
......
/**
* Test searching and executing custom AS services.
*/
define(['jquery', 'underscore', 'openbis', 'test/common'], function($, _, openbis, common) {
return function() {
QUnit.module("Custom AS service tests")
var testAction = function(c, fAction, fCheck) {
c.start();
c.createFacadeAndLogin().then(function(facade) {
c.ok("Login");
return fAction(facade).then(function(result) {
c.ok("Got results");
fCheck(facade, result);
c.finish();
});
}).fail(function(error) {
c.fail(error.message);
c.finish();
});
}
QUnit.test("searchCustomASServices()", function(assert) {
var c = new common(assert);
var fAction = function(facade) {
var criteria = new c.CustomASServiceSearchCriteria();
criteria.withCode().thatStartsWith("simple");
return facade.searchCustomASServices(criteria, new c.CustomASServiceFetchOptions());
}
var fCheck = function(facade, result) {
var services = result.getObjects();
c.assertEqual(services.length, 1);
var service = services[0];
c.assertEqual(service.getCode().getPermId(), "simple-service", "Code");
c.assertEqual(service.getDescription(), "a simple service", "Description");
}
testAction(c, fAction, fCheck);
})
QUnit.test("executeCustomASService()", function(assert){
var c = new common(assert);
var fAction = function(facade) {
var id = new c.CustomASServiceCode("simple-service");
var options = new c.CustomASServiceExecutionOptions().withParameter("a", "1").withParameter("space-code", "TEST");
return facade.executeCustomASService(id, options);
}
var fCheck = function(facade, result) {
c.assertEqual(1, result.getTotalCount());
var space = result.getObjects()[0];
c.assertEqual(space.getPermId(), "TEST", "PermId");
c.assertEqual(space.getCode(), "TEST", "Code");
c.assertEqual(space.getDescription(), null, "Description");
c.assertDate(space.getRegistrationDate(), "Registration date", 2013, 04, 12, 12, 59);
}
testAction(c, fAction, fCheck);
})
}
})
\ No newline at end of file
......@@ -39,5 +39,5 @@ define([ "stjs", "util/Exceptions" ], function(stjs, exceptions) {
}, {
fetchOptions : "CustomASServiceFetchOptions"
});
return Service;
return CustomASService;
})
\ No newline at end of file
......@@ -2,7 +2,7 @@ define([ "stjs"], function(stjs) {
var CustomASServiceExecutionOptions = function() {
this.parameters = {};
};
stjs.extend(ExecutionOptions, null, [ ], function(constructor, prototype) {
stjs.extend(CustomASServiceExecutionOptions, null, [ ], function(constructor, prototype) {
prototype['@type'] = 'as.dto.service.CustomASServiceExecutionOptions';
constructor.serialVersionUID = 1;
prototype.parameters = null;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment