-
Notifications
You must be signed in to change notification settings - Fork 38
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
29 changed files
with
476 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
nflow-tests/src/main/java/io/nflow/tests/demo/domain/AbstractRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
package io.nflow.tests.demo.domain; | ||
|
||
import org.apache.commons.lang3.builder.ToStringBuilder; | ||
|
||
public class AbstractRequest { | ||
|
||
@Override | ||
public String toString() { | ||
return ToStringBuilder.reflectionToString(this); | ||
} | ||
|
||
} |
14 changes: 14 additions & 0 deletions
14
nflow-tests/src/main/java/io/nflow/tests/demo/domain/AbstractResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
package io.nflow.tests.demo.domain; | ||
|
||
import org.apache.commons.lang3.builder.ToStringBuilder; | ||
|
||
public class AbstractResponse { | ||
|
||
public boolean success; | ||
|
||
@Override | ||
public String toString() { | ||
return ToStringBuilder.reflectionToString(this); | ||
} | ||
|
||
} |
11 changes: 11 additions & 0 deletions
11
nflow-tests/src/main/java/io/nflow/tests/demo/domain/CreateCreditApplicationRequest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package io.nflow.tests.demo.domain; | ||
|
||
public class CreateCreditApplicationRequest extends AbstractRequest { | ||
|
||
public String accountNo; | ||
public int amount; | ||
public String clientId; | ||
public String productId; | ||
public int processWorkflowId; | ||
|
||
} |
18 changes: 18 additions & 0 deletions
18
nflow-tests/src/main/java/io/nflow/tests/demo/domain/CreateLoanResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
package io.nflow.tests.demo.domain; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class CreateLoanResponse extends AbstractResponse { | ||
|
||
public String accountNo; | ||
public boolean active; | ||
public int amount; | ||
public String applicationId; | ||
public String archiveId; | ||
public String clientId; | ||
// created | ||
public String loanId; | ||
public String productId; | ||
|
||
} |
8 changes: 8 additions & 0 deletions
8
nflow-tests/src/main/java/io/nflow/tests/demo/domain/CreditDecisionData.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
package io.nflow.tests.demo.domain; | ||
|
||
public class CreditDecisionData extends AbstractRequest { | ||
|
||
public String clientId; | ||
public int amount; | ||
|
||
} |
17 changes: 17 additions & 0 deletions
17
nflow-tests/src/main/java/io/nflow/tests/demo/domain/QueryCreditApplicationResponse.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package io.nflow.tests.demo.domain; | ||
|
||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties; | ||
|
||
@JsonIgnoreProperties(ignoreUnknown = true) | ||
public class QueryCreditApplicationResponse extends AbstractResponse { | ||
|
||
public String accountNo; | ||
public boolean active; | ||
public int amount; | ||
public String applicationId; | ||
public String clientId; | ||
// created | ||
public String productId; | ||
public String status; | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
88 changes: 88 additions & 0 deletions
88
nflow-tests/src/main/java/io/nflow/tests/demo/workflow/CreditDecisionWorkflow.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,88 @@ | ||
package io.nflow.tests.demo.workflow; | ||
|
||
import static io.nflow.engine.workflow.definition.NextAction.moveToState; | ||
import static io.nflow.engine.workflow.definition.WorkflowStateType.end; | ||
import static io.nflow.engine.workflow.definition.WorkflowStateType.manual; | ||
import static io.nflow.engine.workflow.definition.WorkflowStateType.normal; | ||
import static io.nflow.engine.workflow.definition.WorkflowStateType.start; | ||
import static io.nflow.tests.demo.workflow.CreditDecisionWorkflow.State.approved; | ||
import static io.nflow.tests.demo.workflow.CreditDecisionWorkflow.State.decisionEngine; | ||
import static io.nflow.tests.demo.workflow.CreditDecisionWorkflow.State.internalBlacklist; | ||
import static io.nflow.tests.demo.workflow.CreditDecisionWorkflow.State.manualDecision; | ||
import static io.nflow.tests.demo.workflow.CreditDecisionWorkflow.State.rejected; | ||
import static io.nflow.tests.demo.workflow.CreditDecisionWorkflow.State.satQuery; | ||
|
||
import org.springframework.stereotype.Component; | ||
|
||
import io.nflow.engine.workflow.definition.NextAction; | ||
import io.nflow.engine.workflow.definition.StateExecution; | ||
import io.nflow.engine.workflow.definition.StateVar; | ||
import io.nflow.engine.workflow.definition.WorkflowDefinition; | ||
import io.nflow.engine.workflow.definition.WorkflowStateType; | ||
import io.nflow.tests.demo.domain.CreditDecisionData; | ||
|
||
@Component | ||
public class CreditDecisionWorkflow extends WorkflowDefinition<CreditDecisionWorkflow.State> { | ||
|
||
public static final String TYPE = "creditDecision"; | ||
public static final String VAR_REQUEST_DATA = "requestData"; | ||
|
||
public enum State implements io.nflow.engine.workflow.definition.WorkflowState { | ||
internalBlacklist(start, "Reject internally blacklisted customers"), | ||
decisionEngine(normal, "Check if application ok for decision engine"), | ||
satQuery(normal, "Query customer credit rating from SAT"), | ||
manualDecision(manual, "Manually approve or reject the application"), | ||
approved(end, "Credit Decision Approved"), | ||
rejected(end, "Credit Decision Rejected"); | ||
|
||
private WorkflowStateType type; | ||
private String description; | ||
|
||
private State(WorkflowStateType type, String description) { | ||
this.type = type; | ||
this.description = description; | ||
} | ||
|
||
@Override | ||
public WorkflowStateType getType() { | ||
return type; | ||
} | ||
|
||
@Override | ||
public String getDescription() { | ||
return description; | ||
} | ||
} | ||
|
||
public CreditDecisionWorkflow() { | ||
super(TYPE, internalBlacklist, manualDecision); | ||
setDescription("Approve or reject credit application"); | ||
permit(internalBlacklist, decisionEngine); | ||
permit(decisionEngine, satQuery); | ||
permit(satQuery, approved); | ||
permit(satQuery, rejected); | ||
} | ||
|
||
public NextAction internalBlacklist(@SuppressWarnings("unused") StateExecution execution) { | ||
return moveToState(decisionEngine, "Customer not blacklisted"); | ||
} | ||
|
||
public NextAction decisionEngine(@SuppressWarnings("unused") StateExecution execution) { | ||
return moveToState(satQuery, "Decision engine approves"); | ||
} | ||
|
||
public NextAction satQuery(@SuppressWarnings("unused") StateExecution execution) { | ||
return moveToState(manualDecision, "SAT query failed"); | ||
} | ||
|
||
public void approved(StateExecution execution, | ||
@SuppressWarnings("unused") @StateVar(value = VAR_REQUEST_DATA) CreditDecisionData requestData) { | ||
execution.wakeUpParentWorkflow(); | ||
} | ||
|
||
public void rejected(StateExecution execution, | ||
@SuppressWarnings("unused") @StateVar(value = VAR_REQUEST_DATA) CreditDecisionData requestData) { | ||
execution.wakeUpParentWorkflow(); | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.