/** * Constructs an <code>OutputPort</code> for the specified * <code>Activity</code> with the specified name. * <p> * The <code>OutputPort</code> is added to the <code>Activity</code> (if the * <code>Activity</code> is not <code>null</code>). * * @param activity * the <code>Activity</code> to add this <code>Port</code> to. * Can be <code>null</code> * @param name * the name of the <code>Port</code>. <strong>Must not</strong> * be <code>null</code> or an empty String. */ public OutputActivityPort(Activity activity, String name) { super(name); setParent(activity); }
outputPort.setParent(activity);
outputActivityPort = new OutputActivityPort(); outputActivityPort.setName(fromActivityOutput); outputActivityPort.setParent(parserState.get() .getCurrentActivity()); parserState.get().getCurrentActivity().getOutputPorts()
oap.setGranularDepth(new Integer(1)); oap.setName("fred"); oap.setParent(null);
@Test public void testCorrectnessOfGranularDepthSpecifiedIncorrectly() { OutputActivityPort oap = new OutputActivityPort(); oap.setDepth(new Integer(3)); oap.setGranularDepth(new Integer(-2)); oap.setName("fred"); oap.setParent(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(oap, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(1, negativeValueProblems.size()); if (!negativeValueProblems.isEmpty()) { NegativeValueProblem problem = negativeValueProblems.iterator().next(); assertEquals(problem.getBean(), oap); assertEquals(problem.getFieldName(), "granularDepth"); assertEquals(problem.getFieldValue(), Integer.valueOf("-2")); } Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(0, nullFieldProblems.size()); // only done when completeness check assertEquals(0, rcvl.getIncompatibleGranularDepthProblems().size()); }
@Test public void testCorrectnessOfMissingGranularDepth() { OutputActivityPort oap = new OutputActivityPort(); oap.setDepth(new Integer(3)); oap.setGranularDepth(null); oap.setName("fred"); oap.setParent(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(oap, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(0, negativeValueProblems.size()); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(0, nullFieldProblems.size()); // only done when completeness check assertEquals(0, rcvl.getIncompatibleGranularDepthProblems().size()); }
protected void parseOutputActivityPort( org.apache.taverna.scufl2.xml.OutputActivityPort original) { OutputActivityPort port = new OutputActivityPort(); mapBean(original.getAbout(), port); port.setParent(getParserState().getCurrent(Activity.class)); port.setName(original.getName()); if (original.getPortDepth() != null) port.setDepth(original.getPortDepth().getValue()); if (original.getGranularPortDepth() != null) port.setGranularDepth(original.getGranularPortDepth().getValue()); }
oap.setGranularDepth(new Integer(-2)); oap.setName("fred"); oap.setParent(null);
@Test public void testCompletenessOfMissingGranularDepth() { OutputActivityPort oap = new OutputActivityPort(); oap.setDepth(new Integer(3)); oap.setGranularDepth(null); oap.setName("fred"); oap.setParent(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(oap, true, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(0, negativeValueProblems.size()); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(2, nullFieldProblems.size()); // granular depth and parent boolean granularDepthFieldProblem = false; for (NullFieldProblem nlp : nullFieldProblems) { if (nlp.getBean().equals(oap) && nlp.getFieldName().equals("granularDepth")) { granularDepthFieldProblem = true; } } assertTrue(granularDepthFieldProblem); assertEquals(0, rcvl.getIncompatibleGranularDepthProblems().size()); }
@Test public void testCorrectnessOfInScopeActivityPort() { ProcessorBinding pb = new ProcessorBinding(); Activity activity = new Activity(); pb.setBoundActivity(activity); ProcessorOutputPortBinding pipb = new ProcessorOutputPortBinding(); pipb.setParent(pb); OutputActivityPort port = new OutputActivityPort(); port.setParent(activity); pipb.setBoundActivityPort(port); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pipb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pipb) && nlp.getFieldName().equals("boundActivityPort") && nlp.getValue().equals(port)) { problem = true; } } assertFalse(problem); }
elsewherePort.setParent(otherActivity);