TransformPayloadInputBuilder { public static String build(JoltSpec joltSpec, String delegateExecutionRequestJsonPayload, MultiMap headers, final Matcher matcher){ if(joltSpec.isWithMetadata()){ JsonObject withMetadata = new JsonObject(); withMetadata.put(URL_PARTS, buildUrlParts(matcher)); withMetadata.put(HEADERS, buildHeaders(headers)); withMetadata.put(PAYLOAD, new JsonObject(delegateExecutionRequestJsonPayload)); return withMetadata.encode(); } else { return delegateExecutionRequestJsonPayload; } }  static String build(JoltSpec joltSpec, String delegateExecutionRequestJsonPayload, MultiMap headers, final Matcher matcher);  }
@Test public void testBuildNoMetadata(TestContext context) throws Exception { JoltSpec spec = JoltSpecBuilder.buildSpec(specValid, false); MultiMap headers = new VertxHttpHeaders(); String builtInput = TransformPayloadInputBuilder.build(spec, SIMPLE_PAYLOAD, headers, matcher); context.assertEquals(SIMPLE_PAYLOAD, builtInput); }
@Test public void testBuildWithMetadata(TestContext context) throws Exception { JoltSpec spec = JoltSpecBuilder.buildSpec(specValid, true); MultiMap headers = new VertxHttpHeaders(); headers.add("x-abc", "x"); headers.add("x-def", "y"); headers.add("x-def", "y2"); headers.add("x-ghi", "z"); headers.add("x-ghi", "z2"); headers.add("x-ghi", "z3"); String builtInput = TransformPayloadInputBuilder.build(spec, SIMPLE_PAYLOAD, headers, matcher); String expected = "{\n" + "\t\"urlParts\": [\"/some/test/url\", \"url\"],\n" + "\t\"headers\": {\n" + "\t\t\"x-abc\": \"x\",\n" + "\t\t\"x-def\": \"y,y2\",\n" + "\t\t\"x-ghi\": \"z,z2,z3\"\n" + "\t},\n" + "\t\"payload\": {\n" + "\t\t\"key\": \"value\",\n" + "\t\t\"key2\": 344\n" + "\t}\n" + "}"; context.assertEquals(new JsonObject(expected), new JsonObject(builtInput)); }