test_class.declarator: THING_ID = ThingId.of("thing:id")
test_class.modifier: private static final
test_class.original_string: private static final ThingId THING_ID = ThingId.of("thing:id");
test_class.type: ThingId
test_class.var_name: THING_ID
test_class.declarator: ADAPTER = DittoProtocolAdapter.newInstance()
test_class.modifier: private static final
test_class.original_string: private static final ProtocolAdapter ADAPTER = DittoProtocolAdapter.newInstance();
test_class.type: ProtocolAdapter
test_class.var_name: ADAPTER
test_class.declarator: underTest
test_class.modifier: private
test_class.original_string: private MessageMapper underTest;
test_class.type: MessageMapper
test_class.var_name: underTest
test_class.file: services/connectivity/mapping/src/test/java/org/eclipse/ditto/services/connectivity/mapping/RawMessageMapperTest.java
test_class.identifier: RawMessageMapperTest
test_case.body: @Test
      public void mapToTextMessageWithContentTypeOverride() {
          final Map<String, String> headers = Map.of(
                  "content-type", "application/octet-stream",
                  "ditto-message-subject", "hello/world",
                  "ditto-message-thing-id", "thing:id"
          );
          final String payload = "lorem ipsum dolor sit amet";
          underTest.configure(DefaultMappingConfig.of(ConfigFactory.empty()),
                  DefaultMessageMapperConfiguration.of("RawMessage",
                          Map.of("incomingMessageHeaders", JsonObject.newBuilder()
                                  .set("content-type", "text/plain")
                                  .build()
                          ), Map.of(), Map.of()));
          final List<Adaptable> adaptables =
                  underTest.map(ExternalMessageFactory.newExternalMessageBuilder(headers)
                          .withBytes(payload.getBytes())
                          .build());
          assertThat(adaptables).hasSize(1);
          final Signal<?> signal = ADAPTER.fromAdaptable(adaptables.get(0));
          assertThat(signal).isInstanceOf(SendThingMessage.class);
          final SendThingMessage<?> sendThingMessage = (SendThingMessage<?>) signal;
          assertThat(sendThingMessage.getEntityId().toString()).isEqualTo("thing:id");
          assertThat(sendThingMessage.getMessage().getPayload().orElseThrow()).isEqualTo(payload);
      }
test_case.class_method_signature: RawMessageMapperTest.mapToTextMessageWithContentTypeOverride()
test_case.full_signature: @Test public void mapToTextMessageWithContentTypeOverride()
test_case.identifier: mapToTextMessageWithContentTypeOverride
test_case.invocations: of configure of empty of of build set newBuilder of of map build withBytes newExternalMessageBuilder getBytes hasSize assertThat fromAdaptable get isInstanceOf assertThat isEqualTo assertThat toString getEntityId isEqualTo assertThat orElseThrow getPayload getMessage
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void mapToTextMessageWithContentTypeOverride()
focal_class.declarator: MESSAGES_JSON_KEY = JsonKey.of("messages")
focal_class.modifier: private static final
focal_class.original_string: private static final JsonKey MESSAGES_JSON_KEY = JsonKey.of("messages");
focal_class.type: JsonKey
focal_class.var_name: MESSAGES_JSON_KEY
focal_class.declarator: OUTGOING_CONTENT_TYPE_KEY = "outgoingContentType"
focal_class.modifier: private static final
focal_class.original_string: private static final String OUTGOING_CONTENT_TYPE_KEY = "outgoingContentType";
focal_class.type: String
focal_class.var_name: OUTGOING_CONTENT_TYPE_KEY
focal_class.declarator: INCOMING_MESSAGE_HEADERS = "incomingMessageHeaders"
focal_class.modifier: private static final
focal_class.original_string: private static final String INCOMING_MESSAGE_HEADERS = "incomingMessageHeaders";
focal_class.type: String
focal_class.var_name: INCOMING_MESSAGE_HEADERS
focal_class.declarator: DEFAULT_OUTGOING_CONTENT_TYPE =
              ContentType.of(ContentTypes.TEXT_PLAIN_UTF8.toString())
