Search in sources :

Example 1 with RestClientStepNode

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

the class MetaverseValidationIT method testRestClientStepNode_urlFromField.

@Test
public void testRestClientStepNode_urlFromField() throws Exception {
    RestClientStepNode node = root.getRestClientStepNode("REST Client - parameterized");
    assertNotNull(node);
    Iterable<FramedMetaverseNode> inputUrls = node.getInputUrls();
    assertEquals("REST Client", node.getStepType());
    RestMeta stepMeta = (RestMeta) getStepMeta(node);
    for (FramedMetaverseNode inputUrl : inputUrls) {
        assertEquals(stepMeta.getUrlField(), inputUrl.getName());
    }
    Set<String> usedFields = new HashSet<>();
    Collections.addAll(usedFields, stepMeta.getHeaderField());
    Collections.addAll(usedFields, stepMeta.getParameterField());
    if (stepMeta.isUrlInField()) {
        usedFields.add(stepMeta.getUrlField());
    }
    if (stepMeta.isDynamicMethod()) {
        usedFields.add(stepMeta.getMethodFieldName());
    }
    if (StringUtils.isNotEmpty(stepMeta.getBodyField())) {
        usedFields.add(stepMeta.getBodyField());
    }
    // 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 : RestMeta(org.pentaho.di.trans.steps.rest.RestMeta) RestClientStepNode(org.pentaho.metaverse.frames.RestClientStepNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) FramedMetaverseNode(org.pentaho.metaverse.frames.FramedMetaverseNode) HashSet(java.util.HashSet) Test(org.junit.Test)

Example 2 with RestClientStepNode

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

the class MetaverseValidationIT method testRestClientStepNode.

@Test
public void testRestClientStepNode() throws Exception {
    RestClientStepNode node = root.getRestClientStepNode("REST Client");
    assertNotNull(node);
    Iterable<FramedMetaverseNode> inputUrls = node.getInputUrls();
    int countInputUrls = getIterableSize(inputUrls);
    assertEquals(1, countInputUrls);
    assertEquals("REST Client", node.getStepType());
    RestMeta stepMeta = (RestMeta) getStepMeta(node);
    for (FramedMetaverseNode inputUrl : inputUrls) {
        assertEquals(stepMeta.getUrl(), inputUrl.getName());
    }
    // check the param  field is "used"
    Iterable<StreamFieldNode> streamFieldNodesUses = node.getStreamFieldNodesUses();
    assertEquals(1, getIterableSize(streamFieldNodesUses));
    for (StreamFieldNode streamFieldNodesUse : streamFieldNodesUses) {
        assertEquals(stepMeta.getParameterField()[0], streamFieldNodesUse.getName());
    }
    Iterable<StreamFieldNode> outputs = node.getOutputStreamFields();
    assertEquals(4, 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 : RestMeta(org.pentaho.di.trans.steps.rest.RestMeta) RestClientStepNode(org.pentaho.metaverse.frames.RestClientStepNode) StreamFieldNode(org.pentaho.metaverse.frames.StreamFieldNode) FramedMetaverseNode(org.pentaho.metaverse.frames.FramedMetaverseNode) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 RestMeta (org.pentaho.di.trans.steps.rest.RestMeta)2 FramedMetaverseNode (org.pentaho.metaverse.frames.FramedMetaverseNode)2 RestClientStepNode (org.pentaho.metaverse.frames.RestClientStepNode)2 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)2 HashSet (java.util.HashSet)1