public RepositoryMeta createRepository( String id, Map<String, Object> items ) {
    RepositoryMeta repositoryMeta;
    try {
      repositoryMeta = pluginRegistry.loadClass( RepositoryPluginType.class, id, RepositoryMeta.class );
      repositoryMeta.populate( items, repositoriesMeta );

      if ( repositoryMeta.getName() != null ) {
        Repository repository =
          pluginRegistry.loadClass( RepositoryPluginType.class, repositoryMeta.getId(), Repository.class );
        repository.init( repositoryMeta );
        repositoriesMeta.addRepository( repositoryMeta );
        repositoriesMeta.writeData();
        currentRepository = repositoryMeta;
        if ( !testRepository( repository ) ) {
          return null;
        }
        ( (AbstractRepository) repository ).create();
      }
    } catch ( KettleException ke ) {
      log.logError( "Unable to load repository type", ke );
      return null;
    }
    return repositoryMeta;
  }
@Test
  public void testCreateRepository() throws Exception {
    String id = ID;
    Map<String, Object> items = new HashMap<>();

    when( pluginRegistry.loadClass( RepositoryPluginType.class, id, RepositoryMeta.class ) )
      .thenReturn( repositoryMeta );
    when( pluginRegistry.loadClass( RepositoryPluginType.class, repositoryMeta.getId(), Repository.class ) )
      .thenReturn( repository );

    when( repository.test() ).thenReturn( true );

    RepositoryMeta result = controller.createRepository( id, items );

    assertNotEquals( null, result );

    when( repository.test() ).thenReturn( false );

    result = controller.createRepository( id, items );

    assertEquals( null, result );

    doThrow( new KettleException( "forced exception" ) ).when( repositoriesMeta ).writeData();

    result = controller.createRepository( id, items );
    assertEquals( null, result );
  }