test_class.declarator: CONTENT_TYPE_PLAIN = "text/plain"
test_class.modifier: private static final
test_class.original_string: private static final String CONTENT_TYPE_PLAIN = "text/plain";
test_class.type: String
test_class.var_name: CONTENT_TYPE_PLAIN
test_class.declarator: CONTENT_TYPE_BINARY = "application/octet-stream"
test_class.modifier: private static final
test_class.original_string: private static final String CONTENT_TYPE_BINARY = "application/octet-stream";
test_class.type: String
test_class.var_name: CONTENT_TYPE_BINARY
test_class.declarator: HEADER_CORRELATION_ID = "correlation-id"
test_class.modifier: private static final
test_class.original_string: private static final String HEADER_CORRELATION_ID = "correlation-id";
test_class.type: String
test_class.var_name: HEADER_CORRELATION_ID
test_class.declarator: MAPPING_INCOMING_NAMESPACE = "org.eclipse.ditto"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_INCOMING_NAMESPACE = "org.eclipse.ditto";
test_class.type: String
test_class.var_name: MAPPING_INCOMING_NAMESPACE
test_class.declarator: MAPPING_INCOMING_ID = "fancy-car-11"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_INCOMING_ID = "fancy-car-11";
test_class.type: String
test_class.var_name: MAPPING_INCOMING_ID
test_class.declarator: MAPPING_INCOMING_PATH = "/attributes/foo"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_INCOMING_PATH = "/attributes/foo";
test_class.type: String
test_class.var_name: MAPPING_INCOMING_PATH
test_class.declarator: MAPPING_INCOMING_PAYLOAD_STRING = "hello!"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_INCOMING_PAYLOAD_STRING = "hello!";
test_class.type: String
test_class.var_name: MAPPING_INCOMING_PAYLOAD_STRING
test_class.declarator: MAPPING_INCOMING_PAYLOAD_BYTES = ByteBuffer.wrap(
              MAPPING_INCOMING_PAYLOAD_STRING.getBytes(StandardCharsets.UTF_8))
test_class.modifier: private static final
test_class.original_string: private static final ByteBuffer MAPPING_INCOMING_PAYLOAD_BYTES = ByteBuffer.wrap(
              MAPPING_INCOMING_PAYLOAD_STRING.getBytes(StandardCharsets.UTF_8));
test_class.type: ByteBuffer
test_class.var_name: MAPPING_INCOMING_PAYLOAD_BYTES
test_class.declarator: MAPPING_CONFIG =
              DefaultMappingConfig.of(ConfigFactory.parseString(
                      "mapping {\n" +
                              "  javascript {\n" +
                              "    maxScriptSizeBytes = 50000 # 50kB\n" +
                              "    maxScriptExecutionTime = 500ms\n" +
                              "    maxScriptStackDepth = 10\n" +
                              "  }\n" +
                              "}"))
test_class.modifier: private static final
test_class.original_string: private static final MappingConfig MAPPING_CONFIG =
              DefaultMappingConfig.of(ConfigFactory.parseString(
                      "mapping {\n" +
                              "  javascript {\n" +
                              "    maxScriptSizeBytes = 50000 # 50kB\n" +
                              "    maxScriptExecutionTime = 500ms\n" +
                              "    maxScriptStackDepth = 10\n" +
                              "  }\n" +
                              "}"));
test_class.type: MappingConfig
test_class.var_name: MAPPING_CONFIG
test_class.declarator: MAPPING_INCOMING_PLAIN =
              "function mapToDittoProtocolMsg(\n" +
                      "    headers,\n" +
                      "    textPayload,\n" +
                      "    bytePayload,\n" +
                      "    contentType\n" +
                      ") {\n" +
                      "\n" +
                      "    // ###\n" +
                      "    // Insert your mapping logic here\n" +
                      "    let namespace = \"" + MAPPING_INCOMING_NAMESPACE + "\";\n" +
                      "    let id = \"" + MAPPING_INCOMING_ID + "\";\n" +
                      "    let group = \"things\";\n" +
                      "    let channel = \"twin\";\n" +
                      "    let criterion = \"commands\";\n" +
                      "    let action = \"modify\";\n" +
                      "    let path = \"" + MAPPING_INCOMING_PATH + "\";\n" +
                      "    let dittoHeaders = {};\n" +
                      "    dittoHeaders[\"correlation-id\"] = headers[\"correlation-id\"];\n" +
                      "    let value = textPayload;\n" +
                      "    // ###\n" +
                      "\n" +
                      "    return Ditto.buildDittoProtocolMsg(\n" +
                      "        namespace,\n" +
                      "        id,\n" +
                      "        group,\n" +
                      "        channel,\n" +
                      "        criterion,\n" +
                      "        action,\n" +
                      "        path,\n" +
                      "        dittoHeaders,\n" +
                      "        value\n" +
                      "    );\n" +
                      "}"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_INCOMING_PLAIN =
              "function mapToDittoProtocolMsg(\n" +
                      "    headers,\n" +
                      "    textPayload,\n" +
                      "    bytePayload,\n" +
                      "    contentType\n" +
                      ") {\n" +
                      "\n" +
                      "    // ###\n" +
                      "    // Insert your mapping logic here\n" +
                      "    let namespace = \"" + MAPPING_INCOMING_NAMESPACE + "\";\n" +
                      "    let id = \"" + MAPPING_INCOMING_ID + "\";\n" +
                      "    let group = \"things\";\n" +
                      "    let channel = \"twin\";\n" +
                      "    let criterion = \"commands\";\n" +
                      "    let action = \"modify\";\n" +
                      "    let path = \"" + MAPPING_INCOMING_PATH + "\";\n" +
                      "    let dittoHeaders = {};\n" +
                      "    dittoHeaders[\"correlation-id\"] = headers[\"correlation-id\"];\n" +
                      "    let value = textPayload;\n" +
                      "    // ###\n" +
                      "\n" +
                      "    return Ditto.buildDittoProtocolMsg(\n" +
                      "        namespace,\n" +
                      "        id,\n" +
                      "        group,\n" +
                      "        channel,\n" +
                      "        criterion,\n" +
                      "        action,\n" +
                      "        path,\n" +
                      "        dittoHeaders,\n" +
                      "        value\n" +
                      "    );\n" +
                      "}";
