test_class.declarator: TYPE = ConnectionType.AMQP_10
test_class.modifier: private static final
test_class.original_string: private static final ConnectionType TYPE = ConnectionType.AMQP_10;
test_class.type: ConnectionType
test_class.var_name: TYPE
test_class.declarator: STATUS = ConnectivityStatus.OPEN
test_class.modifier: private static final
test_class.original_string: private static final ConnectivityStatus STATUS = ConnectivityStatus.OPEN;
test_class.type: ConnectivityStatus
test_class.var_name: STATUS
test_class.declarator: ID = ConnectionId.of("myConnectionId")
test_class.modifier: private static final
test_class.original_string: private static final ConnectionId ID = ConnectionId.of("myConnectionId");
test_class.type: ConnectionId
test_class.var_name: ID
test_class.declarator: NAME = "myConnection"
test_class.modifier: private static final
test_class.original_string: private static final String NAME = "myConnection";
test_class.type: String
test_class.var_name: NAME
test_class.declarator: URI = "amqps://foo:bar@example.com:443"
test_class.modifier: private static final
test_class.original_string: private static final String URI = "amqps://foo:bar@example.com:443";
test_class.type: String
test_class.var_name: URI
test_class.declarator: CREDENTIALS = ClientCertificateCredentials.newBuilder().build()
test_class.modifier: private static final
test_class.original_string: private static final Credentials CREDENTIALS = ClientCertificateCredentials.newBuilder().build();
test_class.type: Credentials
test_class.var_name: CREDENTIALS
test_class.declarator: AUTHORIZATION_CONTEXT =
              AuthorizationContext.newInstance(DittoAuthorizationContextType.PRE_AUTHENTICATED_CONNECTION,
                      AuthorizationSubject.newInstance("myIssuer:mySubject"))
test_class.modifier: private static final
test_class.original_string: private static final AuthorizationContext AUTHORIZATION_CONTEXT =
              AuthorizationContext.newInstance(DittoAuthorizationContextType.PRE_AUTHENTICATED_CONNECTION,
                      AuthorizationSubject.newInstance("myIssuer:mySubject"));
test_class.type: AuthorizationContext
test_class.var_name: AUTHORIZATION_CONTEXT
test_class.declarator: STATUS_MAPPING = "ConnectionStatus"
test_class.modifier: private static final
test_class.original_string: private static final String STATUS_MAPPING = "ConnectionStatus";
test_class.type: String
test_class.var_name: STATUS_MAPPING
test_class.declarator: JAVA_SCRIPT_MAPPING = "JavaScript"
test_class.modifier: private static final
test_class.original_string: private static final String JAVA_SCRIPT_MAPPING = "JavaScript";
test_class.type: String
test_class.var_name: JAVA_SCRIPT_MAPPING
test_class.declarator: MIGRATED_MAPPER_ID = "javascript"
test_class.modifier: private static final
test_class.original_string: private static final String MIGRATED_MAPPER_ID = "javascript";
test_class.type: String
test_class.var_name: MIGRATED_MAPPER_ID
test_class.declarator: SOURCE1 = ConnectivityModelFactory.newSource(AUTHORIZATION_CONTEXT, "amqp/source1")
test_class.modifier: private static final
test_class.original_string: private static final Source SOURCE1 = ConnectivityModelFactory.newSource(AUTHORIZATION_CONTEXT, "amqp/source1");
test_class.type: Source
test_class.var_name: SOURCE1
test_class.declarator: SOURCE2 = ConnectivityModelFactory.newSource(AUTHORIZATION_CONTEXT, "amqp/source2", 1)
test_class.modifier: private static final
test_class.original_string: private static final Source SOURCE2 = ConnectivityModelFactory.newSource(AUTHORIZATION_CONTEXT, "amqp/source2", 1);
test_class.type: Source
test_class.var_name: SOURCE2
test_class.declarator: SOURCES = Arrays.asList(SOURCE1, SOURCE2)
test_class.modifier: private static final
test_class.original_string: private static final List<Source> SOURCES = Arrays.asList(SOURCE1, SOURCE2);
test_class.type: List<Source>
test_class.var_name: SOURCES
test_class.declarator: SOURCES_WITH_REPLY_TARGET_DISABLED = SOURCES.stream()
              .map(s -> ConnectivityModelFactory.newSourceBuilder(s).replyTargetEnabled(false).build())
              .collect(Collectors.toList())
test_class.modifier: private static final
test_class.original_string: private static final List<Source> SOURCES_WITH_REPLY_TARGET_DISABLED = SOURCES.stream()
              .map(s -> ConnectivityModelFactory.newSourceBuilder(s).replyTargetEnabled(false).build())
              .collect(Collectors.toList());
test_class.type: List<Source>
test_class.var_name: SOURCES_WITH_REPLY_TARGET_DISABLED
test_class.declarator: HEADER_MAPPING = null
test_class.modifier: private static final
test_class.original_string: private static final HeaderMapping HEADER_MAPPING = null;
test_class.type: HeaderMapping
test_class.var_name: HEADER_MAPPING
test_class.declarator: TARGET1 = ConnectivityModelFactory.newTargetBuilder()
              .address("amqp/target1")
              .authorizationContext(AUTHORIZATION_CONTEXT)
              .headerMapping(HEADER_MAPPING)
              .topics(Topic.TWIN_EVENTS, Topic.LIVE_EVENTS)
              .build()
