test_class.declarator: PAYLOAD = "payload"
test_class.modifier: private static final
test_class.original_string: private static final String PAYLOAD = "payload";
test_class.type: String
test_class.var_name: PAYLOAD
test_class.declarator: BYTES = PAYLOAD.getBytes()
test_class.modifier: private static final
test_class.original_string: private static final byte[] BYTES = PAYLOAD.getBytes();
test_class.type: byte[]
test_class.var_name: BYTES
test_class.file: services/connectivity/mapping/src/test/java/org/eclipse/ditto/services/connectivity/mapping/javascript/ScriptedIncomingMappingTest.java
test_class.identifier: ScriptedIncomingMappingTest
test_case.body: @Test
      public void mapExternalMessageTextAndBytes() {
          final ExternalMessage externalMessage = ExternalMessageFactory
                  .newExternalMessageBuilder(new HashMap<>())
                  .withTextAndBytes(PAYLOAD, ByteBuffer.wrap(BYTES))
                  .build();
  
          final NativeObject nativeObject = ScriptedIncomingMapping.mapExternalMessageToNativeObject(externalMessage);
  
          final String textPayload = (String) nativeObject.get("textPayload");
          final NativeArrayBuffer bytePayload = (NativeArrayBuffer) nativeObject.get("bytePayload");
          assertThat(textPayload).isEqualTo(PAYLOAD);
          assertThat(bytePayload.getBuffer()).isEqualTo(BYTES);
      }
test_case.class_method_signature: ScriptedIncomingMappingTest.mapExternalMessageTextAndBytes()
test_case.full_signature: @Test public void mapExternalMessageTextAndBytes()
test_case.identifier: mapExternalMessageTextAndBytes
test_case.invocations: build withTextAndBytes newExternalMessageBuilder wrap mapExternalMessageToNativeObject get get isEqualTo assertThat isEqualTo assertThat getBuffer
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void mapExternalMessageTextAndBytes()
focal_class.declarator: EXTERNAL_MESSAGE_HEADERS = "headers"
focal_class.modifier: private static final
focal_class.original_string: private static final String EXTERNAL_MESSAGE_HEADERS = "headers";
focal_class.type: String
focal_class.var_name: EXTERNAL_MESSAGE_HEADERS
focal_class.declarator: EXTERNAL_MESSAGE_CONTENT_TYPE = "contentType"
focal_class.modifier: private static final
focal_class.original_string: private static final String EXTERNAL_MESSAGE_CONTENT_TYPE = "contentType";
focal_class.type: String
focal_class.var_name: EXTERNAL_MESSAGE_CONTENT_TYPE
focal_class.declarator: EXTERNAL_MESSAGE_TEXT_PAYLOAD = "textPayload"
focal_class.modifier: private static final
focal_class.original_string: private static final String EXTERNAL_MESSAGE_TEXT_PAYLOAD = "textPayload";
focal_class.type: String
focal_class.var_name: EXTERNAL_MESSAGE_TEXT_PAYLOAD
focal_class.declarator: EXTERNAL_MESSAGE_BYTE_PAYLOAD = "bytePayload"
focal_class.modifier: private static final
focal_class.original_string: private static final String EXTERNAL_MESSAGE_BYTE_PAYLOAD = "bytePayload";
focal_class.type: String
focal_class.var_name: EXTERNAL_MESSAGE_BYTE_PAYLOAD
focal_class.declarator: INCOMING_FUNCTION_NAME = "mapToDittoProtocolMsgWrapper"
focal_class.modifier: private static final
focal_class.original_string: private static final String INCOMING_FUNCTION_NAME = "mapToDittoProtocolMsgWrapper";
focal_class.type: String
focal_class.var_name: INCOMING_FUNCTION_NAME
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: scope
focal_class.modifier: @Nullable
      private
focal_class.original_string: @Nullable
      private Scriptable scope;