test_class.type: String
test_class.var_name: MAPPING_INCOMING_PLAIN
test_class.declarator: MAPPING_OUTGOING_PLAIN = "function mapFromDittoProtocolMsg(\n" +
              "    namespace,\n" +
              "    id,\n" +
              "    group,\n" +
              "    channel,\n" +
              "    criterion,\n" +
              "    action,\n" +
              "    path,\n" +
              "    dittoHeaders,\n" +
              "    value,\n" +
              "    status,\n" +
              "    extra\n" +
              ") {\n" +
              "\n" +
              "    // ###\n" +
              "    // Insert your mapping logic here\n" +
              "    let headers = {};\n" +
              "    headers['correlation-id'] = dittoHeaders['correlation-id'];\n" +
              "    let textPayload = \"Thing ID was: \" + namespace + \":\" + id;\n" +
              "    let bytePayload = null;\n" +
              "    let contentType = \"" + CONTENT_TYPE_PLAIN + "\";\n" +
              "    // ###\n" +
              "\n" +
              "     return Ditto.buildExternalMsg(\n" +
              "        headers,\n" +
              "        textPayload,\n" +
              "        bytePayload,\n" +
              "        contentType\n" +
              "    );" +
              "}"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_OUTGOING_PLAIN = "function mapFromDittoProtocolMsg(\n" +
              "    namespace,\n" +
              "    id,\n" +
              "    group,\n" +
              "    channel,\n" +
              "    criterion,\n" +
              "    action,\n" +
              "    path,\n" +
              "    dittoHeaders,\n" +
              "    value,\n" +
              "    status,\n" +
              "    extra\n" +
              ") {\n" +
              "\n" +
              "    // ###\n" +
              "    // Insert your mapping logic here\n" +
              "    let headers = {};\n" +
              "    headers['correlation-id'] = dittoHeaders['correlation-id'];\n" +
              "    let textPayload = \"Thing ID was: \" + namespace + \":\" + id;\n" +
              "    let bytePayload = null;\n" +
              "    let contentType = \"" + CONTENT_TYPE_PLAIN + "\";\n" +
              "    // ###\n" +
              "\n" +
              "     return Ditto.buildExternalMsg(\n" +
              "        headers,\n" +
              "        textPayload,\n" +
              "        bytePayload,\n" +
              "        contentType\n" +
              "    );" +
              "}";
test_class.type: String
test_class.var_name: MAPPING_OUTGOING_PLAIN
test_class.declarator: MAPPING_INCOMING_EMPTY =
              "function mapToDittoProtocolMsg(\n" +
                      "    headers,\n" +
                      "    textPayload,\n" +
                      "    bytePayload,\n" +
                      "    contentType\n" +
                      ") {\n" +
                      "\n" +
                      "    return null;\n" +
                      "}"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_INCOMING_EMPTY =
              "function mapToDittoProtocolMsg(\n" +
                      "    headers,\n" +
                      "    textPayload,\n" +
                      "    bytePayload,\n" +
                      "    contentType\n" +
                      ") {\n" +
                      "\n" +
                      "    return null;\n" +
                      "}";
test_class.type: String
test_class.var_name: MAPPING_INCOMING_EMPTY
test_class.declarator: MAPPING_OUTGOING_EMPTY = "function mapFromDittoProtocolMsg(\n" +
              "    namespace,\n" +
              "    id,\n" +
              "    group,\n" +
              "    channel,\n" +
              "    criterion,\n" +
              "    action,\n" +
              "    path,\n" +
              "    dittoHeaders,\n" +
              "    value,\n" +
              "    status,\n" +
              "    extra\n" +
              ") {\n" +
              "\n" +
              "    return null;" +
              "}"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_OUTGOING_EMPTY = "function mapFromDittoProtocolMsg(\n" +
              "    namespace,\n" +
              "    id,\n" +
              "    group,\n" +
              "    channel,\n" +
              "    criterion,\n" +
              "    action,\n" +
              "    path,\n" +
              "    dittoHeaders,\n" +
              "    value,\n" +
              "    status,\n" +
              "    extra\n" +
              ") {\n" +
              "\n" +
              "    return null;" +
              "}";
