Search in sources :

Example 1 with MemoryRepository

use of org.pentaho.di.trans.steps.loadsave.MemoryRepository in project pentaho-kettle by pentaho.

the class UnivariateStatsMetaFunctionTest method testRepoConstructor.

@Test
public void testRepoConstructor() throws ParseException, KettleException, IOException {
    String jsString = IOUtils.toString(UnivariateStatsMetaTest.class.getClassLoader().getResourceAsStream("org/pentaho/di/trans/steps/univariatestats/trueValuesUnivariateStatsMetaFunctionNode.json"));
    Repository repo = new MemoryRepository(jsString);
    UnivariateStatsMetaFunction function = new UnivariateStatsMetaFunction(repo, new StringObjectId("test"), 0);
    assertEquals("test", function.getSourceFieldName());
    assertTrue(function.getCalcN());
    assertTrue(function.getCalcMean());
    assertTrue(function.getCalcStdDev());
    assertTrue(function.getCalcMin());
    assertTrue(function.getCalcMax());
    assertTrue(function.getCalcMedian());
    assertEquals(0.5, function.getCalcPercentile(), 0);
    assertTrue(function.getInterpolatePercentile());
    jsString = IOUtils.toString(UnivariateStatsMetaTest.class.getClassLoader().getResourceAsStream("org/pentaho/di/trans/steps/univariatestats/falseValuesUnivariateStatsMetaFunctionNode.json"));
    repo = new MemoryRepository(jsString);
    function = new UnivariateStatsMetaFunction(repo, new StringObjectId("test"), 0);
    assertTrue(Utils.isEmpty(function.getSourceFieldName()));
    assertFalse(function.getCalcN());
    assertFalse(function.getCalcMean());
    assertFalse(function.getCalcStdDev());
    assertFalse(function.getCalcMin());
    assertFalse(function.getCalcMax());
    assertFalse(function.getCalcMedian());
    assertEquals(-1.0, function.getCalcPercentile(), 0);
    assertFalse(function.getInterpolatePercentile());
}
Also used : Repository(org.pentaho.di.repository.Repository) MemoryRepository(org.pentaho.di.trans.steps.loadsave.MemoryRepository) MemoryRepository(org.pentaho.di.trans.steps.loadsave.MemoryRepository) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 2 with MemoryRepository

use of org.pentaho.di.trans.steps.loadsave.MemoryRepository in project pentaho-kettle by pentaho.

the class TableOutputMetaTest method testReadRep.

/**
 * @see
 *     <a href=http://jira.pentaho.com/browse/BACKLOG-377>http://jira.pentaho.com/browse/BACKLOG-377</a>
 * @throws KettleException
 */
@Test
public void testReadRep() throws KettleException {
    // check variable
    String commitSize = "${test}";
    Repository rep = new MemoryRepository();
    rep.saveStepAttribute(null, null, "commit", commitSize);
    TableOutputMeta tableOutputMeta = new TableOutputMeta();
    tableOutputMeta.readRep(rep, metaStore, null, databases);
    assertEquals(commitSize, tableOutputMeta.getCommitSize());
    // check integer size
    int commitSizeInt = 1;
    Repository rep2 = new MemoryRepository();
    rep2.saveStepAttribute(null, null, "commit", commitSizeInt);
    TableOutputMeta tableOutputMeta2 = new TableOutputMeta();
    tableOutputMeta2.readRep(rep2, metaStore, null, databases);
    assertEquals(String.valueOf(commitSizeInt), tableOutputMeta2.getCommitSize());
}
Also used : Repository(org.pentaho.di.repository.Repository) MemoryRepository(org.pentaho.di.trans.steps.loadsave.MemoryRepository) MemoryRepository(org.pentaho.di.trans.steps.loadsave.MemoryRepository) Test(org.junit.Test)

Example 3 with MemoryRepository

use of org.pentaho.di.trans.steps.loadsave.MemoryRepository in project pentaho-kettle by pentaho.

the class LoadSaveTester method testRepoRoundTrip.

public void testRepoRoundTrip() throws KettleException {
    T metaToSave = createMeta();
    Map<String, FieldLoadSaveValidator<?>> validatorMap = createValidatorMapAndInvokeSetters(repoAttributes, metaToSave);
    T metaLoaded = createMeta();
    Repository rep = new MemoryRepository();
    metaToSave.saveRep(rep, null, null);
    metaLoaded.loadRep(rep, null);
    validateLoadedMeta(repoAttributes, validatorMap, metaToSave, metaLoaded);
}
Also used : Repository(org.pentaho.di.repository.Repository) MemoryRepository(org.pentaho.di.trans.steps.loadsave.MemoryRepository) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) MemoryRepository(org.pentaho.di.trans.steps.loadsave.MemoryRepository)

Example 4 with MemoryRepository

use of org.pentaho.di.trans.steps.loadsave.MemoryRepository in project pentaho-kettle by pentaho.

the class RowGeneratorMetaTest method setUp.

@Before
public void setUp() throws KettleException {
    rep = new MemoryRepository();
    id_step = new StringObjectId("aStringObjectID");
    rep.saveStepAttribute(new StringObjectId("transId"), id_step, rowGeneratorRowLimitCode, launchVariable);
}
Also used : MemoryRepository(org.pentaho.di.trans.steps.loadsave.MemoryRepository) StringObjectId(org.pentaho.di.repository.StringObjectId) Before(org.junit.Before)

Example 5 with MemoryRepository

use of org.pentaho.di.trans.steps.loadsave.MemoryRepository in project pentaho-kettle by pentaho.

the class LoadSaveTester method testRepoRoundTrip.

@SuppressWarnings("deprecation")
public void testRepoRoundTrip() throws KettleException {
    T metaToSave = createMeta();
    if (initializer != null) {
        initializer.modify(metaToSave);
    }
    Map<String, FieldLoadSaveValidator<?>> validatorMap = createValidatorMapAndInvokeSetters(repoAttributes, metaToSave);
    T metaLoaded = createMeta();
    Repository rep = new MemoryRepository();
    metaToSave.saveRep(rep, null, null);
    metaLoaded.loadRep(rep, null, null, databases, null);
    validateLoadedMeta(repoAttributes, validatorMap, metaToSave, metaLoaded);
}
Also used : Repository(org.pentaho.di.repository.Repository) MemoryRepository(org.pentaho.di.trans.steps.loadsave.MemoryRepository) FieldLoadSaveValidator(org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator) MemoryRepository(org.pentaho.di.trans.steps.loadsave.MemoryRepository)

Aggregations

MemoryRepository (org.pentaho.di.trans.steps.loadsave.MemoryRepository)5 Repository (org.pentaho.di.repository.Repository)4 Test (org.junit.Test)2 StringObjectId (org.pentaho.di.repository.StringObjectId)2 FieldLoadSaveValidator (org.pentaho.di.trans.steps.loadsave.validator.FieldLoadSaveValidator)2 Before (org.junit.Before)1