@Test void testJsonSchema() throws IOException { InputStream in = new ByteArrayInputStream(example.getBytes()); Map<String,Object> schemaMap = JsonSchemaUtil.load(in); in.close(); assertEquals ("object", schemaMap.get("type")); Map<String,Object> properties = (Map<String,Object>)schemaMap.get("properties"); assertEquals(2,properties.size()); assertTrue((Boolean)((Map)properties.get("approved")).get("output")); assertTrue((Boolean)((Map)properties.get("traveller")).get("input")); }
public static Map<String, Object> load(ClassLoader cl, String processId, String taskName) { Path jsonFile = jsonDir.resolve(getFileName(getJsonSchemaName(processId, taskName))); try (InputStream in = cl.getResourceAsStream(jsonFile.toString())) { if (in == null) { throw new IllegalArgumentException("Cannot find file " + jsonFile + " in classpath"); } return load(in); } catch (IOException io) { throw new IllegalStateException("Error loading schema " + jsonFile, io); } }
JsonSchemaUtil { public static Map<String, Object> load(ClassLoader cl, String processId, String taskName) { Path jsonFile = jsonDir.resolve(getFileName(getJsonSchemaName(processId, taskName))); try (InputStream in = cl.getResourceAsStream(jsonFile.toString())) { if (in == null) { throw new IllegalArgumentException("Cannot find file " + jsonFile + " in classpath"); } return load(in); } catch (IOException io) { throw new IllegalStateException("Error loading schema " + jsonFile, io); } } }
JsonSchemaUtil { public static Map<String, Object> load(ClassLoader cl, String processId, String taskName) { Path jsonFile = jsonDir.resolve(getFileName(getJsonSchemaName(processId, taskName))); try (InputStream in = cl.getResourceAsStream(jsonFile.toString())) { if (in == null) { throw new IllegalArgumentException("Cannot find file " + jsonFile + " in classpath"); } return load(in); } catch (IOException io) { throw new IllegalStateException("Error loading schema " + jsonFile, io); } } private  JsonSchemaUtil(); }
JsonSchemaUtil { public static Map<String, Object> load(ClassLoader cl, String processId, String taskName) { Path jsonFile = jsonDir.resolve(getFileName(getJsonSchemaName(processId, taskName))); try (InputStream in = cl.getResourceAsStream(jsonFile.toString())) { if (in == null) { throw new IllegalArgumentException("Cannot find file " + jsonFile + " in classpath"); } return load(in); } catch (IOException io) { throw new IllegalStateException("Error loading schema " + jsonFile, io); } } private  JsonSchemaUtil(); static String getJsonSchemaName(String processId, String taskName); static Path getJsonDir(); static String getFileName(String key); static Map<String, Object> load(ClassLoader cl, String processId, String taskName); static Map<String, Object> load(InputStream in); static Map<String, Object> addPhases(Process<T> process,
                                                    Application application,
                                                    String processInstanceId,
                                                    String workItemId,
                                                    Policy<?>[] policies,
                                                    Map<String, Object> jsonSchema); static Set<String> allowedPhases(WorkItemHandler handler, WorkItem workItem); }
JsonSchemaUtil { public static Map<String, Object> load(ClassLoader cl, String processId, String taskName) { Path jsonFile = jsonDir.resolve(getFileName(getJsonSchemaName(processId, taskName))); try (InputStream in = cl.getResourceAsStream(jsonFile.toString())) { if (in == null) { throw new IllegalArgumentException("Cannot find file " + jsonFile + " in classpath"); } return load(in); } catch (IOException io) { throw new IllegalStateException("Error loading schema " + jsonFile, io); } } private  JsonSchemaUtil(); static String getJsonSchemaName(String processId, String taskName); static Path getJsonDir(); static String getFileName(String key); static Map<String, Object> load(ClassLoader cl, String processId, String taskName); static Map<String, Object> load(InputStream in); static Map<String, Object> addPhases(Process<T> process,
                                                    Application application,
                                                    String processInstanceId,
                                                    String workItemId,
                                                    Policy<?>[] policies,
                                                    Map<String, Object> jsonSchema); static Set<String> allowedPhases(WorkItemHandler handler, WorkItem workItem);  }