Skip to content

Commit

Permalink
Added test checking triggering of child node to a multi arg push meth…
Browse files Browse the repository at this point in the history
…od on parent
  • Loading branch information
greg-higgins committed Jan 12, 2025
1 parent 466eb80 commit b6dc2f8
Showing 1 changed file with 34 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import com.fluxtion.compiler.generation.util.CompiledAndInterpretedSepTest;
import com.fluxtion.compiler.generation.util.MultipleSepTargetInProcessTest;
import com.fluxtion.runtime.annotations.OnTrigger;
import com.fluxtion.runtime.node.BaseNode;
import lombok.Data;
import org.junit.Assert;
Expand All @@ -42,6 +43,7 @@ public void setup() {
public void biPushTest() {
sep(c -> {
MyPushTarget myPushTarget = c.addNode(new MyPushTarget(), "myPushTarget");
c.addNode(new PushTriggerMonitor(myPushTarget), "monitor");
DataFlow.push(
myPushTarget::update,
DataFlow.subscribe(String.class),
Expand All @@ -50,7 +52,11 @@ public void biPushTest() {

MyPushTarget myPushTarget = getField("myPushTarget");

PushTriggerMonitor monitor = getField("monitor");
Assert.assertFalse(monitor.isTriggered());

publishIntSignal("count", 200);
Assert.assertTrue(monitor.isTriggered());
Assert.assertEquals(200, MyPushTarget.inputCount);
Assert.assertEquals(200, myPushTarget.getInstanceCount());
Assert.assertNull(MyPushTarget.stringInput);
Expand All @@ -67,6 +73,7 @@ public void biPushTest() {
public void triPushTest() {
sep(c -> {
MyPushTarget myPushTarget = c.addNode(new MyPushTarget(), "myPushTarget");
c.addNode(new PushTriggerMonitor(myPushTarget), "monitor");
DataFlow.push(
myPushTarget::update3,
DataFlow.subscribe(String.class),
Expand All @@ -76,7 +83,11 @@ public void triPushTest() {

MyPushTarget myPushTarget = getField("myPushTarget");

PushTriggerMonitor monitor = getField("monitor");
Assert.assertFalse(monitor.isTriggered());

onEvent("stringFlow");
Assert.assertTrue(monitor.isTriggered());
Assert.assertEquals("stringFlow", myPushTarget.getInput1());
Assert.assertEquals("stringFlow", myPushTarget.getInput2());
Assert.assertEquals("stringFlow", myPushTarget.getInput3());
Expand All @@ -86,6 +97,7 @@ public void triPushTest() {
public void quadPushTest() {
sep(c -> {
MyPushTarget myPushTarget = c.addNode(new MyPushTarget(), "myPushTarget");
c.addNode(new PushTriggerMonitor(myPushTarget), "monitor");
DataFlow.push(
myPushTarget::update4,
DataFlow.subscribe(String.class),
Expand All @@ -96,7 +108,11 @@ public void quadPushTest() {

MyPushTarget myPushTarget = getField("myPushTarget");

PushTriggerMonitor monitor = getField("monitor");
Assert.assertFalse(monitor.isTriggered());

onEvent("stringFlow");
Assert.assertTrue(monitor.isTriggered());
Assert.assertEquals("stringFlow", myPushTarget.getInput1());
Assert.assertEquals("stringFlow", myPushTarget.getInput2());
Assert.assertEquals("stringFlow", myPushTarget.getInput3());
Expand Down Expand Up @@ -180,5 +196,23 @@ public void update4(String input1, String input2, String input3, String input4)
this.input4 = input4;
update4Called = true;
}

@OnTrigger
public boolean onTrigger() {
return true;
}
}

@Data
public static class PushTriggerMonitor extends BaseNode {
private final MyPushTarget myPushTarget;
private boolean triggered;

@OnTrigger
public boolean onTrigger() {
auditLog.info("myPushTarget", myPushTarget);
triggered = true;
return true;
}
}
}

0 comments on commit b6dc2f8

Please sign in to comment.