test_class.type: String
test_class.var_name: MAPPING_OUTGOING_EMPTY
test_class.declarator: MAPPING_INCOMING_BINARY =
              "function mapToDittoProtocolMsg(\n" +
                      "    headers,\n" +
                      "    textPayload,\n" +
                      "    bytePayload,\n" +
                      "    contentType\n" +
                      ") {\n" +
                      "\n" +
                      "    // ###\n" +
                      "    // Insert your mapping logic here\n" +
                      "    let namespace = \"" + MAPPING_INCOMING_NAMESPACE + "\";\n" +
                      "    let id = \"" + MAPPING_INCOMING_ID + "\";\n" +
                      "    let group = \"things\";\n" +
                      "    let channel = \"twin\";\n" +
                      "    let criterion = \"commands\";\n" +
                      "    let action = \"modify\";\n" +
                      "    let path = \"" + MAPPING_INCOMING_PATH + "\";\n" +
                      "    let dittoHeaders = {};\n" +
                      "    dittoHeaders[\"correlation-id\"] = headers[\"correlation-id\"];\n" +
                      "    let value = Ditto.arrayBufferToString(bytePayload);\n" +
                      "    // ###\n" +
                      "\n" +
                      "    return Ditto.buildDittoProtocolMsg(\n" +
                      "        namespace,\n" +
                      "        id,\n" +
                      "        group,\n" +
                      "        channel,\n" +
                      "        criterion,\n" +
                      "        action,\n" +
                      "        path,\n" +
                      "        dittoHeaders,\n" +
                      "        value\n" +
                      "    );\n" +
                      "}"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_INCOMING_BINARY =
              "function mapToDittoProtocolMsg(\n" +
                      "    headers,\n" +
                      "    textPayload,\n" +
                      "    bytePayload,\n" +
                      "    contentType\n" +
                      ") {\n" +
                      "\n" +
                      "    // ###\n" +
                      "    // Insert your mapping logic here\n" +
                      "    let namespace = \"" + MAPPING_INCOMING_NAMESPACE + "\";\n" +
                      "    let id = \"" + MAPPING_INCOMING_ID + "\";\n" +
                      "    let group = \"things\";\n" +
                      "    let channel = \"twin\";\n" +
                      "    let criterion = \"commands\";\n" +
                      "    let action = \"modify\";\n" +
                      "    let path = \"" + MAPPING_INCOMING_PATH + "\";\n" +
                      "    let dittoHeaders = {};\n" +
                      "    dittoHeaders[\"correlation-id\"] = headers[\"correlation-id\"];\n" +
                      "    let value = Ditto.arrayBufferToString(bytePayload);\n" +
                      "    // ###\n" +
                      "\n" +
                      "    return Ditto.buildDittoProtocolMsg(\n" +
                      "        namespace,\n" +
                      "        id,\n" +
                      "        group,\n" +
                      "        channel,\n" +
                      "        criterion,\n" +
                      "        action,\n" +
                      "        path,\n" +
                      "        dittoHeaders,\n" +
                      "        value\n" +
                      "    );\n" +
                      "}";
test_class.type: String
test_class.var_name: MAPPING_INCOMING_BINARY
test_class.declarator: MAPPING_OUTGOING_BINARY = "function mapFromDittoProtocolMsg(\n" +
              "    namespace,\n" +
              "    id,\n" +
              "    group,\n" +
              "    channel,\n" +
              "    criterion,\n" +
              "    action,\n" +
              "    path,\n" +
              "    dittoHeaders,\n" +
              "    value,\n" +
              "    status,\n" +
              "    extra\n" +
              ") {\n" +
              "\n" +
              "    // ###\n" +
              "    // Insert your mapping logic here\n" +
              "    let headers = {};\n" +
              "    headers['correlation-id'] = dittoHeaders['correlation-id'];\n" +
              "    let textPayload = null;\n" +
              "    let thingId = namespace + \":\" + id;\n" +
              "    let bytePayload = Ditto.stringToArrayBuffer(thingId);\n" +
              "    let contentType = \"" + CONTENT_TYPE_BINARY + "\";\n" +
              "    // ###\n" +
              "\n" +
              "     return Ditto.buildExternalMsg(\n" +
              "        headers,\n" +
              "        textPayload,\n" +
              "        bytePayload,\n" +
              "        contentType\n" +
              "    );" +
              "}"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_OUTGOING_BINARY = "function mapFromDittoProtocolMsg(\n" +
              "    namespace,\n" +
              "    id,\n" +
              "    group,\n" +
              "    channel,\n" +
              "    criterion,\n" +
              "    action,\n" +
              "    path,\n" +
              "    dittoHeaders,\n" +
              "    value,\n" +
              "    status,\n" +
              "    extra\n" +
              ") {\n" +
              "\n" +
              "    // ###\n" +
              "    // Insert your mapping logic here\n" +
              "    let headers = {};\n" +
              "    headers['correlation-id'] = dittoHeaders['correlation-id'];\n" +
              "    let textPayload = null;\n" +
              "    let thingId = namespace + \":\" + id;\n" +
              "    let bytePayload = Ditto.stringToArrayBuffer(thingId);\n" +
              "    let contentType = \"" + CONTENT_TYPE_BINARY + "\";\n" +
              "    // ###\n" +
              "\n" +
              "     return Ditto.buildExternalMsg(\n" +
              "        headers,\n" +
              "        textPayload,\n" +
              "        bytePayload,\n" +
              "        contentType\n" +
              "    );" +
              "}";
