Search in sources :

Example 1 with MemoryMetaStore

use of org.pentaho.metastore.stores.memory.MemoryMetaStore in project pentaho-kettle by pentaho.

the class TransMetaTest method testDatabaseNotOverridden.

@Test
public void testDatabaseNotOverridden() throws Exception {
    final String name = "db meta";
    DatabaseMeta dbMetaShared = new DatabaseMeta();
    dbMetaShared.setName(name);
    dbMetaShared.setHostname("host");
    DatabaseMeta dbMetaStore = new DatabaseMeta();
    dbMetaStore.setName(name);
    dbMetaStore.setHostname("anotherhost");
    IMetaStore mstore = new MemoryMetaStore();
    DatabaseMetaStoreUtil.createDatabaseElement(mstore, dbMetaStore);
    TransMeta trans = new TransMeta();
    trans.addOrReplaceDatabase(dbMetaShared);
    trans.setMetaStore(mstore);
    trans.importFromMetaStore();
    DatabaseMeta dbMeta = trans.findDatabase(name);
    assertEquals(dbMetaShared.getHostname(), dbMeta.getHostname());
}
Also used : MemoryMetaStore(org.pentaho.metastore.stores.memory.MemoryMetaStore) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 2 with MemoryMetaStore

use of org.pentaho.metastore.stores.memory.MemoryMetaStore in project pentaho-kettle by pentaho.

the class RepositoryUnitIT method testGetXMLDataMetaSaveAndReadRep.

/**
 * This test is to ensure that the metadata for the GetXMLData step is preserved when saving to a
 * repository. The test creates a GetXMLData step and saves it to the repository. Then the local
 * data is changed and the step is read back in from the repository. It is then asserted that the
 * field value(s) are equal to what was saved.
 *
 * Test method for
 * {@link org.pentaho.di.trans.steps.getxmldata.GetXMLDataMeta#readRep(org.pentaho.di.repository.Repository,
 * org.pentaho.di.repository.ObjectId, java.util.List, java.util.Map)}
 * . Test method for
 * {@link org.pentaho.di.trans.steps.getxmldata.GetXMLDataMeta#saveRep(org.pentaho.di.repository.Repository,
 * org.pentaho.di.repository.ObjectId, jorg.pentaho.di.repository.ObjectId)}
 * .
 */
@Test
public void testGetXMLDataMetaSaveAndReadRep() {
    // 
    // Create a new transformation...
    // 
    TransMeta transMeta = new TransMeta();
    transMeta.setName("getxmldata1");
    // 
    // Create a Get XML Data step
    // 
    String getXMLDataName = "get xml data step";
    GetXMLDataMeta gxdm = new GetXMLDataMeta();
    String getXMLDataPid = registry.getPluginId(StepPluginType.class, gxdm);
    StepMeta getXMLDataStep = new StepMeta(getXMLDataPid, getXMLDataName, gxdm);
    transMeta.addStep(getXMLDataStep);
    GetXMLDataField[] fields = new GetXMLDataField[1];
    for (int idx = 0; idx < fields.length; idx++) {
        fields[idx] = new GetXMLDataField();
    }
    fields[0].setName("objectid");
    fields[0].setXPath("ObjectID");
    fields[0].setElementType(GetXMLDataField.ELEMENT_TYPE_NODE);
    fields[0].setResultType(GetXMLDataField.RESULT_TYPE_TYPE_SINGLE_NODE);
    fields[0].setType(ValueMetaInterface.TYPE_STRING);
    fields[0].setFormat("");
    fields[0].setLength(-1);
    fields[0].setPrecision(-1);
    fields[0].setCurrencySymbol("");
    fields[0].setDecimalSymbol("");
    fields[0].setGroupSymbol("");
    fields[0].setTrimType(GetXMLDataField.TYPE_TRIM_NONE);
    gxdm.setDefault();
    gxdm.setEncoding("UTF-8");
    gxdm.setIsAFile(false);
    gxdm.setInFields(true);
    gxdm.setLoopXPath("/");
    gxdm.setXMLField("field1");
    gxdm.setInputFields(fields);
    try {
        // Now save the transformation and then read it back in
        transMeta.setRepository(repository);
        RepositoryDirectoryInterface repositoryDirectory = repository.findDirectory("/");
        transMeta.setRepositoryDirectory(repositoryDirectory);
        repository.transDelegate.saveTransformation(transMeta, "None", null, true);
        // Create a new placeholder meta and set the result type to something different than what was
        // saved,
        // to ensure the saveRep code is working correctly.
        GetXMLDataMeta newMeta = (GetXMLDataMeta) gxdm.clone();
        for (GetXMLDataField f : newMeta.getInputFields()) {
            f.setResultType(GetXMLDataField.RESULT_TYPE_VALUE_OF);
        }
        newMeta.readRep(repository, new MemoryMetaStore(), getXMLDataStep.getObjectId(), repository.getDatabases());
        // Check that the value of Result Type is what was saved in the repo
        assertEquals(newMeta.getInputFields()[0].getResultTypeCode(), "singlenode");
    } catch (KettleException e) {
        fail("Test failed due to exception: " + e.getLocalizedMessage());
    }
}
Also used : MemoryMetaStore(org.pentaho.metastore.stores.memory.MemoryMetaStore) KettleException(org.pentaho.di.core.exception.KettleException) GetXMLDataMeta(org.pentaho.di.trans.steps.getxmldata.GetXMLDataMeta) TransMeta(org.pentaho.di.trans.TransMeta) GetXMLDataField(org.pentaho.di.trans.steps.getxmldata.GetXMLDataField) StepMeta(org.pentaho.di.trans.step.StepMeta) Test(org.junit.Test)

