Search in sources :

Example 46 with IMetaStore

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

the class WebServiceMetaTest method testCheck.

@Test
public void testCheck() throws Exception {
    WebServiceMeta webServiceMeta = new WebServiceMeta();
    TransMeta transMeta = mock(TransMeta.class);
    StepMeta stepMeta = mock(StepMeta.class);
    RowMetaInterface prev = mock(RowMetaInterface.class);
    RowMetaInterface info = mock(RowMetaInterface.class);
    Repository rep = mock(Repository.class);
    IMetaStore metastore = mock(IMetaStore.class);
    String[] input = { "one" };
    ArrayList<CheckResultInterface> remarks = new ArrayList<>();
    webServiceMeta.check(remarks, transMeta, stepMeta, null, input, null, info, new Variables(), rep, metastore);
    assertEquals(2, remarks.size());
    assertEquals("Not receiving any fields from previous steps!", remarks.get(0).getText());
    assertEquals("Step is receiving info from other steps.", remarks.get(1).getText());
    remarks.clear();
    webServiceMeta.setInFieldArgumentName("ifan");
    when(prev.size()).thenReturn(2);
    webServiceMeta.check(remarks, transMeta, stepMeta, prev, new String[] {}, null, info, new Variables(), rep, metastore);
    assertEquals(2, remarks.size());
    assertEquals("Step is connected to previous one, receiving 2 fields", remarks.get(0).getText());
    assertEquals("No input received from other steps!", remarks.get(1).getText());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) Repository(org.pentaho.di.repository.Repository) TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 47 with IMetaStore

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

the class ZipFileMetaTest method testLoadAndGetXml.

@Test
public void testLoadAndGetXml() throws Exception {
    ZipFileMeta zipFileMeta = new ZipFileMeta();
    Node stepnode = getTestNode();
    DatabaseMeta dbMeta = mock(DatabaseMeta.class);
    IMetaStore metaStore = mock(IMetaStore.class);
    StepMeta mockParentStepMeta = mock(StepMeta.class);
    zipFileMeta.setParentStepMeta(mockParentStepMeta);
    TransMeta mockTransMeta = mock(TransMeta.class);
    NamedClusterEmbedManager embedManager = mock(NamedClusterEmbedManager.class);
    when(mockParentStepMeta.getParentTransMeta()).thenReturn(mockTransMeta);
    when(mockTransMeta.getNamedClusterEmbedManager()).thenReturn(embedManager);
    zipFileMeta.loadXML(stepnode, Collections.singletonList(dbMeta), metaStore);
    assertXmlOutputMeta(zipFileMeta);
}
Also used : Node(org.w3c.dom.Node) TransMeta(org.pentaho.di.trans.TransMeta) NamedClusterEmbedManager(org.pentaho.di.trans.steps.named.cluster.NamedClusterEmbedManager) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) StepMeta(org.pentaho.di.trans.step.StepMeta) Test(org.junit.Test)

Example 48 with IMetaStore

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

the class ZipFileMetaTest method testCheck.