test_class.type: String
test_class.var_name: MAPPING_OUTGOING_BINARY
test_class.declarator: MAPPING_INCOMING_WITH_STATUS =
              "function mapToDittoProtocolMsg(\n" +
                      "    headers,\n" +
                      "    textPayload,\n" +
                      "    bytePayload,\n" +
                      "    contentType\n" +
                      ") {\n" +
                      "\n" +
                      "    // ###\n" +
                      "    // Insert your mapping logic here\n" +
                      "    let namespace = \"" + MAPPING_INCOMING_NAMESPACE + "\";\n" +
                      "    let id = \"" + MAPPING_INCOMING_ID + "\";\n" +
                      "    let group = \"things\";\n" +
                      "    let channel = \"twin\";\n" +
                      "    let criterion = \"commands\";\n" +
                      "    let action = \"modify\";\n" +
                      "    let path = \"" + MAPPING_INCOMING_PATH + "\";\n" +
                      "    let dittoHeaders = {};\n" +
                      "    dittoHeaders[\"correlation-id\"] = headers[\"correlation-id\"];\n" +
                      "    let value = textPayload;\n" +
                      "    let status = 204;\n" +
                      "    // ###\n" +
                      "\n" +
                      "    return Ditto.buildDittoProtocolMsg(\n" +
                      "        namespace,\n" +
                      "        id,\n" +
                      "        group,\n" +
                      "        channel,\n" +
                      "        criterion,\n" +
                      "        action,\n" +
                      "        path,\n" +
                      "        dittoHeaders,\n" +
                      "        value,\n" +
                      "        status\n" +
                      "    );\n" +
                      "}"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_INCOMING_WITH_STATUS =
              "function mapToDittoProtocolMsg(\n" +
                      "    headers,\n" +
                      "    textPayload,\n" +
                      "    bytePayload,\n" +
                      "    contentType\n" +
                      ") {\n" +
                      "\n" +
                      "    // ###\n" +
                      "    // Insert your mapping logic here\n" +
                      "    let namespace = \"" + MAPPING_INCOMING_NAMESPACE + "\";\n" +
                      "    let id = \"" + MAPPING_INCOMING_ID + "\";\n" +
                      "    let group = \"things\";\n" +
                      "    let channel = \"twin\";\n" +
                      "    let criterion = \"commands\";\n" +
                      "    let action = \"modify\";\n" +
                      "    let path = \"" + MAPPING_INCOMING_PATH + "\";\n" +
                      "    let dittoHeaders = {};\n" +
                      "    dittoHeaders[\"correlation-id\"] = headers[\"correlation-id\"];\n" +
                      "    let value = textPayload;\n" +
                      "    let status = 204;\n" +
                      "    // ###\n" +
                      "\n" +
                      "    return Ditto.buildDittoProtocolMsg(\n" +
                      "        namespace,\n" +
                      "        id,\n" +
                      "        group,\n" +
                      "        channel,\n" +
                      "        criterion,\n" +
                      "        action,\n" +
                      "        path,\n" +
                      "        dittoHeaders,\n" +
                      "        value,\n" +
                      "        status\n" +
                      "    );\n" +
                      "}";
test_class.type: String
test_class.var_name: MAPPING_INCOMING_WITH_STATUS
test_class.declarator: MAPPING_INCOMING_WITH_STATUS_AND_EXTRA =
              "function mapToDittoProtocolMsg(\n" +
                      "    headers,\n" +
                      "    textPayload,\n" +
                      "    bytePayload,\n" +
                      "    contentType\n" +
                      ") {\n" +
                      "\n" +
                      "    // ###\n" +
                      "    // Insert your mapping logic here\n" +
                      "    let namespace = \"" + MAPPING_INCOMING_NAMESPACE + "\";\n" +
                      "    let id = \"" + MAPPING_INCOMING_ID + "\";\n" +
                      "    let group = \"things\";\n" +
                      "    let channel = \"twin\";\n" +
                      "    let criterion = \"commands\";\n" +
                      "    let action = \"modify\";\n" +
                      "    let path = \"" + MAPPING_INCOMING_PATH + "\";\n" +
                      "    let dittoHeaders = {};\n" +
                      "    dittoHeaders[\"correlation-id\"] = headers[\"correlation-id\"];\n" +
                      "    let value = textPayload;\n" +
                      "    let status = 204;\n" +
                      "    let extra = {};\n" +
                      "    extra.attributes = {};\n" +
                      "    extra.attributes.enriched = 'field';\n" +
                      "    // ###\n" +
                      "\n" +
                      "    return Ditto.buildDittoProtocolMsg(\n" +
                      "        namespace,\n" +
                      "        id,\n" +
                      "        group,\n" +
                      "        channel,\n" +
                      "        criterion,\n" +
                      "        action,\n" +
                      "        path,\n" +
                      "        dittoHeaders,\n" +
                      "        value,\n" +
                      "        status,\n" +
                      "        extra\n" +
                      "    );\n" +
                      "}"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_INCOMING_WITH_STATUS_AND_EXTRA =
              "function mapToDittoProtocolMsg(\n" +
                      "    headers,\n" +
                      "    textPayload,\n" +
                      "    bytePayload,\n" +
                      "    contentType\n" +
                      ") {\n" +
                      "\n" +
                      "    // ###\n" +
                      "    // Insert your mapping logic here\n" +
                      "    let namespace = \"" + MAPPING_INCOMING_NAMESPACE + "\";\n" +
                      "    let id = \"" + MAPPING_INCOMING_ID + "\";\n" +
                      "    let group = \"things\";\n" +
                      "    let channel = \"twin\";\n" +
                      "    let criterion = \"commands\";\n" +
                      "    let action = \"modify\";\n" +
                      "    let path = \"" + MAPPING_INCOMING_PATH + "\";\n" +
                      "    let dittoHeaders = {};\n" +
                      "    dittoHeaders[\"correlation-id\"] = headers[\"correlation-id\"];\n" +
                      "    let value = textPayload;\n" +
                      "    let status = 204;\n" +
                      "    let extra = {};\n" +
                      "    extra.attributes = {};\n" +
                      "    extra.attributes.enriched = 'field';\n" +
                      "    // ###\n" +
                      "\n" +
                      "    return Ditto.buildDittoProtocolMsg(\n" +
                      "        namespace,\n" +
                      "        id,\n" +
                      "        group,\n" +
                      "        channel,\n" +
                      "        criterion,\n" +
                      "        action,\n" +
                      "        path,\n" +
                      "        dittoHeaders,\n" +
                      "        value,\n" +
                      "        status,\n" +
                      "        extra\n" +
                      "    );\n" +
                      "}";