Example 3 with MemoryMetaStore

use of org.pentaho.metastore.stores.memory.MemoryMetaStore in project pdi-dataservice-server-plugin by pentaho.

the class DataServiceFactoryTest method testLocalMetaStore.

@Test
public void testLocalMetaStore() throws Exception {
    DataServiceFactory.localPentahoMetaStore = new MemoryMetaStore();
    assertThat(factory.getRepository(), sameInstance(repository));
    assertThat(factory.getMetaStore(), sameInstance((IMetaStore) metaStore));
    when(supplier.get()).thenReturn(null);
    assertThat(factory.getRepository(), nullValue());
    assertThat(factory.getMetaStore(), sameInstance(DataServiceFactory.localPentahoMetaStore));
}
Also used : MemoryMetaStore(org.pentaho.metastore.stores.memory.MemoryMetaStore) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 4 with MemoryMetaStore

use of org.pentaho.metastore.stores.memory.MemoryMetaStore in project pentaho-kettle by pentaho.

the class RunConfigurationManagerTest method setup.

@Before
public void setup() throws Exception {
    MemoryMetaStore memoryMetaStore = new MemoryMetaStore();
    MetastoreLocator metastoreLocator = createMetastoreLocator(memoryMetaStore);
    DefaultRunConfigurationProvider defaultRunConfigurationProvider = new DefaultRunConfigurationProvider(metastoreLocator, defaultRunConfigurationExecutor);
    SparkRunConfigurationExecutor sparkRunConfigurationExecutor = new SparkRunConfigurationExecutor(null);
    SparkRunConfigurationProvider sparkRunConfigurationProvider = new SparkRunConfigurationProvider(metastoreLocator, sparkRunConfigurationExecutor);
    List<RunConfigurationProvider> runConfigurationProviders = new ArrayList<>();
    runConfigurationProviders.add(sparkRunConfigurationProvider);
    executionConfigurationManager = new RunConfigurationManager(runConfigurationProviders);
    executionConfigurationManager.setDefaultRunConfigurationProvider(defaultRunConfigurationProvider);
    DefaultRunConfiguration defaultRunConfiguration = new DefaultRunConfiguration();
    defaultRunConfiguration.setName("Default Configuration");
    defaultRunConfiguration.setDescription("Default Configuration Description");
    defaultRunConfiguration.setLocal(true);
    executionConfigurationManager.save(defaultRunConfiguration);
    SparkRunConfiguration sparkRunConfiguration = new SparkRunConfiguration();
    sparkRunConfiguration.setName("Spark Configuration");
    sparkRunConfiguration.setDescription("Spark Configuration Description");
    sparkRunConfiguration.setUrl("127.0.0.1");
    executionConfigurationManager.save(sparkRunConfiguration);
}
Also used : MemoryMetaStore(org.pentaho.metastore.stores.memory.MemoryMetaStore) DefaultRunConfigurationProvider(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfigurationProvider) SparkRunConfigurationProvider(org.pentaho.di.engine.configuration.impl.spark.SparkRunConfigurationProvider) SparkRunConfiguration(org.pentaho.di.engine.configuration.impl.spark.SparkRunConfiguration) SparkRunConfigurationExecutor(org.pentaho.di.engine.configuration.impl.spark.SparkRunConfigurationExecutor) ArrayList(java.util.ArrayList) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) MetastoreLocator(org.pentaho.osgi.metastore.locator.api.MetastoreLocator) SparkRunConfigurationProvider(org.pentaho.di.engine.configuration.impl.spark.SparkRunConfigurationProvider) RunConfigurationProvider(org.pentaho.di.engine.configuration.api.RunConfigurationProvider) DefaultRunConfigurationProvider(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfigurationProvider) Before(org.junit.Before)

Example 5 with MemoryMetaStore

use of org.pentaho.metastore.stores.memory.MemoryMetaStore in project pentaho-kettle by pentaho.

the class RunConfigurationManagerTest method testOrdering.

