Search in sources :

Example 1 with HttpClientStepNode

use of org.pentaho.metaverse.frames.HttpClientStepNode in project pentaho-metaverse by pentaho.

the class MetaverseValidationIT method testHttpClientStep.

@Test
public void testHttpClientStep() throws Exception {
    HttpClientStepNode node = root.getHttpClientStepNode();
    assertNotNull(node);
    Iterable<FramedMetaverseNode> inputUrls = node.getInputUrls();
    int countInputUrls = getIterableSize(inputUrls);
    assertEquals(1, countInputUrls);
    assertEquals("HTTP Client", node.getStepType());
    HTTPMeta stepMeta = (HTTPMeta) getStepMeta(node);
    for (FramedMetaverseNode inputUrl : inputUrls) {
        assertEquals(stepMeta.getUrl(), inputUrl.getName());
    }
    // check the param  field is "used"
    Iterable<StreamFieldNode> streamFieldNodesUses = node.getStreamFieldNodesUses();
    assertEquals(2, getIterableSize(streamFieldNodesUses));
    Iterable<StreamFieldNode> outputs = node.getOutputStreamFields();
    assertEquals(5, getIterableSize(outputs));
    Iterable<StreamFieldNode> inputs = node.getInputStreamFields();
    assertEquals(3, getIterableSize(inputs));
    for (StreamFieldNode in : inputs) {
        assertNotNull(in.getFieldNodesDerivedFromMe());
        assertEquals(in.getName(), in.getFieldNodesDerivedFromMe().iterator().next().getName());
    }
}
Also used : StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) FramedMetaverseNode(org.pentaho.metaverse.frames.FramedMetaverseNode) HttpClientStepNode(org.pentaho.metaverse.frames.HttpClientStepNode) HTTPMeta(org.pentaho.di.trans.steps.http.HTTPMeta) Test(org.junit.Test)

Example 2 with HttpClientStepNode

use of org.pentaho.metaverse.frames.HttpClientStepNode in project pentaho-metaverse by pentaho.

the class MetaverseValidationIT method testHTTPClientStep_UrlFromField.

@Test
public void testHTTPClientStep_UrlFromField() throws Exception {
    // this is testing a specific TextFileInputStep instance
    HttpClientStepNode node = root.getHttpClientStepNode_urlFromField();
    assertNotNull(node);
    // this HTTP Client gets it's files from an incoming stream field, there should be no files modeled statically
    Iterable<FramedMetaverseNode> inputUrls = node.getInputUrls();
    int countInputUrls = getIterableSize(inputUrls);
    // it is coming from a field
    assertEquals(0, countInputUrls);
    HTTPMeta stepMeta = (HTTPMeta) getStepMeta(node);
    assertEquals("HTTP Client", node.getStepType());
    Set<String> usedFields = new HashSet<>();
    Collections.addAll(usedFields, stepMeta.getHeaderField());
    Collections.addAll(usedFields, stepMeta.getArgumentField());
    if (stepMeta.isUrlInField()) {
        usedFields.add(stepMeta.getUrlField());
    }
    // check the param  field is "used"
    Iterable<StreamFieldNode> streamFieldNodesUses = node.getStreamFieldNodesUses();
    assertEquals(usedFields.size(), getIterableSize(streamFieldNodesUses));
    for (StreamFieldNode streamFieldNodesUse : streamFieldNodesUses) {
        assertTrue(usedFields.contains(streamFieldNodesUse.getName()));
    }
    Iterable<StreamFieldNode> outputs = node.getOutputStreamFields();
    assertEquals(getExpectedOutputFieldCount(stepMeta), getIterableSize(outputs));
}
Also used : StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) FramedMetaverseNode(org.pentaho.metaverse.frames.FramedMetaverseNode) HttpClientStepNode(org.pentaho.metaverse.frames.HttpClientStepNode) HTTPMeta(org.pentaho.di.trans.steps.http.HTTPMeta) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 HTTPMeta (org.pentaho.di.trans.steps.http.HTTPMeta)2 FramedMetaverseNode (org.pentaho.metaverse.frames.FramedMetaverseNode)2 HttpClientStepNode (org.pentaho.metaverse.frames.HttpClientStepNode)2 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)2 HashSet (java.util.HashSet)1