@SuppressWarnings("unchecked") @Override public Object call() throws Exception { List<Object> grids = U.list(); Map<String, Object> sections = U.cast(Conf.ROOT.toMap()); sections = Msc.protectSensitiveInfo(sections, FA.QUESTION_CIRCLE); Map<String, Object> root = U.map(); for (Map.Entry<String, Object> entry : sections.entrySet()) { String key = entry.getKey(); Object value = entry.getValue(); if (value instanceof Map<?, ?>) { grids.add(h4(span(key).class_("label " + styleOf(key)))); grids.add(grid((Map<String, ?>) value)); } else { root.put(key, value); } } if (!root.isEmpty()) { grids.add(0, h4(span("<root>").class_("label " + styleOf("root")))); grids.add(1, grid(root)); } return multi(grids); }
@Test public void testConfigRootAndFileSetup() { String dir = createTempDir("app"); IO.save(Msc.path(dir, "the-config.yml"), "id: abc2"); Env.setArgs("root=" + dir, "config=the-config"); eq(Conf.ROOT.entry("id").getOrNull(), "abc2"); }
@Test public void testWithInvalidEncoding() { On.get("/").json(req -> U.map("uri", req.uri(), "query", req.query(), "data", req.data())); String resp = Msc.connect( "localhost", 8888, (in, reader, out) -> { out.writeBytes("GET /?a=[%A%]&b=bb!&c=%&d=%% HTTP/1.0\n\n"); return Flow.of(reader.lines()).findLast().get(); }); verify(resp); }