focal_class.type: Scriptable
focal_class.var_name: scope
focal_class.file: services/connectivity/mapping/src/main/java/org/eclipse/ditto/services/connectivity/mapping/javascript/ScriptedIncomingMapping.java
focal_class.identifier: ScriptedIncomingMapping
focal_class.interfaces: implements MappingFunction<ExternalMessage, List<Adaptable>>
focal_class.class_method_signature: ScriptedIncomingMapping.ScriptedIncomingMapping(@Nullable final ContextFactory contextFactory, @Nullable final Scriptable scope)
focal_class.full_signature:   ScriptedIncomingMapping(@Nullable final ContextFactory contextFactory, @Nullable final Scriptable scope)
focal_class.identifier: ScriptedIncomingMapping
focal_class.parameters: (@Nullable final ContextFactory contextFactory, @Nullable final Scriptable scope)
focal_class.signature:  ScriptedIncomingMapping(@Nullable final ContextFactory contextFactory, @Nullable final Scriptable scope)
focal_class.class_method_signature: ScriptedIncomingMapping.apply(final ExternalMessage message)
focal_class.full_signature: @Override public List<Adaptable> apply(final ExternalMessage message)
focal_class.identifier: apply
focal_class.modifiers: @Override public
focal_class.parameters: (final ExternalMessage message)
focal_class.return: List<Adaptable>
focal_class.signature: List<Adaptable> apply(final ExternalMessage message)
focal_class.class_method_signature: ScriptedIncomingMapping.mapExternalMessageToNativeObject(final ExternalMessage message)
focal_class.full_signature: static NativeObject mapExternalMessageToNativeObject(final ExternalMessage message)
focal_class.identifier: mapExternalMessageToNativeObject
focal_class.modifiers: static
focal_class.parameters: (final ExternalMessage message)
focal_class.return: NativeObject
focal_class.signature: NativeObject mapExternalMessageToNativeObject(final ExternalMessage message)
focal_class.class_method_signature: ScriptedIncomingMapping.getAdaptableFromObject(final Context cx, final Object result)
focal_class.full_signature: private Adaptable getAdaptableFromObject(final Context cx, final Object result)
focal_class.identifier: getAdaptableFromObject
focal_class.modifiers: private
focal_class.parameters: (final Context cx, final Object result)
focal_class.return: Adaptable
focal_class.signature: Adaptable getAdaptableFromObject(final Context cx, final Object result)
focal_method.body: static NativeObject mapExternalMessageToNativeObject(final ExternalMessage message) {
          final NativeObject headersObj = new NativeObject();
          message.getHeaders().forEach((key, value) -> headersObj.put(key, headersObj, value));
  
          final NativeArrayBuffer bytePayload =
                  message.getBytePayload()
                          .map(bb -> {
                              final NativeArrayBuffer nativeArrayBuffer = new NativeArrayBuffer(bb.remaining());
                              bb.get(nativeArrayBuffer.getBuffer());
                              return nativeArrayBuffer;
                          })
                          .orElse(null);
  
          final String contentType = message.getHeaders().get(ExternalMessage.CONTENT_TYPE_HEADER);
          final String textPayload = message.getTextPayload().orElse(null);
  
          final NativeObject externalMessage = new NativeObject();
          externalMessage.put(EXTERNAL_MESSAGE_HEADERS, externalMessage, headersObj);
          externalMessage.put(EXTERNAL_MESSAGE_TEXT_PAYLOAD, externalMessage, textPayload);
          externalMessage.put(EXTERNAL_MESSAGE_BYTE_PAYLOAD, externalMessage, bytePayload);
          externalMessage.put(EXTERNAL_MESSAGE_CONTENT_TYPE, externalMessage, contentType);
          return externalMessage;
      }
focal_method.class_method_signature: ScriptedIncomingMapping.mapExternalMessageToNativeObject(final ExternalMessage message)
focal_method.full_signature: static NativeObject mapExternalMessageToNativeObject(final ExternalMessage message)
focal_method.identifier: mapExternalMessageToNativeObject
focal_method.invocations: forEach getHeaders put orElse map getBytePayload remaining get getBuffer get getHeaders orElse getTextPayload put put put put
focal_method.modifiers: static
focal_method.parameters: (final ExternalMessage message)
focal_method.return: NativeObject
focal_method.signature: NativeObject mapExternalMessageToNativeObject(final ExternalMessage message)