RAWvernaActivity extends AbstractAsynchronousActivity<RAWvernaActivityConfigurationBean> implements
    AsynchronousActivity<RAWvernaActivityConfigurationBean> { @Override public void configure(RAWvernaActivityConfigurationBean configBean) throws ActivityConfigurationException { if (configBean.getExampleString().equals("invalidExample")) { throw new ActivityConfigurationException("Example string can't be 'invalidExample'"); } this.configBean = configBean; configurePorts(); }  @Override void configure(RAWvernaActivityConfigurationBean configBean); @SuppressWarnings("unchecked") @Override void executeAsynch(final Map<String, T2Reference> inputs, final AsynchronousActivityCallback callback); @Override RAWvernaActivityConfigurationBean getConfiguration();  }
@Test(expected = ActivityConfigurationException.class) public void invalidConfiguration() throws ActivityConfigurationException { RAWvernaActivityConfigurationBean invalidBean = new RAWvernaActivityConfigurationBean(); invalidBean.setExampleString("invalidExample"); activity.configure(invalidBean); }
@Test public void reConfiguredActivity() throws Exception { assertEquals("Unexpected inputs", 0, activity.getInputPorts().size()); assertEquals("Unexpected outputs", 0, activity.getOutputPorts().size()); activity.configure(configBean); assertEquals("Unexpected inputs", 1, activity.getInputPorts().size()); assertEquals("Unexpected outputs", 2, activity.getOutputPorts().size()); activity.configure(configBean); assertEquals("Unexpected inputs", 1, activity.getInputPorts().size()); assertEquals("Unexpected outputs", 2, activity.getOutputPorts().size()); }
@Test public void reConfiguredSpecialPorts() throws Exception { activity.configure(configBean); RAWvernaActivityConfigurationBean specialBean = new RAWvernaActivityConfigurationBean(); specialBean.setExampleString("specialCase"); specialBean.setExampleUri(URI.create("http: activity.configure(specialBean); assertEquals("Unexpected inputs", 2, activity.getInputPorts().size()); assertEquals("Unexpected outputs", 3, activity.getOutputPorts().size()); }
@Test public void configureActivity() throws Exception { Set<String> expectedInputs = new HashSet<String>(); expectedInputs.add("firstInput"); Set<String> expectedOutputs = new HashSet<String>(); expectedOutputs.add("simpleOutput"); expectedOutputs.add("moreOutputs"); activity.configure(configBean); Set<ActivityInputPort> inputPorts = activity.getInputPorts(); assertEquals(expectedInputs.size(), inputPorts.size()); for (ActivityInputPort inputPort : inputPorts) { assertTrue("Wrong input : " + inputPort.getName(), expectedInputs.remove(inputPort.getName())); } Set<OutputPort> outputPorts = activity.getOutputPorts(); assertEquals(expectedOutputs.size(), outputPorts.size()); for (OutputPort outputPort : outputPorts) { assertTrue("Wrong output : " + outputPort.getName(), expectedOutputs.remove(outputPort.getName())); } }