()
| 12 | |
| 13 | #[test] |
| 14 | fn test_fraud_detection_queries() { |
| 15 | let fixture = TestFixture::new().expect("Failed to create test fixture"); |
| 16 | // Setup fresh graph for this test to avoid interference |
| 17 | fixture |
| 18 | .setup_graph("test_fraud_detection_queries") |
| 19 | .expect("Failed to setup graph"); |
| 20 | // Re-insert fraud data since we have a fresh graph |
| 21 | fixture |
| 22 | .insert_fraud_data() |
| 23 | .expect("Failed to insert fraud data"); |
| 24 | |
| 25 | // Test 1: Count total accounts |
| 26 | fixture.assert_first_value( |
| 27 | "MATCH (a:Account) RETURN count(a) as account_count", |
| 28 | "account_count", |
| 29 | Value::Number(50.0), |
| 30 | ); |
| 31 | |
| 32 | // Test 2: Count total merchants |
| 33 | fixture.assert_first_value( |
| 34 | "MATCH (m:Merchant) RETURN count(m) as merchant_count", |
| 35 | "merchant_count", |
| 36 | Value::Number(20.0), |
| 37 | ); |
| 38 | |
| 39 | // Test 3: Count transaction relationships |
| 40 | fixture.assert_first_value( |
| 41 | "MATCH ()-[t:Transaction]->() RETURN count(t) as transaction_count", |
| 42 | "transaction_count", |
| 43 | Value::Number(100.0), |
| 44 | ); |
| 45 | |
| 46 | // Test 4: Find high-value transactions |
| 47 | let result = fixture.assert_query_succeeds( |
| 48 | "MATCH (a:Account)-[t:Transaction]->(m:Merchant) WHERE t.amount > 100 RETURN count(t) as high_value_count" |
| 49 | ); |
| 50 | assert_eq!(result.rows.len(), 1); |
| 51 | |
| 52 | // Test 5: Active vs inactive accounts |
| 53 | // The fixture creates 45 active accounts (all except every 10th account) |
| 54 | // and 5 inactive accounts (accounts 10, 20, 30, 40, 50) |
| 55 | fixture.assert_first_value( |
| 56 | "MATCH (a:Account) WHERE a.status = 'active' RETURN count(a) as active_count", |
| 57 | "active_count", |
| 58 | Value::Number(45.0), |
| 59 | ); |
| 60 | |
| 61 | fixture.assert_first_value( |
| 62 | "MATCH (a:Account) WHERE a.status = 'inactive' RETURN count(a) as inactive_count", |
| 63 | "inactive_count", |
| 64 | Value::Number(5.0), |
| 65 | ); |
| 66 | |
| 67 | // Test 6: Group merchants by category (all merchants have category='retail' in fixture) |
| 68 | let result = fixture.assert_query_succeeds( |
| 69 | "MATCH (m:Merchant) |
| 70 | RETURN m.category as category, count(m) as count |
| 71 | ORDER BY count DESC", |
nothing calls this directly
no test coverage detected