focal_class.modifier: private static final
focal_class.original_string: private static final ContentType DEFAULT_OUTGOING_CONTENT_TYPE =
              ContentType.of(ContentTypes.TEXT_PLAIN_UTF8.toString());
focal_class.type: ContentType
focal_class.var_name: DEFAULT_OUTGOING_CONTENT_TYPE
focal_class.declarator: DEFAULT_INCOMING_HEADERS = Map.of(
              DittoHeaderDefinition.CONTENT_TYPE.getKey(),
              getFromHeaderOrDefault(DittoHeaderDefinition.CONTENT_TYPE.getKey(),
                      ContentTypes.APPLICATION_OCTET_STREAM.toString()),
              MessageHeaderDefinition.DIRECTION.getKey(),
              getFromHeaderOrDefault(MessageHeaderDefinition.DIRECTION.getKey(), MessageDirection.TO.toString()),
              MessageHeaderDefinition.THING_ID.getKey(), asPlaceholder(MessageHeaderDefinition.THING_ID),
              MessageHeaderDefinition.SUBJECT.getKey(), asPlaceholder(MessageHeaderDefinition.SUBJECT),
              MessageHeaderDefinition.STATUS_CODE.getKey(), asPlaceholder(MessageHeaderDefinition.STATUS_CODE),
              MessageHeaderDefinition.FEATURE_ID.getKey(), asPlaceholder(MessageHeaderDefinition.FEATURE_ID)
      )
focal_class.modifier: private static final
focal_class.original_string: private static final Map<String, String> DEFAULT_INCOMING_HEADERS = Map.of(
              DittoHeaderDefinition.CONTENT_TYPE.getKey(),
              getFromHeaderOrDefault(DittoHeaderDefinition.CONTENT_TYPE.getKey(),
                      ContentTypes.APPLICATION_OCTET_STREAM.toString()),
              MessageHeaderDefinition.DIRECTION.getKey(),
              getFromHeaderOrDefault(MessageHeaderDefinition.DIRECTION.getKey(), MessageDirection.TO.toString()),
              MessageHeaderDefinition.THING_ID.getKey(), asPlaceholder(MessageHeaderDefinition.THING_ID),
              MessageHeaderDefinition.SUBJECT.getKey(), asPlaceholder(MessageHeaderDefinition.SUBJECT),
              MessageHeaderDefinition.STATUS_CODE.getKey(), asPlaceholder(MessageHeaderDefinition.STATUS_CODE),
              MessageHeaderDefinition.FEATURE_ID.getKey(), asPlaceholder(MessageHeaderDefinition.FEATURE_ID)
      );
focal_class.type: Map<String, String>
focal_class.var_name: DEFAULT_INCOMING_HEADERS
focal_class.declarator: DEFAULT_CONFIG = DittoMessageMapper.DEFAULT_OPTIONS.toBuilder()
              .set(OUTGOING_CONTENT_TYPE_KEY, DEFAULT_OUTGOING_CONTENT_TYPE.getValue())
              .set(INCOMING_MESSAGE_HEADERS, DEFAULT_INCOMING_HEADERS.entrySet()
                      .stream()
                      .map(entry -> JsonField.newInstance(entry.getKey(), JsonValue.of(entry.getValue())))
                      .collect(JsonCollectors.fieldsToObject()))
              .build()
focal_class.modifier: private static final
focal_class.original_string: private static final JsonObject DEFAULT_CONFIG = DittoMessageMapper.DEFAULT_OPTIONS.toBuilder()
              .set(OUTGOING_CONTENT_TYPE_KEY, DEFAULT_OUTGOING_CONTENT_TYPE.getValue())
              .set(INCOMING_MESSAGE_HEADERS, DEFAULT_INCOMING_HEADERS.entrySet()
                      .stream()
                      .map(entry -> JsonField.newInstance(entry.getKey(), JsonValue.of(entry.getValue())))
                      .collect(JsonCollectors.fieldsToObject()))
              .build();