@Test
public void testOrdering() {
    MemoryMetaStore memoryMetaStore = new MemoryMetaStore();
    MetastoreLocator metastoreLocator = createMetastoreLocator(memoryMetaStore);
    DefaultRunConfigurationProvider defaultRunConfigurationProvider = new DefaultRunConfigurationProvider(metastoreLocator, defaultRunConfigurationExecutor);
    SparkRunConfigurationExecutor sparkRunConfigurationExecutor = new SparkRunConfigurationExecutor(null);
    SparkRunConfigurationProvider sparkRunConfigurationProvider = new SparkRunConfigurationProvider(metastoreLocator, sparkRunConfigurationExecutor);
    List<RunConfigurationProvider> runConfigurationProviders = new ArrayList<>();
    runConfigurationProviders.add(sparkRunConfigurationProvider);
    executionConfigurationManager = new RunConfigurationManager(runConfigurationProviders);
    executionConfigurationManager.setDefaultRunConfigurationProvider(defaultRunConfigurationProvider);
    DefaultRunConfiguration defaultRunConfiguration1 = new DefaultRunConfiguration();
    defaultRunConfiguration1.setName("z");
    executionConfigurationManager.save(defaultRunConfiguration1);
    DefaultRunConfiguration defaultRunConfiguration2 = new DefaultRunConfiguration();
    defaultRunConfiguration2.setName("f");
    executionConfigurationManager.save(defaultRunConfiguration2);
    DefaultRunConfiguration defaultRunConfiguration3 = new DefaultRunConfiguration();
    defaultRunConfiguration3.setName("x");
    executionConfigurationManager.save(defaultRunConfiguration3);
    SparkRunConfiguration sparkRunConfiguration = new SparkRunConfiguration();
    sparkRunConfiguration.setName("d");
    executionConfigurationManager.save(sparkRunConfiguration);
    DefaultRunConfiguration defaultRunConfiguration5 = new DefaultRunConfiguration();
    defaultRunConfiguration5.setName("a");
    executionConfigurationManager.save(defaultRunConfiguration5);
    List<RunConfiguration> runConfigurations = executionConfigurationManager.load();
    assertEquals(runConfigurations.get(0).getName(), DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME);
    assertEquals(runConfigurations.get(1).getName(), "a");
    assertEquals(runConfigurations.get(2).getName(), "d");
    assertEquals(runConfigurations.get(3).getName(), "f");
    assertEquals(runConfigurations.get(4).getName(), "x");
    assertEquals(runConfigurations.get(5).getName(), "z");
    List<String> names = executionConfigurationManager.getNames();
    assertEquals(names.get(0), DefaultRunConfigurationProvider.DEFAULT_CONFIG_NAME);
    assertEquals(names.get(1), "a");
    assertEquals(names.get(2), "d");
    assertEquals(names.get(3), "f");
    assertEquals(names.get(4), "x");
    assertEquals(names.get(5), "z");
}
Also used : DefaultRunConfigurationProvider(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfigurationProvider) SparkRunConfiguration(org.pentaho.di.engine.configuration.impl.spark.SparkRunConfiguration) ArrayList(java.util.ArrayList) MetastoreLocator(org.pentaho.osgi.metastore.locator.api.MetastoreLocator) MemoryMetaStore(org.pentaho.metastore.stores.memory.MemoryMetaStore) SparkRunConfigurationProvider(org.pentaho.di.engine.configuration.impl.spark.SparkRunConfigurationProvider) RunConfiguration(org.pentaho.di.engine.configuration.api.RunConfiguration) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) SparkRunConfiguration(org.pentaho.di.engine.configuration.impl.spark.SparkRunConfiguration) SparkRunConfigurationExecutor(org.pentaho.di.engine.configuration.impl.spark.SparkRunConfigurationExecutor) DefaultRunConfiguration(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration) SparkRunConfigurationProvider(org.pentaho.di.engine.configuration.impl.spark.SparkRunConfigurationProvider) RunConfigurationProvider(org.pentaho.di.engine.configuration.api.RunConfigurationProvider) DefaultRunConfigurationProvider(org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfigurationProvider) Test(org.junit.Test)

Aggregations

MemoryMetaStore (org.pentaho.metastore.stores.memory.MemoryMetaStore)5 Test (org.junit.Test)4 ArrayList (java.util.ArrayList)2 RunConfigurationProvider (org.pentaho.di.engine.configuration.api.RunConfigurationProvider)2 DefaultRunConfiguration (org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfiguration)2 DefaultRunConfigurationProvider (org.pentaho.di.engine.configuration.impl.pentaho.DefaultRunConfigurationProvider)2 SparkRunConfiguration (org.pentaho.di.engine.configuration.impl.spark.SparkRunConfiguration)2 SparkRunConfigurationExecutor (org.pentaho.di.engine.configuration.impl.spark.SparkRunConfigurationExecutor)2 SparkRunConfigurationProvider (org.pentaho.di.engine.configuration.impl.spark.SparkRunConfigurationProvider)2 IMetaStore (org.pentaho.metastore.api.IMetaStore)2 MetastoreLocator (org.pentaho.osgi.metastore.locator.api.MetastoreLocator)2 Before (org.junit.Before)1 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)1 KettleException (org.pentaho.di.core.exception.KettleException)1 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)1 RunConfiguration (org.pentaho.di.engine.configuration.api.RunConfiguration)1 TransMeta (org.pentaho.di.trans.TransMeta)1 StepMeta (org.pentaho.di.trans.step.StepMeta)1 GetXMLDataField (org.pentaho.di.trans.steps.getxmldata.GetXMLDataField)1 GetXMLDataMeta (org.pentaho.di.trans.steps.getxmldata.GetXMLDataMeta)1