diff --git a/tests/qa/tck_engine/tests/cypher_graph_gists/features/credit_card_fraud_detection.feature b/tests/qa/tck_engine/tests/cypher_graph_gists/features/credit_card_fraud_detection.feature new file mode 100644 index 000000000..0f6172dc8 --- /dev/null +++ b/tests/qa/tck_engine/tests/cypher_graph_gists/features/credit_card_fraud_detection.feature @@ -0,0 +1,80 @@ +Feature: Credit Card Fraud Detection + + Scenario: Match all disputed transactions + Given graph "credit_card_fraud_detection" + When executing query: + """ + MATCH (victim:Person)-[r:HAS_BOUGHT_AT]->(merchant) WHERE r.status = "Disputed" RETURN victim.name AS `Customer Name`, merchant.name AS `Store Name`, r.amount AS Amount, r.time AS `Transaction Time` ORDER BY `Transaction Time` DESC + """ + Then the result should be: + | Customer Name | Store Name | Amount | Transaction Time | + | 'Olivia' | 'Urban Outfitters' | '1152' | '8/10/2014' | + | 'Olivia' | 'RadioShack' | '1884' | '8/1/2014' | + | 'Paul' | 'Apple Store' | '1021' | '7/18/2014' | + | 'Marc' | 'Apple Store' | '1914' | '7/18/2014' | + | 'Olivia' | 'Apple Store' | '1149' | '7/18/2014' | + | 'Madison' | 'Apple Store' | '1925' | '7/18/2014' | + | 'Madison' | 'Urban Outfitters' | '1374' | '7/10/2014' | + | 'Madison' | 'RadioShack' | '1368' | '7/1/2014' | + | 'Paul' | 'Urban Outfitters' | '1732' | '5/10/2014' | + | 'Marc' | 'Urban Outfitters' | '1424' | '5/10/2014' | + | 'Paul' | 'RadioShack' | '1415' | '4/1/2014' | + | 'Marc' | 'RadioShack' | '1721' | '4/1/2014' | + | 'Paul' | 'Macys' | '1849' | '12/20/2014' | + | 'Marc' | 'Macys' | '1003' | '12/20/2014' | + | 'Olivia' | 'Macys' | '1790' | '12/20/2014' | + | 'Madison' | 'Macys' | '1816' | '12/20/2014' | + + Scenario: Identify the Point of Origin of the Fraud + Given graph "credit_card_fraud_detection" + When executing query: + """ + MATCH (victim:Person)-[r:HAS_BOUGHT_AT]->(merchant) WHERE r.status = "Disputed" MATCH (victim)-[t:HAS_BOUGHT_AT]->(othermerchants) WHERE t.status = "Undisputed" AND t.time < r.time WITH victim, othermerchants, t ORDER BY t.time DESC RETURN victim.name AS `Customer Name`, othermerchants.name AS `Store Name`, t.amount AS Amount, t.time AS `Transaction Time` ORDER BY `Transaction Time` DESC + """ + Then the result should be: + | Customer Name | Store Name | Amount | Transaction Time | + | 'Olivia' | 'Wallmart' | '231' | '7/12/2014' | + | 'Olivia' | 'Wallmart' | '231' | '7/12/2014' | + | 'Olivia' | 'Wallmart' | '231' | '7/12/2014' | + | 'Madison' | 'Wallmart' | '91' | '6/29/2014' | + | 'Madison' | 'Wallmart' | '91' | '6/29/2014' | + | 'Madison' | 'Wallmart' | '91' | '6/29/2014' | + | 'Paul' | 'Starbucks' | '239' | '5/15/2014' | + | 'Marc' | 'American Apparel' | '336' | '4/3/2014' | + | 'Marc' | 'American Apparel' | '336' | '4/3/2014' | + | 'Paul' | 'Just Brew It' | '986' | '4/17/2014' | + | 'Paul' | 'Just Brew It' | '986' | '4/17/2014' | + | 'Marc' | 'Amazon' | '134' | '4/14/2014' | + | 'Marc' | 'Amazon' | '134' | '4/14/2014' | + | 'Paul' | 'Sears' | '475' | '3/28/2014' | + | 'Paul' | 'Sears' | '475' | '3/28/2014' | + | 'Paul' | 'Sears' | '475' | '3/28/2014' | + | 'Marc' | 'Wallmart' | '964' | '3/22/2014' | + | 'Marc' | 'Wallmart' | '964' | '3/22/2014' | + | 'Marc' | 'Wallmart' | '964' | '3/22/2014' | + | 'Paul' | 'Wallmart' | '654' | '3/20/2014' | + | 'Paul' | 'Wallmart' | '654' | '3/20/2014' | + | 'Paul' | 'Wallmart' | '654' | '3/20/2014' | + | 'Madison' | 'Subway' | '352' | '12/16/2014' | + | 'Madison' | 'Subway' | '352' | '12/16/2014' | + | 'Madison' | 'Subway' | '352' | '12/16/2014' | + | 'Madison' | 'Subway' | '352' | '12/16/2014' | + | 'Madison' | 'MacDonalds' | '630' | '10/6/2014' | + | 'Madison' | 'MacDonalds' | '630' | '10/6/2014' | + | 'Madison' | 'MacDonalds' | '630' | '10/6/2014' | + | 'Madison' | 'MacDonalds' | '630' | '10/6/2014' | + | 'Olivia' | 'Soccer for the City' | '924' | '10/4/2014' | + | 'Olivia' | 'Soccer for the City' | '924' | '10/4/2014' | + | 'Olivia' | 'Soccer for the City' | '924' | '10/4/2014' | + | 'Olivia' | 'Soccer for the City' | '924' | '10/4/2014' | + + # doesnt' work because of count(DISTINCT ...) and collect(DISTINCT ...) + Scenario: Zero in on the criminal + Given graph "credit_card_fraud_detection" + When executing query: + """ + MATCH (victim:Person)-[r:HAS_BOUGHT_AT]->(merchant) WHERE r.status = "Disputed" MATCH (victim)-[t:HAS_BOUGHT_AT]->(othermerchants) WHERE t.status = "Undisputed" AND t.time < r.time WITH victim, othermerchants, t ORDER BY t.time DESC RETURN DISTINCT othermerchants.name AS `Suspicious Store`, count(DISTINCT t) AS CountT, collect(DISTINCT victim.name) AS Victims ORDER BY CountT DESC + """ + Then the result should be: + | Suspicious Store | Count | Victims | + | 'Wallmart' | 4 | ['Olivia', 'Madison', 'Marc', 'Paul'] | diff --git a/tests/qa/tck_engine/tests/cypher_graph_gists/features/restaurant_recommendations.feature b/tests/qa/tck_engine/tests/cypher_graph_gists/features/restaurant_recommendations.feature new file mode 100644 index 000000000..32c03adc0 --- /dev/null +++ b/tests/qa/tck_engine/tests/cypher_graph_gists/features/restaurant_recommendations.feature @@ -0,0 +1,36 @@ +Feature: Restaurant Recommendations + + Scenario: Match all disputed transactions + Given graph "restaurant_recommendations" + When executing query: + """ + MATCH (philip:Person {name:"Philip"})-[:IS_FRIEND_OF]-(person) RETURN person.name AS person ORDER BY person ASC + """ + Then the result should be: + | person | + | 'Andreas' | + | 'Emil' | + | 'Michael' | + + Scenario: Restaurants in NYC and their cusines + Given graph "restaurant_recommendations" + When executing query: + """ + MATCH (nyc:City {name:"New York"})<-[:LOCATED_IN]-(restaurant)-[:SERVES]->(cusine) RETURN nyc, restaurant, cusine + """ + Then the result should be: + |nyc |restaurant| cusine| + |(:City {name:'New York'}) | (:Restaurant{name:'Zushi Zam'}) | (:Cuisine{name:'Sushi'}) | + |(:City {name:'New York'}) | (:Restaurant{name:'iSushi'}) | (:Cuisine{name:'Sushi'}) | + + Scenario: Graph Search Recommendation + Given graph "restaurant_recommendations" + When executing query: + """ + MATCH (philip:Person {name:"Philip"}), (philip)-[:IS_FRIEND_OF]-(friend), (restaurant:Restaurant)-[:LOCATED_IN]->(:City {name:"New York"}), (restaurant)-[:SERVES]->(:Cuisine {name:"Sushi"}), (friend)-[:LIKES]->(restaurant) RETURN restaurant.name AS restaurant, collect(friend.name) as likers, count(*) as occurence ORDER BY occurence DESC + """ + Then the result should be: + | restaurant | likers | occurence | + | 'iSushi' | ['Andreas', 'Michael'] | 2 | + | 'Zushi Zam' | ['Andreas'] | 1 | + diff --git a/tests/qa/tck_engine/tests/cypher_graph_gists/graphs/credit_card_fraud_detection.cypher b/tests/qa/tck_engine/tests/cypher_graph_gists/graphs/credit_card_fraud_detection.cypher new file mode 100644 index 000000000..112d17fea --- /dev/null +++ b/tests/qa/tck_engine/tests/cypher_graph_gists/graphs/credit_card_fraud_detection.cypher @@ -0,0 +1 @@ +CREATE (Paul:Person {id:'1', name:'Paul', gender:'man', age:'50'}) CREATE (Jean:Person {id:'2', name:'Jean', gender:'man', age:'48'}) CREATE (Dan:Person {id:'3', name:'Dan', gender:'man', age:'23'}) CREATE (Marc:Person {id:'4', name:'Marc', gender:'man', age:'30'}) CREATE (John:Person {id:'5', name:'John', gender:'man', age:'31'}) CREATE (Zoey:Person {id:'6', name:'Zoey', gender:'woman', age:'52'}) CREATE (Ava:Person {id:'7', name:'Ava', gender:'woman', age:'23'}) CREATE (Olivia:Person {id:'8', name:'Olivia', gender:'woman', age:'58'}) CREATE (Mia:Person {id:'9', name:'Mia', gender:'woman', age:'51'}) CREATE (Madison:Person {id:'10', name:'Madison', gender:'woman', age:'37'}) CREATE (Amazon:Merchant {id:'11', name:'Amazon', street:'2626 Wilkinson Court', address:'San Bernardino, CA 92410'}) CREATE (Abercrombie:Merchant {id:'12', name:'Abercrombie', street:'4355 Walnut Street', age:'San Bernardino, CA 92410'}) CREATE (Wallmart:Merchant {id:'13', name:'Wallmart', street:'2092 Larry Street', age:'San Bernardino, CA 92410'}) CREATE (MacDonalds:Merchant {id:'14', name:'MacDonalds', street:'1870 Caynor Circle', age:'San Bernardino, CA 92410'}) CREATE (American_Apparel:Merchant {id:'15', name:'American Apparel', street:'1381 Spruce Drive', age:'San Bernardino, CA 92410'}) CREATE (Just_Brew_It:Merchant {id:'16', name:'Just Brew It', street:'826 Anmoore Road', age:'San Bernardino, CA 92410'}) CREATE (Justice:Merchant {id:'17', name:'Justice', street:'1925 Spring Street', age:'San Bernardino, CA 92410'}) CREATE (Sears:Merchant {id:'18', name:'Sears', street:'4209 Elsie Drive', age:'San Bernardino, CA 92410'}) CREATE (Soccer_for_the_City:Merchant {id:'19', name:'Soccer for the City', street:'86 D Street', age:'San Bernardino, CA 92410'}) CREATE (Sprint:Merchant {id:'20', name:'Sprint', street:'945 Kinney Street', age:'San Bernardino, CA 92410'}) CREATE (Starbucks:Merchant {id:'21', name:'Starbucks', street:'3810 Apple Lane', age:'San Bernardino, CA 92410'}) CREATE (Subway:Merchant {id:'22', name:'Subway', street:'3778 Tenmile Road', age:'San Bernardino, CA 92410'}) CREATE (Apple_Store:Merchant {id:'23', name:'Apple Store', street:'349 Bel Meadow Drive', age:'Kansas City, MO 64105'}) CREATE (Urban_Outfitters:Merchant {id:'24', name:'Urban Outfitters', street:'99 Strother Street', age:'Kansas City, MO 64105'}) CREATE (RadioShack:Merchant {id:'25', name:'RadioShack', street:'3306 Douglas Dairy Road', age:'Kansas City, MO 64105'}) CREATE (Macys:Merchant {id:'26', name:'Macys', street:'2912 Nutter Street', age:'Kansas City, MO 64105'}) CREATE (Paul)-[:HAS_BOUGHT_AT {amount:'986', time:'4/17/2014', status:'Undisputed'}]->(Just_Brew_It) CREATE (Paul)-[:HAS_BOUGHT_AT {amount:'239', time:'5/15/2014', status:'Undisputed'}]->(Starbucks) CREATE (Paul)-[:HAS_BOUGHT_AT {amount:'475', time:'3/28/2014', status:'Undisputed'}]->(Sears) CREATE (Paul)-[:HAS_BOUGHT_AT {amount:'654', time:'3/20/2014', status:'Undisputed'}]->(Wallmart) CREATE (Jean)-[:HAS_BOUGHT_AT {amount:'196', time:'7/24/2014', status:'Undisputed'}]->(Soccer_for_the_City) CREATE (Jean)-[:HAS_BOUGHT_AT {amount:'502', time:'4/9/2014', status:'Undisputed'}]->(Abercrombie) CREATE (Jean)-[:HAS_BOUGHT_AT {amount:'848', time:'5/29/2014', status:'Undisputed'}]->(Wallmart) CREATE (Jean)-[:HAS_BOUGHT_AT {amount:'802', time:'3/11/2014', status:'Undisputed'}]->(Amazon) CREATE (Jean)-[:HAS_BOUGHT_AT {amount:'203', time:'3/27/2014', status:'Undisputed'}]->(Subway) CREATE (Dan)-[:HAS_BOUGHT_AT {amount:'35', time:'1/23/2014', status:'Undisputed'}]->(MacDonalds) CREATE (Dan)-[:HAS_BOUGHT_AT {amount:'605', time:'1/27/2014', status:'Undisputed'}]->(MacDonalds) CREATE (Dan)-[:HAS_BOUGHT_AT {amount:'62', time:'9/17/2014', status:'Undisputed'}]->(Soccer_for_the_City) CREATE (Dan)-[:HAS_BOUGHT_AT {amount:'141', time:'11/14/2014', status:'Undisputed'}]->(Amazon) CREATE (Marc)-[:HAS_BOUGHT_AT {amount:'134', time:'4/14/2014', status:'Undisputed'}]->(Amazon) CREATE (Marc)-[:HAS_BOUGHT_AT {amount:'336', time:'4/3/2014', status:'Undisputed'}]->(American_Apparel) CREATE (Marc)-[:HAS_BOUGHT_AT {amount:'964', time:'3/22/2014', status:'Undisputed'}]->(Wallmart) CREATE (Marc)-[:HAS_BOUGHT_AT {amount:'430', time:'8/10/2014', status:'Undisputed'}]->(Sears) CREATE (Marc)-[:HAS_BOUGHT_AT {amount:'11', time:'9/4/2014', status:'Undisputed'}]->(Soccer_for_the_City) CREATE (John)-[:HAS_BOUGHT_AT {amount:'545', time:'10/6/2014', status:'Undisputed'}]->(Soccer_for_the_City) CREATE (John)-[:HAS_BOUGHT_AT {amount:'457', time:'10/15/2014', status:'Undisputed'}]->(Sprint) CREATE (John)-[:HAS_BOUGHT_AT {amount:'468', time:'7/29/2014', status:'Undisputed'}]->(Justice) CREATE (John)-[:HAS_BOUGHT_AT {amount:'768', time:'11/28/2014', status:'Undisputed'}]->(American_Apparel) CREATE (John)-[:HAS_BOUGHT_AT {amount:'921', time:'3/12/2014', status:'Undisputed'}]->(Just_Brew_It) CREATE (Zoey)-[:HAS_BOUGHT_AT {amount:'740', time:'12/15/2014', status:'Undisputed'}]->(MacDonalds) CREATE (Zoey)-[:HAS_BOUGHT_AT {amount:'510', time:'11/27/2014', status:'Undisputed'}]->(Abercrombie) CREATE (Zoey)-[:HAS_BOUGHT_AT {amount:'414', time:'1/20/2014', status:'Undisputed'}]->(Just_Brew_It) CREATE (Zoey)-[:HAS_BOUGHT_AT {amount:'721', time:'7/17/2014', status:'Undisputed'}]->(Amazon) CREATE (Zoey)-[:HAS_BOUGHT_AT {amount:'353', time:'10/25/2014', status:'Undisputed'}]->(Subway) CREATE (Ava)-[:HAS_BOUGHT_AT {amount:'681', time:'12/28/2014', status:'Undisputed'}]->(Sears) CREATE (Ava)-[:HAS_BOUGHT_AT {amount:'87', time:'2/19/2014', status:'Undisputed'}]->(Wallmart) CREATE (Ava)-[:HAS_BOUGHT_AT {amount:'533', time:'8/6/2014', status:'Undisputed'}]->(American_Apparel) CREATE (Ava)-[:HAS_BOUGHT_AT {amount:'723', time:'1/8/2014', status:'Undisputed'}]->(American_Apparel) CREATE (Ava)-[:HAS_BOUGHT_AT {amount:'627', time:'5/20/2014', status:'Undisputed'}]->(Just_Brew_It) CREATE (Olivia)-[:HAS_BOUGHT_AT {amount:'74', time:'9/4/2014', status:'Undisputed'}]->(Soccer_for_the_City) CREATE (Olivia)-[:HAS_BOUGHT_AT {amount:'231', time:'7/12/2014', status:'Undisputed'}]->(Wallmart) CREATE (Olivia)-[:HAS_BOUGHT_AT {amount:'924', time:'10/4/2014', status:'Undisputed'}]->(Soccer_for_the_City) CREATE (Olivia)-[:HAS_BOUGHT_AT {amount:'742', time:'8/12/2014', status:'Undisputed'}]->(Just_Brew_It) CREATE (Mia)-[:HAS_BOUGHT_AT {amount:'276', time:'12/24/2014', status:'Undisputed'}]->(Soccer_for_the_City) CREATE (Mia)-[:HAS_BOUGHT_AT {amount:'66', time:'4/16/2014', status:'Undisputed'}]->(Starbucks) CREATE (Mia)-[:HAS_BOUGHT_AT {amount:'467', time:'12/23/2014', status:'Undisputed'}]->(MacDonalds) CREATE (Mia)-[:HAS_BOUGHT_AT {amount:'830', time:'3/13/2014', status:'Undisputed'}]->(Sears) CREATE (Mia)-[:HAS_BOUGHT_AT {amount:'240', time:'7/9/2014', status:'Undisputed'}]->(Amazon) CREATE (Mia)-[:HAS_BOUGHT_AT {amount:'164', time:'12/26/2014', status:'Undisputed'}]->(Soccer_for_the_City) CREATE (Madison)-[:HAS_BOUGHT_AT {amount:'630', time:'10/6/2014', status:'Undisputed'}]->(MacDonalds) CREATE (Madison)-[:HAS_BOUGHT_AT {amount:'19', time:'7/29/2014', status:'Undisputed'}]->(Abercrombie) CREATE (Madison)-[:HAS_BOUGHT_AT {amount:'352', time:'12/16/2014', status:'Undisputed'}]->(Subway) CREATE (Madison)-[:HAS_BOUGHT_AT {amount:'147', time:'8/3/2014', status:'Undisputed'}]->(Amazon) CREATE (Madison)-[:HAS_BOUGHT_AT {amount:'91', time:'6/29/2014', status:'Undisputed'}]->(Wallmart) CREATE (Paul)-[:HAS_BOUGHT_AT {amount:'1021', time:'7/18/2014', status:'Disputed'}]->(Apple_Store) CREATE (Paul)-[:HAS_BOUGHT_AT {amount:'1732', time:'5/10/2014', status:'Disputed'}]->(Urban_Outfitters) CREATE (Paul)-[:HAS_BOUGHT_AT {amount:'1415', time:'4/1/2014', status:'Disputed'}]->(RadioShack) CREATE (Paul)-[:HAS_BOUGHT_AT {amount:'1849', time:'12/20/2014', status:'Disputed'}]->(Macys) CREATE (Marc)-[:HAS_BOUGHT_AT {amount:'1914', time:'7/18/2014', status:'Disputed'}]->(Apple_Store) CREATE (Marc)-[:HAS_BOUGHT_AT {amount:'1424', time:'5/10/2014', status:'Disputed'}]->(Urban_Outfitters) CREATE (Marc)-[:HAS_BOUGHT_AT {amount:'1721', time:'4/1/2014', status:'Disputed'}]->(RadioShack) CREATE (Marc)-[:HAS_BOUGHT_AT {amount:'1003', time:'12/20/2014', status:'Disputed'}]->(Macys) CREATE (Olivia)-[:HAS_BOUGHT_AT {amount:'1149', time:'7/18/2014', status:'Disputed'}]->(Apple_Store) CREATE (Olivia)-[:HAS_BOUGHT_AT {amount:'1152', time:'8/10/2014', status:'Disputed'}]->(Urban_Outfitters) CREATE (Olivia)-[:HAS_BOUGHT_AT {amount:'1884', time:'8/1/2014', status:'Disputed'}]->(RadioShack) CREATE (Olivia)-[:HAS_BOUGHT_AT {amount:'1790', time:'12/20/2014', status:'Disputed'}]->(Macys) CREATE (Madison)-[:HAS_BOUGHT_AT {amount:'1925', time:'7/18/2014', status:'Disputed'}]->(Apple_Store) CREATE (Madison)-[:HAS_BOUGHT_AT {amount:'1374', time:'7/10/2014', status:'Disputed'}]->(Urban_Outfitters) CREATE (Madison)-[:HAS_BOUGHT_AT {amount:'1368', time:'7/1/2014', status:'Disputed'}]->(RadioShack) CREATE (Madison)-[:HAS_BOUGHT_AT {amount:'1816', time:'12/20/2014', status:'Disputed'}]->(Macys) RETURN *; diff --git a/tests/qa/tck_engine/tests/cypher_graph_gists/graphs/restaurant_recommendations.cypher b/tests/qa/tck_engine/tests/cypher_graph_gists/graphs/restaurant_recommendations.cypher new file mode 100644 index 000000000..b3745fbbe --- /dev/null +++ b/tests/qa/tck_engine/tests/cypher_graph_gists/graphs/restaurant_recommendations.cypher @@ -0,0 +1 @@ +CREATE (philip:Person {name:"Philip"})-[:IS_FRIEND_OF]->(emil:Person {name:"Emil"}), (philip)-[:IS_FRIEND_OF]->(michael:Person {name:"Michael"}), (philip)-[:IS_FRIEND_OF]->(andreas:Person {name:"Andreas"}) create (sushi:Cuisine {name:"Sushi"}), (nyc:City {name:"New York"}), (iSushi:Restaurant {name:"iSushi"})-[:SERVES]->(sushi),(iSushi)-[:LOCATED_IN]->(nyc), (michael)-[:LIKES]->(iSushi), (andreas)-[:LIKES]->(iSushi), (zam:Restaurant {name:"Zushi Zam"})-[:SERVES]->(sushi),(zam)-[:LOCATED_IN]->(nyc), (andreas)-[:LIKES]->(zam); diff --git a/tests/stress/create_match.py b/tests/stress/create_match.py old mode 100644 new mode 100755