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 8ef41d3bc4a4973e32ca1ee6eef48aedbf896600..d621e9ee344ef6a6c17bb452436fc858793d0322 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 @@ -22,7 +22,165 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open c.finish(); }); } - + + var testFetchOptions = function(c, fo, toTest) { + + if(toTest.hasSample) { + fo.withSampleUsing(null); + fo.withSample(); + fo.hasSample(); + } + + if(toTest.hasDataStore) { + fo.withDataStoreUsing(null); + fo.withDataStore(); + fo.hasDataStore(); + } + + if(toTest.hasTags) { + fo.withTagsUsing(null); + fo.withTags(); + fo.hasTags(); + } + + if(toTest.hasLinkedData) { + fo.withLinkedDataUsing(null); + fo.withLinkedData(); + fo.hasLinkedData(); + } + + if(toTest.hasPhysicalData) { + fo.withPhysicalDataUsing(null); + fo.withPhysicalData(); + fo.hasPhysicalData(); + } + + if(toTest.hasContainers) { + fo.withContainersUsing(null); + fo.withContainers(); + fo.hasContainers(); + } + + if(toTest.hasComponents) { + fo.withComponentsUsing(null); + fo.withComponents(); + fo.hasComponents(); + } + + if(toTest.hasContainer) { + fo.withContainerUsing(null); + fo.withContainer(); + fo.hasContainer(); + } + + if(toTest.hasChildren) { + fo.withChildrenUsing(null); + fo.withChildren(); + fo.hasChildren(); + } + + if(toTest.hasParents) { + fo.withParentsUsing(null); + fo.withParents(); + fo.hasParents(); + } + + if(toTest.hasSortBy) { + fo.sortBy().code(); + c.assertEqual(true, ((fo.getSortBy())?true:false)); + } + + if(toTest.hasExperiments) { + fo.withExperimentsUsing(null); + fo.withExperiments(); + c.assertEqual(true, fo.hasExperiments()); + } + + if(toTest.hasSamples) { + fo.withSamplesUsing(null); + fo.withSamples(); + c.assertEqual(true, fo.hasSamples()); + } + + if(toTest.hasSpace) { + fo.withSpaceUsing(null); + fo.withSpace(); + c.assertEqual(true, fo.hasSpace()); + } + + if(toTest.hasRegistrator) { + fo.withRegistratorUsing(null); + fo.withRegistrator(); + c.assertEqual(true, fo.hasRegistrator()); + } + + if(toTest.hasModifier) { + fo.withModifierUsing(null); + fo.withModifier(); + c.assertEqual(true, fo.hasModifier()); + } + + if(toTest.hasLeader) { + fo.withLeaderUsing(null); + fo.withLeader(); + c.assertEqual(true, fo.hasLeader()); + } + + if(toTest.hasAttachments) { + fo.withAttachmentsUsing(null); + fo.withAttachments(); + c.assertEqual(true, fo.hasAttachments()); + } + + if(toTest.hasHistory) { + fo.withHistoryUsing(null); + fo.withHistory(); + c.assertEqual(true, fo.hasHistory()); + } + + if(toTest.hasType) { + fo.withTypeUsing(null); + fo.withType(); + c.assertEqual(true, fo.hasType()); + } + + if(toTest.hasProject) { + fo.withProjectUsing(null); + fo.withProject(); + c.assertEqual(true, fo.hasProject()); + } + + if(toTest.hasDataSets) { + fo.withDataSetsUsing(null); + fo.withDataSets(); + c.assertEqual(true, fo.hasDataSets()); + } + + if(toTest.hasDataSets) { + fo.withDataSetsUsing(null); + fo.withDataSets(); + c.assertEqual(true, fo.hasDataSets()); + } + + if(toTest.hasProperties) { + fo.withPropertiesUsing(null); + fo.withProperties(); + c.assertEqual(true, fo.hasProperties()); + } + + if(toTest.hasMaterialProperties) { + fo.withMaterialPropertiesUsing(null); + fo.withMaterialProperties(); + c.assertEqual(true, fo.hasMaterialProperties()); + } + + if(toTest.hasTags) { + fo.withTagsUsing(null); + fo.withTags(); + c.assertEqual(true, fo.hasTags()); + } + } + QUnit.test("mapSpaces()", function(assert) { var c = new common(assert); @@ -31,11 +189,20 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open return [ permId1, permId2 ]; }); } - + var fMap = function(facade, permIds) { - return facade.mapSpaces(permIds, new c.SpaceFetchOptions()); + var fo = new c.SpaceFetchOptions(); + + testFetchOptions(c, fo, { + hasRegistrator : true, + hasProjects : true, + hasSamples : true, + hasSortBy : true + }); + + return facade.mapSpaces(permIds, fo); } - + testMap(c, fCreate, fMap); }); @@ -49,7 +216,22 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open } var fMap = function(facade, permIds) { - return facade.mapProjects(permIds, new c.ProjectFetchOptions()); + var fo = new c.ProjectFetchOptions(); + + testFetchOptions(c, fo, { + hasExperiments : true, + hasSpace : true, + hasLeader : true, + hasModifier : true, + hasAttachments : true, + hasRegistrator : true, + hasProjects : true, + hasSamples : true, + hasSortBy : true, + hasHistory : true + }); + + return facade.mapProjects(permIds, fo); } testMap(c, fCreate, fMap); @@ -65,7 +247,24 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open } var fMap = function(facade, permIds) { - return facade.mapExperiments(permIds, new c.ExperimentFetchOptions()); + var fo = new c.ExperimentFetchOptions(); + + testFetchOptions(c, fo, { + hasType : true, + hasProject : true, + hasDataSets : true, + hasProperties : true, + hasMaterialProperties : true, + hasTags : true, + hasSamples : true, + hasHistory : true, + hasRegistrator : true, + hasModifier : true, + hasAttachments : true, + hasSortBy : true + }); + + return facade.mapExperiments(permIds, fo); } testMap(c, fCreate, fMap); @@ -79,9 +278,27 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open return [ permId1, permId2 ]; }); } - + var fMap = function(facade, permIds) { - return facade.mapSamples(permIds, new c.SampleFetchOptions()); + var fo = new c.SampleFetchOptions(); + + testFetchOptions(c, fo, { + hasParents : true, + hasChildren : true, + hasContainer : true, + hasComponents : true, + hasType : true, + hasProject : true, + hasSpace : true, + hasExperiment : true, + hasProperties : true, + hasMaterialProperties : true, + hasDataSets : true, + hasHistory : true, + hasSortBy : true + }); + + return facade.mapSamples(permIds, fo); } testMap(c, fCreate, fMap); @@ -97,7 +314,29 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open } var fMap = function(facade, permIds) { - var result = facade.mapDataSets(permIds, new c.DataSetFetchOptions()); + var fo = new c.DataSetFetchOptions(); + + testFetchOptions(c, fo, { + hasParents : true, + hasChildren : true, + hasComponents : true, + hasType : true, + hasHistory : true, + hasExperiment : true, + hasProperties : true, + hasMaterialProperties : true, + hasModifier : true, + hasRegistrator : true, + hasContainers : true, + hasPhysicalData : true, + hasLinkedData : true, + hasTags : true, + hasDataStore : true, + hasSortBy : true + }); + + var result = facade.mapDataSets(permIds, fo); + result.then(function(map) { permIds.forEach(function(permId) { var entity = map[permId]; @@ -120,7 +359,19 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open } var fMap = function(facade, permIds) { - return facade.mapMaterials(permIds, new c.MaterialFetchOptions()); + var fo = new c.MaterialFetchOptions(); + + testFetchOptions(c, fo, { + hasType : true, + hasHistory : true, + hasRegistrator : true, + hasProperties : true, + hasMaterialProperties : true, + hasTags : true, + hasSortBy : true + }); + + return facade.mapMaterials(permIds, fo); } testMap(c, fCreate, fMap);