From 53dafce182c9a283a8c85194538fd9ccb5af7daf Mon Sep 17 00:00:00 2001
From: pkupczyk <pkupczyk>
Date: Tue, 5 Mar 2013 14:57:26 +0000
Subject: [PATCH] SP-529 / BIS-151 : Provide only one version of openbis.js
 file - create separate js automated tests for screening

SVN: 28528
---
 .../applications/common-test/common-test.js   | 71 ++++++++++++++++++
 .../{openbistest => common-test}/qunit.css    |  0
 .../{openbistest => common-test}/qunit.js     |  0
 .../openbis-screening-test.html               | 20 ++++++
 .../openbis-screening-test.js                 | 13 ++++
 .../openbis-test/openbis-test.html            | 19 +++++
 .../openbis-test.js}                          | 72 -------------------
 .../applications/openbistest/openbistest.html | 18 -----
 .../resources/js-new/openbis-screening.js     |  9 ++-
 9 files changed, 127 insertions(+), 95 deletions(-)
 create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/common-test/common-test.js
 rename openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/{openbistest => common-test}/qunit.css (100%)
 rename openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/{openbistest => common-test}/qunit.js (100%)
 create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-screening-test/openbis-screening-test.html
 create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-screening-test/openbis-screening-test.js
 create mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-test/openbis-test.html
 rename openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/{openbistest/openbistest.js => openbis-test/openbis-test.js} (87%)
 delete mode 100644 openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbistest/openbistest.html

diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/common-test/common-test.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/common-test/common-test.js
new file mode 100644
index 00000000000..49eaccaeb6b
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/common-test/common-test.js
@@ -0,0 +1,71 @@
+var createFacade = function(){
+	return new openbis('http://127.0.0.1:8888/openbis/openbis');
+}
+
+var createFacadeAndLogin = function(action, timeoutOrNull){
+	stop();
+	
+	var facade = createFacade();
+
+	facade.login('admin','password', function(){
+		action(facade);
+	});
+	
+	setTimeout(function(){
+		start();
+	}, (timeoutOrNull ? timeoutOrNull : 1000));
+}
+
+var createSearchCriteriaForCodes = function(codes){
+	var clauses = [];
+	
+	$.each(codes, function(index, code){
+		clauses.push({"@type":"AttributeMatchClause",
+			attribute : "CODE",
+			fieldType : "ATTRIBUTE",
+			desiredValue : code 
+		});
+	});
+	
+	var searchCriteria = {
+		"@type" : "SearchCriteria",
+		matchClauses : clauses,
+		operator : "MATCH_ANY_CLAUSES"
+	};
+	
+	return searchCriteria;
+}
+
+var assertObjectsCount = function(objects, count){
+	equal(objects.length, count, 'Got ' + count + ' object(s)');
+}
+
+var assertObjectsWithCodes = function(objects, codes){
+	deepEqual(objects.map(function(object){
+		return object.code;
+	}).sort(), codes.sort(), 'Objects have correct codes')
+}
+
+var assertObjectsWithProperties = function(objects){
+	ok(objects.some(function(object){
+		return object.properties && Object.keys(object.properties).length > 0;
+	}), 'Object properties have been fetched');
+}
+
+var assertObjectsWithoutProperties = function(objects){
+	ok(objects.every(function(object){
+		return !object.properties || Object.keys(object.properties).length == 0;
+	}), 'Object properties havent been fetched');
+}
+
+var assertObjectsWithParentCodes = function(objects){
+	equal(objects.some(function(object){
+		return object.parentCodes && object.parentCodes.length > 0;
+	}), true, 'Object parent codes have been fetched');
+}
+
+var assertObjectsWithoutParentCodes = function(objects){
+	ok(objects.every(function(object){
+		return !object.parentCodes || object.parentCodes.length == 0;
+	}), 'Object parent codes havent been fetched');
+}
\ No newline at end of file
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbistest/qunit.css b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/common-test/qunit.css
similarity index 100%
rename from openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbistest/qunit.css
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/common-test/qunit.css
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbistest/qunit.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/common-test/qunit.js
similarity index 100%
rename from openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbistest/qunit.js
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/common-test/qunit.js
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-screening-test/openbis-screening-test.html b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-screening-test/openbis-screening-test.html
new file mode 100644
index 00000000000..95ba3f495ab
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-screening-test/openbis-screening-test.html
@@ -0,0 +1,20 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Openbis-screening.js test</title>
+  <link rel="stylesheet" href="../common-test/qunit.css">
+
+  <script src="../../js-new/jquery.js"></script>
+  <script src="../../js-new/openbis.js"></script>
+  <script src="../../js-new/openbis-screening.js"></script>
+  <script src="../common-test/qunit.js"></script>
+  <script src="../common-test/common-test.js"></script>
+  <script src="openbis-screening-test.js"></script>
+
+</head>
+<body>
+  <div id="qunit"></div>
+  <div id="qunit-fixture"></div>
+</body>
+</html>
\ No newline at end of file
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-screening-test/openbis-screening-test.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-screening-test/openbis-screening-test.js
new file mode 100644
index 00000000000..7570ee26326
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-screening-test/openbis-screening-test.js
@@ -0,0 +1,13 @@
+/*
+ * These tests should be run against openBIS instance  
+ * with screening sprint server database version
+ */
+
+test("listPlates()", function(){
+	createFacadeAndLogin(function(facade){
+		
+		facade.listPlates(function(response){
+			assertObjectsCount(response.result, 215);
+		});
+	});
+});
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-test/openbis-test.html b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-test/openbis-test.html
new file mode 100644
index 00000000000..78307a284e2
--- /dev/null
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-test/openbis-test.html
@@ -0,0 +1,19 @@
+<!DOCTYPE html>
+<html>
+<head>
+  <meta charset="utf-8">
+  <title>Openbis.js test</title>
+  <link rel="stylesheet" href="../common-test/qunit.css">
+
+  <script src="../../js-new/jquery.js"></script>
+  <script src="../../js-new/openbis.js"></script>
+  <script src="../common-test/qunit.js"></script>
+  <script src="../common-test/common-test.js"></script>
+  <script src="openbis-test.js"></script>
+
+</head>
+<body>
+  <div id="qunit"></div>
+  <div id="qunit-fixture"></div>
+</body>
+</html>
\ No newline at end of file
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbistest/openbistest.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-test/openbis-test.js
similarity index 87%
rename from openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbistest/openbistest.js
rename to openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-test/openbis-test.js
index 1938c0adc7d..e462f8c21c9 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbistest/openbistest.js
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbis-test/openbis-test.js
@@ -3,78 +3,6 @@
  * with screening sprint server database version
  */
 