test_class.type: String
test_class.var_name: MAPPING_INCOMING_WITH_STATUS_AND_EXTRA
test_class.declarator: MAPPING_INCOMING_DEFAULT = "function mapToDittoProtocolMsg(\n" +
              "  headers,\n" +
              "  textPayload,\n" +
              "  bytePayload,\n" +
              "  contentType\n" +
              ") {\n" +
              "\n" +
              "  // ###\n" +
              "  // Insert your mapping logic here:\n" +
              "  if (contentType === 'application/vnd.eclipse.ditto+json') {\n" +
              "    let dittoProtocolMsg = JSON.parse(textPayload);\n" +
              "    Object.assign(dittoProtocolMsg.headers, headers);\n" +
              "    return dittoProtocolMsg;\n" +
              "  }\n" +
              "  if (headers) {\n" +
              "    return null; // returning 'null' means that the message will be dropped\n" +
              "    // TODO replace with something useful\n" +
              "  }\n" +
              "  // ###\n" +
              "\n" +
              "  return Ditto.buildDittoProtocolMsg(\n" +
              "    namespace, // The namespace of the entity in java package notation, e.g.: \"org.eclipse.ditto\"\n" +
              "    id, // The ID of the entity\n" +
              "    group, // The affected group/entity, one of: \"things\"\n" +
              "    channel, // The channel for the signal, one of: \"twin\"|\"live\"\n" +
              "    criterion, // The criterion to apply, one of: \"commands\"|\"events\"|\"search\"|\"messages\"|\"errors\"\n" +
              "    action, // The action to perform, one of: \"create\"|\"retrieve\"|\"modify\"|\"delete\"\n" +
              "    path, // The path which is affected by the message, e.g.: \"/attributes\"\n" +
              "    dittoHeaders, // The headers Object containing all Ditto Protocol header values\n" +
              "    value, // The value to apply / which was applied (e.g. in a \"modify\" action)\n" +
              "    status, // The status code that indicates the result of the command\n" +
              "    extra // The enriched extra fields\n" +
              "  );\n" +
              "}\n"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_INCOMING_DEFAULT = "function mapToDittoProtocolMsg(\n" +
              "  headers,\n" +
              "  textPayload,\n" +
              "  bytePayload,\n" +
              "  contentType\n" +
              ") {\n" +
              "\n" +
              "  // ###\n" +
              "  // Insert your mapping logic here:\n" +
              "  if (contentType === 'application/vnd.eclipse.ditto+json') {\n" +
              "    let dittoProtocolMsg = JSON.parse(textPayload);\n" +
              "    Object.assign(dittoProtocolMsg.headers, headers);\n" +
              "    return dittoProtocolMsg;\n" +
              "  }\n" +
              "  if (headers) {\n" +
              "    return null; // returning 'null' means that the message will be dropped\n" +
              "    // TODO replace with something useful\n" +
              "  }\n" +
              "  // ###\n" +
              "\n" +
              "  return Ditto.buildDittoProtocolMsg(\n" +
              "    namespace, // The namespace of the entity in java package notation, e.g.: \"org.eclipse.ditto\"\n" +
              "    id, // The ID of the entity\n" +
              "    group, // The affected group/entity, one of: \"things\"\n" +
              "    channel, // The channel for the signal, one of: \"twin\"|\"live\"\n" +
              "    criterion, // The criterion to apply, one of: \"commands\"|\"events\"|\"search\"|\"messages\"|\"errors\"\n" +
              "    action, // The action to perform, one of: \"create\"|\"retrieve\"|\"modify\"|\"delete\"\n" +
              "    path, // The path which is affected by the message, e.g.: \"/attributes\"\n" +
              "    dittoHeaders, // The headers Object containing all Ditto Protocol header values\n" +
              "    value, // The value to apply / which was applied (e.g. in a \"modify\" action)\n" +
              "    status, // The status code that indicates the result of the command\n" +
              "    extra // The enriched extra fields\n" +
              "  );\n" +
              "}\n";
