Search in sources :

Example 1 with GenericOperator

use of com.datatorrent.stram.engine.GenericNodeTest.GenericOperator in project apex-core by apache.

the class OiOStreamTest method validatePositiveOiOOptionalInput.

@Test
public void validatePositiveOiOOptionalInput() {
    LogicalPlan plan = new LogicalPlan();
    RecoverableInputOperator inputOp1 = plan.addOperator("InputOperator1", new RecoverableInputOperator());
    GenericOperator genOp = plan.addOperator("GenericOperator", new GenericOperator());
    plan.addStream("OiO1", inputOp1.output, genOp.ip1).setLocality(Locality.THREAD_LOCAL);
    try {
        plan.validate();
        Assert.assertTrue("OiO validation", true);
    } catch (ConstraintViolationException ex) {
        Assert.fail("OiO Single Connected InputPort");
    }
}
Also used : RecoverableInputOperator(com.datatorrent.stram.engine.RecoverableInputOperator) ConstraintViolationException(javax.validation.ConstraintViolationException) LogicalPlan(com.datatorrent.stram.plan.logical.LogicalPlan) GenericOperator(com.datatorrent.stram.engine.GenericNodeTest.GenericOperator) Test(org.junit.Test)

Example 2 with GenericOperator

use of com.datatorrent.stram.engine.GenericNodeTest.GenericOperator in project apex-core by apache.

the class OiOStreamTest method validateNegativeOiO.

@Test
public void validateNegativeOiO() {
    LogicalPlan plan = new LogicalPlan();
    RecoverableInputOperator inputOp1 = plan.addOperator("InputOperator1", new RecoverableInputOperator());
    RecoverableInputOperator inputOp2 = plan.addOperator("InputOperator2", new RecoverableInputOperator());
    GenericOperator genOp = plan.addOperator("GenericOperator", new GenericOperator());
    StreamMeta oio1 = plan.addStream("OiO1", inputOp1.output, genOp.ip1).setLocality(Locality.THREAD_LOCAL);
    StreamMeta oio2 = plan.addStream("OiO2", inputOp2.output, genOp.ip2).setLocality(Locality.THREAD_LOCAL);
    try {
        plan.validate();
        Assert.fail("OIO Both InputPorts");
    } catch (ConstraintViolationException ex) {
        Assert.assertTrue("OiO validation passed", true);
    } catch (ValidationException ex) {
        Assert.assertTrue("OiO validation passed", true);
    }
    oio1.setLocality(null);
    try {
        plan.validate();
        Assert.fail("OIO First InputPort");
    } catch (ConstraintViolationException ex) {
        Assert.assertTrue("OiO validation passed", true);
    } catch (ValidationException ex) {
        Assert.assertTrue("OiO validation passed", true);
    }
    oio1.setLocality(Locality.THREAD_LOCAL);
    oio2.setLocality(null);
    try {
        plan.validate();
        Assert.fail("OIO Second InputPort");
    } catch (ConstraintViolationException ex) {
        Assert.assertTrue("OiO validation passed", true);
    } catch (ValidationException ex) {
        Assert.assertTrue("OiO validation passed", true);
    }
}
Also used : RecoverableInputOperator(com.datatorrent.stram.engine.RecoverableInputOperator) StreamMeta(com.datatorrent.stram.plan.logical.LogicalPlan.StreamMeta) ValidationException(javax.validation.ValidationException) ConstraintViolationException(javax.validation.ConstraintViolationException) LogicalPlan(com.datatorrent.stram.plan.logical.LogicalPlan) GenericOperator(com.datatorrent.stram.engine.GenericNodeTest.GenericOperator) Test(org.junit.Test)

Aggregations

GenericOperator (com.datatorrent.stram.engine.GenericNodeTest.GenericOperator)2 RecoverableInputOperator (com.datatorrent.stram.engine.RecoverableInputOperator)2 LogicalPlan (com.datatorrent.stram.plan.logical.LogicalPlan)2 ConstraintViolationException (javax.validation.ConstraintViolationException)2 Test (org.junit.Test)2 StreamMeta (com.datatorrent.stram.plan.logical.LogicalPlan.StreamMeta)1 ValidationException (javax.validation.ValidationException)1