-var createFacade = function(){
-	return new openbis('http://127.0.0.1:8888/openbis/openbis');
-}
-
-var createFacadeAndLogin = function(action, timeoutOrNull){
-	stop();
-	
-	var facade = createFacade();
-
-	facade.login('admin','password', function(){
-		action(facade);
-	});
-	
-	setTimeout(function(){
-		start();
-	}, (timeoutOrNull ? timeoutOrNull : 1000));
-}
-
-var createSearchCriteriaForCodes = function(codes){
-	var clauses = [];
-	
-	$.each(codes, function(index, code){
-		clauses.push({"@type":"AttributeMatchClause",
-			attribute : "CODE",
-			fieldType : "ATTRIBUTE",
-			desiredValue : code 
-		});
-	});
-	
-	var searchCriteria = {
-		"@type" : "SearchCriteria",
-		matchClauses : clauses,
-		operator : "MATCH_ANY_CLAUSES"
-	};
-	
-	return searchCriteria;
-}
-
-var assertObjectsCount = function(objects, count){
-	equal(objects.length, count, 'Got ' + count + ' object(s)');
-}
-
-var assertObjectsWithCodes = function(objects, codes){
-	deepEqual(objects.map(function(object){
-		return object.code;
-	}).sort(), codes.sort(), 'Objects have correct codes')
-}
-
-var assertObjectsWithProperties = function(objects){
-	ok(objects.some(function(object){
-		return object.properties && Object.keys(object.properties).length > 0;
-	}), 'Object properties have been fetched');
-}
-
-var assertObjectsWithoutProperties = function(objects){
-	ok(objects.every(function(object){
-		return !object.properties || Object.keys(object.properties).length == 0;
-	}), 'Object properties havent been fetched');
-}
-
-var assertObjectsWithParentCodes = function(objects){
-	equal(objects.some(function(object){
-		return object.parentCodes && object.parentCodes.length > 0;
-	}), true, 'Object parent codes have been fetched');
-}
-
-var assertObjectsWithoutParentCodes = function(objects){
-	ok(objects.every(function(object){
-		return !object.parentCodes || object.parentCodes.length == 0;
-	}), 'Object parent codes havent been fetched');
-}
-
 test("logout", function(){
 
 	stop();
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbistest/openbistest.html b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbistest/openbistest.html
deleted file mode 100644
index 28c1bc5c35a..00000000000
--- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/applications/openbistest/openbistest.html
+++ /dev/null
@@ -1,18 +0,0 @@
-<!DOCTYPE html>
-<html>
-<head>
-  <meta charset="utf-8">
-  <title>Openbis.js test</title>
-  <link rel="stylesheet" href="qunit.css">
-
-  <script src="http://127.0.0.1:8888/ch.systemsx.cisd.openbis.plugin.screening.OpenBIS/resources/js-new/jquery.js"></script>
-  <script src="http://127.0.0.1:8888/ch.systemsx.cisd.openbis.plugin.screening.OpenBIS/resources/js-new/openbis.js"></script>
-  <script src="qunit.js"></script>
-  <script src="openbistest.js"></script>
-
-</head>
-<body>
-  <div id="qunit"></div>
-  <div id="qunit-fixture"></div>
-</body>
-</html>
\ No newline at end of file
diff --git a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js-new/openbis-screening.js b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js-new/openbis-screening.js
index f52789bb941..32b59714022 100644
--- a/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js-new/openbis-screening.js
+++ b/openbis/source/java/ch/systemsx/cisd/openbis/public/resources/js-new/openbis-screening.js
@@ -14,6 +14,8 @@ var _openbisInternal = function(openbisUrl){
 	this.init(openbisUrl);
 }
 
+$.extend(_openbisInternal.prototype, _openbisInternalGeneric.prototype);
+
 _openbisInternal.prototype.init = function(openbisUrl){
 	_openbisInternalGeneric.prototype.init.call(this, openbisUrl);
 	this.screeningUrl = openbisUrl + "/rmi-screening-api-v1.json"
@@ -23,11 +25,8 @@ _openbisInternal.prototype.getScreeningDataStoreApiUrlForDataStoreUrl = function
 	return dataStoreUrl + "/rmi-datastore-server-screening-api-v1.json"
 }
 
-$.extend(_openbisInternal.prototype, _openbisIternalGeneric.prototype);
-
 var _openbisGeneric = openbis;
 
-
 /**
  * =========================
  * OpenBIS screening facade 
@@ -41,8 +40,8 @@ var _openbisGeneric = openbis;
  * 
  */
 
-var openbis = function(openbisUrl, dssUrl){
-	this._internal = _openbisInternal(openbisUrl, dssUrl);
+var openbis = function(openbisUrl){
+	this._internal = new _openbisInternal(openbisUrl);
 }
 
 $.extend(openbis.prototype, _openbisGeneric.prototype);
-- 
GitLab