forked from lightbend/kalix-jvm-sdk
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCounterJournalToTopicActionTestKit.java
More file actions
54 lines (44 loc) · 2.16 KB
/
Copy pathCounterJournalToTopicActionTestKit.java
File metadata and controls
54 lines (44 loc) · 2.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/* This code is managed by Akka Serverless tooling.
* It will be re-generated to reflect any changes to your protobuf definitions.
* DO NOT EDIT
*/
package com.example.actions;
import java.util.ArrayList;
import java.util.List;
import java.util.function.Function;
import java.util.Optional;
import com.akkaserverless.javasdk.action.Action;
import com.akkaserverless.javasdk.testkit.ActionResult;
import com.akkaserverless.javasdk.action.ActionCreationContext;
import com.akkaserverless.javasdk.testkit.impl.ActionResultImpl;
import com.akkaserverless.javasdk.impl.action.ActionEffectImpl;
import com.example.actions.CounterJournalToTopicAction;
import com.akkaserverless.javasdk.testkit.impl.StubActionCreationContext;
import com.akkaserverless.javasdk.testkit.impl.StubActionContext;
import com.example.actions.CounterTopicApi;
import com.example.domain.CounterDomain;
public final class CounterJournalToTopicActionTestKit {
private Function<ActionCreationContext, CounterJournalToTopicAction> actionFactory;
private CounterJournalToTopicAction createAction() {
CounterJournalToTopicAction action = actionFactory.apply(new StubActionCreationContext());
action._internalSetActionContext(Optional.of(new StubActionContext()));
return action;
};
public static CounterJournalToTopicActionTestKit of(Function<ActionCreationContext, CounterJournalToTopicAction> actionFactory) {
return new CounterJournalToTopicActionTestKit(actionFactory);
}
private CounterJournalToTopicActionTestKit(Function<ActionCreationContext, CounterJournalToTopicAction> actionFactory) {
this.actionFactory = actionFactory;
}
private <E> ActionResult<E> interpretEffects(Action.Effect<E> effect) {
return new ActionResultImpl(effect);
}
public ActionResult<CounterTopicApi.Increased> increase(CounterDomain.ValueIncreased event) {
Action.Effect<CounterTopicApi.Increased> effect = createAction().increase(event);
return interpretEffects(effect);
}
public ActionResult<CounterTopicApi.Decreased> decrease(CounterDomain.ValueDecreased event) {
Action.Effect<CounterTopicApi.Decreased> effect = createAction().decrease(event);
return interpretEffects(effect);
}
}