test_class.modifier: private static final
test_class.original_string: private static final Target TARGET1 = ConnectivityModelFactory.newTargetBuilder()
              .address("amqp/target1")
              .authorizationContext(AUTHORIZATION_CONTEXT)
              .headerMapping(HEADER_MAPPING)
              .topics(Topic.TWIN_EVENTS, Topic.LIVE_EVENTS)
              .build();
test_class.type: Target
test_class.var_name: TARGET1
test_class.declarator: TARGET2 = ConnectivityModelFactory.newTargetBuilder()
              .address("amqp/target2")
              .authorizationContext(AUTHORIZATION_CONTEXT)
              .headerMapping(HEADER_MAPPING)
              .topics(Topic.LIVE_MESSAGES, Topic.LIVE_MESSAGES, Topic.LIVE_EVENTS)
              .build()
test_class.modifier: private static final
test_class.original_string: private static final Target TARGET2 = ConnectivityModelFactory.newTargetBuilder()
              .address("amqp/target2")
              .authorizationContext(AUTHORIZATION_CONTEXT)
              .headerMapping(HEADER_MAPPING)
              .topics(Topic.LIVE_MESSAGES, Topic.LIVE_MESSAGES, Topic.LIVE_EVENTS)
              .build();
test_class.type: Target
test_class.var_name: TARGET2
test_class.declarator: TARGET3 = ConnectivityModelFactory.newTargetBuilder()
              .address("amqp/target3")
              .authorizationContext(AUTHORIZATION_CONTEXT)
              .headerMapping(HEADER_MAPPING)
              .topics(Topic.LIVE_MESSAGES, Topic.LIVE_MESSAGES, Topic.LIVE_COMMANDS)
              .build()
test_class.modifier: private static final
test_class.original_string: private static final Target TARGET3 = ConnectivityModelFactory.newTargetBuilder()
              .address("amqp/target3")
              .authorizationContext(AUTHORIZATION_CONTEXT)
              .headerMapping(HEADER_MAPPING)
              .topics(Topic.LIVE_MESSAGES, Topic.LIVE_MESSAGES, Topic.LIVE_COMMANDS)
              .build();
test_class.type: Target
test_class.var_name: TARGET3
test_class.declarator: TARGETS = Arrays.asList(TARGET1, TARGET2, TARGET3)
test_class.modifier: private static final
test_class.original_string: private static final List<Target> TARGETS = Arrays.asList(TARGET1, TARGET2, TARGET3);
test_class.type: List<Target>
test_class.var_name: TARGETS
test_class.declarator: KNOWN_SOURCES_JSON =
              SOURCES.stream().map(Source::toJson).collect(JsonCollectors.valuesToArray())
test_class.modifier: private static final
test_class.original_string: private static final JsonArray KNOWN_SOURCES_JSON =
              SOURCES.stream().map(Source::toJson).collect(JsonCollectors.valuesToArray());
test_class.type: JsonArray
test_class.var_name: KNOWN_SOURCES_JSON
test_class.declarator: KNOWN_TARGETS_JSON =
              TARGETS.stream().map(Target::toJson).collect(JsonCollectors.valuesToArray())
test_class.modifier: private static final
test_class.original_string: private static final JsonArray KNOWN_TARGETS_JSON =
              TARGETS.stream().map(Target::toJson).collect(JsonCollectors.valuesToArray());
test_class.type: JsonArray
test_class.var_name: KNOWN_TARGETS_JSON
test_class.declarator: KNOWN_SOURCES_WITH_MAPPING_JSON =
              KNOWN_SOURCES_JSON.stream()
                      .map(JsonValue::asObject)
                      .map(o -> o.set(Source.JsonFields.PAYLOAD_MAPPING, JsonArray.of(JsonValue.of(JAVA_SCRIPT_MAPPING))))
                      .collect(JsonCollectors.valuesToArray())
test_class.modifier: private static final
test_class.original_string: private static final JsonArray KNOWN_SOURCES_WITH_MAPPING_JSON =
              KNOWN_SOURCES_JSON.stream()
                      .map(JsonValue::asObject)
                      .map(o -> o.set(Source.JsonFields.PAYLOAD_MAPPING, JsonArray.of(JsonValue.of(JAVA_SCRIPT_MAPPING))))
                      .collect(JsonCollectors.valuesToArray());
test_class.type: JsonArray
test_class.var_name: KNOWN_SOURCES_WITH_MAPPING_JSON
test_class.declarator: KNOWN_TARGETS_WITH_MAPPING_JSON =
              KNOWN_TARGETS_JSON.stream()
                      .map(JsonValue::asObject)
                      .map(o -> o.set(Source.JsonFields.PAYLOAD_MAPPING, JsonArray.of(JsonValue.of(STATUS_MAPPING))))
                      .collect(JsonCollectors.valuesToArray())
test_class.modifier: private static final
test_class.original_string: private static final JsonArray KNOWN_TARGETS_WITH_MAPPING_JSON =
              KNOWN_TARGETS_JSON.stream()
                      .map(JsonValue::asObject)
                      .map(o -> o.set(Source.JsonFields.PAYLOAD_MAPPING, JsonArray.of(JsonValue.of(STATUS_MAPPING))))
                      .collect(JsonCollectors.valuesToArray());
