| 97 | |
| 98 | /** |
| 99 | * Checks that tags with a count > 1000 are not reported as false positives. |
| 100 | * @throws SAXException if any XML parsing error occurs |
| 101 | * @throws IOException if any I/O error occurs |
| 102 | * @throws ParseException if any MapCSS parsing error occurs |
| 103 | */ |
| 104 | @Test |
| 105 | public void testCheckLessPopularTags() throws SAXException, IOException, ParseException { |
| 106 | TaggingPresets.readFromPreferences(); |
| 107 | TagChecker tc = new TagChecker(); |
| 108 | tc.initialize(); |
| 109 | tc.startTest(null); |
| 110 | |
| 111 | List<String> errors = new ArrayList<>(); |
| 112 | try ( |
| 113 | CachedFile cf = new CachedFile("nodist/data/frequent-tags.cfg"); |
| 114 | BufferedReader reader = cf.getContentReader() |
| 115 | ) { |
| 116 | String line; |
| 117 | while ((line = reader.readLine()) != null && (!line.isEmpty())) { |
| 118 | if (!line.startsWith("#")) { |
| 119 | String[] parts = line.split("\\|"); |
| 120 | // select key, value, count_nodes, count_ways, count_relations from tags |
| 121 | if (parts.length >= 2) { |
| 122 | String key = parts[0]; |
| 123 | String value = parts[1]; |
| 124 | |
| 125 | if (!TagChecker.isTagInPresets(key, value) && !TagChecker.isTagIgnored(key, value)) { |
| 126 | Node n = new Node(LatLon.NORTH_POLE); |
| 127 | n.put(key, value); |
| 128 | new DataSet(n); |
| 129 | tc.check(n); |
| 130 | if (!tc.getErrors().isEmpty()) { |
| 131 | for (TestError e : tc.getErrors()) { |
| 132 | if (e.getDescription() != null && e.getDescription().contains("is meant?")) { |
| 133 | errors.add(key+"="+value+ " " + e.getDescription() + " " + line); |
| 134 | } |
| 135 | } |
| 136 | |
| 137 | } |
| 138 | tc.clear(); |
| 139 | } |
| 140 | } |
| 141 | } |
| 142 | } |
| 143 | } |
| 144 | for (String error : errors) { |
| 145 | System.err.println("false positive? " + error); |
| 146 | } |
| 147 | assertTrue(errors.toString(), errors.isEmpty()); |
| 148 | } |