private void makeProfile(ScuflType wf) { Profile profile = new Profile(SCUFL + "-" + wf.getVersion()); profile.setParent(parserState.get().getCurrentWorkflowBundle()); parserState.get().getCurrentWorkflowBundle().setMainProfile(profile); parserState.get().setCurrentProfile(profile); }
protected void makeProfile(org.apache.taverna.scufl2.xml.t2flow.jaxb.Workflow wf) { // TODO: What should the default be? Should there be one? Who knows Profile profile = new Profile( wf.getProducedBy() == null ? DEFAULT_PRODUCED_BY : wf.getProducedBy()); profile.setParent(parserState.get().getCurrentWorkflowBundle()); parserState.get().getCurrentWorkflowBundle().setMainProfile(profile); parserState.get().setCurrentProfile(profile); }
private void parseProfile(Scanner scanner) { level = Level.Profile; profile = new Profile(); String profileName = parseName(scanner); profile.setName(profileName); wb.getProfiles().add(profile); if (profileName.equals(mainProfile)) wb.setMainProfile(profile); }
@Test public void profileName() throws Exception { Profile p = new Profile(); UUID uuid = UUID.fromString(p.getName()); assertEquals(4, uuid.version()); }
@Test public void testCorrectnessOfInvalidProfilePosition() { Profile profile = new Profile(); Integer profilePosition = Integer.valueOf(-3); profile.setProfilePosition(profilePosition); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(profile, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); boolean problem = false; for (NegativeValueProblem nlp : negativeValueProblems) { if (nlp.getBean().equals(profile) && nlp.getFieldName().equals("profilePosition") && nlp.getFieldValue().equals(profilePosition)) { problem = true; } } assertTrue(problem); }
protected void parseProfile(Profile original, URI profileUri) { org.apache.taverna.scufl2.api.profiles.Profile p = new org.apache.taverna.scufl2.api.profiles.Profile(); p.setParent(getParserState().getCurrent(WorkflowBundle.class)); getParserState().push(p); if (original.getAbout() != null) { URI about = getParserState().getCurrentBase().resolve( original.getAbout()); mapBean(about, p); } else mapBean(profileUri, p); if (original.getName() != null) p.setName(original.getName()); // Note - we'll pop() in profileSecond() instead }
@Test public void testCorrectnessOfValidProfilePosition() { Profile profile = new Profile(); Integer profilePosition = Integer.valueOf(3); profile.setProfilePosition(profilePosition); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(profile, false, rcvl); Set<NegativeValueProblem> negativeValueProblems = rcvl.getNegativeValueProblems(); assertEquals(Collections.EMPTY_SET, negativeValueProblems); }
@Test public void testCompletenessOfMissingProfilePosition() { // should be OK Profile profile = new Profile(); profile.setProfilePosition(null); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(profile, true, rcvl); Set<NullFieldProblem> nullFieldProblems = rcvl.getNullFieldProblems(); boolean problem = false; for (NullFieldProblem nlp : nullFieldProblems) { if (nlp.getBean().equals(profile) && nlp.getFieldName().equals("profilePosition")) { problem = true; } } assertFalse(problem); }
public Profile makeMainProfile() { Profile profile = new Profile(); profile.setName("tavernaWorkbench"); // FIXME: Can't set dc:creator/date/description // FIXME: Can't create recommendsEnvironment/requiresEnvironment makeActivity().setParent(profile); makeConfiguration().setParent(profile); makeProcessorBinding().setParent(profile); // profile.setProfilePosition(0); return profile; }
@Test public void testOutOfScopeMainProfile() { DummyWorkflowBundle dwb = new DummyWorkflowBundle(); Profile orphanProfile = new Profile(); dwb.setMainProfile(orphanProfile); dwb.setProfiles(new NamedSet<Profile>()); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(dwb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(dwb) && nlp.getFieldName().equals("mainProfile") && nlp.getValue().equals(orphanProfile)) { problem = true; } } assertTrue(problem); }
/** * @throws java.lang.Exception */ @Before public void setUp() throws Exception { workflow = new Workflow(); mainWorkflow = new Workflow(); profile = new Profile(); mainProfile = new Profile(); workflowBundle = new WorkflowBundle(); workflowBundle.setMainProfile(mainProfile); workflowBundle.setMainWorkflow(mainWorkflow); executionService = new LocalExecutionService(); executionEnvironment = new LocalExecutionEnvironment(executionService, null, null); dataBundle = DataBundles.createBundle(); runProfile = new RunProfile(executionEnvironment, workflowBundle, workflow.getName(), profile.getName(), dataBundle); }
@Test public void testCorrectnessOfOutOfScopeBoundActivity() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Activity orphanActivity = new Activity(); pb.setBoundActivity(orphanActivity); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundActivity") && nlp.getValue().equals(orphanActivity)) { problem = true; } } assertTrue(problem); }
@Test public void testInScopeMainProfile() { DummyWorkflowBundle dwb = new DummyWorkflowBundle(); Profile profile = new Profile(); dwb.setMainProfile(profile); NamedSet<Profile> profiles = new NamedSet<Profile>(); dwb.setProfiles(profiles); profiles.add(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(dwb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(dwb) && nlp.getFieldName().equals("mainProfile") && nlp.getValue().equals(profile)) { problem = true; } } assertFalse(problem); }
@Test public void testCorrectnessOfOutOfScopeBoundProcessor1() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Processor orphanProcessor = new Processor(); pb.setBoundProcessor(orphanProcessor); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundProcessor") && nlp.getValue().equals(orphanProcessor)) { problem = true; } } assertTrue(problem); }
@Test public void testCorrectnessOfOutOfScopeBoundProcessor2() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Workflow w = new Workflow(); Processor processor = new Processor(); processor.setParent(w); pb.setBoundProcessor(processor); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundProcessor") && nlp.getValue().equals(processor)) { problem = true; } } assertTrue(problem); }
@Test public void testCorrectnessOfInScopeBoundActivity1() { // Test when in same profile WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Activity activity = new Activity(); activity.setParent(profile); pb.setBoundActivity(activity); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundActivity") && nlp.getValue().equals(activity)) { problem = true; } } assertFalse(problem); }
@Test public void testCorrectnessOfInScopeBoundProcessor() { WorkflowBundle wb = new WorkflowBundle(); Profile profile = new Profile(); profile.setParent(wb); ProcessorBinding pb = new ProcessorBinding(); Workflow w = new Workflow(); Processor processor = new Processor(); processor.setParent(w); w.setParent(wb); pb.setBoundProcessor(processor); pb.setParent(profile); CorrectnessValidator cv = new CorrectnessValidator(); ReportCorrectnessValidationListener rcvl = new ReportCorrectnessValidationListener(); cv.checkCorrectness(pb, false, rcvl); Set<OutOfScopeValueProblem> outOfScopeValueProblems = rcvl.getOutOfScopeValueProblems(); // assertFalse(outOfScopeValueProblems.isEmpty()); boolean problem = false; for (OutOfScopeValueProblem nlp : outOfScopeValueProblems) { if (nlp.getBean().equals(pb) && nlp.getFieldName().equals("boundProcessor") && nlp.getValue().equals(processor)) { problem = true; } } assertFalse(problem); }
/** * Similar bug to {@link DataLinkCompareTest#dataLinkNotAddedTwice()} */ @Test public void configurationNotAddedTwice() throws Exception { Configuration c1a = new Configuration("c1"); Profile p1 = new Profile("p1"); p1.getConfigurations().add(c1a); c1a.setParent(p1); p1.getConfigurations().add(c1a); Configuration c1b = new Configuration("c1"); Profile p2 = new Profile("p2"); p2.getConfigurations().add(c1b); c1b.setParent(p2); p2.getConfigurations().add(c1b); WorkflowBundle bundle = new WorkflowBundle(); p1.setParent(bundle); p2.setParent(bundle); new Scufl2Tools().setParents(bundle); assertEquals(1, p1.getConfigurations().size()); assertEquals(1, p2.getConfigurations().size()); }
@Test public void createActivityFromProcessor() throws Exception { Processor p = new Processor(); new InputProcessorPort(p, "in1"); new InputProcessorPort(p, "in2").setDepth(1); new OutputProcessorPort(p, "out1"); new OutputProcessorPort(p, "out2").setDepth(0); OutputProcessorPort pOut3 = new OutputProcessorPort(p, "out3"); pOut3.setDepth(2); pOut3.setGranularDepth(1); Profile profile = new Profile(); Activity a = scufl2Tools.createActivityFromProcessor(p, profile); assertEquals(profile, a.getParent()); ProcessorBinding binding = scufl2Tools.processorBindingForProcessor(p, profile); assertEquals(2, a.getInputPorts().size()); assertEquals(3, a.getOutputPorts().size()); assertEquals(2, binding.getInputPortBindings().size()); assertEquals(3, binding.getOutputPortBindings().size()); assertEquals(a, binding.getBoundActivity()); assertEquals(p, binding.getBoundProcessor()); }
@Test public void createProcessorFromActivity() throws Exception { Profile profile = new Profile(); Activity a = new Activity(); a.setParent(profile); new InputActivityPort(a, "in1"); new InputActivityPort(a, "in2").setDepth(1); new OutputActivityPort(a, "out1"); new OutputActivityPort(a, "out2").setDepth(0); OutputActivityPort aOut3 = new OutputActivityPort(a, "out3"); aOut3.setDepth(2); aOut3.setGranularDepth(1); ProcessorBinding binding = scufl2Tools.createProcessorAndBindingFromActivity(a); Processor p = binding.getBoundProcessor(); assertEquals(profile, binding.getParent()); assertEquals(2, p.getInputPorts().size()); assertEquals(3, p.getOutputPorts().size()); assertEquals(2, binding.getInputPortBindings().size()); assertEquals(3, binding.getOutputPortBindings().size()); assertEquals(a, binding.getBoundActivity()); assertEquals(p, binding.getBoundProcessor()); }