/** * Constructs an <code>InputPort</code> for the specified * <code>Activity</code> with the specified name. * <p> * The <code>InputPort</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 InputActivityPort(Activity activity, String name) { super(name); setParent(activity); }
inputPort.setParent(activity);
inputActivityPort = new InputActivityPort(); inputActivityPort.setName(toActivityOutput); inputActivityPort.setParent(parserState.get() .getCurrentActivity()); parserState.get().getCurrentActivity().getInputPorts()
protected void parseInputActivityPort( org.apache.taverna.scufl2.xml.InputActivityPort original) { InputActivityPort port = new InputActivityPort(); mapBean(original.getAbout(), port); port.setParent(getParserState().getCurrent(Activity.class)); port.setName(original.getName()); if (original.getPortDepth() != null) port.setDepth(original.getPortDepth().getValue()); }
iap.setDepth(new Integer(-3)); iap.setName("fred"); iap.setParent(null);
@Test public void testCorrectnessOfDepthSpecifiedIncorrectly() { InputActivityPort iap = new InputActivityPort(); iap.setDepth(new Integer(-3)); iap.setName("fred"); iap.setParent(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(iap, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(1, negativeValueProblems.size()); if (!negativeValueProblems.isEmpty()) { NegativeValueProblem problem = negativeValueProblems.iterator().next(); assertEquals(problem.getBean(), iap); assertEquals(problem.getFieldName(), "depth"); assertEquals(problem.getFieldValue(), Integer.valueOf("-3")); } Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(Collections.EMPTY_SET, nullFieldProblems); // only done when completeness check }
@Test public void testCompletenessOfMissingDepth() { InputActivityPort iap = new InputActivityPort(); iap.setDepth(null); iap.setName("fred"); iap.setParent(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(iap, true, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(0, negativeValueProblems.size()); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertFalse(nullFieldProblems.isEmpty()); // depth and parent boolean depthFieldProblem = false; for (NullFieldProblem nlp : nullFieldProblems) { if (nlp.getBean().equals(iap) && nlp.getFieldName().equals("depth")) { depthFieldProblem = true; } } assertTrue(depthFieldProblem); }
@Test public void testCorrectnessOfInScopeActivityPort() { ProcessorBinding pb = new ProcessorBinding(); Activity activity = new Activity(); pb.setBoundActivity(activity); ProcessorInputPortBinding pipb = new ProcessorInputPortBinding(); pipb.setParent(pb); InputActivityPort port = new InputActivityPort(); 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);
@Test public void testCorrectnessOfMissingDepth() { InputActivityPort iap = new InputActivityPort(); iap.setDepth(null); iap.setName("fred"); iap.setParent(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(iap, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(Collections.EMPTY_SET, negativeValueProblems); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); assertEquals(Collections.EMPTY_SET, nullFieldProblems); // only done when completeness check }