Search in sources :

Example 46 with StringObjectId

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

the class KettleDatabaseRepository_GetObjectInformation_Test method getObjectInformation_ExistingJob_IsDeletedFlagNotSet.

@Test
public void getObjectInformation_ExistingJob_IsDeletedFlagNotSet() throws Exception {
    KettleDatabaseRepositoryJobDelegate jobDelegate = spy(new KettleDatabaseRepositoryJobDelegate(repository));
    RowMeta meta = createMetaForJob();
    Object[] values = new Object[meta.size()];
    values[Arrays.asList(meta.getFieldNames()).indexOf(KettleDatabaseRepositoryBase.FIELD_JOB_NAME)] = EXISTING_ID;
    doReturn(new RowMetaAndData(meta, values)).when(jobDelegate).getJob(new StringObjectId(EXISTING_ID));
    assertIsDeletedNotSet_ForExistingObject(null, jobDelegate, RepositoryObjectType.JOB);
}
Also used : RowMetaAndData(org.pentaho.di.core.RowMetaAndData) KettleDatabaseRepositoryJobDelegate(org.pentaho.di.repository.kdr.delegates.KettleDatabaseRepositoryJobDelegate) RowMeta(org.pentaho.di.core.row.RowMeta) RepositoryObject(org.pentaho.di.repository.RepositoryObject) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 47 with StringObjectId

use of org.pentaho.di.repository.StringObjectId 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 48 with StringObjectId

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

the class WebServiceMetaTest method testReadRep.

@Test
public void testReadRep() throws Exception {
    Repository rep = mock(Repository.class);
    IMetaStore metastore = mock(IMetaStore.class);
    DatabaseMeta dbMeta = mock(DatabaseMeta.class);
    StringObjectId id_step = new StringObjectId("oid");
    when(rep.getStepAttributeString(id_step, "wsOperation")).thenReturn("GetCurrentExchangeRate");
    when(rep.getStepAttributeString(id_step, "wsOperationRequest")).thenReturn("opRequest");
    when(rep.getStepAttributeString(id_step, "wsOperationNamespace")).thenReturn("opNamespace");
    when(rep.getStepAttributeString(id_step, "wsInFieldContainer")).thenReturn("ifc");
    when(rep.getStepAttributeString(id_step, "wsInFieldArgument")).thenReturn("ifa");
    when(rep.getStepAttributeString(id_step, "wsOutFieldContainer")).thenReturn("ofc");
    when(rep.getStepAttributeString(id_step, "wsOutFieldArgument")).thenReturn("ofa");
    when(rep.getStepAttributeString(id_step, "proxyHost")).thenReturn("phost");
    when(rep.getStepAttributeString(id_step, "proxyPort")).thenReturn("1234");
    when(rep.getStepAttributeString(id_step, "httpLogin")).thenReturn("user");
    when(rep.getStepAttributeString(id_step, "httpPassword")).thenReturn("password");
    when(rep.getStepAttributeInteger(id_step, "callStep")).thenReturn(2L);
    when(rep.getStepAttributeBoolean(id_step, "passingInputData")).thenReturn(true);
    when(rep.getStepAttributeBoolean(id_step, 0, "compatible", true)).thenReturn(false);
    when(rep.getStepAttributeString(id_step, "repeating_element")).thenReturn("repeat");
    when(rep.getStepAttributeBoolean(id_step, 0, "reply_as_string")).thenReturn(true);
    when(rep.countNrStepAttributes(id_step, "fieldIn_ws_name")).thenReturn(2);
    when(rep.getStepAttributeString(id_step, 0, "fieldIn_name")).thenReturn("bank");
    when(rep.getStepAttributeString(id_step, 0, "fieldIn_ws_name")).thenReturn("inBank");
    when(rep.getStepAttributeString(id_step, 0, "fieldIn_xsd_type")).thenReturn("string");
    when(rep.getStepAttributeString(id_step, 1, "fieldIn_name")).thenReturn("branch");
    when(rep.getStepAttributeString(id_step, 1, "fieldIn_ws_name")).thenReturn("inBranch");
    when(rep.getStepAttributeString(id_step, 1, "fieldIn_xsd_type")).thenReturn("string");
    when(rep.countNrStepAttributes(id_step, "fieldOut_ws_name")).thenReturn(2);
    when(rep.getStepAttributeString(id_step, 0, "fieldOut_name")).thenReturn("balance");
    when(rep.getStepAttributeString(id_step, 0, "fieldOut_ws_name")).thenReturn("outBalance");
    when(rep.getStepAttributeString(id_step, 0, "fieldOut_xsd_type")).thenReturn("int");
    when(rep.getStepAttributeString(id_step, 1, "fieldOut_name")).thenReturn("transactions");
    when(rep.getStepAttributeString(id_step, 1, "fieldOut_ws_name")).thenReturn("outTransactions");
    when(rep.getStepAttributeString(id_step, 1, "fieldOut_xsd_type")).thenReturn("int");
    WebServiceMeta webServiceMeta = new WebServiceMeta(rep, metastore, id_step, Collections.singletonList(dbMeta));
    String expectedXml = "" + "    <wsURL/>\n" + "    <wsOperation>GetCurrentExchangeRate</wsOperation>\n" + "    <wsOperationRequest>opRequest</wsOperationRequest>\n" + "    <wsOperationNamespace>opNamespace</wsOperationNamespace>\n" + "    <wsInFieldContainer>ifc</wsInFieldContainer>\n" + "    <wsInFieldArgument>ifa</wsInFieldArgument>\n" + "    <wsOutFieldContainer>ofc</wsOutFieldContainer>\n" + "    <wsOutFieldArgument>ofa</wsOutFieldArgument>\n" + "    <proxyHost>phost</proxyHost>\n" + "    <proxyPort>1234</proxyPort>\n" + "    <httpLogin>user</httpLogin>\n" + "    <httpPassword>password</httpPassword>\n" + "    <callStep>2</callStep>\n" + "    <passingInputData>Y</passingInputData>\n" + "    <compatible>N</compatible>\n" + "    <repeating_element>repeat</repeating_element>\n" + "    <reply_as_string>Y</reply_as_string>\n" + "    <fieldsIn>\n" + "    <field>\n" + "        <name>bank</name>\n" + "        <wsName>inBank</wsName>\n" + "        <xsdType>string</xsdType>\n" + "    </field>\n" + "    <field>\n" + "        <name>branch</name>\n" + "        <wsName>inBranch</wsName>\n" + "        <xsdType>string</xsdType>\n" + "    </field>\n" + "      </fieldsIn>\n" + "    <fieldsOut>\n" + "    <field>\n" + "        <name>balance</name>\n" + "        <wsName>outBalance</wsName>\n" + "        <xsdType>int</xsdType>\n" + "    </field>\n" + "    <field>\n" + "        <name>transactions</name>\n" + "        <wsName>outTransactions</wsName>\n" + "        <xsdType>int</xsdType>\n" + "    </field>\n" + "      </fieldsOut>\n";
    String actualXml = TestUtils.toUnixLineSeparators(webServiceMeta.getXML());
    assertEquals(expectedXml, actualXml);
}
Also used : Repository(org.pentaho.di.repository.Repository) ValueMetaString(org.pentaho.di.core.row.value.ValueMetaString) IMetaStore(org.pentaho.metastore.api.IMetaStore) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 49 with StringObjectId

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