test_class.type: JsonArray
test_class.var_name: KNOWN_TARGETS_WITH_MAPPING_JSON
test_class.declarator: KNOWN_SOURCES_WITH_REPLY_TARGET =
              KNOWN_SOURCES_WITH_MAPPING_JSON.stream()
                      .map(o -> o.asObject().toBuilder()
                              .set(Source.JsonFields.HEADER_MAPPING.getPointer(),
                                      ImmutableSource.DEFAULT_SOURCE_HEADER_MAPPING.toJson())
                              .set(Source.JsonFields.REPLY_TARGET.getPointer(),
                                      ReplyTarget.newBuilder().address(ImmutableSource.DEFAULT_REPLY_TARGET_ADDRESS)
                                              .headerMapping(ImmutableSource.DEFAULT_REPLY_TARGET_HEADER_MAPPING)
                                              .build()
                                              .toJson())
                              .set(Source.JsonFields.REPLY_TARGET_ENABLED, true)
                              .build())
                      .collect(JsonCollectors.valuesToArray())
test_class.modifier: private static final
test_class.original_string: private static final JsonArray KNOWN_SOURCES_WITH_REPLY_TARGET =
              KNOWN_SOURCES_WITH_MAPPING_JSON.stream()
                      .map(o -> o.asObject().toBuilder()
                              .set(Source.JsonFields.HEADER_MAPPING.getPointer(),
                                      ImmutableSource.DEFAULT_SOURCE_HEADER_MAPPING.toJson())
                              .set(Source.JsonFields.REPLY_TARGET.getPointer(),
                                      ReplyTarget.newBuilder().address(ImmutableSource.DEFAULT_REPLY_TARGET_ADDRESS)
                                              .headerMapping(ImmutableSource.DEFAULT_REPLY_TARGET_HEADER_MAPPING)
                                              .build()
                                              .toJson())
                              .set(Source.JsonFields.REPLY_TARGET_ENABLED, true)
                              .build())
                      .collect(JsonCollectors.valuesToArray());
test_class.type: JsonArray
test_class.var_name: KNOWN_SOURCES_WITH_REPLY_TARGET
test_class.declarator: KNOWN_TARGETS_WITH_HEADER_MAPPING =
              KNOWN_TARGETS_WITH_MAPPING_JSON.stream()
                      .map(o -> o.asObject().toBuilder()
                              .set(Target.JsonFields.HEADER_MAPPING, o.asObject()
                                      .getValue(Target.JsonFields.HEADER_MAPPING)
                                      .orElseGet(ImmutableTarget.DEFAULT_HEADER_MAPPING::toJson))
                              .build())
                      .collect(JsonCollectors.valuesToArray())
test_class.modifier: private static final
test_class.original_string: private static final JsonArray KNOWN_TARGETS_WITH_HEADER_MAPPING =
              KNOWN_TARGETS_WITH_MAPPING_JSON.stream()
                      .map(o -> o.asObject().toBuilder()
                              .set(Target.JsonFields.HEADER_MAPPING, o.asObject()
                                      .getValue(Target.JsonFields.HEADER_MAPPING)
                                      .orElseGet(ImmutableTarget.DEFAULT_HEADER_MAPPING::toJson))
                              .build())
                      .collect(JsonCollectors.valuesToArray());
