@NonNull
  public <T extends VFSConnectionDetails> VFSConnectionProvider<T> getExistingProvider(
    @NonNull ConnectionManager manager,
    @Nullable String key )
    throws KettleException {

    VFSConnectionProvider<T> provider = getProvider( manager, key );
    if ( provider == null ) {
      throw new KettleException( String.format( "Undefined connection provider for key '%s'.", key ) );
    }

    return provider;
  }
@Test
  public void testGetExistingProviderReturnsExistingCastedProviderFromManager() throws KettleException {
    String provider1Key = "provider1Key";

    ConnectionProvider<? extends ConnectionDetails> provider1 =
      (ConnectionProvider<? extends ConnectionDetails>) mock( VFSConnectionProvider.class );

    doReturn( provider1 ).when( connectionManager ).getConnectionProvider( provider1Key );

    VFSConnectionProvider<VFSConnectionDetails> result =
      vfsConnectionManagerHelper.getExistingProvider( connectionManager, provider1Key );

    assertSame( provider1, result );
  }