focal_class.type: JsonObject
focal_class.var_name: DEFAULT_CONFIG
focal_class.declarator: fallbackOutgoingContentType = DEFAULT_OUTGOING_CONTENT_TYPE
focal_class.modifier: private
focal_class.original_string: private ContentType fallbackOutgoingContentType = DEFAULT_OUTGOING_CONTENT_TYPE;
focal_class.type: ContentType
focal_class.var_name: fallbackOutgoingContentType
focal_class.declarator: incomingMessageHeaders = DEFAULT_INCOMING_HEADERS
focal_class.modifier: private
focal_class.original_string: private Map<String, String> incomingMessageHeaders = DEFAULT_INCOMING_HEADERS;
focal_class.type: Map<String, String>
focal_class.var_name: incomingMessageHeaders
focal_class.declarator: dittoMessageMapper = new DittoMessageMapper()
focal_class.modifier: private final
focal_class.original_string: private final DittoMessageMapper dittoMessageMapper = new DittoMessageMapper();
focal_class.type: DittoMessageMapper
focal_class.var_name: dittoMessageMapper
focal_class.declarator: CONTEXT = ConnectivityModelFactory.newMappingContext(
              RawMessageMapper.class.getCanonicalName(),
              DEFAULT_CONFIG
      )
focal_class.modifier: public static final
focal_class.original_string: public static final MappingContext CONTEXT = ConnectivityModelFactory.newMappingContext(
              RawMessageMapper.class.getCanonicalName(),
              DEFAULT_CONFIG
      );
focal_class.type: MappingContext
focal_class.var_name: CONTEXT
focal_class.file: services/connectivity/mapping/src/main/java/org/eclipse/ditto/services/connectivity/mapping/RawMessageMapper.java
focal_class.identifier: RawMessageMapper
focal_class.class_method_signature: RawMessageMapper.map(final ExternalMessage externalMessage)
focal_class.full_signature: @Override public List<Adaptable> map(final ExternalMessage externalMessage)
focal_class.identifier: map
focal_class.modifiers: @Override public
focal_class.parameters: (final ExternalMessage externalMessage)
focal_class.return: List<Adaptable>
focal_class.signature: List<Adaptable> map(final ExternalMessage externalMessage)
focal_class.class_method_signature: RawMessageMapper.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: RawMessageMapper.getDefaultOptions()
focal_class.full_signature: @Override public JsonObject getDefaultOptions()
focal_class.identifier: getDefaultOptions
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: JsonObject
focal_class.signature: JsonObject getDefaultOptions()
focal_class.class_method_signature: RawMessageMapper.doConfigure(final MappingConfig mappingConfig, final MessageMapperConfiguration configuration)
focal_class.full_signature: @Override protected void doConfigure(final MappingConfig mappingConfig, final MessageMapperConfiguration configuration)
focal_class.identifier: doConfigure
focal_class.modifiers: @Override protected
focal_class.parameters: (final MappingConfig mappingConfig, final MessageMapperConfiguration configuration)
focal_class.return: void
focal_class.signature: void doConfigure(final MappingConfig mappingConfig, final MessageMapperConfiguration configuration)
focal_class.class_method_signature: RawMessageMapper.toOutgoingText(final JsonValue value)
focal_class.full_signature: private static String toOutgoingText(final JsonValue value)
focal_class.identifier: toOutgoingText
focal_class.modifiers: private static
focal_class.parameters: (final JsonValue value)
focal_class.return: String
focal_class.signature: String toOutgoingText(final JsonValue value)
focal_class.class_method_signature: RawMessageMapper.toOutgoingBinary(final String base64Encoded)
focal_class.full_signature: private static Optional<byte[]> toOutgoingBinary(final String base64Encoded)
focal_class.identifier: toOutgoingBinary
focal_class.modifiers: private static
focal_class.parameters: (final String base64Encoded)
focal_class.return: Optional<byte[]>
focal_class.signature: Optional<byte[]> toOutgoingBinary(final String base64Encoded)
focal_class.class_method_signature: RawMessageMapper.badContentType(final String contentType, final DittoHeaders headers)
focal_class.full_signature: private static MessageFormatInvalidException badContentType(final String contentType, final DittoHeaders headers)
focal_class.identifier: badContentType
focal_class.modifiers: private static
focal_class.parameters: (final String contentType, final DittoHeaders headers)
focal_class.return: MessageFormatInvalidException
focal_class.signature: MessageFormatInvalidException badContentType(final String contentType, final DittoHeaders headers)
focal_class.class_method_signature: RawMessageMapper.isMessageCommandOrResponse(final Adaptable adaptable)
focal_class.full_signature: private static boolean isMessageCommandOrResponse(final Adaptable adaptable)
focal_class.identifier: isMessageCommandOrResponse
focal_class.modifiers: private static
focal_class.parameters: (final Adaptable adaptable)
focal_class.return: boolean
focal_class.signature: boolean isMessageCommandOrResponse(final Adaptable adaptable)
focal_class.class_method_signature: RawMessageMapper.asPlaceholder(final MessageHeaderDefinition messageHeaderDefinition)
focal_class.full_signature: private static String asPlaceholder(final MessageHeaderDefinition messageHeaderDefinition)
focal_class.identifier: asPlaceholder
focal_class.modifiers: private static
focal_class.parameters: (final MessageHeaderDefinition messageHeaderDefinition)
focal_class.return: String
focal_class.signature: String asPlaceholder(final MessageHeaderDefinition messageHeaderDefinition)
focal_class.class_method_signature: RawMessageMapper.getFromHeaderOrDefault(final String headerKey, final String defaultValue)
focal_class.full_signature: private static String getFromHeaderOrDefault(final String headerKey, final String defaultValue)
focal_class.identifier: getFromHeaderOrDefault
focal_class.modifiers: private static
focal_class.parameters: (final String headerKey, final String defaultValue)
focal_class.return: String
focal_class.signature: String getFromHeaderOrDefault(final String headerKey, final String defaultValue)
focal_class.class_method_signature: RawMessageMapper.evaluateOutgoingMessageHeaders(final Adaptable adaptable,
              @Nullable final ContentType contentType)
