Search in sources :

Example 56 with IMetaStore

use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.

the class SharedDimensionMetaStoreUtilTest method testGetSharedDimensionElementTypeNew.

@Test
public void testGetSharedDimensionElementTypeNew() throws Exception {
    final IMetaStore metaStore = mock(IMetaStore.class);
    final IMetaStoreElementType metaStoreElementType = mock(IMetaStoreElementType.class);
    when(metaStore.newElementType(anyString())).thenReturn(metaStoreElementType);
    final IMetaStoreElementType sharedDimensionElementType = SharedDimensionMetaStoreUtil.getSharedDimensionElementType(metaStore);
    verify(metaStore, times(1)).createNamespace(anyString());
    assertNotNull(sharedDimensionElementType);
    assertEquals(metaStoreElementType, sharedDimensionElementType);
    verify(sharedDimensionElementType, times(1)).setName(eq(SharedDimensionMetaStoreUtil.METASTORE_SHARED_DIMENSION_TYPE_NAME));
    verify(sharedDimensionElementType, times(1)).setDescription(eq(SharedDimensionMetaStoreUtil.METASTORE_SHARED_DIMENSION_TYPE_DESCRIPTION));
    verify(metaStore, times(1)).createElementType(anyString(), eq(sharedDimensionElementType));
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 57 with IMetaStore

use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.

the class SharedDimensionMetaStoreUtilTest method testGetSharedDimensionElementTypeExist.

@Test
public void testGetSharedDimensionElementTypeExist() throws Exception {
    final IMetaStore metaStore = mock(IMetaStore.class);
    final IMetaStoreElementType metaStoreElementType = mock(IMetaStoreElementType.class);
    when(metaStore.getElementTypeByName(anyString(), eq(SharedDimensionMetaStoreUtil.METASTORE_SHARED_DIMENSION_TYPE_NAME))).thenReturn(metaStoreElementType);
    final IMetaStoreElementType sharedDimensionElementType = SharedDimensionMetaStoreUtil.getSharedDimensionElementType(metaStore);
    verify(metaStore, times(1)).createNamespace(anyString());
    assertNotNull(sharedDimensionElementType);
    assertEquals(metaStoreElementType, sharedDimensionElementType);
    verify(sharedDimensionElementType, never()).setName(eq(SharedDimensionMetaStoreUtil.METASTORE_SHARED_DIMENSION_TYPE_NAME));
    verify(sharedDimensionElementType, never()).setDescription(eq(SharedDimensionMetaStoreUtil.METASTORE_SHARED_DIMENSION_TYPE_DESCRIPTION));
    verify(metaStore, never()).createElementType(anyString(), eq(sharedDimensionElementType));
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 58 with IMetaStore

use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.

the class Spoon method setRepository.

public void setRepository(Repository rep) {
    this.rep = rep;
    this.repositoryName = rep != null ? rep.getName() : null;
    try {
        // 
        if (metaStore.getMetaStoreList().size() > 1) {
            metaStore.getMetaStoreList().remove(0);
            metaStore.setActiveMetaStoreName(metaStore.getMetaStoreList().get(0).getName());
        }
        if (rep != null) {
            this.capabilities = rep.getRepositoryMeta().getRepositoryCapabilities();
            // add a wrapper metastore to the delegation
            // 
            IMetaStore repositoryMetaStore = rep.getMetaStore();
            if (repositoryMetaStore != null) {
                // first priority for explicitly connected repositories.
                metaStore.addMetaStore(0, repositoryMetaStore);
                metaStore.setActiveMetaStoreName(repositoryMetaStore.getName());
                log.logBasic("Connected to metastore : " + repositoryMetaStore.getName() + ", added to delegating metastore");
            } else {
                log.logBasic("No metastore found in the repository : " + rep.getName() + ", connected? " + rep.isConnected());
            }
        }
    } catch (MetaStoreException e) {
        new ErrorDialog(shell, BaseMessages.getString(PKG, "Spoon.Dialog.ErrorAddingRepositoryMetaStore.Title"), BaseMessages.getString(PKG, "Spoon.Dialog.ErrorReadingSharedObjects.Message"), e);
    }
    // Registering the UI Support classes
    UISupportRegistery.getInstance().registerUISupport(RepositorySecurityProvider.class, BaseRepositoryExplorerUISupport.class);
    UISupportRegistery.getInstance().registerUISupport(RepositorySecurityManager.class, ManageUserUISupport.class);
    if (rep != null) {
        SpoonPluginManager.getInstance().notifyLifecycleListeners(SpoonLifeCycleEvent.REPOSITORY_CHANGED);
    }
    delegates.update(this);
    enableMenus();
}
Also used : MetaStoreException(org.pentaho.metastore.api.exceptions.MetaStoreException) ErrorDialog(org.pentaho.di.ui.core.dialog.ErrorDialog) IMetaStore(org.pentaho.metastore.api.IMetaStore)

Example 59 with IMetaStore

use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.

the class SystemDataMetaTest method testLoadXML.

@Test
public void testLoadXML() throws Exception {
    SystemDataMeta systemDataMeta = new SystemDataMeta();
    DocumentBuilderFactory documentBuilderFactory = DocumentBuilderFactory.newInstance();
    DocumentBuilder documentBuilder = documentBuilderFactory.newDocumentBuilder();
    Document document = documentBuilder.parse(new InputSource(new StringReader(expectedXML)));
    Node node = document;
    IMetaStore store = null;
    systemDataMeta.loadXML(node, null, store);
    assertEquals(expectedSystemDataMeta, systemDataMeta);
}
Also used : InputSource(org.xml.sax.InputSource) DocumentBuilderFactory(javax.xml.parsers.DocumentBuilderFactory) DocumentBuilder(javax.xml.parsers.DocumentBuilder) Node(org.w3c.dom.Node) StringReader(java.io.StringReader) Document(org.w3c.dom.Document) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 60 with IMetaStore

use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.

the class AbortMetaTest method testBackwardsCapatibilityAbortWithError.

@Test
public void testBackwardsCapatibilityAbortWithError() throws KettleXMLException {
    IMetaStore metaStore = mock(IMetaStore.class);
    AbortMeta meta = new AbortMeta();
    // Abort with error
    String inputXml = "  <step>\n" + "    <name>Abort</name>\n" + "    <type>Abort</type>\n" + "    <abort_with_error>Y</abort_with_error>\n" + "  </step>";
    Node node = XMLHandler.loadXMLString(inputXml).getFirstChild();
    meta.loadXML(node, Collections.emptyList(), metaStore);
    assertTrue(meta.isAbortWithError());
    // Don't abort with error
    inputXml = "  <step>\n" + "    <name>Abort</name>\n" + "    <type>Abort</type>\n" + "    <abort_with_error>N</abort_with_error>\n" + "  </step>";
    node = XMLHandler.loadXMLString(inputXml).getFirstChild();
    meta.loadXML(node, Collections.emptyList(), metaStore);
    assertTrue(meta.isAbort());
    // Don't abort with error
    inputXml = "  <step>\n" + "    <name>Abort</name>\n" + "    <type>Abort</type>\n" + "  </step>";
    node = XMLHandler.loadXMLString(inputXml).getFirstChild();
    meta.loadXML(node, Collections.emptyList(), metaStore);
    assertTrue(meta.isAbortWithError());
}
Also used : Node(org.w3c.dom.Node) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Aggregations

IMetaStore (org.pentaho.metastore.api.IMetaStore)75 Test (org.junit.Test)55 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)20 SQL (org.pentaho.di.core.sql.SQL)17 Repository (org.pentaho.di.repository.Repository)17 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)11 TransMeta (org.pentaho.di.trans.TransMeta)11 Matchers.anyString (org.mockito.Matchers.anyString)10 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)10 StepMeta (org.pentaho.di.trans.step.StepMeta)10 KettleException (org.pentaho.di.core.exception.KettleException)9 IMetaStoreElementType (org.pentaho.metastore.api.IMetaStoreElementType)9 Node (org.w3c.dom.Node)8 ArrayList (java.util.ArrayList)7 Variables (org.pentaho.di.core.variables.Variables)7 PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)7 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)7 IMetaStoreElement (org.pentaho.metastore.api.IMetaStoreElement)6 CheckResultInterface (org.pentaho.di.core.CheckResultInterface)5 StringObjectId (org.pentaho.di.repository.StringObjectId)5