@Test
public void migrateConnectionContainingSourcesAndTargetsWithOwnAuthContextWithGlobalAuthContext() {

    final JsonObjectBuilder builder = KNOWN_CONNECTION_JSON.toBuilder();
    builder.set(Connection.JsonFields.SOURCES,
            MigrateAuthorizationContexts.migrateSources(KNOWN_CONNECTION_JSON, ALT_AUTHORIZATION_CONTEXT
                    .getAuthorizationSubjectIds()
                    .stream()
                    .map(JsonValue::of)
                    .collect(JsonCollectors.valuesToArray())).get());
    builder.set(Connection.JsonFields.TARGETS,
            MigrateAuthorizationContexts.migrateTargets(KNOWN_CONNECTION_JSON, ALT_AUTHORIZATION_CONTEXT
                    .getAuthorizationSubjectIds()
                    .stream()
                    .map(JsonValue::of)
                    .collect(JsonCollectors.valuesToArray())).get());
    final Connection migratedConnection = ConnectionMigrationUtil.connectionFromJsonWithMigration(builder.build());
    assertThat((CharSequence) migratedConnection.getId()).isEqualTo(ID);
    assertThat(migratedConnection.getName()).contains(NAME);
    assertThat((Object) migratedConnection.getConnectionType()).isEqualTo(TYPE);
    assertThat(migratedConnection.getUri()).isEqualTo(URI);
    migratedConnection.getSources().forEach(source ->
            assertThat(source.getAuthorizationContext()).isEqualTo(ALT_AUTHORIZATION_CONTEXT));
    migratedConnection.getTargets().forEach(target ->
            assertThat(target.getAuthorizationContext()).isEqualTo(ALT_AUTHORIZATION_CONTEXT));
}