1
0
Fork 0

Improved Graph AQL query tests. Some tests are missing.

This commit is contained in:
Michael Hackstein 2014-10-16 09:21:11 +02:00
parent 7bcac607bb
commit 5da5bf112a
1 changed files with 1220 additions and 1089 deletions

View File

@ -41,6 +41,7 @@ var assertQueryError = helper.assertQueryError;
function ahuacatlQueryGeneralEdgesTestSuite() {
var gN = "bla3";
var v1 = "UnitTestsAhuacatlVertex1";
var v2 = "UnitTestsAhuacatlVertex2";
var v3 = "UnitTestsAhuacatlVertex3";
@ -49,11 +50,14 @@ function ahuacatlQueryGeneralEdgesTestSuite() {
var e2 = "UnitTestsAhuacatlEdge2";
var or = "UnitTestsAhuacatlOrphan";
var AQL_VERTICES = "FOR e IN GRAPH_VERTICES(@name, @example, @options) SORT e._id RETURN e";
var AQL_EDGES = "FOR e IN GRAPH_EDGES(@name, @example, @options) SORT e.what RETURN e.what";
return {
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
setUp: function () {
db._drop(v1);
@ -112,9 +116,9 @@ function ahuacatlQueryGeneralEdgesTestSuite() {
);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
tearDown: function () {
db._drop(v1);
@ -127,26 +131,160 @@ function ahuacatlQueryGeneralEdgesTestSuite() {
db._collection("_graphs").remove("_graphs/bla3");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_EDGES() and GRAPH_NEIGHBOURS() and GRAPH_VERTICES()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_VERTICES()
////////////////////////////////////////////////////////////////////////////////
testVertices: function () {
var bindVars = {
name: gN,
example: v1 + "/v1",
options: {direction : 'any'}
};
var actual = getRawQueryResults(AQL_VERTICES, bindVars);
assertEqual(actual[0]._id, v1 + '/v1');
},
testVerticesRestricted: function() {
var bindVars = {
name: gN,
example: {},
options: {
direction : 'any',
vertexCollectionRestriction: or
}
};
var actual = getRawQueryResults(AQL_VERTICES, bindVars);
assertEqual(actual[0]._id, 'UnitTestsAhuacatlOrphan/orphan');
assertEqual(actual.length, 1);
},
testVerticesExample: function () {
var bindVars = {
name: gN,
example: [{hugo : true}, {heinz : 1}],
options: {direction : 'any'}
};
var actual = getRawQueryResults(AQL_VERTICES, bindVars);
assertEqual(actual[0]._id, 'UnitTestsAhuacatlVertex1/v1');
assertEqual(actual[1]._id, 'UnitTestsAhuacatlVertex1/v2');
assertEqual(actual[2]._id, 'UnitTestsAhuacatlVertex2/v3');
assertEqual(actual[3]._id, 'UnitTestsAhuacatlVertex4/v8');
assertEqual(actual.length, 4);
},
testVerticesWithInboundEdges: function () {
var bindVars = {
name: gN,
example: v3 + "/v5",
options: {direction : 'inbound'}
};
var actual = getRawQueryResults(AQL_VERTICES, bindVars);
assertEqual(actual[0]._id, 'UnitTestsAhuacatlVertex3/v5');
assertEqual(actual.length, 1);
},
testVerticesWithInboundEdgesHasNoInboundEdges: function () {
var bindVars = {
name: gN,
example: v2 + "/v3",
options: {direction : 'inbound'}
};
var actual = getRawQueryResults(AQL_VERTICES, bindVars);
assertEqual(actual.length, 0);
},
testVerticesWithInboundEdgesAndExample: function () {
var bindVars = {
name: gN,
example: [{hugo : true}, {heinz : 1}],
options: {direction : 'inbound'}
};
var actual = getRawQueryResults(AQL_VERTICES, bindVars);
assertEqual(actual[0]._id, 'UnitTestsAhuacatlVertex1/v1');
assertEqual(actual[1]._id, 'UnitTestsAhuacatlVertex1/v2');
assertEqual(actual[2]._id, 'UnitTestsAhuacatlVertex4/v8');
assertEqual(actual.length, 3);
},
testVerticesWithInboundEdgesRestrictedHasNoInbound: function() {
var bindVars = {
name: gN,
example: {},
options: {
direction : 'inbound',
vertexCollectionRestriction: v2
}
};
var actual = getRawQueryResults(AQL_VERTICES, bindVars);
assertEqual(actual.length, 0);
},
testVerticesWithInboundEdgesRestrictedHasInbound: function() {
var bindVars = {
name: gN,
example: {},
options: {
direction : 'inbound',
vertexCollectionRestriction: v3
}
};
var actual = getRawQueryResults(AQL_VERTICES, bindVars);
assertEqual(actual[0]._id, v3 + '/v5');
assertEqual(actual[1]._id, v3 + '/v6');
assertEqual(actual.length, 2);
},
testVerticesWithOutboundEdgesRestrictedHasOutbound: function() {
var bindVars = {
name: gN,
example: {},
options: {
direction : 'outbound',
vertexCollectionRestriction: v2
}
};
var actual = getRawQueryResults(AQL_VERTICES, bindVars);
assertEqual(actual[0]._id, v2 + '/v3');
assertEqual(actual[1]._id, v2 + '/v4');
assertEqual(actual.length, 2);
},
testVerticesWithOutboundEdgesRestrictedHasNoOutbound: function() {
var bindVars = {
name: gN,
example: {},
options: {
direction : 'outbound',
vertexCollectionRestriction: v3
}
};
var actual = getRawQueryResults(AQL_VERTICES, bindVars);
assertEqual(actual.length, 0);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_EDGES()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// Section any direction
////////////////////////////////////////////////////////////////////////////////
testEdgesAny: function () {
var actual;
actual = getRawQueryResults("FOR e IN GRAPH_VERTICES('bla3', '" + v1 + "/v1', {direction : 'any'}) RETURN e");
assertEqual(actual[0]._id, v1 + '/v1');
actual = getRawQueryResults("FOR e IN GRAPH_VERTICES('bla3', {}, {direction : 'any', vertexCollectionRestriction : 'UnitTestsAhuacatlOrphan'}) RETURN e");
assertEqual(actual[0]._id, 'UnitTestsAhuacatlOrphan/orphan');
actual = getQueryResults("FOR e IN GRAPH_EDGES('bla3', 'UnitTestsAhuacatlVertex1/v1', {direction : 'any'}) SORT e.what RETURN e.what");
assertEqual(actual, [ "v1->v2", "v1->v5", "v2->v1" ]);
},
testEdgesAnyRestricted: function () {
var actual;
actual = getQueryResults("FOR e IN GRAPH_EDGES('bla3', 'UnitTestsAhuacatlVertex1/v1', {direction : 'any' , edgeCollectionRestriction: ['UnitTestsAhuacatlEdge1']}) " +
"SORT e.what RETURN e.what");
assertEqual(actual, [ "v1->v2", "v2->v1" ]);
},
testEdgesAnyStartExample: function () {
var actual;
actual = getQueryResults("FOR e IN GRAPH_EDGES('bla3', [{hugo : true}, {heinz : 1}], {direction : 'any'}) " +
"SORT e.what RETURN e.what");
assertEqual(actual, [ "v1->v2",
@ -156,24 +294,27 @@ function ahuacatlQueryGeneralEdgesTestSuite() {
"v3->v5",
"v3->v6",
"v3->v8" ]);
},
actual = getRawQueryResults("FOR e IN GRAPH_VERTICES('bla3', [{hugo : true}, {heinz : 1}], {direction : 'any'}) SORT e._id RETURN e");
assertEqual(actual[0]._id, 'UnitTestsAhuacatlVertex1/v1');
assertEqual(actual[1]._id, 'UnitTestsAhuacatlVertex1/v2');
assertEqual(actual[2]._id, 'UnitTestsAhuacatlVertex2/v3');
assertEqual(actual[3]._id, 'UnitTestsAhuacatlVertex4/v8');
testEdgesAnyStartExampleEdgeExample: function () {
var actual;
actual = getQueryResults("FOR e IN GRAPH_EDGES('bla3', 'UnitTestsAhuacatlVertex1/v1', {direction : 'any' , edgeExamples : [{'what' : 'v2->v1'}]}) SORT e.what RETURN e.what");
assertEqual(actual, [ "v2->v1" ]);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_NEIGHBORS()
////////////////////////////////////////////////////////////////////////////////
testNeighborsAnyStartExampleEdgeExample: function () {
var actual;
actual = getQueryResults("FOR e IN GRAPH_NEIGHBORS('bla3', 'UnitTestsAhuacatlVertex1/v1', {direction : 'any' , edgeExamples : [{'what' : 'v2->v1'}]}) SORT e.what RETURN e");
assertEqual(actual[0].path.edges[0].what, "v2->v1");
assertEqual(actual[0].vertex._key, "v2");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks EDGES()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief checks EDGES()
////////////////////////////////////////////////////////////////////////////////
testEdgesIn: function () {
var actual;
@ -181,17 +322,7 @@ function ahuacatlQueryGeneralEdgesTestSuite() {
actual = getQueryResults("FOR e IN GRAPH_EDGES('bla3', 'UnitTestsAhuacatlVertex3/v5', {direction : 'inbound'}) SORT e.what RETURN e.what");
assertEqual(actual, [ "v1->v5", "v2->v5", "v3->v5"]);
actual = getRawQueryResults("FOR e IN GRAPH_VERTICES('bla3', 'UnitTestsAhuacatlVertex3/v5', {direction : 'inbound'}) SORT e._id RETURN e");
assertEqual(actual[0]._id, 'UnitTestsAhuacatlVertex3/v5');
actual = getRawQueryResults("FOR e IN GRAPH_VERTICES('bla3', [{hugo : true}, {heinz : 1}], {direction : 'inbound'}) SORT e._id RETURN e");
assertEqual(actual[0]._id, 'UnitTestsAhuacatlVertex1/v1');
assertEqual(actual[1]._id, 'UnitTestsAhuacatlVertex1/v2');
assertEqual(actual[2]._id, 'UnitTestsAhuacatlVertex4/v8');
assertTrue(actual.length === 3);
actual = getQueryResults("FOR e IN GRAPH_EDGES('bla3', 'UnitTestsAhuacatlVertex3/v5', {direction : 'inbound' ,edgeCollectionRestriction: 'UnitTestsAhuacatlEdge2'}) SORT e.what RETURN e.what");
actual = getQueryResults("FOR e IN GRAPH_EDGES('bla3', 'UnitTestsAhuacatlVertex3/v5', {direction : 'inbound' ,edgeCollectionRestriction: ['UnitTestsAhuacatlEdge2']}) SORT e.what RETURN e.what");
assertEqual(actual, [ "v1->v5", "v2->v5", "v3->v5"]);
actual = getQueryResults("FOR e IN GRAPH_EDGES('bla3', 'UnitTestsAhuacatlVertex3/v5', {direction : 'inbound' , edgeExamples : [{'what' : 'v2->v5'}]}) SORT e.what RETURN e.what");
@ -203,9 +334,9 @@ function ahuacatlQueryGeneralEdgesTestSuite() {
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks EDGES()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief checks EDGES()
////////////////////////////////////////////////////////////////////////////////
testEdgesOut: function () {
var actual;
@ -256,9 +387,9 @@ function ahuacatlQueryGeneralEdgesTestSuite() {
assertEqual(actual[2].vertex._key, "v5");
assertEqual(actual[3].vertex._key, "v5");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks EDGES() exceptions
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief checks EDGES() exceptions
////////////////////////////////////////////////////////////////////////////////
testEdgesExceptions: function () {
return undefined;
@ -274,9 +405,9 @@ function ahuacatlQueryGeneralEdgesTestSuite() {
function ahuacatlQueryGeneralCommonTestSuite() {
return {
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
setUp: function () {
db._drop("UnitTestsAhuacatlVertex1");
@ -326,9 +457,9 @@ function ahuacatlQueryGeneralCommonTestSuite() {
);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
tearDown: function () {
db._drop("UnitTestsAhuacatlVertex1");
@ -340,20 +471,20 @@ function ahuacatlQueryGeneralCommonTestSuite() {
}
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_COMMON_NEIGHBORS() and GRAPH_COMMON_PROPERTIES()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_COMMON_NEIGHBORS() and GRAPH_COMMON_PROPERTIES()
////////////////////////////////////////////////////////////////////////////////
testEdgesAny: function () {
testCommonNeighbors: function () {
var actual = getQueryResults("FOR e IN GRAPH_COMMON_NEIGHBORS('bla3', 'UnitTestsAhuacatlVertex1/v3' , 'UnitTestsAhuacatlVertex2/v6', {direction : 'any'}) SORT ATTRIBUTES(e)[0] RETURN e");
assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v3"]["UnitTestsAhuacatlVertex2/v6"][0]._id, "UnitTestsAhuacatlVertex1/v2");
assertEqual(actual[0]["UnitTestsAhuacatlVertex1/v3"]["UnitTestsAhuacatlVertex2/v6"][1]._id, "UnitTestsAhuacatlVertex2/v7");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_COMMON_NEIGHBORS()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_COMMON_NEIGHBORS()
////////////////////////////////////////////////////////////////////////////////
testCommonNeighborsIn: function () {
var actual = getQueryResults("FOR e IN GRAPH_COMMON_NEIGHBORS('bla3', {} , {}, {direction : 'inbound'}, {direction : 'inbound'}) SORT TO_STRING(ATTRIBUTES(e)) RETURN e");
@ -371,9 +502,9 @@ function ahuacatlQueryGeneralCommonTestSuite() {
assertEqual(actual[4]["UnitTestsAhuacatlVertex2/v8"]["UnitTestsAhuacatlVertex2/v7"][0]._id, "UnitTestsAhuacatlVertex1/v3");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_COMMON_NEIGHBORS()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_COMMON_NEIGHBORS()
////////////////////////////////////////////////////////////////////////////////
testCommonNeighborsOut: function () {
var actual = getQueryResults("FOR e IN GRAPH_COMMON_NEIGHBORS('bla3', { hugo : true } , {heinz : 1}, " +
@ -392,9 +523,9 @@ function ahuacatlQueryGeneralCommonTestSuite() {
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_COMMON_NEIGHBORS()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_COMMON_NEIGHBORS()
////////////////////////////////////////////////////////////////////////////////
testCommonNeighborsMixedOptions: function () {
var actual = getQueryResults("FOR e IN GRAPH_COMMON_NEIGHBORS('bla3', {} , {}, " +
@ -417,9 +548,9 @@ function ahuacatlQueryGeneralCommonTestSuite() {
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_COMMON_PROPERTIES()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_COMMON_PROPERTIES()
////////////////////////////////////////////////////////////////////////////////
testCommonProperties: function () {
var actual = getQueryResults("FOR e IN GRAPH_COMMON_PROPERTIES('bla3', { } , {}, {}) SORT ATTRIBUTES(e)[0] RETURN e");
@ -468,9 +599,9 @@ function ahuacatlQueryGeneralCommonTestSuite() {
function ahuacatlQueryGeneralPathsTestSuite() {
return {
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
setUp: function () {
db._drop("UnitTestsAhuacatlVertex1");
@ -525,9 +656,9 @@ function ahuacatlQueryGeneralPathsTestSuite() {
makeEdge(v3._id, v5._id, g[e2]);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
tearDown: function () {
db._drop("UnitTestsAhuacatlVertex1");
@ -539,9 +670,9 @@ function ahuacatlQueryGeneralPathsTestSuite() {
db._collection("_graphs").remove("_graphs/bla3");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_PATHS()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_PATHS()
////////////////////////////////////////////////////////////////////////////////
testPaths: function () {
var actual;
@ -698,9 +829,9 @@ function ahuacatlQueryGeneralPathsTestSuite() {
function ahuacatlQueryGeneralTraversalTestSuite() {
return {
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
setUp: function () {
db._drop("UnitTests_Berliner");
@ -756,9 +887,9 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
makeEdge(Emil._id, Fritz._id, g[KenntAnderen], 0.2);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
tearDown: function () {
db._drop("UnitTests_Berliner");
@ -770,9 +901,9 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
db._collection("_graphs").remove("_graphs/werKenntWen");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_TRAVERSAL()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_TRAVERSAL()
////////////////////////////////////////////////////////////////////////////////
testGRAPH_TRAVERSALs: function () {
var actual, result = [];
@ -1139,20 +1270,20 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
1
]
]
);
);
actual = getQueryResults("FOR e IN GRAPH_SHORTEST_PATH('werKenntWen', 'UnitTests_Hamburger/Caesar', " +
actual = getQueryResults("FOR e IN GRAPH_SHORTEST_PATH('werKenntWen', 'UnitTests_Hamburger/Caesar', " +
" 'UnitTests_Berliner/Anton', {direction : 'outbound', weight: 'entfernung', algorithm : 'Floyd-Warshall'}) SORT e.startVertex, e.vertex._id RETURN e.paths[0].vertices");
assertEqual(actual[0].length, 3);
assertEqual(actual[0].length, 3);
actual = getQueryResults("FOR e IN GRAPH_SHORTEST_PATH('werKenntWen', 'UnitTests_Hamburger/Caesar', " +
actual = getQueryResults("FOR e IN GRAPH_SHORTEST_PATH('werKenntWen', 'UnitTests_Hamburger/Caesar', " +
" 'UnitTests_Berliner/Anton', {direction : 'outbound', algorithm : 'Floyd-Warshall'}) SORT e.startVertex, e.vertex._id RETURN e.paths[0].vertices");
assertEqual(actual[0].length, 2);
assertEqual(actual[0].length, 2);
actual = getQueryResults("FOR e IN GRAPH_DISTANCE_TO('werKenntWen', 'UnitTests_Hamburger/Caesar', 'UnitTests_Frankfurter/Emil', " +
actual = getQueryResults("FOR e IN GRAPH_DISTANCE_TO('werKenntWen', 'UnitTests_Hamburger/Caesar', 'UnitTests_Frankfurter/Emil', " +
"{direction : 'outbound', weight: 'entfernung', defaultWeight : 80, algorithm : 'Floyd-Warshall'}) RETURN [e.startVertex, e.vertex._id, e.distance]");
assertEqual(actual,
assertEqual(actual,
[
[
"UnitTests_Hamburger/Caesar",
@ -1160,12 +1291,12 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
830.1
]
]
);
);
},
},
testGRAPH_SHORTEST_PATH_WITH_DIJSKTRA: function () {
testGRAPH_SHORTEST_PATH_WITH_DIJSKTRA: function () {
var actual;
actual = getQueryResults("FOR e IN GRAPH_SHORTEST_PATH('werKenntWen', 'UnitTests_Hamburger/Caesar', " +
@ -1200,9 +1331,9 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
);
},
},
testGRAPH_CLOSENESS: function () {
testGRAPH_CLOSENESS: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_CLOSENESS('werKenntWen', {algorithm : 'Floyd-Warshall'})");
assertEqual(actual[0]["UnitTests_Berliner/Anton"].toFixed(2), 0.69);
@ -1230,10 +1361,10 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
assertEqual(actual[0]["UnitTests_Frankfurter/Fritz"].toFixed(1), 2671.4);
assertEqual(actual[0]["UnitTests_Hamburger/Caesar"].toFixed(1), 3140.9);
assertEqual(actual[0]["UnitTests_Hamburger/Dieter"].toFixed(1), 1770.4);
},
},
testGRAPH_CLOSENESS_OUTBOUND: function () {
testGRAPH_CLOSENESS_OUTBOUND: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_CLOSENESS('werKenntWen', {direction : 'outbound', algorithm : 'Floyd-Warshall'})");
assertEqual(actual[0]["UnitTests_Berliner/Anton"], 0);
@ -1253,9 +1384,9 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
assertEqual(actual[0]["UnitTests_Hamburger/Caesar"].toFixed(3), 0.001);
assertEqual(actual[0]["UnitTests_Hamburger/Dieter"].toFixed(3), 0.001);
assertEqual(actual[0]["UnitTests_Leipziger/Gerda"].toFixed(3), 0.002);
},
},
testGRAPH_CLOSENESS_INBOUND: function () {
testGRAPH_CLOSENESS_INBOUND: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_CLOSENESS('werKenntWen', {direction : 'inbound', algorithm : 'Floyd-Warshall'})");
assertEqual(actual[0]["UnitTests_Berliner/Anton"].toFixed(2), 0.88);
@ -1275,10 +1406,10 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
assertEqual(actual[0]["UnitTests_Hamburger/Caesar"], 0);
assertEqual(actual[0]["UnitTests_Hamburger/Dieter"].toFixed(3), 0.002);
assertEqual(actual[0]["UnitTests_Leipziger/Gerda"].toFixed(4), 0.0007);
},
},
testGRAPH_ECCENTRICITY: function () {
testGRAPH_ECCENTRICITY: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_ECCENTRICITY('werKenntWen', {algorithm : 'Floyd-Warshall'})");
assertEqual(actual[0]["UnitTests_Berliner/Anton"].toFixed(1), 0.6);
@ -1314,9 +1445,9 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
assertEqual(actual[0]["UnitTests_Leipziger/Gerda"], 1);
},
},
testGRAPH_BETWEENNESS: function () {
testGRAPH_BETWEENNESS: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_ABSOLUTE_BETWEENNESS('werKenntWen', {algorithm : 'Floyd-Warshall'})");
@ -1370,9 +1501,9 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
assertEqual(actual[0]["UnitTests_Leipziger/Gerda"], 1);
},
},
testGRAPH_DIAMETER_AND_RADIUS: function () {
testGRAPH_DIAMETER_AND_RADIUS: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_RADIUS('werKenntWen', {algorithm : 'Floyd-Warshall'})");
assertEqual(actual[0], 3);
@ -1414,9 +1545,9 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
},
},
testGRAPH_SHORTEST_PATHWithExamples: function () {
testGRAPH_SHORTEST_PATHWithExamples: function () {
var actual;
actual = getQueryResults("FOR e IN GRAPH_SHORTEST_PATH('werKenntWen', {gender : 'female'}, {gender : 'male', age : 30}, " +
@ -1439,11 +1570,11 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
"UnitTests_Hamburger/Caesar"
]
]
);
);
actual = getQueryResults("FOR e IN GRAPH_DISTANCE_TO('werKenntWen', {gender : 'female'}, {gender : 'male', age : 30}, " +
actual = getQueryResults("FOR e IN GRAPH_DISTANCE_TO('werKenntWen', {gender : 'female'}, {gender : 'male', age : 30}, " +
"{direction : 'any'}) SORT e.startVertex, e.vertex._id SORT e.startVertex, e.vertex._id RETURN [e.startVertex, e.vertex._id, e.distance]");
assertEqual(actual, [
assertEqual(actual, [
[
"UnitTests_Berliner/Berta",
"UnitTests_Frankfurter/Fritz",
@ -1465,13 +1596,13 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
"UnitTests_Hamburger/Caesar",
2
]
]
);
]
);
},
},
testGRAPH_CLOSENESS_WITH_DIJSKTRA: function () {
testGRAPH_CLOSENESS_WITH_DIJSKTRA: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_CLOSENESS('werKenntWen', {algorithm : 'dijkstra'})");
@ -1493,10 +1624,10 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
assertEqual(actual[0]["UnitTests_Hamburger/Dieter"].toFixed(2), 0.95);
assertEqual(actual[0]["UnitTests_Leipziger/Gerda"], 1);
},
},
testGRAPH_CLOSENESS_OUTBOUND_WITH_DIJSKTRA: function () {
testGRAPH_CLOSENESS_OUTBOUND_WITH_DIJSKTRA: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_CLOSENESS('werKenntWen', {algorithm : 'dijkstra', direction : 'outbound'})");
assertEqual(actual[0]["UnitTests_Berliner/Anton"], 0);
@ -1516,10 +1647,10 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
assertEqual(actual[0]["UnitTests_Hamburger/Caesar"].toFixed(3), 0.001);
assertEqual(actual[0]["UnitTests_Hamburger/Dieter"].toFixed(3), 0.001);
assertEqual(actual[0]["UnitTests_Leipziger/Gerda"].toFixed(3), 0.002);
},
},
testGRAPH_CLOSENESS_INBOUND_WITH_DIJSKTRA: function () {
testGRAPH_CLOSENESS_INBOUND_WITH_DIJSKTRA: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_CLOSENESS('werKenntWen', {algorithm : 'dijkstra', direction : 'inbound'})");
assertEqual(actual[0]["UnitTests_Berliner/Anton"].toFixed(2), 0.88);
@ -1539,10 +1670,10 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
assertEqual(actual[0]["UnitTests_Hamburger/Dieter"].toFixed(3), 0.002);
assertEqual(actual[0]["UnitTests_Leipziger/Gerda"].toFixed(4), 0.0007);
},
},
testGRAPH_ECCENTRICITY_WITH_DIJSKTRA: function () {
testGRAPH_ECCENTRICITY_WITH_DIJSKTRA: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_ECCENTRICITY('werKenntWen', {algorithm : 'dijkstra'})");
assertEqual(actual[0]["UnitTests_Berliner/Anton"].toFixed(1), 0.6);
@ -1581,9 +1712,9 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
assertEqual(actual[0]["UnitTests_Hamburger/Caesar"].toFixed(2), 0.54);
assertEqual(actual[0]["UnitTests_Hamburger/Dieter"].toFixed(2), 0.85);
assertEqual(actual[0]["UnitTests_Leipziger/Gerda"], 1);
},
},
testGRAPH_DIAMETER_AND_RADIUS_WITH_DIJSKTRA: function () {
testGRAPH_DIAMETER_AND_RADIUS_WITH_DIJSKTRA: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_RADIUS('werKenntWen', {algorithm : 'dijkstra'})");
assertEqual(actual[0], 3);
@ -1596,9 +1727,9 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
actual = getQueryResults("RETURN GRAPH_DIAMETER('werKenntWen', {algorithm : 'dijkstra', weight : 'entfernung', defaultWeight : 80})");
assertEqual(actual[0].toFixed(1), 830.3);
},
},
testGRAPH_SHORTEST_PATHWithExamples_WITH_DIJSKTRA: function () {
testGRAPH_SHORTEST_PATHWithExamples_WITH_DIJSKTRA: function () {
var actual;
actual = getQueryResults("FOR e IN GRAPH_SHORTEST_PATH('werKenntWen', {gender : 'female'}, {gender : 'male', age : 30}, " +
@ -1621,11 +1752,11 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
"UnitTests_Hamburger/Caesar"
]
]
);
);
actual = getQueryResults("FOR e IN GRAPH_DISTANCE_TO('werKenntWen', {gender : 'female'}, {gender : 'male', age : 30}, " +
actual = getQueryResults("FOR e IN GRAPH_DISTANCE_TO('werKenntWen', {gender : 'female'}, {gender : 'male', age : 30}, " +
"{direction : 'any'}) SORT e.startVertex, e.vertex._id SORT e.startVertex, e.vertex._id RETURN [e.startVertex, e.vertex._id, e.distance]");
assertEqual(actual, [
assertEqual(actual, [
[
"UnitTests_Berliner/Berta",
"UnitTests_Frankfurter/Fritz",
@ -1647,12 +1778,12 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
"UnitTests_Hamburger/Caesar",
2
]
]
);
]
);
}
};
}
};
}
@ -1663,9 +1794,9 @@ function ahuacatlQueryGeneralTraversalTestSuite() {
function ahuacatlQueryGeneralCyclesSuite() {
return {
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief set up
////////////////////////////////////////////////////////////////////////////////
setUp: function () {
db._drop("UnitTests_Berliner");
@ -1720,9 +1851,9 @@ function ahuacatlQueryGeneralCyclesSuite() {
makeEdge(Berta._id, Anton._id, g[KenntAnderen], 3);
},
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief tear down
////////////////////////////////////////////////////////////////////////////////
tearDown: function () {
db._drop("UnitTests_Berliner");
@ -1734,9 +1865,9 @@ function ahuacatlQueryGeneralCyclesSuite() {
db._collection("_graphs").remove("_graphs/werKenntWen");
},
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_TRAVERSAL()
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
/// @brief checks GRAPH_TRAVERSAL()
////////////////////////////////////////////////////////////////////////////////
testGRAPH_SHORTEST_PATH: function () {
var actual;
@ -1942,9 +2073,9 @@ function ahuacatlQueryGeneralCyclesSuite() {
]
]
);
},
},
testGRAPH_CLOSENESS: function () {
testGRAPH_CLOSENESS: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_ABSOLUTE_CLOSENESS('werKenntWen', {}, {algorithm : 'Floyd-Warshall'})");
@ -1975,10 +2106,10 @@ function ahuacatlQueryGeneralCyclesSuite() {
assertEqual(actual[0]["UnitTests_Hamburger/Caesar"].toFixed(2), 0.94);
assertEqual(actual[0]["UnitTests_Hamburger/Dieter"], 0);
assertEqual(actual[0]["UnitTests_Leipziger/Gerda"], 0);
},
},
testGRAPH_CLOSENESS_OUTBOUND: function () {
testGRAPH_CLOSENESS_OUTBOUND: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_ABSOLUTE_CLOSENESS('werKenntWen',{}, {direction : 'outbound', algorithm : 'Floyd-Warshall'})");
assertEqual(actual[0]["UnitTests_Berliner/Anton"], 4);
@ -1997,9 +2128,9 @@ function ahuacatlQueryGeneralCyclesSuite() {
assertEqual(actual[0]["UnitTests_Hamburger/Caesar"], 1);
assertEqual(actual[0]["UnitTests_Hamburger/Dieter"], 0);
assertEqual(actual[0]["UnitTests_Leipziger/Gerda"], 0);
},
},
testGRAPH_CLOSENESS_INBOUND: function () {
testGRAPH_CLOSENESS_INBOUND: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_ABSOLUTE_CLOSENESS('werKenntWen', {}, {direction : 'inbound', algorithm : 'Floyd-Warshall'})");
@ -2019,10 +2150,10 @@ function ahuacatlQueryGeneralCyclesSuite() {
assertEqual(actual[0]["UnitTests_Hamburger/Caesar"].toFixed(2), 0.39);
assertEqual(actual[0]["UnitTests_Hamburger/Dieter"], 0);
assertEqual(actual[0]["UnitTests_Leipziger/Gerda"], 0);
},
},
testGRAPH_ECCENTRICITY: function () {
testGRAPH_ECCENTRICITY: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_ABSOLUTE_ECCENTRICITY('werKenntWen',{}, {algorithm : 'Floyd-Warshall'})");
@ -2080,9 +2211,9 @@ function ahuacatlQueryGeneralCyclesSuite() {
assertEqual(actual[0]["UnitTests_Leipziger/Gerda"], 0);
},
},
testGRAPH_BETWEENNESS: function () {
testGRAPH_BETWEENNESS: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_ABSOLUTE_BETWEENNESS('werKenntWen', {algorithm : 'Floyd-Warshall'})");
@ -2134,9 +2265,9 @@ function ahuacatlQueryGeneralCyclesSuite() {
assertEqual(actual[0]["UnitTests_Leipziger/Gerda"], 0);
},
},
testGRAPH_DIAMETER_AND_RADIUS: function () {
testGRAPH_DIAMETER_AND_RADIUS: function () {
var actual;
actual = getQueryResults("RETURN GRAPH_RADIUS('werKenntWen', {algorithm : 'Floyd-Warshall'})");
assertEqual(actual[0], 2);
@ -2167,8 +2298,8 @@ function ahuacatlQueryGeneralCyclesSuite() {
actual = getQueryResults("RETURN GRAPH_RADIUS('werKenntWen', {direction : 'outbound', algorithm : 'Floyd-Warshall'})");
assertEqual(actual[0], 2);
}
};
}
};
}