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);
}
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());
}
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);
}
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);
}
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;
}
Aggregations