the class ZipFileMetaTest method testReadRep.

@Test
public void testReadRep() throws Exception {
    ZipFileMeta zipFileMeta = new ZipFileMeta();
    Repository rep = mock(Repository.class);
    IMetaStore metastore = mock(IMetaStore.class);
    DatabaseMeta dbMeta = mock(DatabaseMeta.class);
    StringObjectId oid = new StringObjectId("oid");
    when(rep.getStepAttributeString(oid, "sourcefilenamefield")).thenReturn(SOURCE_FILENAME);
    when(rep.getStepAttributeString(oid, "targetfilenamefield")).thenReturn(TARGET_FILENAME);
    when(rep.getStepAttributeString(oid, "baseFolderField")).thenReturn(BASE_FOLDER);
    when(rep.getStepAttributeString(oid, "operation_type")).thenReturn(OPERATION_TYPE);
    when(rep.getStepAttributeBoolean(oid, "addresultfilenames")).thenReturn(ADD_RESULT_FILENAME);
    when(rep.getStepAttributeBoolean(oid, "overwritezipentry")).thenReturn(OVERWRITE_ZIP_ENTRY);
    when(rep.getStepAttributeBoolean(oid, "createparentfolder")).thenReturn(CREATE_PARENT_FOLDER);
    when(rep.getStepAttributeBoolean(oid, "keepsourcefolder")).thenReturn(KEEP_SOURCE_FOLDER);
    when(rep.getStepAttributeString(oid, "movetofolderfield")).thenReturn(MOVE_TO_FOLDER_FIELD);
    zipFileMeta.readRep(rep, metastore, oid, Collections.singletonList(dbMeta));
    assertEquals(SOURCE_FILENAME, zipFileMeta.getDynamicSourceFileNameField());
    assertEquals(TARGET_FILENAME, zipFileMeta.getDynamicTargetFileNameField());
    assertEquals(BASE_FOLDER, zipFileMeta.getBaseFolderField());
    assertEquals(ZipFileMeta.getOperationTypeByDesc(OPERATION_TYPE), zipFileMeta.getOperationType());
    assertEquals(MOVE_TO_FOLDER_FIELD, zipFileMeta.getMoveToFolderField());
    assertTrue(zipFileMeta.isaddTargetFileNametoResult());
    assertTrue(zipFileMeta.isOverwriteZipEntry());
    assertTrue(zipFileMeta.isKeepSouceFolder());
    assertTrue(zipFileMeta.isCreateParentFolder());
    Mockito.reset(rep, metastore);
    StringObjectId transid = new StringObjectId("transid");
    zipFileMeta.saveRep(rep, metastore, transid, oid);
    verify(rep).saveStepAttribute(transid, oid, "sourcefilenamefield", SOURCE_FILENAME);
    verify(rep).saveStepAttribute(transid, oid, "targetfilenamefield", TARGET_FILENAME);
    verify(rep).saveStepAttribute(transid, oid, "baseFolderField", BASE_FOLDER);
    verify(rep).saveStepAttribute(transid, oid, "operation_type", OPERATION_TYPE);
    verify(rep).saveStepAttribute(transid, oid, "addresultfilenames", ADD_RESULT_FILENAME);
    verify(rep).saveStepAttribute(transid, oid, "overwritezipentry", OVERWRITE_ZIP_ENTRY);
    verify(rep).saveStepAttribute(transid, oid, "createparentfolder", CREATE_PARENT_FOLDER);
    verify(rep).saveStepAttribute(transid, oid, "keepsourcefolder", KEEP_SOURCE_FOLDER);
    verify(rep).saveStepAttribute(transid, oid, "movetofolderfield", MOVE_TO_FOLDER_FIELD);
    Mockito.verifyNoMoreInteractions(rep, metastore);
}
Also used : Repository(org.pentaho.di.repository.Repository) IMetaStore(org.pentaho.metastore.api.IMetaStore) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 50 with StringObjectId

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

