Search in sources :

Example 11 with IOperation

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

the class ComponentDerivationRecordTest method testAddOperationNull.

@Test
public void testAddOperationNull() throws Exception {
    record.operations = null;
    String operands = "testOperand1, testOperand2";
    record.addOperation(new Operation("testOperation", operands));
    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("testOperand1 not in operands!", checkOperation.getDescription().contains("testOperand1"));
    assertTrue("testOperand2 not in operands!", checkOperation.getDescription().contains("testOperand2"));
}
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 12 with IOperation

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

the class ComponentDerivationRecordTest method testAddOperation.

@Test
public void testAddOperation() throws Exception {
    Operations operations = record.getOperations();
    assertNotNull(operations);
    assertTrue(operations.isEmpty());
    String operands = "testOperand1, testOperand2";
    record.addOperation(new Operation("testOperation", operands));
    operations = record.getOperations();
    assertNotNull(operations);
    List<IOperation> checkOperations = operations.get(ChangeType.METADATA);
    assertNotNull(checkOperations);
    assertEquals(1, checkOperations.size());
    IOperation checkOperation = checkOperations.get(0);
    assertTrue("testOperand1 not in operands!", checkOperation.getDescription().contains("testOperand1"));
    assertTrue("testOperand2 not in operands!", checkOperation.getDescription().contains("testOperand2"));
}
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 13 with IOperation

use of org.pentaho.metaverse.api.model.IOperation 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)

Example 14 with IOperation

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

the class NumberRangeStepAnalyzerTest method testGetChangeRecords.

@Test
public void testGetChangeRecords() throws Exception {
    Set<ComponentDerivationRecord> changeRecords = analyzer.getChangeRecords(meta);
    assertEquals(1, changeRecords.size());
    ComponentDerivationRecord changeRecord = changeRecords.iterator().next();
    assertEquals("inField", changeRecord.getOriginalEntityName());
    assertEquals("outField", changeRecord.getChangedEntityName());
    Operations operations = changeRecord.getOperations();
    // Only data operations
    assertEquals(1, operations.size());
    List<IOperation> dataOperations = operations.get(ChangeType.DATA);
    assertEquals(2, dataOperations.size());
}
Also used : IOperation(org.pentaho.metaverse.api.model.IOperation) ComponentDerivationRecord(org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord) Operations(org.pentaho.metaverse.api.model.Operations) Test(org.junit.Test)

Example 15 with IOperation

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

the class MetaverseUtilTest method testConvertOperationsStringToMap.

@Test
public void testConvertOperationsStringToMap() {
    // Test null string
    assertNull(MetaverseUtil.convertOperationsStringToMap(null));
    assertNull(MetaverseUtil.convertOperationsStringToMap(""));
    assertNull(MetaverseUtil.convertOperationsStringToMap("{"));
    assertNotNull(MetaverseUtil.convertOperationsStringToMap("{}"));
    Operations ops = MetaverseUtil.convertOperationsStringToMap("{\"metadataOperations\":[{\"category\":\"changeMetadata\",\"class\":" + "\"Operation\",\"description\":\"name\"," + "\"name\":\"modified\",\"type\":\"METADATA\"}]}");
    assertNotNull(ops);
    assertNull(ops.get(ChangeType.DATA));
    List<IOperation> metadataOps = ops.get(ChangeType.METADATA);
    assertNotNull(metadataOps);
    assertEquals(1, metadataOps.size());
    IOperation op = metadataOps.get(0);
    assertEquals(Operation.METADATA_CATEGORY, op.getCategory());
    assertEquals(DictionaryConst.PROPERTY_MODIFIED, op.getName());
    assertEquals("name", op.getDescription());
}
Also used : IOperation(org.pentaho.metaverse.api.model.IOperation) Operations(org.pentaho.metaverse.api.model.Operations) Test(org.junit.Test)

Aggregations

IOperation (org.pentaho.metaverse.api.model.IOperation)16 Operations (org.pentaho.metaverse.api.model.Operations)16 Test (org.junit.Test)15 Operation (org.pentaho.metaverse.api.model.Operation)7 StreamFieldNode (org.pentaho.metaverse.frames.StreamFieldNode)4 ComponentDerivationRecord (org.pentaho.metaverse.api.analyzer.kettle.ComponentDerivationRecord)3 TransformationStepNode (org.pentaho.metaverse.frames.TransformationStepNode)3 List (java.util.List)2 ValueMapperMeta (org.pentaho.di.trans.steps.valuemapper.ValueMapperMeta)2 FieldNode (org.pentaho.metaverse.frames.FieldNode)2 JSONDeserializer (flexjson.JSONDeserializer)1 Set (java.util.Set)1 NumberRangeMeta (org.pentaho.di.trans.steps.numberrange.NumberRangeMeta)1 SelectValuesMeta (org.pentaho.di.trans.steps.selectvalues.SelectValuesMeta)1 MetaverseAnalyzerException (org.pentaho.metaverse.api.MetaverseAnalyzerException)1 MetaverseException (org.pentaho.metaverse.api.MetaverseException)1 StepFieldOperations (org.pentaho.metaverse.api.StepFieldOperations)1 SelectValuesTransStepNode (org.pentaho.metaverse.frames.SelectValuesTransStepNode)1