Skip to content

Commit da815f2

Browse files
authored
Add errorTags (#659)
1 parent 4c09977 commit da815f2

File tree

2 files changed

+38
-25
lines changed
  • src
    • main/java/org/openstreetmap/atlas/checks/maproulette/data
    • test/java/org/openstreetmap/atlas/checks/maproulette/data

2 files changed

+38
-25
lines changed

src/main/java/org/openstreetmap/atlas/checks/maproulette/data/Task.java

Lines changed: 29 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
package org.openstreetmap.atlas.checks.maproulette.data;
22

3+
import static org.openstreetmap.atlas.checks.constants.CommonConstants.EMPTY_STRING;
4+
35
import java.util.ArrayList;
46
import java.util.HashSet;
57
import java.util.List;
@@ -26,31 +28,6 @@
2628
*/
2729
public class Task
2830
{
29-
/**
30-
* A class holding a point and some description for that point
31-
*/
32-
private class PointInformation
33-
{
34-
private final Location location;
35-
private final Optional<String> description;
36-
37-
PointInformation(final Location location, final Optional<String> description)
38-
{
39-
this.location = location;
40-
this.description = description;
41-
}
42-
43-
public Optional<String> getDescription()
44-
{
45-
return this.description;
46-
}
47-
48-
public Location getLocation()
49-
{
50-
return this.location;
51-
}
52-
}
53-
5431
/**
5532
* Given some feature changes, convert them one by one to JSON cooperative challenge operations.
5633
* This is in {@link Task} since cooperativeWork objects are part of the Task geojson, and so
@@ -91,6 +68,31 @@ private List<JsonObject> convert()
9168
}
9269
}
9370

71+
/**
72+
* A class holding a point and some description for that point
73+
*/
74+
private class PointInformation
75+
{
76+
private final Location location;
77+
private final Optional<String> description;
78+
79+
PointInformation(final Location location, final Optional<String> description)
80+
{
81+
this.location = location;
82+
this.description = description;
83+
}
84+
85+
public Optional<String> getDescription()
86+
{
87+
return this.description;
88+
}
89+
90+
public Location getLocation()
91+
{
92+
return this.location;
93+
}
94+
}
95+
9496
protected static final String FEATURE = "Feature";
9597
protected static final String POINT = "Point";
9698
protected static final String TASK_FEATURES = "features";
@@ -107,6 +109,7 @@ private List<JsonObject> convert()
107109
private static final String FRAMEWORK_GENERATOR = "flag:generator";
108110
private static final String FRAMEWORK = "Atlas Checks";
109111
private static final String COOPERATIVE_WORK = "cooperativeWork";
112+
private static final String ERROR_TAGS = "errorTags";
110113
private String challengeName;
111114
private Optional<JsonArray> geoJson = Optional.empty();
112115
private String instruction;
@@ -156,6 +159,7 @@ public JsonObject generateTask(final long parentIdentifier)
156159
task.add(TASK_NAME, new JsonPrimitive(this.getTaskIdentifier()));
157160
task.add(TASK_PARENT_ID, new JsonPrimitive(parentIdentifier));
158161
task.add(TASK_GEOMETRIES, result);
162+
task.add(ERROR_TAGS, new JsonPrimitive(EMPTY_STRING));
159163
return task;
160164
}
161165

src/test/java/org/openstreetmap/atlas/checks/maproulette/data/TaskTest.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
import java.util.stream.Collectors;
99
import java.util.stream.Stream;
1010

11+
import org.junit.Assert;
1112
import org.junit.Rule;
1213
import org.junit.Test;
1314
import org.openstreetmap.atlas.geography.Location;
@@ -57,6 +58,14 @@ private static Task createTaskSkeleton(final Set<Location> points)
5758
return task;
5859
}
5960

61+
@Test
62+
public void generateTaskTest()
63+
{
64+
final var task = createTaskSkeleton(this.rule.getAtlas().point(1000000).getLocation());
65+
final var taskJson = task.generateTask(1);
66+
Assert.assertEquals("", taskJson.get("errorTags").getAsString());
67+
}
68+
6069
/**
6170
* Test for the private inner class FixSuggestionToCooperativeWorkConverter (Geometry)
6271
*/

0 commit comments

Comments
 (0)