test_class.type: String
test_class.var_name: MAPPING_INCOMING_DEFAULT
test_class.declarator: MAPPING_OUTGOING_DEFAULT = "function mapFromDittoProtocolMsg(\n" +
              "  namespace,\n" +
              "  id,\n" +
              "  group,\n" +
              "  channel,\n" +
              "  criterion,\n" +
              "  action,\n" +
              "  path,\n" +
              "  dittoHeaders,\n" +
              "  value,\n" +
              "  status,\n" +
              "  extra\n" +
              ") {\n" +
              "\n" +
              "  // ###\n" +
              "  // Insert your mapping logic here:\n" +
              "  let headers = dittoHeaders;\n" +
              "  let textPayload = JSON.stringify(Ditto.buildDittoProtocolMsg(namespace, id, group, channel, criterion, action, path, dittoHeaders, value, status));\n" +
              "  // TODO replace with something useful, this will publish the message in Ditto Protocol JSON\n" +
              "  let bytePayload = null;\n" +
              "  let contentType = 'application/vnd.eclipse.ditto+json';\n" +
              "  // ###\n" +
              "\n" +
              "  return Ditto.buildExternalMsg(\n" +
              "    headers, // The external headers Object containing header values\n" +
              "    textPayload, // The external mapped String\n" +
              "    bytePayload, // The external mapped byte[]\n" +
              "    contentType // The returned Content-Type\n" +
              "  );\n" +
              "}\n"
test_class.modifier: private static final
test_class.original_string: private static final String MAPPING_OUTGOING_DEFAULT = "function mapFromDittoProtocolMsg(\n" +
              "  namespace,\n" +
              "  id,\n" +
              "  group,\n" +
              "  channel,\n" +
              "  criterion,\n" +
              "  action,\n" +
              "  path,\n" +
              "  dittoHeaders,\n" +
              "  value,\n" +
              "  status,\n" +
              "  extra\n" +
              ") {\n" +
              "\n" +
              "  // ###\n" +
              "  // Insert your mapping logic here:\n" +
              "  let headers = dittoHeaders;\n" +
              "  let textPayload = JSON.stringify(Ditto.buildDittoProtocolMsg(namespace, id, group, channel, criterion, action, path, dittoHeaders, value, status));\n" +
              "  // TODO replace with something useful, this will publish the message in Ditto Protocol JSON\n" +
              "  let bytePayload = null;\n" +
              "  let contentType = 'application/vnd.eclipse.ditto+json';\n" +
              "  // ###\n" +
              "\n" +
              "  return Ditto.buildExternalMsg(\n" +
              "    headers, // The external headers Object containing header values\n" +
              "    textPayload, // The external mapped String\n" +
              "    bytePayload, // The external mapped byte[]\n" +
              "    contentType // The returned Content-Type\n" +
              "  );\n" +
              "}\n";
test_class.type: String
test_class.var_name: MAPPING_OUTGOING_DEFAULT
test_class.declarator: javaScriptRhinoMapperNoop
test_class.modifier: private static
test_class.original_string: private static MessageMapper javaScriptRhinoMapperNoop;
test_class.type: MessageMapper
test_class.var_name: javaScriptRhinoMapperNoop
test_class.declarator: javaScriptRhinoMapperPlain
test_class.modifier: private static
test_class.original_string: private static MessageMapper javaScriptRhinoMapperPlain;
test_class.type: MessageMapper
test_class.var_name: javaScriptRhinoMapperPlain
test_class.declarator: javaScriptRhinoMapperPlainWithStatus
test_class.modifier: private static
test_class.original_string: private static MessageMapper javaScriptRhinoMapperPlainWithStatus;
test_class.type: MessageMapper
test_class.var_name: javaScriptRhinoMapperPlainWithStatus
test_class.declarator: javaScriptRhinoMapperPlainWithStatusAndExtra
test_class.modifier: private static
test_class.original_string: private static MessageMapper javaScriptRhinoMapperPlainWithStatusAndExtra;
test_class.type: MessageMapper
test_class.var_name: javaScriptRhinoMapperPlainWithStatusAndExtra
test_class.declarator: javaScriptRhinoMapperEmpty
test_class.modifier: private static
test_class.original_string: private static MessageMapper javaScriptRhinoMapperEmpty;
test_class.type: MessageMapper
test_class.var_name: javaScriptRhinoMapperEmpty
test_class.declarator: javaScriptRhinoMapperBinary
test_class.modifier: private static
test_class.original_string: private static MessageMapper javaScriptRhinoMapperBinary;
test_class.type: MessageMapper
test_class.var_name: javaScriptRhinoMapperBinary
test_class.declarator: javaScriptRhinoMapperDefault
test_class.modifier: private static
test_class.original_string: private static MessageMapper javaScriptRhinoMapperDefault;
test_class.type: MessageMapper
test_class.var_name: javaScriptRhinoMapperDefault
test_class.file: services/connectivity/mapping/src/test/java/org/eclipse/ditto/services/connectivity/mapping/javascript/JavaScriptMessageMapperRhinoTest.java
test_class.identifier: JavaScriptMessageMapperRhinoTest
test_case.body: @Test
      public void testPlainJavascriptIncomingMappingWithStatus() {
          final String correlationId = UUID.randomUUID().toString();
          final Map<String, String> headers = new HashMap<>();
          headers.put(HEADER_CORRELATION_ID, correlationId);
          headers.put(ExternalMessage.CONTENT_TYPE_HEADER, CONTENT_TYPE_PLAIN);
          final ThingId thingId = ThingId.of("org.eclipse.ditto:foo-bar-plain");
          final ModifyThingResponse modifyThingResponse = ModifyThingResponse.modified(thingId, DittoHeaders.newBuilder()
                  .correlationId(correlationId)
                  .putHeader("subject", "{{topic:action-subject}}")
                  .build());
          final ExternalMessage message = ExternalMessageFactory.newExternalMessageBuilder(headers)
                  .withText(modifyThingResponse.toJsonString())
                  .build();
  
  
          final long startTs = System.nanoTime();
          final List<Adaptable> adaptables = javaScriptRhinoMapperPlainWithStatus.map(message);
          final Adaptable adaptable = adaptables.get(0);
          System.out.println(adaptable);
          System.out.println(
                  "testPlainJavascriptIncomingMapping Duration: " + (System.nanoTime() - startTs) / 1000000.0 + "ms");
  
          assertThat(adaptable.getTopicPath().getChannel()).isEqualTo(TopicPath.Channel.TWIN);
          assertThat(adaptable.getTopicPath().getCriterion()).isEqualTo(TopicPath.Criterion.COMMANDS);
          assertThat(adaptable.getTopicPath().getAction()).contains(TopicPath.Action.MODIFY);
          assertThat(adaptable.getTopicPath().getNamespace()).isEqualTo(MAPPING_INCOMING_NAMESPACE);
          assertThat(adaptable.getTopicPath().getId()).isEqualTo(MAPPING_INCOMING_ID);
          assertThat(adaptable.getPayload().getPath().toString()).isEqualTo(MAPPING_INCOMING_PATH);
          assertThat(adaptable.getPayload().getValue()).map(JsonValue::asString).contains(modifyThingResponse.toJsonString());
          assertThat(adaptable.getPayload().getStatus()).contains(HttpStatusCode.NO_CONTENT);
      }
