Search in sources :

Example 1 with Operation

use of org.pentaho.metaverse.api.model.Operation in project pentaho-metaverse by pentaho.

the class StepAnalyzerTest method testMapChange.

@Test
public void testMapChange() throws Exception {
    doReturn(outputs).when(analyzer).getOutputs();
    doReturn(inputs).when(analyzer).getInputs();
    Operation operation = new Operation("testOperation", "testOperation");
    StepField original = new StepField("previousStep", "address");
    StepField changed = new StepField("nextStep", "address");
    ComponentDerivationRecord cdr = new ComponentDerivationRecord(original, changed);
    cdr.addOperation(operation);
    ComponentDerivationRecord spyCdr = spy(cdr);
    analyzer.mapChange(spyCdr);
    // get operations to verify it is not null, then agains to toString it
    verify(spyCdr, times(1)).getOperations();
    verify(analyzer).linkChangeNodes(any(IMetaverseNode.class), any(IMetaverseNode.class));
}
Also used : IMetaverseNode(org.pentaho.metaverse.api.IMetaverseNode) StepField(org.pentaho.metaverse.api.StepField) ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Operation(org.pentaho.metaverse.api.model.Operation) Test(org.junit.Test)

Example 2 with Operation

use of org.pentaho.metaverse.api.model.Operation in project pentaho-metaverse by pentaho.

the class StepFieldOperationsTest method testToString.

@Test
public void testToString() {
    stepFieldOperations = new StepFieldOperations("testStep", "testField", null);
    assertEquals("{ step:testStep, field:testField, operations: { none } }", stepFieldOperations.toString());
    Operations operations = new Operations();
    operations.addOperation(ChangeType.METADATA, Operation.getRenameOperation());
    operations.addOperation(ChangeType.DATA, new Operation(Operation.CALC_CATEGORY, ChangeType.DATA, "dataOp", "calcStuff"));
    stepFieldOperations.setOperations(operations);
    assertEquals("{ step:testStep, field:testField, operations: " + "{metadataOperations=[modified: name], dataOperations=[dataOp: calcStuff]} }", stepFieldOperations.toString());
}
Also used : Operation(org.pentaho.metaverse.api.model.Operation) Operations(org.pentaho.metaverse.api.model.Operations) Test(org.junit.Test)

Example 3 with Operation

use of org.pentaho.metaverse.api.model.Operation in project pentaho-metaverse by pentaho.

the class ComponentDerivationRecordTest method testGetOperations.

@Test
public void testGetOperations() throws Exception {
    Operations operations = record.getOperations();
    assertNotNull(operations);
    assertTrue(operations.isEmpty());
    String operands = "testOperand1, testOperand2";
    record.addOperation(new Operation("testOperation", operands));
    assertNull(record.getOperations(ChangeType.DATA));
    assertNotNull(record.getOperations(ChangeType.METADATA));
}
Also used : IOperation(org.pentaho.metaverse.api.model.IOperation) Operation(org.pentaho.metaverse.api.model.Operation) Operations(org.pentaho.metaverse.api.model.Operations) Test(org.junit.Test)

Example 4 with Operation

use of org.pentaho.metaverse.api.model.Operation in project pentaho-metaverse by pentaho.

the class ComponentDerivationRecordTest method testAddOperand.

@Test
public void testAddOperand() throws Exception {
    record.operations = null;
    record.addOperation(new Operation("testOperation", "testOperand"));
    Operations operations = record.getOperations();
    assertNotNull(operations);
    List<IOperation> checkOperations = operations.get(ChangeType.METADATA);
    assertNotNull(checkOperations);
    assertEquals(1, checkOperations.size());
    IOperation checkOperation = checkOperations.get(0);
    assertTrue("testOperand not in operands!", checkOperation.getDescription().contains("testOperand"));
}
Also used : IOperation(org.pentaho.metaverse.api.model.IOperation) IOperation(org.pentaho.metaverse.api.model.IOperation) Operation(org.pentaho.metaverse.api.model.Operation) Operations(org.pentaho.metaverse.api.model.Operations) Test(org.junit.Test)

Example 5 with Operation

use of org.pentaho.metaverse.api.model.Operation in project pentaho-metaverse by pentaho.

the class ComponentDerivationRecordTest method testPutOperationNullOperation.

@Test
public void testPutOperationNullOperation() throws Exception {
    Operations operations = record.getOperations();
    assertNotNull(operations);
    assertTrue(operations.isEmpty());
    record.addOperation(null);
    String operands = "testOperand1, testOperand2";
    record.addOperation(new Operation(null, operands));
    operations = record.getOperations();
    assertNotNull(operations);
    List<IOperation> checkOperands = operations.get("testOperation");
    assertNull(checkOperands);
}
Also used : IOperation(org.pentaho.metaverse.api.model.IOperation) IOperation(org.pentaho.metaverse.api.model.IOperation) Operation(org.pentaho.metaverse.api.model.Operation) Operations(org.pentaho.metaverse.api.model.Operations) Test(org.junit.Test)

Aggregations

Operation (org.pentaho.metaverse.api.model.Operation)22 Test (org.junit.Test)12 ComponentDerivationRecord (org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)11 IOperation (org.pentaho.metaverse.api.model.IOperation)10 Operations (org.pentaho.metaverse.api.model.Operations)10 HashSet (java.util.HashSet)7 ArrayList (java.util.ArrayList)2 IMetaverseNode (org.pentaho.metaverse.api.IMetaverseNode)2 StepField (org.pentaho.metaverse.api.StepField)2 Arrays (java.util.Arrays)1 List (java.util.List)1 Set (java.util.Set)1 Collectors (java.util.stream.Collectors)1 CollectionUtils (org.apache.commons.collections.CollectionUtils)1 ArrayUtils (org.apache.commons.lang.ArrayUtils)1 StringUtils (org.apache.commons.lang.StringUtils)1 Condition (org.pentaho.di.core.Condition)1 Const (org.pentaho.di.core.Const)1 RowMetaInterface (org.pentaho.di.core.row.RowMetaInterface)1 ValueMetaInterface (org.pentaho.di.core.row.ValueMetaInterface)1