Search in sources :

Example 1 with HttpPostStepNode

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

the class MetaverseValidationIT method testHTTPPostStep_UrlFromField.

@Test
public void testHTTPPostStep_UrlFromField() throws Exception {
    // this is testing a specific TextFileInputStep instance
    HttpPostStepNode node = root.getHttpPostStepNode_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);
    assertEquals(0, countInputUrls);
    assertEquals("HTTP Post", node.getStepType());
    HTTPPOSTMeta stepMeta = (HTTPPOSTMeta) getStepMeta(node);
    Set<String> usedFields = new HashSet<>();
    Collections.addAll(usedFields, stepMeta.getQueryField());
    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 : HTTPPOSTMeta(org.pentaho.di.trans.steps.httppost.HTTPPOSTMeta) HttpPostStepNode(org.pentaho.metaverse.frames.HttpPostStepNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) FramedMetaverseNode(org.pentaho.metaverse.frames.FramedMetaverseNode) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with HttpPostStepNode

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

the class MetaverseValidationIT method testHttpPostStep.

@Test
public void testHttpPostStep() throws Exception {
    // this is testing a specific TextFileInputStep instance
    HttpPostStepNode node = root.getHttpPostStepNode();
    assertNotNull(node);
    Iterable<FramedMetaverseNode> inputUrls = node.getInputUrls();
    int countUrls = getIterableSize(inputUrls);
    assertEquals(1, countUrls);
    for (FramedMetaverseNode inputUrl : inputUrls) {
        assertTrue(inputUrl.getName().endsWith("/posts"));
    }
    assertEquals("HTTP Post", node.getStepType());
    // check the param  field is "used"
    Iterable<StreamFieldNode> streamFieldNodesUses = node.getStreamFieldNodesUses();
    assertEquals(1, getIterableSize(streamFieldNodesUses));
    Iterable<StreamFieldNode> outputs = node.getOutputStreamFields();
    assertEquals(3, getIterableSize(outputs));
    Iterable<StreamFieldNode> inputs = node.getInputStreamFields();
    assertEquals(1, getIterableSize(inputs));
    for (StreamFieldNode in : inputs) {
        assertNotNull(in.getFieldNodesDerivedFromMe());
        assertEquals(in.getName(), in.getFieldNodesDerivedFromMe().iterator().next().getName());
    }
}
Also used : HttpPostStepNode(org.pentaho.metaverse.frames.HttpPostStepNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) FramedMetaverseNode(org.pentaho.metaverse.frames.FramedMetaverseNode) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 FramedMetaverseNode (org.pentaho.metaverse.frames.FramedMetaverseNode)2 HttpPostStepNode (org.pentaho.metaverse.frames.HttpPostStepNode)2 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)2 HashSet (java.util.HashSet)1 HTTPPOSTMeta (org.pentaho.di.trans.steps.httppost.HTTPPOSTMeta)1