Search in sources :

Example 1 with RepositoryElementInterface

use of org.pentaho.di.repository.RepositoryElementInterface in project pentaho-kettle by pentaho.

the class PurRepository_SharedObjects_IT method loadAllShared.

@Test
public void loadAllShared() throws Exception {
    ClusterSchema cluster = cluster();
    DatabaseMeta database = database();
    SlaveServer slaveServer = slaveServer();
    PartitionSchema partition = partition();
    purRepository.save(cluster, null, null);
    purRepository.save(database, null, null);
    purRepository.save(slaveServer, null, null);
    purRepository.save(partition, null, null);
    Map<RepositoryObjectType, List<? extends SharedObjectInterface>> map = map();
    purRepository.readSharedObjects(map, RepositoryObjectType.CLUSTER_SCHEMA, RepositoryObjectType.DATABASE, RepositoryObjectType.SLAVE_SERVER, RepositoryObjectType.PARTITION_SCHEMA);
    RepositoryElementInterface[] saved = new RepositoryElementInterface[] { cluster, database, slaveServer, partition };
    assertEquals(saved.length, map.size());
    for (RepositoryElementInterface sharedObject : saved) {
        List<? extends SharedObjectInterface> list = map.get(sharedObject.getRepositoryElementType());
        assertEquals(1, list.size());
        assertEquals(sharedObject, list.get(0));
    }
}
Also used : RepositoryElementInterface(org.pentaho.di.repository.RepositoryElementInterface) PartitionSchema(org.pentaho.di.partition.PartitionSchema) RepositoryObjectType(org.pentaho.di.repository.RepositoryObjectType) List(java.util.List) SharedObjectInterface(org.pentaho.di.shared.SharedObjectInterface) SlaveServer(org.pentaho.di.cluster.SlaveServer) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) ClusterSchema(org.pentaho.di.cluster.ClusterSchema) Test(org.junit.Test)

Example 2 with RepositoryElementInterface

use of org.pentaho.di.repository.RepositoryElementInterface in project pentaho-kettle by pentaho.

the class PurRepositoryIT method doesNotChangeFileWhenFailsToRename_slaves.

@Test
public void doesNotChangeFileWhenFailsToRename_slaves() throws Exception {
    final SlaveServer server1 = new SlaveServer();
    final SlaveServer server2 = new SlaveServer();
    try {
        testDoesNotChangeFileWhenFailsToRename(server1, server2, new Callable<RepositoryElementInterface>() {

            @Override
            public RepositoryElementInterface call() throws Exception {
                return repository.loadSlaveServer(server2.getObjectId(), null);
            }
        });
    } finally {
        repository.deleteSlave(server1.getObjectId());
        repository.deleteSlave(server2.getObjectId());
    }
}
Also used : RepositoryElementInterface(org.pentaho.di.repository.RepositoryElementInterface) SlaveServer(org.pentaho.di.cluster.SlaveServer) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) BeansException(org.springframework.beans.BeansException) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) SAXException(org.xml.sax.SAXException) KettleException(org.pentaho.di.core.exception.KettleException) SAXParseException(org.xml.sax.SAXParseException) Test(org.junit.Test)

Example 3 with RepositoryElementInterface

use of org.pentaho.di.repository.RepositoryElementInterface in project pentaho-kettle by pentaho.

the class PurRepositoryIT method testDoesNotChangeFileWhenFailsToRename.

private void testDoesNotChangeFileWhenFailsToRename(RepositoryElementInterface element1, RepositoryElementInterface element2, Callable<RepositoryElementInterface> loader) throws Exception {
    final String name1 = "name1";
    final String name2 = "name2";
    element1.setName(name1);
    element2.setName(name2);
    repository.save(element1, "", null);
    repository.save(element2, "", null);
    element2.setName(name1);
    try {
        repository.save(element2, "", null, true);
        fail("A naming conflict should occur");
    } catch (KettleException e) {
        // expected to be thrown
        element2.setName(name2);
    }
    RepositoryElementInterface loaded = loader.call();
    assertEquals(element2, loaded);
}
Also used : KettleException(org.pentaho.di.core.exception.KettleException) RepositoryElementInterface(org.pentaho.di.repository.RepositoryElementInterface) Matchers.anyString(org.mockito.Matchers.anyString)