test_class.type: JsonArray
test_class.var_name: KNOWN_TARGETS_WITH_HEADER_MAPPING
test_class.declarator: KNOWN_MAPPING_CONTEXT = ConnectivityModelFactory.newMappingContext(
              JAVA_SCRIPT_MAPPING,
              Collections.singletonMap("incomingScript",
                      "function mapToDittoProtocolMsg(\n" +
                              "    headers,\n" +
                              "    textPayload,\n" +
                              "    bytePayload,\n" +
                              "    contentType\n" +
                              ") {\n" +
                              "\n" +
                              "    // ###\n" +
                              "    // Insert your mapping logic here\n" +
                              "    let namespace = \"org.eclipse.ditto\";\n" +
                              "    let id = \"foo-bar\";\n" +
                              "    let group = \"things\";\n" +
                              "    let channel = \"twin\";\n" +
                              "    let criterion = \"commands\";\n" +
                              "    let action = \"modify\";\n" +
                              "    let path = \"/attributes/foo\";\n" +
                              "    let dittoHeaders = headers;\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 MappingContext KNOWN_MAPPING_CONTEXT = ConnectivityModelFactory.newMappingContext(
              JAVA_SCRIPT_MAPPING,
              Collections.singletonMap("incomingScript",
                      "function mapToDittoProtocolMsg(\n" +
                              "    headers,\n" +
                              "    textPayload,\n" +
                              "    bytePayload,\n" +
                              "    contentType\n" +
                              ") {\n" +
                              "\n" +
                              "    // ###\n" +
                              "    // Insert your mapping logic here\n" +
                              "    let namespace = \"org.eclipse.ditto\";\n" +
                              "    let id = \"foo-bar\";\n" +
                              "    let group = \"things\";\n" +
                              "    let channel = \"twin\";\n" +
                              "    let criterion = \"commands\";\n" +
                              "    let action = \"modify\";\n" +
                              "    let path = \"/attributes/foo\";\n" +
                              "    let dittoHeaders = headers;\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: MappingContext
test_class.var_name: KNOWN_MAPPING_CONTEXT
test_class.declarator: KNOWN_JAVA_MAPPING_CONTEXT = ConnectivityModelFactory.newMappingContext(
              STATUS_MAPPING, new HashMap<>())
test_class.modifier: private static final
test_class.original_string: private static final MappingContext KNOWN_JAVA_MAPPING_CONTEXT = ConnectivityModelFactory.newMappingContext(
              STATUS_MAPPING, new HashMap<>());
test_class.type: MappingContext
test_class.var_name: KNOWN_JAVA_MAPPING_CONTEXT
test_class.declarator: KNOWN_MAPPING_DEFINITIONS =
              ConnectivityModelFactory.newPayloadMappingDefinition(
                      Stream.of(KNOWN_MAPPING_CONTEXT, KNOWN_JAVA_MAPPING_CONTEXT)
                              .collect(Collectors.toMap(MappingContext::getMappingEngine, ctx -> ctx)))
test_class.modifier: private static final
test_class.original_string: private static final PayloadMappingDefinition KNOWN_MAPPING_DEFINITIONS =
              ConnectivityModelFactory.newPayloadMappingDefinition(
                      Stream.of(KNOWN_MAPPING_CONTEXT, KNOWN_JAVA_MAPPING_CONTEXT)
                              .collect(Collectors.toMap(MappingContext::getMappingEngine, ctx -> ctx)));
test_class.type: PayloadMappingDefinition
test_class.var_name: KNOWN_MAPPING_DEFINITIONS
test_class.declarator: LEGACY_MAPPINGS =
              ConnectivityModelFactory.newPayloadMappingDefinition(
                      Stream.of(KNOWN_MAPPING_CONTEXT).collect(Collectors.toMap(ctx -> MIGRATED_MAPPER_ID, ctx -> ctx)))
test_class.modifier: private static final
test_class.original_string: private static final PayloadMappingDefinition LEGACY_MAPPINGS =
              ConnectivityModelFactory.newPayloadMappingDefinition(
                      Stream.of(KNOWN_MAPPING_CONTEXT).collect(Collectors.toMap(ctx -> MIGRATED_MAPPER_ID, ctx -> ctx)));
test_class.type: PayloadMappingDefinition
test_class.var_name: LEGACY_MAPPINGS
test_class.declarator: KNOWN_TAGS = Collections.singleton("HONO")
test_class.modifier: private static final
test_class.original_string: private static final Set<String> KNOWN_TAGS = Collections.singleton("HONO");
test_class.type: Set<String>
test_class.var_name: KNOWN_TAGS
test_class.declarator: KNOWN_JSON = JsonObject.newBuilder()
              .set(Connection.JsonFields.ID, ID.toString())
              .set(Connection.JsonFields.NAME, NAME)
              .set(Connection.JsonFields.CONNECTION_TYPE, TYPE.getName())
              .set(Connection.JsonFields.CONNECTION_STATUS, STATUS.getName())
              .set(Connection.JsonFields.CREDENTIALS, CREDENTIALS.toJson())
              .set(Connection.JsonFields.URI, URI)
              .set(Connection.JsonFields.SOURCES, KNOWN_SOURCES_WITH_MAPPING_JSON)
              .set(Connection.JsonFields.TARGETS, KNOWN_TARGETS_WITH_MAPPING_JSON)
              .set(Connection.JsonFields.CLIENT_COUNT, 2)
              .set(Connection.JsonFields.FAILOVER_ENABLED, true)
              .set(Connection.JsonFields.VALIDATE_CERTIFICATES, true)
              .set(Connection.JsonFields.PROCESSOR_POOL_SIZE, 5)
              .set(Connection.JsonFields.MAPPING_DEFINITIONS,
                      JsonObject.newBuilder()
                              .set(JAVA_SCRIPT_MAPPING, KNOWN_MAPPING_CONTEXT.toJson())
                              .set(STATUS_MAPPING, KNOWN_JAVA_MAPPING_CONTEXT.toJson())
                              .build())
              .set(Connection.JsonFields.TAGS, KNOWN_TAGS.stream()
                      .map(JsonFactory::newValue)
                      .collect(JsonCollectors.valuesToArray()))
              .build()
test_class.modifier: private static final
test_class.original_string: private static final JsonObject KNOWN_JSON = JsonObject.newBuilder()
              .set(Connection.JsonFields.ID, ID.toString())
              .set(Connection.JsonFields.NAME, NAME)
              .set(Connection.JsonFields.CONNECTION_TYPE, TYPE.getName())
              .set(Connection.JsonFields.CONNECTION_STATUS, STATUS.getName())
              .set(Connection.JsonFields.CREDENTIALS, CREDENTIALS.toJson())
              .set(Connection.JsonFields.URI, URI)
              .set(Connection.JsonFields.SOURCES, KNOWN_SOURCES_WITH_MAPPING_JSON)
              .set(Connection.JsonFields.TARGETS, KNOWN_TARGETS_WITH_MAPPING_JSON)
              .set(Connection.JsonFields.CLIENT_COUNT, 2)
              .set(Connection.JsonFields.FAILOVER_ENABLED, true)
              .set(Connection.JsonFields.VALIDATE_CERTIFICATES, true)
              .set(Connection.JsonFields.PROCESSOR_POOL_SIZE, 5)
              .set(Connection.JsonFields.MAPPING_DEFINITIONS,
                      JsonObject.newBuilder()
                              .set(JAVA_SCRIPT_MAPPING, KNOWN_MAPPING_CONTEXT.toJson())
                              .set(STATUS_MAPPING, KNOWN_JAVA_MAPPING_CONTEXT.toJson())
                              .build())
              .set(Connection.JsonFields.TAGS, KNOWN_TAGS.stream()
                      .map(JsonFactory::newValue)
                      .collect(JsonCollectors.valuesToArray()))
              .build();
test_class.type: JsonObject
test_class.var_name: KNOWN_JSON
test_class.declarator: KNOWN_JSON_WITH_REPLY_TARGET = KNOWN_JSON
              .set(Connection.JsonFields.SOURCES, KNOWN_SOURCES_WITH_REPLY_TARGET)
              .set(Connection.JsonFields.TARGETS, KNOWN_TARGETS_WITH_HEADER_MAPPING)
test_class.modifier: private static final
test_class.original_string: private static final JsonObject KNOWN_JSON_WITH_REPLY_TARGET = KNOWN_JSON
              .set(Connection.JsonFields.SOURCES, KNOWN_SOURCES_WITH_REPLY_TARGET)
              .set(Connection.JsonFields.TARGETS, KNOWN_TARGETS_WITH_HEADER_MAPPING);
test_class.type: JsonObject
test_class.var_name: KNOWN_JSON_WITH_REPLY_TARGET
test_class.declarator: KNOWN_LEGACY_JSON = KNOWN_JSON
              .set(Connection.JsonFields.MAPPING_CONTEXT, KNOWN_MAPPING_CONTEXT.toJson())
test_class.modifier: private static final
test_class.original_string: private static final JsonObject KNOWN_LEGACY_JSON = KNOWN_JSON
              .set(Connection.JsonFields.MAPPING_CONTEXT, KNOWN_MAPPING_CONTEXT.toJson());
test_class.type: JsonObject
test_class.var_name: KNOWN_LEGACY_JSON
test_class.file: model/connectivity/src/test/java/org/eclipse/ditto/model/connectivity/ImmutableConnectionTest.java
test_class.identifier: ImmutableConnectionTest
test_case.body: @Test
      public void fromJsonWithLegacyMappingContextReturnsExpected() {
  
          final Map<String, MappingContext> definitions = new HashMap<>(KNOWN_MAPPING_DEFINITIONS.getDefinitions());
          definitions.putAll(LEGACY_MAPPINGS.getDefinitions());
          final Connection expected = ConnectivityModelFactory.newConnectionBuilder(ID, TYPE, STATUS, URI)
                  .credentials(CREDENTIALS)
                  .name(NAME)
                  .setSources(addSourceMapping(SOURCES, JAVA_SCRIPT_MAPPING, "javascript"))
                  .setTargets(addTargetMapping(TARGETS, STATUS_MAPPING, "javascript"))
                  .clientCount(2)
                  .payloadMappingDefinition(ConnectivityModelFactory.newPayloadMappingDefinition(definitions))
                  .tags(KNOWN_TAGS)
                  .build();
  
          final Connection actual = ImmutableConnection.fromJson(KNOWN_LEGACY_JSON);
          assertThat(actual).isEqualTo(expected);
      }
test_case.class_method_signature: ImmutableConnectionTest.fromJsonWithLegacyMappingContextReturnsExpected()
test_case.full_signature: @Test public void fromJsonWithLegacyMappingContextReturnsExpected()
test_case.identifier: fromJsonWithLegacyMappingContextReturnsExpected
test_case.invocations: getDefinitions putAll getDefinitions build tags payloadMappingDefinition clientCount setTargets setSources name credentials newConnectionBuilder addSourceMapping addTargetMapping newPayloadMappingDefinition fromJson isEqualTo assertThat
test_case.modifiers: @Test public
test_case.parameters: ()
test_case.return: void
test_case.signature: void fromJsonWithLegacyMappingContextReturnsExpected()
focal_class.declarator: id
focal_class.modifier: private final
focal_class.original_string: private final ConnectionId id;
focal_class.type: ConnectionId
focal_class.var_name: id
focal_class.declarator: name
focal_class.modifier: @Nullable private final
focal_class.original_string: @Nullable private final String name;
focal_class.type: String
focal_class.var_name: name
focal_class.declarator: connectionType
focal_class.modifier: private final
focal_class.original_string: private final ConnectionType connectionType;
focal_class.type: ConnectionType
focal_class.var_name: connectionType
focal_class.declarator: connectionStatus
focal_class.modifier: private final
focal_class.original_string: private final ConnectivityStatus connectionStatus;
focal_class.type: ConnectivityStatus
focal_class.var_name: connectionStatus
focal_class.declarator: uri
focal_class.modifier: private final
focal_class.original_string: private final ConnectionUri uri;
focal_class.type: ConnectionUri
focal_class.var_name: uri
focal_class.declarator: credentials
focal_class.modifier: @Nullable private final
focal_class.original_string: @Nullable private final Credentials credentials;
focal_class.type: Credentials
focal_class.var_name: credentials
focal_class.declarator: trustedCertificates
focal_class.modifier: @Nullable private final
focal_class.original_string: @Nullable private final String trustedCertificates;
focal_class.type: String
focal_class.var_name: trustedCertificates
focal_class.declarator: lifecycle
focal_class.modifier: @Nullable private final
focal_class.original_string: @Nullable private final ConnectionLifecycle lifecycle;
focal_class.type: ConnectionLifecycle
focal_class.var_name: lifecycle
focal_class.declarator: sources
focal_class.modifier: private final
focal_class.original_string: private final List<Source> sources;
focal_class.type: List<Source>
focal_class.var_name: sources
focal_class.declarator: targets
focal_class.modifier: private final
focal_class.original_string: private final List<Target> targets;
focal_class.type: List<Target>
focal_class.var_name: targets
focal_class.declarator: clientCount
focal_class.modifier: private final
focal_class.original_string: private final int clientCount;
focal_class.type: int
focal_class.var_name: clientCount
focal_class.declarator: failOverEnabled
focal_class.modifier: private final
focal_class.original_string: private final boolean failOverEnabled;
focal_class.type: boolean
focal_class.var_name: failOverEnabled
focal_class.declarator: validateCertificate
focal_class.modifier: private final
focal_class.original_string: private final boolean validateCertificate;
focal_class.type: boolean
focal_class.var_name: validateCertificate
focal_class.declarator: processorPoolSize
focal_class.modifier: private final
focal_class.original_string: private final int processorPoolSize;
focal_class.type: int
focal_class.var_name: processorPoolSize
focal_class.declarator: specificConfig
focal_class.modifier: private final
focal_class.original_string: private final Map<String, String> specificConfig;
focal_class.type: Map<String, String>
focal_class.var_name: specificConfig
focal_class.declarator: payloadMappingDefinition
focal_class.modifier: private final
focal_class.original_string: private final PayloadMappingDefinition payloadMappingDefinition;
focal_class.type: PayloadMappingDefinition
focal_class.var_name: payloadMappingDefinition
focal_class.declarator: tags
focal_class.modifier: private final
focal_class.original_string: private final Set<String> tags;
focal_class.type: Set<String>
focal_class.var_name: tags
focal_class.file: model/connectivity/src/main/java/org/eclipse/ditto/model/connectivity/ImmutableConnection.java
focal_class.identifier: ImmutableConnection
focal_class.interfaces: implements Connection
focal_class.class_method_signature: ImmutableConnection.ImmutableConnection(final Builder builder)
focal_class.full_signature: private  ImmutableConnection(final Builder builder)
focal_class.identifier: ImmutableConnection
focal_class.modifiers: private
focal_class.parameters: (final Builder builder)
focal_class.signature:  ImmutableConnection(final Builder builder)
focal_class.class_method_signature: ImmutableConnection.getBuilder(final ConnectionId id,
              final ConnectionType connectionType,
              final ConnectivityStatus connectionStatus,
              final String uri)
focal_class.full_signature: public static ConnectionBuilder getBuilder(final ConnectionId id,
              final ConnectionType connectionType,
              final ConnectivityStatus connectionStatus,
              final String uri)
focal_class.identifier: getBuilder
focal_class.modifiers: public static
focal_class.parameters: (final ConnectionId id,
              final ConnectionType connectionType,
              final ConnectivityStatus connectionStatus,
              final String uri)
focal_class.return: ConnectionBuilder
focal_class.signature: ConnectionBuilder getBuilder(final ConnectionId id,
              final ConnectionType connectionType,
              final ConnectivityStatus connectionStatus,
              final String uri)
focal_class.class_method_signature: ImmutableConnection.getBuilder(final Connection connection)
focal_class.full_signature: public static ConnectionBuilder getBuilder(final Connection connection)
focal_class.identifier: getBuilder
focal_class.modifiers: public static
focal_class.parameters: (final Connection connection)
focal_class.return: ConnectionBuilder
focal_class.signature: ConnectionBuilder getBuilder(final Connection connection)
focal_class.class_method_signature: ImmutableConnection.fromJson(final JsonObject jsonObject)
focal_class.full_signature: public static Connection fromJson(final JsonObject jsonObject)
focal_class.identifier: fromJson
focal_class.modifiers: public static
focal_class.parameters: (final JsonObject jsonObject)
focal_class.return: Connection
focal_class.signature: Connection fromJson(final JsonObject jsonObject)
focal_class.class_method_signature: ImmutableConnection.getConnectionTypeOrThrow(final JsonObject jsonObject)
focal_class.full_signature: private static ConnectionType getConnectionTypeOrThrow(final JsonObject jsonObject)
focal_class.identifier: getConnectionTypeOrThrow
focal_class.modifiers: private static
focal_class.parameters: (final JsonObject jsonObject)
focal_class.return: ConnectionType
focal_class.signature: ConnectionType getConnectionTypeOrThrow(final JsonObject jsonObject)
focal_class.class_method_signature: ImmutableConnection.getConnectionStatusOrThrow(final JsonObject jsonObject)
focal_class.full_signature: private static ConnectivityStatus getConnectionStatusOrThrow(final JsonObject jsonObject)
focal_class.identifier: getConnectionStatusOrThrow
focal_class.modifiers: private static
focal_class.parameters: (final JsonObject jsonObject)
focal_class.return: ConnectivityStatus
focal_class.signature: ConnectivityStatus getConnectionStatusOrThrow(final JsonObject jsonObject)
focal_class.class_method_signature: ImmutableConnection.getSources(final JsonObject jsonObject)
focal_class.full_signature: private static List<Source> getSources(final JsonObject jsonObject)
focal_class.identifier: getSources
focal_class.modifiers: private static
focal_class.parameters: (final JsonObject jsonObject)
focal_class.return: List<Source>
focal_class.signature: List<Source> getSources(final JsonObject jsonObject)
focal_class.class_method_signature: ImmutableConnection.getTargets(final JsonObject jsonObject)
focal_class.full_signature: private static List<Target> getTargets(final JsonObject jsonObject)
focal_class.identifier: getTargets
focal_class.modifiers: private static
focal_class.parameters: (final JsonObject jsonObject)
focal_class.return: List<Target>
focal_class.signature: List<Target> getTargets(final JsonObject jsonObject)
focal_class.class_method_signature: ImmutableConnection.getSpecificConfiguration(final JsonObject jsonObject)
focal_class.full_signature: private static Map<String, String> getSpecificConfiguration(final JsonObject jsonObject)
focal_class.identifier: getSpecificConfiguration
focal_class.modifiers: private static
focal_class.parameters: (final JsonObject jsonObject)
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> getSpecificConfiguration(final JsonObject jsonObject)
focal_class.class_method_signature: ImmutableConnection.getTags(final JsonObject jsonObject)
focal_class.full_signature: private static Set<String> getTags(final JsonObject jsonObject)
focal_class.identifier: getTags
focal_class.modifiers: private static
focal_class.parameters: (final JsonObject jsonObject)
focal_class.return: Set<String>
focal_class.signature: Set<String> getTags(final JsonObject jsonObject)
focal_class.class_method_signature: ImmutableConnection.getId()
focal_class.full_signature: @Override public ConnectionId getId()
focal_class.identifier: getId
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: ConnectionId
focal_class.signature: ConnectionId getId()
focal_class.class_method_signature: ImmutableConnection.getName()
focal_class.full_signature: @Override public Optional<String> getName()
focal_class.identifier: getName
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Optional<String>
focal_class.signature: Optional<String> getName()
focal_class.class_method_signature: ImmutableConnection.getConnectionType()
focal_class.full_signature: @Override public ConnectionType getConnectionType()
focal_class.identifier: getConnectionType
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: ConnectionType
focal_class.signature: ConnectionType getConnectionType()
focal_class.class_method_signature: ImmutableConnection.getConnectionStatus()
focal_class.full_signature: @Override public ConnectivityStatus getConnectionStatus()
focal_class.identifier: getConnectionStatus
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: ConnectivityStatus
focal_class.signature: ConnectivityStatus getConnectionStatus()
focal_class.class_method_signature: ImmutableConnection.getSources()
focal_class.full_signature: @Override public List<Source> getSources()
focal_class.identifier: getSources
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: List<Source>
focal_class.signature: List<Source> getSources()
focal_class.class_method_signature: ImmutableConnection.getTargets()
focal_class.full_signature: @Override public List<Target> getTargets()
focal_class.identifier: getTargets
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: List<Target>
focal_class.signature: List<Target> getTargets()
focal_class.class_method_signature: ImmutableConnection.getClientCount()
focal_class.full_signature: @Override public int getClientCount()
focal_class.identifier: getClientCount
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getClientCount()
focal_class.class_method_signature: ImmutableConnection.isFailoverEnabled()
focal_class.full_signature: @Override public boolean isFailoverEnabled()
focal_class.identifier: isFailoverEnabled
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isFailoverEnabled()
focal_class.class_method_signature: ImmutableConnection.getCredentials()
focal_class.full_signature: @Override public Optional<Credentials> getCredentials()
focal_class.identifier: getCredentials
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Optional<Credentials>
focal_class.signature: Optional<Credentials> getCredentials()
focal_class.class_method_signature: ImmutableConnection.getTrustedCertificates()
focal_class.full_signature: @Override public Optional<String> getTrustedCertificates()
focal_class.identifier: getTrustedCertificates
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Optional<String>
focal_class.signature: Optional<String> getTrustedCertificates()
focal_class.class_method_signature: ImmutableConnection.getUri()
focal_class.full_signature: @Override public String getUri()
focal_class.identifier: getUri
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getUri()
focal_class.class_method_signature: ImmutableConnection.getProtocol()
focal_class.full_signature: @Override public String getProtocol()
focal_class.identifier: getProtocol
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getProtocol()
focal_class.class_method_signature: ImmutableConnection.getUsername()
focal_class.full_signature: @Override public Optional<String> getUsername()
focal_class.identifier: getUsername
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Optional<String>
focal_class.signature: Optional<String> getUsername()
focal_class.class_method_signature: ImmutableConnection.getPassword()
focal_class.full_signature: @Override public Optional<String> getPassword()
focal_class.identifier: getPassword
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Optional<String>
focal_class.signature: Optional<String> getPassword()
focal_class.class_method_signature: ImmutableConnection.getHostname()
focal_class.full_signature: @Override public String getHostname()
focal_class.identifier: getHostname
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String getHostname()
focal_class.class_method_signature: ImmutableConnection.getPort()
focal_class.full_signature: @Override public int getPort()
focal_class.identifier: getPort
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getPort()
focal_class.class_method_signature: ImmutableConnection.getPath()
focal_class.full_signature: @Override public Optional<String> getPath()
focal_class.identifier: getPath
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Optional<String>
focal_class.signature: Optional<String> getPath()
focal_class.class_method_signature: ImmutableConnection.isValidateCertificates()
focal_class.full_signature: @Override public boolean isValidateCertificates()
focal_class.identifier: isValidateCertificates
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: boolean
focal_class.signature: boolean isValidateCertificates()
focal_class.class_method_signature: ImmutableConnection.getProcessorPoolSize()
focal_class.full_signature: @Override public int getProcessorPoolSize()
focal_class.identifier: getProcessorPoolSize
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int getProcessorPoolSize()
focal_class.class_method_signature: ImmutableConnection.getSpecificConfig()
focal_class.full_signature: @Override public Map<String, String> getSpecificConfig()
focal_class.identifier: getSpecificConfig
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Map<String, String>
focal_class.signature: Map<String, String> getSpecificConfig()
focal_class.class_method_signature: ImmutableConnection.getPayloadMappingDefinition()
focal_class.full_signature: @Override public PayloadMappingDefinition getPayloadMappingDefinition()
focal_class.identifier: getPayloadMappingDefinition
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: PayloadMappingDefinition
focal_class.signature: PayloadMappingDefinition getPayloadMappingDefinition()
focal_class.class_method_signature: ImmutableConnection.getTags()
focal_class.full_signature: @Override public Set<String> getTags()
focal_class.identifier: getTags
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Set<String>
focal_class.signature: Set<String> getTags()
focal_class.class_method_signature: ImmutableConnection.getLifecycle()
focal_class.full_signature: @Override public Optional<ConnectionLifecycle> getLifecycle()
focal_class.identifier: getLifecycle
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: Optional<ConnectionLifecycle>
focal_class.signature: Optional<ConnectionLifecycle> getLifecycle()
focal_class.class_method_signature: ImmutableConnection.toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate)
focal_class.full_signature: @Override public JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate)
focal_class.identifier: toJson
focal_class.modifiers: @Override public
focal_class.parameters: (final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate)
focal_class.return: JsonObject
focal_class.signature: JsonObject toJson(final JsonSchemaVersion schemaVersion, final Predicate<JsonField> thePredicate)
focal_class.class_method_signature: ImmutableConnection.equals(@Nullable final Object o)
focal_class.full_signature: @SuppressWarnings("OverlyComplexMethod") @Override public boolean equals(@Nullable final Object o)
focal_class.identifier: equals
focal_class.modifiers: @SuppressWarnings("OverlyComplexMethod") @Override public
focal_class.parameters: (@Nullable final Object o)
focal_class.return: boolean
focal_class.signature: boolean equals(@Nullable final Object o)
focal_class.class_method_signature: ImmutableConnection.hashCode()
focal_class.full_signature: @Override public int hashCode()
focal_class.identifier: hashCode
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: int
focal_class.signature: int hashCode()
focal_class.class_method_signature: ImmutableConnection.toString()
focal_class.full_signature: @Override public String toString()
focal_class.identifier: toString
focal_class.modifiers: @Override public
focal_class.parameters: ()
focal_class.return: String
focal_class.signature: String toString()
focal_method.body: public static Connection fromJson(final JsonObject jsonObject) {
          final ConnectionType type = getConnectionTypeOrThrow(jsonObject);
          final MappingContext mappingContext = jsonObject.getValue(JsonFields.MAPPING_CONTEXT)
                  .map(ConnectivityModelFactory::mappingContextFromJson)
                  .orElse(null);
  
          final PayloadMappingDefinition payloadMappingDefinition =
                  jsonObject.getValue(JsonFields.MAPPING_DEFINITIONS)
                          .map(ImmutablePayloadMappingDefinition::fromJson)
                          .orElse(ConnectivityModelFactory.emptyPayloadMappingDefinition());
  
          final ConnectionBuilder builder = new Builder(type)
                  .id(ConnectionId.of(jsonObject.getValueOrThrow(JsonFields.ID)))
                  .connectionStatus(getConnectionStatusOrThrow(jsonObject))
                  .uri(jsonObject.getValueOrThrow(JsonFields.URI))
                  .sources(getSources(jsonObject))
                  .targets(getTargets(jsonObject))
                  .name(jsonObject.getValue(JsonFields.NAME).orElse(null))
                  .mappingContext(mappingContext)
                  .payloadMappingDefinition(payloadMappingDefinition)
                  .specificConfig(getSpecificConfiguration(jsonObject))
                  .tags(getTags(jsonObject));
  
          jsonObject.getValue(Connection.JsonFields.LIFECYCLE)
                  .flatMap(ConnectionLifecycle::forName).ifPresent(builder::lifecycle);
          jsonObject.getValue(JsonFields.CREDENTIALS).ifPresent(builder::credentialsFromJson);
          jsonObject.getValue(JsonFields.CLIENT_COUNT).ifPresent(builder::clientCount);
          jsonObject.getValue(JsonFields.FAILOVER_ENABLED).ifPresent(builder::failoverEnabled);
          jsonObject.getValue(JsonFields.VALIDATE_CERTIFICATES).ifPresent(builder::validateCertificate);
          jsonObject.getValue(JsonFields.PROCESSOR_POOL_SIZE).ifPresent(builder::processorPoolSize);
          jsonObject.getValue(JsonFields.TRUSTED_CERTIFICATES).ifPresent(builder::trustedCertificates);
  
          return builder.build();
      }
focal_method.class_method_signature: ImmutableConnection.fromJson(final JsonObject jsonObject)
focal_method.full_signature: public static Connection fromJson(final JsonObject jsonObject)
focal_method.identifier: fromJson
focal_method.invocations: getConnectionTypeOrThrow orElse map getValue orElse map getValue emptyPayloadMappingDefinition tags specificConfig payloadMappingDefinition mappingContext name targets sources uri connectionStatus id of getValueOrThrow getConnectionStatusOrThrow getValueOrThrow getSources getTargets orElse getValue getSpecificConfiguration getTags ifPresent flatMap getValue ifPresent getValue ifPresent getValue ifPresent getValue ifPresent getValue ifPresent getValue ifPresent getValue build
focal_method.modifiers: public static
focal_method.parameters: (final JsonObject jsonObject)
focal_method.return: Connection
focal_method.signature: Connection fromJson(final JsonObject jsonObject)