@Override
    @Nonnull
    public <T extends DataConnection> T getAndRetainDataConnection(String name, Class<T> clazz) {
        DataConnectionEntry dataConnection = dataConnections.computeIfPresent(name, (k, v) -> {
            if (!clazz.isInstance(v.instance)) {
                throw new HazelcastException("Data connection '" + name + "' must be an instance of " + clazz);
            }
            v.instance.retain();
            return v;
        });

        if (dataConnection == null) {
            throw new HazelcastException("Data connection '" + name + "' not found");
        }
        //noinspection unchecked
        return (T) dataConnection.instance;
    }
@Test
    public void should_return_dynamically_added_data_connection() {
        instance.getConfig().addDataConnectionConfig(
                new DataConnectionConfig(TEST_DYNAMIC_CONFIG)
                        .setType(DUMMY_DATA_CONNECTION_TYPE)
                        .setProperty("customProperty", "value")
        );

        DataConnection dataConnection = dataConnectionService.getAndRetainDataConnection(TEST_DYNAMIC_CONFIG, DummyDataConnection.class);

        assertThat(dataConnection).isInstanceOf(DummyDataConnection.class);
        assertThat(dataConnection.getName()).isEqualTo(TEST_DYNAMIC_CONFIG);
        assertThat(dataConnection.getConfig().getProperties())
                .containsEntry("customProperty", "value");
    }