focal_class.full_signature: private static Map<String, String> evaluateOutgoingMessageHeaders(final Adaptable adaptable,
              @Nullable final ContentType contentType)
focal_class.identifier: evaluateOutgoingMessageHeaders
focal_class.modifiers: private static
focal_class.parameters: (final Adaptable adaptable,
              @Nullable final ContentType contentType)
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> evaluateOutgoingMessageHeaders(final Adaptable adaptable,
              @Nullable final ContentType contentType)
focal_class.class_method_signature: RawMessageMapper.evaluateIncomingMessageHeaders(final ExternalMessage externalMessage,
              final Map<String, String> incomingMessageHeaders)
focal_class.full_signature: private static Optional<MessageHeaders> evaluateIncomingMessageHeaders(final ExternalMessage externalMessage,
              final Map<String, String> incomingMessageHeaders)
focal_class.identifier: evaluateIncomingMessageHeaders
focal_class.modifiers: private static
focal_class.parameters: (final ExternalMessage externalMessage,
              final Map<String, String> incomingMessageHeaders)
focal_class.return: Optional<MessageHeaders>
focal_class.signature: Optional<MessageHeaders> evaluateIncomingMessageHeaders(final ExternalMessage externalMessage,
              final Map<String, String> incomingMessageHeaders)
focal_class.class_method_signature: RawMessageMapper.resolve(final ExpressionResolver expressionResolver,
              final Map<String, String> incomingMessageHeaders,
              final String messageHeader)
focal_class.full_signature: @Nullable private static String resolve(final ExpressionResolver expressionResolver,
              final Map<String, String> incomingMessageHeaders,
              final String messageHeader)
focal_class.identifier: resolve
focal_class.modifiers: @Nullable private static
focal_class.parameters: (final ExpressionResolver expressionResolver,
              final Map<String, String> incomingMessageHeaders,
              final String messageHeader)
focal_class.return: String
focal_class.signature: String resolve(final ExpressionResolver expressionResolver,
              final Map<String, String> incomingMessageHeaders,
              final String messageHeader)
