Skip to content
Snippets Groups Projects
Commit 5c6e0583 authored by juanf's avatar juanf
Browse files

SSDM-2782 : Minimum Fech Options Results Tests (Detect that fetch options return results)

SVN: 35397
parent 9d8667ea
No related branches found
No related tags found
No related merge requests found
...@@ -2,7 +2,7 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open ...@@ -2,7 +2,7 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open
return function() { return function() {
QUnit.module("Map tests"); QUnit.module("Map tests");
var testMap = function(c, fCreate, fMap) { var testMap = function(c, fCreate, fMap, fechOptionsTestConfig) {
c.start(); c.start();
c.createFacadeAndLogin().then(function(facade) { c.createFacadeAndLogin().then(function(facade) {
return fCreate(facade).then(function(permIds) { return fCreate(facade).then(function(permIds) {
...@@ -11,6 +11,7 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open ...@@ -11,6 +11,7 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open
c.assertEqual(Object.keys(map).length, permIds.length, "Entity map size is correct"); c.assertEqual(Object.keys(map).length, permIds.length, "Entity map size is correct");
permIds.forEach(function(permId) { permIds.forEach(function(permId) {
var entity = map[permId]; var entity = map[permId];
testFetchOptionsResults(c, fechOptionsTestConfig, true, entity);
c.assertEqual(entity.getPermId().toString(), permId.toString(), "Entity perm id matches"); c.assertEqual(entity.getPermId().toString(), permId.toString(), "Entity perm id matches");
}); });
c.finish(); c.finish();
...@@ -52,34 +53,35 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open ...@@ -52,34 +53,35 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open
} }
} }
var testFetchOptionsResults = function(c, fo, toTest, entity, entityType) { var testFetchOptionsResults = function(c, toTest, expectedShouldSucceed, entity) {
for(property in toTest) { for(property in toTest) {
var expectedShouldSucceed = toTest[property]; if(property !== "SortBy") {
var methodName = "get" + property; var methodName = "get" + property;
if(typeof entity[methodName] === "function") { if(typeof entity[methodName] === "function") {
try { try {
var result = entity[methodName](); //Should not thrown an exception, what it means is right! var result = entity[methodName](); //Should not thrown an exception, what it means is right!
if(!expectedShouldSucceed) { if(!expectedShouldSucceed) {
throw "Calling method " + methodName + " succeed when it should thrown an exception for entity type " + entityType + "."; throw "Calling method " + methodName + " succeed when it should thrown an exception for entity type " + entity.toString() + ".";
} }
} catch(error) { } catch(error) {
if(expectedShouldSucceed) { if(expectedShouldSucceed) {
throw "Calling method " + methodName + " thrown an exception when it should succeed for entity type " + entityType + "."; throw "Calling method " + methodName + " thrown an exception when it should succeed for entity type " + entity.toString() + ".";
}
} }
} else {
throw methodName + " should be a method.";
} }
} else {
throw methodName + " should be a method.";
} }
} }
} }
QUnit.test("mapSpaces()", function(assert) { QUnit.test("mapSpaces()", function(assert) {
var c = new common(assert); var c = new common(assert);
var config = { var fechOptionsTestConfig = {
Registrator : true, Registrator : null,
Projects : true, Projects : null,
Samples : true, Samples : null,
SortBy : true SortBy : null
} }
var fCreate = function(facade) { var fCreate = function(facade) {
...@@ -90,25 +92,25 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open ...@@ -90,25 +92,25 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open
var fMap = function(facade, permIds) { var fMap = function(facade, permIds) {
var fo = new c.SpaceFetchOptions(); var fo = new c.SpaceFetchOptions();
testFetchOptionsAssignation(c, fo, config); testFetchOptionsAssignation(c, fo, fechOptionsTestConfig);
return facade.mapSpaces(permIds, fo); return facade.mapSpaces(permIds, fo);
} }
testMap(c, fCreate, fMap); testMap(c, fCreate, fMap, fechOptionsTestConfig);
}); });
QUnit.test("mapProjects()", function(assert) { QUnit.test("mapProjects()", function(assert) {
var c = new common(assert); var c = new common(assert);
var config = { var fechOptionsTestConfig = {
Experiments : true, Experiments : null,
Space : true, Space : null,
Leader : true, Leader : null,
Modifier : true, Modifier : null,
Attachments : true, Attachments : null,
Registrator : true, Registrator : null,
Samples : true, Samples : null,
SortBy : true, SortBy : null,
History : true History : null
}; };
var fCreate = function(facade) { var fCreate = function(facade) {
...@@ -119,28 +121,28 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open ...@@ -119,28 +121,28 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open
var fMap = function(facade, permIds) { var fMap = function(facade, permIds) {
var fo = new c.ProjectFetchOptions(); var fo = new c.ProjectFetchOptions();
testFetchOptionsAssignation(c, fo, config); testFetchOptionsAssignation(c, fo, fechOptionsTestConfig);
return facade.mapProjects(permIds, fo); return facade.mapProjects(permIds, fo);
} }
testMap(c, fCreate, fMap); testMap(c, fCreate, fMap, fechOptionsTestConfig);
}); });
QUnit.test("mapExperiments()", function(assert) { QUnit.test("mapExperiments()", function(assert) {
var c = new common(assert); var c = new common(assert);
var config = { var fechOptionsTestConfig = {
Type : true, Type : null,
Project : true, Project : null,
DataSets : true, DataSets : null,
Properties : true, Properties : null,
MaterialProperties : true, MaterialProperties : null,
Tags : true, Tags : null,
Samples : true, Samples : null,
History : true, History : null,
Registrator : true, Registrator : null,
Modifier : true, Modifier : null,
Attachments : true, Attachments : null,
SortBy : true SortBy : null
}; };
var fCreate = function(facade) { var fCreate = function(facade) {
...@@ -151,29 +153,29 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open ...@@ -151,29 +153,29 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open
var fMap = function(facade, permIds) { var fMap = function(facade, permIds) {
var fo = new c.ExperimentFetchOptions(); var fo = new c.ExperimentFetchOptions();
testFetchOptionsAssignation(c, fo, config); testFetchOptionsAssignation(c, fo, fechOptionsTestConfig);
return facade.mapExperiments(permIds, fo); return facade.mapExperiments(permIds, fo);
} }
testMap(c, fCreate, fMap); testMap(c, fCreate, fMap, fechOptionsTestConfig);
}); });
QUnit.test("mapSamples()", function(assert) { QUnit.test("mapSamples()", function(assert) {
var c = new common(assert); var c = new common(assert);
var config = { var fechOptionsTestConfig = {
Parents : true, Parents : null,
Children : true, Children : null,
Container : true, Container : null,
Components : true, Components : null,
Type : true, Type : null,
Project : true, Project : null,
Space : true, Space : null,
Experiment : true, Experiment : null,
Properties : true, Properties : null,
MaterialProperties : true, MaterialProperties : null,
DataSets : true, DataSets : null,
History : true, History : null,
SortBy : true SortBy : null
}; };
var fCreate = function(facade) { var fCreate = function(facade) {
...@@ -184,32 +186,32 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open ...@@ -184,32 +186,32 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open
var fMap = function(facade, permIds) { var fMap = function(facade, permIds) {
var fo = new c.SampleFetchOptions(); var fo = new c.SampleFetchOptions();
testFetchOptionsAssignation(c, fo, config); testFetchOptionsAssignation(c, fo, fechOptionsTestConfig);
return facade.mapSamples(permIds, fo); return facade.mapSamples(permIds, fo);
} }
testMap(c, fCreate, fMap); testMap(c, fCreate, fMap, fechOptionsTestConfig);
}); });
QUnit.test("mapDataSets()", function(assert) { QUnit.test("mapDataSets()", function(assert) {
var c = new common(assert); var c = new common(assert);
var config = { var fechOptionsTestConfig = {
Parents : true, Parents : null,
Children : true, Children : null,
Components : true, Components : null,
Type : true, Type : null,
History : true, History : null,
Experiment : true, Experiment : null,
Properties : true, Properties : null,
MaterialProperties : true, MaterialProperties : null,
Modifier : true, Modifier : null,
Registrator : true, Registrator : null,
Containers : true, Containers : null,
PhysicalData : true, PhysicalData : null,
LinkedData : true, LinkedData : null,
Tags : true, Tags : null,
DataStore : true, DataStore : null,
SortBy : true SortBy : null
}; };
var fCreate = function(facade) { var fCreate = function(facade) {
...@@ -220,7 +222,7 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open ...@@ -220,7 +222,7 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open
var fMap = function(facade, permIds) { var fMap = function(facade, permIds) {
var fo = new c.DataSetFetchOptions(); var fo = new c.DataSetFetchOptions();
testFetchOptionsAssignation(c, fo, config); testFetchOptionsAssignation(c, fo, fechOptionsTestConfig);
var result = facade.mapDataSets(permIds, fo); var result = facade.mapDataSets(permIds, fo);
result.then(function(map) { result.then(function(map) {
...@@ -232,19 +234,19 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open ...@@ -232,19 +234,19 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open
return result; return result;
} }
testMap(c, fCreate, fMap); testMap(c, fCreate, fMap, fechOptionsTestConfig);
}); });
QUnit.test("mapMaterials()", function(assert) { QUnit.test("mapMaterials()", function(assert) {
var c = new common(assert); var c = new common(assert);
var config = { var fechOptionsTestConfig = {
Type : true, Type : null,
History : true, History : null,
Registrator : true, Registrator : null,
Properties : true, Properties : null,
MaterialProperties : true, MaterialProperties : null,
Tags : true, Tags : null,
SortBy : true SortBy : null
}; };
var fCreate = function(facade) { var fCreate = function(facade) {
...@@ -255,11 +257,11 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open ...@@ -255,11 +257,11 @@ define([ 'jquery', 'underscore', 'openbis', 'test/common' ], function($, _, open
var fMap = function(facade, permIds) { var fMap = function(facade, permIds) {
var fo = new c.MaterialFetchOptions(); var fo = new c.MaterialFetchOptions();
testFetchOptionsAssignation(c, fo, config); testFetchOptionsAssignation(c, fo, fechOptionsTestConfig);
return facade.mapMaterials(permIds, fo); return facade.mapMaterials(permIds, fo);
} }
testMap(c, fCreate, fMap); testMap(c, fCreate, fMap, fechOptionsTestConfig);
}); });
} }
......
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