@Test
public void testCheck() {
    ZipFileMeta zipFileMeta = new ZipFileMeta();
    zipFileMeta.setDefault();
    TransMeta transMeta = mock(TransMeta.class);
    StepMeta stepInfo = mock(StepMeta.class);
    RowMetaInterface prev = mock(RowMetaInterface.class);
    Repository repos = mock(Repository.class);
    IMetaStore metastore = mock(IMetaStore.class);
    RowMetaInterface info = mock(RowMetaInterface.class);
    ArrayList<CheckResultInterface> remarks = new ArrayList<>();
    zipFileMeta.check(remarks, transMeta, stepInfo, prev, new String[] { "input" }, new String[] { "output" }, info, new Variables(), repos, metastore);
    assertEquals(2, remarks.size());
    assertEquals("Source Filename field is missing!", remarks.get(0).getText());
    assertEquals("Step is receiving info from other steps.", remarks.get(1).getText());
    remarks = new ArrayList<>();
    zipFileMeta = new ZipFileMeta();
    zipFileMeta.setDynamicSourceFileNameField("sourceFileField");
    zipFileMeta.check(remarks, transMeta, stepInfo, prev, new String[0], new String[] { "output" }, info, new Variables(), repos, metastore);
    assertEquals(2, remarks.size());
    assertEquals("Target Filename field was specified", remarks.get(0).getText());
    assertEquals("No input received from other steps!", remarks.get(1).getText());
}
Also used : Variables(org.pentaho.di.core.variables.Variables) Repository(org.pentaho.di.repository.Repository) TransMeta(org.pentaho.di.trans.TransMeta) ArrayList(java.util.ArrayList) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) CheckResultInterface(org.pentaho.di.core.CheckResultInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 49 with IMetaStore

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

the class PurRepositoryIT method testMetaStoreElementTypes.

@Test
public void testMetaStoreElementTypes() throws MetaStoreException {
    IMetaStore metaStore = repository.getMetaStore();
    assertNotNull(metaStore);
    String ns = PentahoDefaults.NAMESPACE;
    // We start with a clean slate...
    // 
    assertEquals(1, metaStore.getNamespaces().size());
    assertEquals(true, metaStore.namespaceExists(ns));
    // Now create an element type
    // 
    IMetaStoreElementType elementType = metaStore.newElementType(ns);
    elementType.setName(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_NAME);
    elementType.setDescription(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_DESCRIPTION);
    metaStore.createElementType(ns, elementType);
    IMetaStoreElementType verifyElementType = metaStore.getElementType(ns, elementType.getId());
    assertEquals(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_NAME, verifyElementType.getName());
    assertEquals(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_DESCRIPTION, verifyElementType.getDescription());
    verifyElementType = metaStore.getElementTypeByName(ns, PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_NAME);
    assertEquals(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_NAME, verifyElementType.getName());
    assertEquals(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_DESCRIPTION, verifyElementType.getDescription());
    // Get the list of element type ids.
    // 
    List<String> ids = metaStore.getElementTypeIds(ns);
    assertNotNull(ids);
    assertEquals(1, ids.size());
    assertEquals(elementType.getId(), ids.get(0));
    // 
    try {
        metaStore.deleteNamespace(ns);
        fail("The namespace deletion didn't cause an exception because there are still an element type in it");
    } catch (MetaStoreDependenciesExistsException e) {
        assertNotNull(e.getDependencies());
        assertEquals(1, e.getDependencies().size());
        assertEquals(elementType.getId(), e.getDependencies().get(0));
    }
    metaStore.deleteElementType(ns, elementType);
    assertEquals(0, metaStore.getElementTypes(ns).size());
    metaStore.deleteNamespace(ns);
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) Matchers.anyString(org.mockito.Matchers.anyString) IMetaStore(org.pentaho.metastore.api.IMetaStore) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) Test(org.junit.Test)

Example 50 with IMetaStore

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

the class PurRepositoryIT method testMetaStoreElements.

@Test
public void testMetaStoreElements() throws MetaStoreException {
    // Set up a namespace
    // 
    String ns = PentahoDefaults.NAMESPACE;
    IMetaStore metaStore = repository.getMetaStore();
    if (!metaStore.namespaceExists(ns)) {
        metaStore.createNamespace(ns);
    }
    // And an element type
    // 
    IMetaStoreElementType elementType = metaStore.newElementType(ns);
    elementType.setName(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_NAME);
    elementType.setDescription(PentahoDefaults.KETTLE_DATA_SERVICE_ELEMENT_TYPE_DESCRIPTION);
    metaStore.createElementType(ns, elementType);
    // Now we play with elements...
    // 
    IMetaStoreElement oneElement = populateElement(metaStore, elementType, "Element One");
    metaStore.createElement(ns, elementType, oneElement);
    IMetaStoreElement verifyOneElement = metaStore.getElement(ns, elementType, oneElement.getId());
    assertNotNull(verifyOneElement);
    validateElement(verifyOneElement, "Element One");
    assertEquals(1, metaStore.getElements(ns, elementType).size());
    IMetaStoreElement twoElement = populateElement(metaStore, elementType, "Element Two");
    metaStore.createElement(ns, elementType, twoElement);
    IMetaStoreElement verifyTwoElement = metaStore.getElement(ns, elementType, twoElement.getId());
    assertNotNull(verifyTwoElement);
    assertEquals(2, metaStore.getElements(ns, elementType).size());
    try {
        metaStore.deleteElementType(ns, elementType);
        fail("Delete element type failed to properly detect element dependencies");
    } catch (MetaStoreDependenciesExistsException e) {
        List<String> ids = e.getDependencies();
        assertEquals(2, ids.size());
        assertTrue(ids.contains(oneElement.getId()));
        assertTrue(ids.contains(twoElement.getId()));
    }
    metaStore.deleteElement(ns, elementType, oneElement.getId());
    assertEquals(1, metaStore.getElements(ns, elementType).size());
    metaStore.deleteElement(ns, elementType, twoElement.getId());
    assertEquals(0, metaStore.getElements(ns, elementType).size());
}
Also used : IMetaStoreElementType(org.pentaho.metastore.api.IMetaStoreElementType) IMetaStoreElement(org.pentaho.metastore.api.IMetaStoreElement) ArrayList(java.util.ArrayList) AbstractList(java.util.AbstractList) List(java.util.List) Matchers.anyString(org.mockito.Matchers.anyString) IMetaStore(org.pentaho.metastore.api.IMetaStore) MetaStoreDependenciesExistsException(org.pentaho.metastore.api.exceptions.MetaStoreDependenciesExistsException) 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