focal_class.class_method_signature: RawMessageMapper.toTopicPath(final MessageHeaders messageHeaders)
focal_class.full_signature: private static TopicPath toTopicPath(final MessageHeaders messageHeaders)
focal_class.identifier: toTopicPath
focal_class.modifiers: private static
focal_class.parameters: (final MessageHeaders messageHeaders)
focal_class.return: TopicPath
focal_class.signature: TopicPath toTopicPath(final MessageHeaders messageHeaders)
focal_class.class_method_signature: RawMessageMapper.toPayload(final ExternalMessage externalMessage, final MessageHeaders messageHeaders)
focal_class.full_signature: private static Payload toPayload(final ExternalMessage externalMessage, final MessageHeaders messageHeaders)
focal_class.identifier: toPayload
focal_class.modifiers: private static
focal_class.parameters: (final ExternalMessage externalMessage, final MessageHeaders messageHeaders)
focal_class.return: Payload
focal_class.signature: Payload toPayload(final ExternalMessage externalMessage, final MessageHeaders messageHeaders)
focal_class.class_method_signature: RawMessageMapper.getPayloadValue(final ExternalMessage externalMessage,
              final ContentType contentType)
focal_class.full_signature: private static Optional<JsonValue> getPayloadValue(final ExternalMessage externalMessage,
              final ContentType contentType)
focal_class.identifier: getPayloadValue
focal_class.modifiers: private static
focal_class.parameters: (final ExternalMessage externalMessage,
              final ContentType contentType)
focal_class.return: Optional<JsonValue>
focal_class.signature: Optional<JsonValue> getPayloadValue(final ExternalMessage externalMessage,
              final ContentType contentType)
focal_class.class_method_signature: RawMessageMapper.retainContentTypeOnly(final MessageHeaders messageHeaders)
focal_class.full_signature: private static DittoHeaders retainContentTypeOnly(final MessageHeaders messageHeaders)
focal_class.identifier: retainContentTypeOnly
focal_class.modifiers: private static
focal_class.parameters: (final MessageHeaders messageHeaders)
focal_class.return: DittoHeaders
focal_class.signature: DittoHeaders retainContentTypeOnly(final MessageHeaders messageHeaders)
focal_class.class_method_signature: RawMessageMapper.toMessagePath(final MessageHeaders messageHeaders)
focal_class.full_signature: private static JsonPointer toMessagePath(final MessageHeaders messageHeaders)
focal_class.identifier: toMessagePath
focal_class.modifiers: private static
focal_class.parameters: (final MessageHeaders messageHeaders)
focal_class.return: JsonPointer
focal_class.signature: JsonPointer toMessagePath(final MessageHeaders messageHeaders)
focal_class.superclass: extends AbstractMessageMapper
focal_method.body: @Override
      public List<Adaptable> map(final ExternalMessage externalMessage) {
          final Optional<MessageHeaders> messageHeadersOptional =
                  evaluateIncomingMessageHeaders(externalMessage, incomingMessageHeaders);
          if (messageHeadersOptional.isEmpty()) {
              // message payload is a Ditto protocol message.
              return dittoMessageMapper.map(externalMessage);
          }
          final MessageHeaders messageHeaders = messageHeadersOptional.get();
          return List.of(ProtocolFactory.newAdaptableBuilder(toTopicPath(messageHeaders))
                  .withPayload(toPayload(externalMessage, messageHeaders))
                  .withHeaders(retainContentTypeOnly(messageHeaders))
                  .build());
      }
focal_method.class_method_signature: RawMessageMapper.map(final ExternalMessage externalMessage)
focal_method.full_signature: @Override public List<Adaptable> map(final ExternalMessage externalMessage)
focal_method.identifier: map
focal_method.invocations: evaluateIncomingMessageHeaders isEmpty map get of build withHeaders withPayload newAdaptableBuilder toTopicPath toPayload retainContentTypeOnly
focal_method.modifiers: @Override public
focal_method.parameters: (final ExternalMessage externalMessage)
focal_method.return: List<Adaptable>
focal_method.signature: List<Adaptable> map(final ExternalMessage externalMessage)