the class SlaveServerConcurrentTest method generateSlaveServer.

private SlaveServer generateSlaveServer() {
    Random random = new Random();
    int id = random.nextInt();
    SlaveServer slaveServer = new SlaveServer();
    slaveServer.setName(NAME + id);
    slaveServer.setHostname(HOST_NAME + id);
    slaveServer.setPort(PORT + id);
    slaveServer.setWebAppName(WEB_APP_NAME + id);
    slaveServer.setUsername(USERNAME + id);
    slaveServer.setPassword(PASSWORD + id);
    slaveServer.setProxyHostname(PROXY_HOST_NAME + id);
    slaveServer.setProxyPort(PROXY_PORT + id);
    slaveServer.setNonProxyHosts(NON_PROXY_HOSTS + id);
    slaveServer.setObjectId(new StringObjectId(ID + id));
    return slaveServer;
}
Also used : Random(java.util.Random) SlaveServer(org.pentaho.di.cluster.SlaveServer) StringObjectId(org.pentaho.di.repository.StringObjectId)

Aggregations

StringObjectId (org.pentaho.di.repository.StringObjectId)123 KettleException (org.pentaho.di.core.exception.KettleException)49 ObjectId (org.pentaho.di.repository.ObjectId)38 Test (org.junit.Test)34 RepositoryFile (org.pentaho.platform.api.repository2.unified.RepositoryFile)25 KettleFileException (org.pentaho.di.core.exception.KettleFileException)21 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)18 MetaStoreNamespaceExistsException (org.pentaho.metastore.api.exceptions.MetaStoreNamespaceExistsException)18 ArrayList (java.util.ArrayList)16 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)15 SOAPFaultException (javax.xml.ws.soap.SOAPFaultException)14 RepositoryObject (org.pentaho.di.repository.RepositoryObject)14 TransMeta (org.pentaho.di.trans.TransMeta)14 IdNotFoundException (org.pentaho.di.core.exception.IdNotFoundException)13 KettleSecurityException (org.pentaho.di.core.exception.KettleSecurityException)13 UnifiedRepositoryCreateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryCreateFileException)13 UnifiedRepositoryUpdateFileException (org.pentaho.platform.api.repository2.unified.UnifiedRepositoryUpdateFileException)13 Repository (org.pentaho.di.repository.Repository)11 IOException (java.io.IOException)10 FileObject (org.apache.commons.vfs2.FileObject)10