test_case.class_method_signature: JavaScriptMessageMapperRhinoTest.testPlainJavascriptIncomingMappingWithStatus()
test_case.full_signature: @Test public void testPlainJavascriptIncomingMappingWithStatus()
test_case.identifier: testPlainJavascriptIncomingMappingWithStatus
test_case.invocations: toString randomUUID put put of modified build putHeader correlationId newBuilder build withText newExternalMessageBuilder toJsonString nanoTime map get println println nanoTime isEqualTo assertThat getChannel getTopicPath isEqualTo assertThat getCriterion getTopicPath contains assertThat getAction getTopicPath isEqualTo assertThat getNamespace getTopicPath isEqualTo assertThat getId getTopicPath isEqualTo assertThat toString getPath getPayload contains map assertThat getValue getPayload toJsonString contains assertThat getStatus getPayload
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void testPlainJavascriptIncomingMappingWithStatus()
focal_class.declarator: WEBJARS_PATH = "/META-INF/resources/webjars"
focal_class.modifier: private static final
focal_class.original_string: private static final String WEBJARS_PATH = "/META-INF/resources/webjars";
focal_class.type: String
focal_class.var_name: WEBJARS_PATH
focal_class.declarator: WEBJARS_BYTEBUFFER = WEBJARS_PATH + "/bytebuffer/5.0.1/dist/bytebuffer.js"
focal_class.modifier: private static final
focal_class.original_string: private static final String WEBJARS_BYTEBUFFER = WEBJARS_PATH + "/bytebuffer/5.0.1/dist/bytebuffer.js";
focal_class.type: String
focal_class.var_name: WEBJARS_BYTEBUFFER
focal_class.declarator: WEBJARS_LONG = WEBJARS_PATH + "/long/3.2.0/dist/long.min.js"
focal_class.modifier: private static final
focal_class.original_string: private static final String WEBJARS_LONG = WEBJARS_PATH + "/long/3.2.0/dist/long.min.js";
focal_class.type: String
focal_class.var_name: WEBJARS_LONG
focal_class.declarator: DITTO_SCOPE_SCRIPT = "/javascript/ditto-scope.js"
focal_class.modifier: static final
focal_class.original_string: static final String DITTO_SCOPE_SCRIPT = "/javascript/ditto-scope.js";
focal_class.type: String
focal_class.var_name: DITTO_SCOPE_SCRIPT
focal_class.declarator: INCOMING_SCRIPT = "/javascript/incoming-mapping.js"
focal_class.modifier: static final
focal_class.original_string: static final String INCOMING_SCRIPT = "/javascript/incoming-mapping.js";
focal_class.type: String
focal_class.var_name: INCOMING_SCRIPT
focal_class.declarator: OUTGOING_SCRIPT = "/javascript/outgoing-mapping.js"
focal_class.modifier: static final
focal_class.original_string: static final String OUTGOING_SCRIPT = "/javascript/outgoing-mapping.js";
focal_class.type: String
focal_class.var_name: OUTGOING_SCRIPT
focal_class.declarator: contextFactory
focal_class.modifier: @Nullable private
focal_class.original_string: @Nullable private ContextFactory contextFactory;
focal_class.type: ContextFactory
focal_class.var_name: contextFactory
focal_class.declarator: configuration
focal_class.modifier: @Nullable private
focal_class.original_string: @Nullable private JavaScriptMessageMapperConfiguration configuration;
focal_class.type: JavaScriptMessageMapperConfiguration
focal_class.var_name: configuration
focal_class.declarator: incomingMapping = DefaultIncomingMapping.get()
focal_class.modifier: private
focal_class.original_string: private MappingFunction<ExternalMessage, List<Adaptable>> incomingMapping = DefaultIncomingMapping.get();
focal_class.type: MappingFunction<ExternalMessage, List<Adaptable>>
focal_class.var_name: incomingMapping
focal_class.declarator: outgoingMapping = DefaultOutgoingMapping.get()
focal_class.modifier: private
focal_class.original_string: private MappingFunction<Adaptable, List<ExternalMessage>> outgoingMapping = DefaultOutgoingMapping.get();
focal_class.type: MappingFunction<Adaptable, List<ExternalMessage>>
focal_class.var_name: outgoingMapping
focal_class.file: services/connectivity/mapping/src/main/java/org/eclipse/ditto/services/connectivity/mapping/javascript/JavaScriptMessageMapperRhino.java
focal_class.identifier: JavaScriptMessageMapperRhino
focal_class.class_method_signature: JavaScriptMessageMapperRhino.JavaScriptMessageMapperRhino()
focal_class.full_signature:   JavaScriptMessageMapperRhino()
focal_class.identifier: JavaScriptMessageMapperRhino
focal_class.parameters: ()
focal_class.signature:  JavaScriptMessageMapperRhino()
focal_class.class_method_signature: JavaScriptMessageMapperRhino.doConfigure(final MappingConfig mappingConfig, final MessageMapperConfiguration options)
focal_class.full_signature: @Override public void doConfigure(final MappingConfig mappingConfig, final MessageMapperConfiguration options)
focal_class.identifier: doConfigure
focal_class.modifiers: @Override public
focal_class.parameters: (final MappingConfig mappingConfig, final MessageMapperConfiguration options)
focal_class.return: void
focal_class.signature: void doConfigure(final MappingConfig mappingConfig, final MessageMapperConfiguration options)
focal_class.class_method_signature: JavaScriptMessageMapperRhino.map(final ExternalMessage message)
focal_class.full_signature: @Override public List<Adaptable> map(final ExternalMessage message)
focal_class.identifier: map
focal_class.modifiers: @Override public
focal_class.parameters: (final ExternalMessage message)
focal_class.return: List<Adaptable>
focal_class.signature: List<Adaptable> map(final ExternalMessage message)
focal_class.class_method_signature: JavaScriptMessageMapperRhino.map(final Adaptable adaptable)
focal_class.full_signature: @Override public List<ExternalMessage> map(final Adaptable adaptable)
focal_class.identifier: map
focal_class.modifiers: @Override public
focal_class.parameters: (final Adaptable adaptable)
focal_class.return: List<ExternalMessage>
focal_class.signature: List<ExternalMessage> map(final Adaptable adaptable)
focal_class.class_method_signature: JavaScriptMessageMapperRhino.initLibraries(final Context cx, final Scriptable scope)
focal_class.full_signature: private void initLibraries(final Context cx, final Scriptable scope)
focal_class.identifier: initLibraries
focal_class.modifiers: private
focal_class.parameters: (final Context cx, final Scriptable scope)
focal_class.return: void
focal_class.signature: void initLibraries(final Context cx, final Scriptable scope)
focal_class.class_method_signature: JavaScriptMessageMapperRhino.getConfiguration()
focal_class.full_signature: private Optional<JavaScriptMessageMapperConfiguration> getConfiguration()
focal_class.identifier: getConfiguration
focal_class.modifiers: private
focal_class.parameters: ()
focal_class.return: Optional<JavaScriptMessageMapperConfiguration>
focal_class.signature: Optional<JavaScriptMessageMapperConfiguration> getConfiguration()
focal_class.class_method_signature: JavaScriptMessageMapperRhino.loadJavascriptLibrary(final Context cx,
              final Scriptable scope,
              final Reader reader,
              final String libraryName)
focal_class.full_signature: static void loadJavascriptLibrary(final Context cx,
              final Scriptable scope,
              final Reader reader,
              final String libraryName)
focal_class.identifier: loadJavascriptLibrary
focal_class.modifiers: static
focal_class.parameters: (final Context cx,
              final Scriptable scope,
              final Reader reader,
              final String libraryName)
focal_class.return: void
focal_class.signature: void loadJavascriptLibrary(final Context cx,
              final Scriptable scope,
              final Reader reader,
              final String libraryName)
focal_class.superclass: extends AbstractMessageMapper
focal_method.body: @Override
      public List<Adaptable> map(final ExternalMessage message) {
          return incomingMapping.apply(message);
      }
focal_method.class_method_signature: JavaScriptMessageMapperRhino.map(final ExternalMessage message)
focal_method.full_signature: @Override public List<Adaptable> map(final ExternalMessage message)
focal_method.identifier: map
focal_method.invocations: apply
focal_method.modifiers: @Override public
focal_method.parameters: (final ExternalMessage message)
focal_method.return: List<Adaptable>
focal_method.signature: List<Adaptable> map(final ExternalMessage message)