use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class MySQLBulkLoaderTest method testFieldFormatType.
@Test
public void testFieldFormatType() throws KettleXMLException {
MySQLBulkLoaderMeta lm = new MySQLBulkLoaderMeta();
Document document = XMLHandler.loadXMLFile(this.getClass().getResourceAsStream("step.xml"));
IMetaStore metastore = null;
Node stepNode = (Node) document.getDocumentElement();
lm.loadXML(stepNode, Collections.EMPTY_LIST, metastore);
int[] codes = lm.getFieldFormatType();
Assert.assertEquals(3, codes[0]);
Assert.assertEquals(4, codes[1]);
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class ReplaceStringMetaTest method testGetFields.
@Test
public void testGetFields() throws KettleStepException {
ReplaceStringMeta meta = new ReplaceStringMeta();
meta.setFieldInStream(new String[] { FIELD_NAME });
meta.setFieldOutStream(new String[] { FIELD_NAME });
ValueMetaInterface inputFieldMeta = mock(ValueMetaInterface.class);
when(inputFieldMeta.getStringEncoding()).thenReturn(ENCODING_NAME);
RowMetaInterface inputRowMeta = mock(RowMetaInterface.class);
when(inputRowMeta.searchValueMeta(anyString())).thenReturn(inputFieldMeta);
StepMeta nextStep = mock(StepMeta.class);
VariableSpace space = mock(VariableSpace.class);
Repository repository = mock(Repository.class);
IMetaStore metaStore = mock(IMetaStore.class);
meta.getFields(inputRowMeta, "test", null, nextStep, space, repository, metaStore);
ArgumentCaptor<ValueMetaInterface> argument = ArgumentCaptor.forClass(ValueMetaInterface.class);
verify(inputRowMeta).addValueMeta(argument.capture());
assertEquals(ENCODING_NAME, argument.getValue().getStringEncoding());
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class RowGeneratorMetaTest method testReadRowLimitAsStringFromRepository.
/**
* If we can read row limit as string from repository then we can run row generator.
* @see RowGeneratorTest
* @throws KettleException
*/
@Test
public void testReadRowLimitAsStringFromRepository() throws KettleException {
RowGeneratorMeta rowGeneratorMeta = new RowGeneratorMeta();
IMetaStore metaStore = Mockito.mock(IMetaStore.class);
DatabaseMeta dbMeta = Mockito.mock(DatabaseMeta.class);
rowGeneratorMeta.readRep(rep, metaStore, id_step, Collections.singletonList(dbMeta));
assertEquals(rowGeneratorMeta.getRowLimit(), launchVariable);
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class WebServiceMetaTest method testSaveRep.
@Test
public void testSaveRep() throws Exception {
Node node = getTestNode();
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
IMetaStore metastore = mock(IMetaStore.class);
Repository rep = mock(Repository.class);
WebServiceMeta webServiceMeta = new WebServiceMeta();
webServiceMeta.loadXML(node, Collections.singletonList(dbMeta), metastore);
StringObjectId aTransId = new StringObjectId("aTransId");
StringObjectId aStepId = new StringObjectId("aStepId");
webServiceMeta.saveRep(rep, metastore, aTransId, aStepId);
verify(rep).saveStepAttribute(aTransId, aStepId, "wsUrl", "http://webservices.gama-system.com/exchangerates.asmx?WSDL");
verify(rep).saveStepAttribute(aTransId, aStepId, "wsOperation", "GetCurrentExchangeRate");
verify(rep).saveStepAttribute(aTransId, aStepId, "wsOperationRequest", "opRequestName");
verify(rep).saveStepAttribute(aTransId, aStepId, "wsOperationNamespace", "http://www.gama-system.com/webservices");
verify(rep).saveStepAttribute(aTransId, aStepId, "wsInFieldContainer", null);
verify(rep).saveStepAttribute(aTransId, aStepId, "wsInFieldArgument", null);
verify(rep).saveStepAttribute(aTransId, aStepId, "wsOutFieldContainer", "GetCurrentExchangeRateResult");
verify(rep).saveStepAttribute(aTransId, aStepId, "wsOutFieldArgument", "GetCurrentExchangeRateResult");
verify(rep).saveStepAttribute(aTransId, aStepId, "proxyHost", "aProxy");
verify(rep).saveStepAttribute(aTransId, aStepId, "proxyPort", "4444");
verify(rep).saveStepAttribute(aTransId, aStepId, "httpLogin", "httpUser");
verify(rep).saveStepAttribute(aTransId, aStepId, "httpPassword", "tryandguess");
verify(rep).saveStepAttribute(aTransId, aStepId, "callStep", 1);
verify(rep).saveStepAttribute(aTransId, aStepId, "passingInputData", false);
verify(rep).saveStepAttribute(aTransId, aStepId, "compatible", true);
verify(rep).saveStepAttribute(aTransId, aStepId, "repeating_element", null);
verify(rep).saveStepAttribute(aTransId, aStepId, "reply_as_string", false);
verify(rep).saveStepAttribute(aTransId, aStepId, 0, "fieldIn_name", "Bank");
verify(rep).saveStepAttribute(aTransId, aStepId, 0, "fieldIn_ws_name", "strBank");
verify(rep).saveStepAttribute(aTransId, aStepId, 0, "fieldIn_xsd_type", "string");
verify(rep).saveStepAttribute(aTransId, aStepId, 1, "fieldIn_name", "ToCurrency");
verify(rep).saveStepAttribute(aTransId, aStepId, 1, "fieldIn_ws_name", "strCurrency");
verify(rep).saveStepAttribute(aTransId, aStepId, 1, "fieldIn_xsd_type", "string");
verify(rep).saveStepAttribute(aTransId, aStepId, 2, "fieldIn_name", "Rank");
verify(rep).saveStepAttribute(aTransId, aStepId, 2, "fieldIn_ws_name", "intRank");
verify(rep).saveStepAttribute(aTransId, aStepId, 2, "fieldIn_xsd_type", "int");
verify(rep).saveStepAttribute(aTransId, aStepId, 0, "fieldOut_name", "GetCurrentExchangeRateResult");
verify(rep).saveStepAttribute(aTransId, aStepId, 0, "fieldOut_ws_name", "GetCurrentExchangeRateResult");
verify(rep).saveStepAttribute(aTransId, aStepId, 0, "fieldOut_xsd_type", "decimal");
Mockito.verifyNoMoreInteractions(rep);
}
use of org.pentaho.metastore.api.IMetaStore in project pentaho-kettle by pentaho.
the class WebServiceMetaTest method testLoadXml.
@Test
public void testLoadXml() throws Exception {
Node node = getTestNode();
DatabaseMeta dbMeta = mock(DatabaseMeta.class);
IMetaStore metastore = mock(IMetaStore.class);
WebServiceMeta webServiceMeta = new WebServiceMeta(node, Collections.singletonList(dbMeta), metastore);
assertEquals("httpUser", webServiceMeta.getHttpLogin());
assertEquals("tryandguess", webServiceMeta.getHttpPassword());
assertEquals("http://webservices.gama-system.com/exchangerates.asmx?WSDL", webServiceMeta.getUrl());
assertEquals("GetCurrentExchangeRate", webServiceMeta.getOperationName());
assertEquals("opRequestName", webServiceMeta.getOperationRequestName());
assertEquals("GetCurrentExchangeRateResult", webServiceMeta.getOutFieldArgumentName());
assertEquals("aProxy", webServiceMeta.getProxyHost());
assertEquals("4444", webServiceMeta.getProxyPort());
assertEquals(1, webServiceMeta.getCallStep());
assertFalse(webServiceMeta.isPassingInputData());
assertTrue(webServiceMeta.isCompatible());
assertFalse(webServiceMeta.isReturningReplyAsString());
List<WebServiceField> fieldsIn = webServiceMeta.getFieldsIn();
assertEquals(3, fieldsIn.size());
assertWebServiceField(fieldsIn.get(0), "Bank", "strBank", "string", 2);
assertWebServiceField(fieldsIn.get(1), "ToCurrency", "strCurrency", "string", 2);
assertWebServiceField(fieldsIn.get(2), "Rank", "intRank", "int", 5);
List<WebServiceField> fieldsOut = webServiceMeta.getFieldsOut();
assertEquals(1, fieldsOut.size());
assertWebServiceField(fieldsOut.get(0), "GetCurrentExchangeRateResult", "GetCurrentExchangeRateResult", "decimal", 6);
WebServiceMeta clone = webServiceMeta.clone();
assertNotSame(clone, webServiceMeta);
assertEquals(clone.getXML(), webServiceMeta.getXML());
}
Aggregations