OLD | NEW |
(Empty) | |
| 1 // Data model for complex tests. |
| 2 |
| 3 class Person { |
| 4 String name; |
| 5 int age; |
| 6 List<Search> searches; |
| 7 |
| 8 Person(this.name, this.age, this.searches); |
| 9 } |
| 10 |
| 11 class Search { |
| 12 String query; |
| 13 int rank; |
| 14 int total; |
| 15 List<Metric> metrics; |
| 16 |
| 17 Search(this.query, this.rank, this.total, this.metrics); |
| 18 } |
| 19 |
| 20 class Metric { |
| 21 String country; |
| 22 int quantity; |
| 23 |
| 24 Metric(this.country, this.quantity); |
| 25 |
| 26 static int grandTotal(List<Metric> metrics) { |
| 27 int total = 0; |
| 28 for (final metric in metrics) { |
| 29 total += metric.quantity; |
| 30 } |
| 31 |
| 32 return total; |
| 33 } |
| 34 } |
| 35 |
| 36 List<Person> get dataModel() { |
| 37 List<Person> persons = []; |
| 38 |
| 39 List<Search> searches = []; |
| 40 List<Metric> metrics = []; |
| 41 |
| 42 // Snooki data |
| 43 metrics = []; |
| 44 metrics.add(new Metric("USA", 200300312)); |
| 45 searches.add(new Search("intellect", 6, Metric.grandTotal(metrics), metrics)); |
| 46 |
| 47 metrics.add(new Metric("USA", 75000000)); |
| 48 metrics.add(new Metric("China", 5)); |
| 49 metrics.add(new Metric("EU", 110000)); |
| 50 metrics.add(new Metric("Canada", 3400000)); |
| 51 metrics.add(new Metric("Mexico", 20000)); |
| 52 searches.add(new Search("breading", 5, Metric.grandTotal(metrics), metrics)); |
| 53 |
| 54 metrics = []; |
| 55 metrics.add(new Metric("USA", 5000000)); |
| 56 metrics.add(new Metric("China", 3)); |
| 57 metrics.add(new Metric("EU", 90000)); |
| 58 metrics.add(new Metric("Canada", 3100000)); |
| 59 metrics.add(new Metric("Mexico", 24000)); |
| 60 searches.add(new Search("booze", 8, Metric.grandTotal(metrics), metrics)); |
| 61 |
| 62 metrics = []; |
| 63 metrics.add(new Metric("USA", 5000000)); |
| 64 metrics.add(new Metric("EU", 90000)); |
| 65 metrics.add(new Metric("Canada", 300000)); |
| 66 searches.add(new Search("turpitude", 10, Metric.grandTotal(metrics), metrics))
; |
| 67 |
| 68 persons.add(new Person("Snooki", 24, searches)); |
| 69 |
| 70 // Lady Gaga |
| 71 searches = []; |
| 72 |
| 73 metrics = []; |
| 74 metrics.add(new Metric("USA", 11000000)); |
| 75 metrics.add(new Metric("China", 5000000000)); |
| 76 metrics.add(new Metric("EU", 8700000)); |
| 77 metrics.add(new Metric("Canada", 3400000)); |
| 78 metrics.add(new Metric("Mexico", 24349898)); |
| 79 searches.add(new Search("bad romance", 3, Metric.grandTotal(metrics), metrics)
); |
| 80 |
| 81 metrics = []; |
| 82 metrics.add(new Metric("USA", 980000)); |
| 83 metrics.add(new Metric("China", 187000000)); |
| 84 searches.add(new Search("fashion", 7, Metric.grandTotal(metrics), metrics)); |
| 85 |
| 86 metrics = []; |
| 87 metrics.add(new Metric("USA", 7630000)); |
| 88 searches.add(new Search("outrageous", 9, Metric.grandTotal(metrics), metrics)
); |
| 89 |
| 90 persons.add(new Person("Lady Gaga", 25, searches)); |
| 91 |
| 92 // Uggie (The Artist dog) |
| 93 searches = []; |
| 94 |
| 95 metrics = []; |
| 96 metrics.add(new Metric("USA", 1000000)); |
| 97 metrics.add(new Metric("China", 34000)); |
| 98 metrics.add(new Metric("EU", 11000000000)); |
| 99 metrics.add(new Metric("Canada", 5023)); |
| 100 metrics.add(new Metric("Mexico", 782)); |
| 101 searches.add(new Search("smart", 2, Metric.grandTotal(metrics), metrics)); |
| 102 |
| 103 metrics = []; |
| 104 metrics.add(new Metric("USA", 18900000)); |
| 105 metrics.add(new Metric("China", 34000)); |
| 106 metrics.add(new Metric("EU", 990000000)); |
| 107 metrics.add(new Metric("Canada", 6739920)); |
| 108 searches.add(new Search("cute", 4, Metric.grandTotal(metrics), metrics)); |
| 109 |
| 110 metrics = []; |
| 111 metrics.add(new Metric("USA", 1)); |
| 112 metrics.add(new Metric("China", 1500000000000)); |
| 113 metrics.add(new Metric("EU", 50)); |
| 114 metrics.add(new Metric("Canada", 0)); |
| 115 metrics.add(new Metric("Mexico", 7801)); |
| 116 searches.add(new Search("tasty", 1, Metric.grandTotal(metrics), metrics)); |
| 117 |
| 118 persons.add(new Person("Uggie (Artist dog)", 10, searches)); |
| 119 |
| 120 return persons; |
| 121 } |
| 122 |
OLD | NEW |