Search in sources :

Example 21 with IHopMetadataProvider

use of org.apache.hop.metadata.api.IHopMetadataProvider in project hop by apache.

the class WorkflowEntrySetVariablesTest method testJobEntrySetVariablesExecute_VARIABLE_TYPE_JVM_VariableNotNull.

@Test
public void testJobEntrySetVariablesExecute_VARIABLE_TYPE_JVM_VariableNotNull() throws Exception {
    IHopMetadataProvider metadataProvider = mock(IHopMetadataProvider.class);
    action.loadXml(getEntryNode("variableNotNull", "someValue", "JVM"), metadataProvider, new Variables());
    assertNull(System.getProperty("variableNotNull"));
    Result result = action.execute(new Result(), 0);
    assertTrue("Result should be true", result.getResult());
    assertEquals("someValue", System.getProperty("variableNotNull"));
}
Also used : Variables(org.apache.hop.core.variables.Variables) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) Result(org.apache.hop.core.Result)

Example 22 with IHopMetadataProvider

use of org.apache.hop.metadata.api.IHopMetadataProvider in project hop by apache.

the class ZipFileMetaTest method testCheck.

@Test
public void testCheck() {
    ZipFileMeta zipFileMeta = new ZipFileMeta();
    zipFileMeta.setDefault();
    PipelineMeta pipelineMeta = mock(PipelineMeta.class);
    TransformMeta transformMeta = mock(TransformMeta.class);
    IRowMeta prev = mock(IRowMeta.class);
    IHopMetadataProvider metadataProvider = mock(IHopMetadataProvider.class);
    IRowMeta info = mock(IRowMeta.class);
    ArrayList<ICheckResult> remarks = new ArrayList<>();
    zipFileMeta.check(remarks, pipelineMeta, transformMeta, prev, new String[] { "input" }, new String[] { "output" }, info, new Variables(), metadataProvider);
    assertEquals(2, remarks.size());
    assertEquals("Source Filename field is missing!", remarks.get(0).getText());
    assertEquals("Transform is receiving info from other transforms.", remarks.get(1).getText());
    remarks = new ArrayList<>();
    zipFileMeta = new ZipFileMeta();
    zipFileMeta.setSourceFilenameField("sourceFileField");
    zipFileMeta.check(remarks, pipelineMeta, transformMeta, prev, new String[0], new String[] { "output" }, info, new Variables(), metadataProvider);
    assertEquals(2, remarks.size());
    assertEquals("Target Filename field was specified", remarks.get(0).getText());
    assertEquals("No input received from other transforms!", remarks.get(1).getText());
}
Also used : Variables(org.apache.hop.core.variables.Variables) IRowMeta(org.apache.hop.core.row.IRowMeta) ICheckResult(org.apache.hop.core.ICheckResult) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) ArrayList(java.util.ArrayList) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) Test(org.junit.Test)

Example 23 with IHopMetadataProvider

use of org.apache.hop.metadata.api.IHopMetadataProvider in project hop by apache.

the class ZipFileMetaTest method testLoadAndGetXml.

@Test
public void testLoadAndGetXml() throws Exception {
    ZipFileMeta zipFileMeta = new ZipFileMeta();
    Node transformNode = getTestNode();
    DatabaseMeta dbMeta = mock(DatabaseMeta.class);
    IHopMetadataProvider metadataProvider = mock(IHopMetadataProvider.class);
    TransformMeta mockParentTransformMeta = mock(TransformMeta.class);
    zipFileMeta.setParentTransformMeta(mockParentTransformMeta);
    PipelineMeta mockPipelineMeta = mock(PipelineMeta.class);
    when(mockParentTransformMeta.getParentPipelineMeta()).thenReturn(mockPipelineMeta);
    zipFileMeta.loadXml(transformNode, metadataProvider);
}
Also used : Node(org.w3c.dom.Node) TransformMeta(org.apache.hop.pipeline.transform.TransformMeta) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta) PipelineMeta(org.apache.hop.pipeline.PipelineMeta) Test(org.junit.Test)

Example 24 with IHopMetadataProvider

use of org.apache.hop.metadata.api.IHopMetadataProvider in project hop by apache.

the class XmlOutputMetaTest method testLoadAndGetXml.

@Test
public void testLoadAndGetXml() throws Exception {
    XmlOutputMeta xmlOutputMeta = new XmlOutputMeta();
    Node transformNode = getTestNode();
    DatabaseMeta dbMeta = mock(DatabaseMeta.class);
    IHopMetadataProvider metadataProvider = mock(IHopMetadataProvider.class);
    xmlOutputMeta.loadXml(transformNode, metadataProvider);
    assertXmlOutputMeta(xmlOutputMeta);
}
Also used : Node(org.w3c.dom.Node) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta) Test(org.junit.Test)

Example 25 with IHopMetadataProvider

use of org.apache.hop.metadata.api.IHopMetadataProvider in project hop by apache.

the class XmlOutputMetaTest method testLoadXmlException.

@Test
public void testLoadXmlException() throws Exception {
    XmlOutputMeta xmlOutputMeta = new XmlOutputMeta();
    DatabaseMeta dbMeta = mock(DatabaseMeta.class);
    IHopMetadataProvider metadataProvider = mock(IHopMetadataProvider.class);
    Node transformNode = mock(Node.class);
    when(transformNode.getChildNodes()).thenThrow(new RuntimeException("some words"));
    try {
        xmlOutputMeta.loadXml(transformNode, metadataProvider);
    } catch (HopXmlException e) {
        assertEquals("some words", e.getCause().getMessage());
    }
}
Also used : HopXmlException(org.apache.hop.core.exception.HopXmlException) Node(org.w3c.dom.Node) IHopMetadataProvider(org.apache.hop.metadata.api.IHopMetadataProvider) DatabaseMeta(org.apache.hop.core.database.DatabaseMeta) Test(org.junit.Test)

Aggregations

IHopMetadataProvider (org.apache.hop.metadata.api.IHopMetadataProvider)72 HopException (org.apache.hop.core.exception.HopException)26 PipelineMeta (org.apache.hop.pipeline.PipelineMeta)24 IVariables (org.apache.hop.core.variables.IVariables)19 ErrorDialog (org.apache.hop.ui.core.dialog.ErrorDialog)18 TransformMeta (org.apache.hop.pipeline.transform.TransformMeta)17 Test (org.junit.Test)17 HopGui (org.apache.hop.ui.hopgui.HopGui)16 IRowMeta (org.apache.hop.core.row.IRowMeta)15 HopTransformException (org.apache.hop.core.exception.HopTransformException)12 Variables (org.apache.hop.core.variables.Variables)11 MultiMetadataProvider (org.apache.hop.metadata.serializer.multi.MultiMetadataProvider)11 ValueMetaString (org.apache.hop.core.row.value.ValueMetaString)10 GuiContextAction (org.apache.hop.core.action.GuiContextAction)9 HopPluginException (org.apache.hop.core.exception.HopPluginException)9 HopValueException (org.apache.hop.core.exception.HopValueException)9 SimpleLoggingObject (org.apache.hop.core.logging.SimpleLoggingObject)9 EnterSelectionDialog (org.apache.hop.ui.core.dialog.EnterSelectionDialog)9 ArrayList (java.util.ArrayList)8 Node (org.w3c.dom.Node)8