Skip to content

Commit

Permalink
Add errorTags (#659)
Browse files Browse the repository at this point in the history
  • Loading branch information
Bentleysb authored Mar 1, 2022
1 parent 4c09977 commit da815f2
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 25 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.openstreetmap.atlas.checks.maproulette.data;

import static org.openstreetmap.atlas.checks.constants.CommonConstants.EMPTY_STRING;

import java.util.ArrayList;
import java.util.HashSet;
import java.util.List;
Expand All @@ -26,31 +28,6 @@
*/
public class Task
{
/**
* A class holding a point and some description for that point
*/
private class PointInformation
{
private final Location location;
private final Optional<String> description;

PointInformation(final Location location, final Optional<String> description)
{
this.location = location;
this.description = description;
}

public Optional<String> getDescription()
{
return this.description;
}

public Location getLocation()
{
return this.location;
}
}

/**
* Given some feature changes, convert them one by one to JSON cooperative challenge operations.
* This is in {@link Task} since cooperativeWork objects are part of the Task geojson, and so
Expand Down Expand Up @@ -91,6 +68,31 @@ private List<JsonObject> convert()
}
}

/**
* A class holding a point and some description for that point
*/
private class PointInformation
{
private final Location location;
private final Optional<String> description;

PointInformation(final Location location, final Optional<String> description)
{
this.location = location;
this.description = description;
}

public Optional<String> getDescription()
{
return this.description;
}

public Location getLocation()
{
return this.location;
}
}

protected static final String FEATURE = "Feature";
protected static final String POINT = "Point";
protected static final String TASK_FEATURES = "features";
Expand All @@ -107,6 +109,7 @@ private List<JsonObject> convert()
private static final String FRAMEWORK_GENERATOR = "flag:generator";
private static final String FRAMEWORK = "Atlas Checks";
private static final String COOPERATIVE_WORK = "cooperativeWork";
private static final String ERROR_TAGS = "errorTags";
private String challengeName;
private Optional<JsonArray> geoJson = Optional.empty();
private String instruction;
Expand Down Expand Up @@ -156,6 +159,7 @@ public JsonObject generateTask(final long parentIdentifier)
task.add(TASK_NAME, new JsonPrimitive(this.getTaskIdentifier()));
task.add(TASK_PARENT_ID, new JsonPrimitive(parentIdentifier));
task.add(TASK_GEOMETRIES, result);
task.add(ERROR_TAGS, new JsonPrimitive(EMPTY_STRING));
return task;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
import java.util.stream.Collectors;
import java.util.stream.Stream;

import org.junit.Assert;
import org.junit.Rule;
import org.junit.Test;
import org.openstreetmap.atlas.geography.Location;
Expand Down Expand Up @@ -57,6 +58,14 @@ private static Task createTaskSkeleton(final Set<Location> points)
return task;
}

@Test
public void generateTaskTest()
{
final var task = createTaskSkeleton(this.rule.getAtlas().point(1000000).getLocation());
final var taskJson = task.generateTask(1);
Assert.assertEquals("", taskJson.get("errorTags").getAsString());
}

/**
* Test for the private inner class FixSuggestionToCooperativeWorkConverter (Geometry)
*/
Expand Down

0 comments on commit da815f2

Please sign in to comment.