Example 4 with RepositoryElementInterface

use of org.pentaho.di.repository.RepositoryElementInterface in project pentaho-kettle by pentaho.

the class PurRepositoryIT method doesNotChangeFileWhenFailsToRename_partitions.

@Test
public void doesNotChangeFileWhenFailsToRename_partitions() throws Exception {
    final PartitionSchema schema1 = new PartitionSchema();
    final PartitionSchema schema2 = new PartitionSchema();
    try {
        testDoesNotChangeFileWhenFailsToRename(schema1, schema2, new Callable<RepositoryElementInterface>() {

            @Override
            public RepositoryElementInterface call() throws Exception {
                return repository.loadPartitionSchema(schema2.getObjectId(), null);
            }
        });
    } finally {
        repository.deletePartitionSchema(schema1.getObjectId());
        repository.deletePartitionSchema(schema2.getObjectId());
    }
}
Also used : RepositoryElementInterface(org.pentaho.di.repository.RepositoryElementInterface) PartitionSchema(org.pentaho.di.partition.PartitionSchema) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) BeansException(org.springframework.beans.BeansException) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) SAXException(org.xml.sax.SAXException) KettleException(org.pentaho.di.core.exception.KettleException) SAXParseException(org.xml.sax.SAXParseException) Test(org.junit.Test)

Example 5 with RepositoryElementInterface

use of org.pentaho.di.repository.RepositoryElementInterface in project pentaho-kettle by pentaho.

the class PurRepositoryIT method doesNotChangeFileWhenFailsToRename_clusters.

@Test
public void doesNotChangeFileWhenFailsToRename_clusters() throws Exception {
    final ClusterSchema schema1 = new ClusterSchema();
    final ClusterSchema schema2 = new ClusterSchema();
    try {
        testDoesNotChangeFileWhenFailsToRename(schema1, schema2, new Callable<RepositoryElementInterface>() {

            @Override
            public RepositoryElementInterface call() throws Exception {
                return repository.loadClusterSchema(schema2.getObjectId(), null, null);
            }
        });
    } finally {
        repository.deleteClusterSchema(schema1.getObjectId());
        repository.deleteClusterSchema(schema2.getObjectId());
    }
}
Also used : RepositoryElementInterface(org.pentaho.di.repository.RepositoryElementInterface) ClusterSchema(org.pentaho.di.cluster.ClusterSchema) MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) BeansException(org.springframework.beans.BeansException) MetaStoreNamespaceExistsException(org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) SAXException(org.xml.sax.SAXException) KettleException(org.pentaho.di.core.exception.KettleException) SAXParseException(org.xml.sax.SAXParseException) Test(org.junit.Test)

Aggregations

RepositoryElementInterface (org.pentaho.di.repository.RepositoryElementInterface)8 Test (org.junit.Test)5 KettleException (org.pentaho.di.core.exception.KettleException)5 SlaveServer (org.pentaho.di.cluster.SlaveServer)3 PartitionSchema (org.pentaho.di.partition.PartitionSchema)3 MetaStoreDependenciesExistsException (org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException)3 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)3 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)3 BeansException (org.springframework.beans.BeansException)3 SAXException (org.xml.sax.SAXException)3 SAXParseException (org.xml.sax.SAXParseException)3 ClusterSchema (org.pentaho.di.cluster.ClusterSchema)2 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)2 RepositoryDirectoryInterface (org.pentaho.di.repository.RepositoryDirectoryInterface)2 RepositoryObjectType (org.pentaho.di.repository.RepositoryObjectType)2 SharedObjectInterface (org.pentaho.di.shared.SharedObjectInterface)2 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Matchers.anyString (org.mockito.Matchers.anyString)1 KettleExtensionPoint (org.pentaho.di.core.extension.KettleExtensionPoint)1