Search in sources :

Example 41 with IMetaStore

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]);
}
Also used : Node(org.w3c.dom.Node) Document(org.w3c.dom.Document) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Example 42 with IMetaStore

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());
}
Also used : Repository(org.pentaho.di.repository.Repository) VariableSpace(org.pentaho.di.core.variables.VariableSpace) RowMetaInterface(org.pentaho.di.core.row.RowMetaInterface) StepMeta(org.pentaho.di.trans.step.StepMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) ValueMetaInterface(org.pentaho.di.core.row.ValueMetaInterface) Test(org.junit.Test)

Example 43 with IMetaStore

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);
}
Also used : IMetaStore(org.pentaho.metastore.api.IMetaStore) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) Test(org.junit.Test)

Example 44 with IMetaStore

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);
}
Also used : Repository(org.pentaho.di.repository.Repository) Node(org.w3c.dom.Node) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) StringObjectId(org.pentaho.di.repository.StringObjectId) Test(org.junit.Test)

Example 45 with IMetaStore

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());
}
Also used : Node(org.w3c.dom.Node) DatabaseMeta(org.pentaho.di.core.database.DatabaseMeta) IMetaStore(org.pentaho.metastore.api.IMetaStore) Test(org.junit.Test)

Aggregations

IMetaStore (org.pentaho.metastore.api.IMetaStore)75 Test (org.junit.Test)55 DatabaseMeta (org.pentaho.di.core.database.DatabaseMeta)20 SQL (org.pentaho.di.core.sql.SQL)17 Repository (org.pentaho.di.repository.Repository)17 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)11 TransMeta (org.pentaho.di.trans.TransMeta)11 Matchers.anyString (org.mockito.Matchers.anyString)10 ValueMetaString (org.pentaho.di.core.row.value.ValueMetaString)10 StepMeta (org.pentaho.di.trans.step.StepMeta)10 KettleException (org.pentaho.di.core.exception.KettleException)9 IMetaStoreElementType (org.pentaho.metastore.api.IMetaStoreElementType)9 Node (org.w3c.dom.Node)8 ArrayList (java.util.ArrayList)7 Variables (org.pentaho.di.core.variables.Variables)7 PushDownOptimizationMeta (org.pentaho.di.trans.dataservice.optimization.PushDownOptimizationMeta)7 MetaStoreException (org.pentaho.metastore.api.exceptions.MetaStoreException)7 IMetaStoreElement (org.pentaho.metastore.api.IMetaStoreElement)6 CheckResultInterface (org.pentaho.di.core.CheckResultInterface)5 StringObjectId (org.pentaho.di.repository.StringObjectId)5