Skip to content

Commit

Permalink
allowedAction JsonArray, fix imageFormats, fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
krwong committed Aug 29, 2024
1 parent f080b96 commit 453177f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,8 @@ public class ListProjectsService {
public static final String PROJECT_PATH = "projectPath";
public static final String STATUS = "status";
public static final String ALLOWED_ACTIONS = "allowedActions";
private static final Set<String> IMAGE_FORMATS = new HashSet<>();
// accepted file types are listed in imageFormats below
static {
IMAGE_FORMATS.addAll(Arrays.asList("tif", "tiff", "jpeg", "jpg", "png", "gif", "pict", "bmp",
"psd", "jp2", "nef", "crw", "cr2", "dng", "raf"));
}
private static final Set<String> IMAGE_FORMATS = new HashSet<>(Arrays.asList("tif", "tiff", "jpeg", "jpg", "png",
"gif", "pict", "bmp", "psd", "jp2", "nef", "crw", "cr2", "dng", "raf"));

/**
* List projects in given directory
Expand All @@ -65,14 +61,14 @@ public JsonNode listProjects(Path directory) throws Exception {

Path projectPath = directory.toAbsolutePath();
String projectStatus = status(project);
List<String> allowedActions = allowedActions(project);
String allowedActions = mapper.writeValueAsString(allowedActions(project));
JsonNode projectProperties = mapper.readTree(project.getProjectPropertiesPath().toFile());

// add project info to JSON
ObjectNode objectNode = mapper.createObjectNode();
objectNode.put(PROJECT_PATH, projectPath.toString());
objectNode.put(STATUS, projectStatus);
objectNode.put(ALLOWED_ACTIONS, String.valueOf(allowedActions));
objectNode.put(ALLOWED_ACTIONS, allowedActions);
objectNode.set("projectProperties", projectProperties);
arrayNode.add(objectNode);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@
import java.nio.charset.StandardCharsets;
import java.nio.file.Path;
import java.time.Instant;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

import static org.junit.jupiter.api.Assertions.assertEquals;
Expand Down Expand Up @@ -84,7 +86,7 @@ public void allowedActionTest() throws Exception {

assertEquals(tmpFolder.toString(), list.findValue(ListProjectsService.PROJECT_PATH).asText());
assertEquals("sources_mapped", list.findValue(ListProjectsService.STATUS).asText());
assertEquals("[crop_color_bars]", list.findValue(ListProjectsService.ALLOWED_ACTIONS).asText());
assertEquals("[\"crop_color_bars\"]", list.findValue(ListProjectsService.ALLOWED_ACTIONS).asText());
assertEquals(PROJECT_NAME, list.findValue("name").asText());
}

Expand Down

0 comments on commit 453177f

Please sign in to comment.