Skip to content
This repository has been archived by the owner on Nov 12, 2020. It is now read-only.

Commit

Permalink
the behaviour model itself should not be executable: removed behaviou…
Browse files Browse the repository at this point in the history
…r#perform()
  • Loading branch information
heiko-braun committed Nov 21, 2012
1 parent 2738861 commit d8f55de
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 48 deletions.
Expand Up @@ -49,15 +49,6 @@ public void setCondition(Condition condition) {
this.condition = condition;
}

public void execute() {

if(condition.isMet())
{
for(Transition action : transitions)
action.perform();
}
}

public void addTransition(Transition transition) {
transitions.add(transition);
}
Expand All @@ -76,4 +67,5 @@ public void setInputs(Trigger<TriggerType>... trigger) {
public boolean isTriggeredBy(Trigger<TriggerType> type) {
return eventConsumption.isTriggeredBy(type);
}

}
@@ -1,16 +1,12 @@
package org.jboss.as.console.client.mbui.aui.aim;

import java.util.Set;

/**
* @author Heiko Braun
* @date 10/31/12
*/
public class FunctionCall extends Transition {

@Override
public void perform() {

protected FunctionCall(QName id) {
super(id);
}

}
Expand Up @@ -5,8 +5,7 @@
* @date 11/1/12
*/
public class Navigation extends Transition {
@Override
public void perform() {

protected Navigation(QName id) {
super(id);
}
}
Expand Up @@ -10,13 +10,19 @@
*/
public abstract class Transition implements TriggerSource {

private String id;
private QName id;

protected Transition(QName id) {
this.id = id;
}

public QName getId() {
return id;
}

private EventProduction eventProduction =
new EventProduction(TriggerType.Transition);

public abstract void perform();

@Override
public boolean doesTrigger() {
return eventProduction.doesTrigger();
Expand Down
Expand Up @@ -30,11 +30,11 @@
import java.util.Set;

import static org.jboss.as.console.client.mbui.TestNamespace.NAMESPACE;
import static org.jboss.as.console.client.mbui.aui.aim.TemporalOperator.Choice;
import static org.jboss.as.console.client.mbui.aui.aim.TemporalOperator.OrderIndependance;
import static org.jboss.as.console.client.mbui.aui.aim.TriggerType.*;
import static org.jboss.as.console.client.mbui.aui.aim.TriggerType.System;
import static org.jboss.as.console.client.mbui.aui.aim.TriggerType.Transition;
import static org.jboss.as.console.client.mbui.aui.aim.TemporalOperator.Choice;
import static org.jboss.as.console.client.mbui.aui.aim.TemporalOperator.OrderIndependance;
import static org.jboss.as.console.client.mbui.aui.mapping.MappingType.RESOURCE;
import static org.junit.Assert.*;

Expand Down Expand Up @@ -126,31 +126,6 @@ public void behaviourResolution()
assertFalse("Behaviour should not be triggered by deviceRotation", behaviour.isTriggeredBy(deviceRotation));
assertFalse("Behaviour should not be triggered by loadData", behaviour.isTriggeredBy(loadData));

final StringBuffer sharedState = new StringBuffer("");

behaviour.setCondition(new Condition()
{
@Override
public boolean isMet()
{
return true;
}
});

behaviour.addTransition(new FunctionCall()
{
@Override
public void perform()
{
sharedState.append("updated");
}
});

if (behaviour.isTriggeredBy(loadData))
{
behaviour.execute();
assertTrue("sharedState should be updated", sharedState.toString().equals("updated"));
}
}

@Test
Expand Down

0 comments on commit d8f55de

Please sign in to comment.