Skip to content

Commit 100602a

Browse files
Readme update and flow test
1 parent c407f02 commit 100602a

File tree

2 files changed

+72
-3
lines changed

2 files changed

+72
-3
lines changed

Advanced/syndicated-lending/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ Go to PartyA's terminal and run the below command
3838
start SubmitProjectProposalFlow lenders: [PartyB, PartyC], projectDescription: "Overseas Expansion", projectCost: 10000000, loanAmount: 8000000
3939
```
4040

41-
Validate the project details are crated and shared with the lenders successfully by running the vaultQuery command in each
41+
Validate the project details are created and shared with the lenders successfully by running the vaultQuery command in each
4242
lender's terminal and borrower's terminal.
4343

4444
```
@@ -67,7 +67,7 @@ Go to PartyA's terminal and run the below command. The loanbid-identifier can be
6767
start ApproveLoanBidFlow bidIdentifier: <loanbid-identifier>
6868
```
6969

70-
One the loan bid has been approved by the borrower, the lender can start the process of creating teh syndicate by
70+
One the loan bid has been approved by the borrower, the lender can start the process of creating the syndicate by
7171
acting as the lead bank and approach participating bank for funds.
7272

7373
Goto PartyB's terminal and run the below command.

Advanced/syndicated-lending/workflows/src/test/java/net/corda/samples/lending/FlowTests.java

Lines changed: 70 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
package net.corda.samples.lending;
22

33
import com.google.common.collect.ImmutableList;
4+
import net.corda.core.concurrent.CordaFuture;
5+
import net.corda.core.transactions.SignedTransaction;
6+
import net.corda.samples.lending.flows.ApproveLoanBidFlow;
7+
import net.corda.samples.lending.flows.SubmitLoanBidFlow;
8+
import net.corda.samples.lending.flows.SubmitProjectProposalFlow;
9+
import net.corda.samples.lending.states.LoanBidState;
10+
import net.corda.samples.lending.states.ProjectState;
411
import net.corda.testing.node.MockNetwork;
512
import net.corda.testing.node.MockNetworkParameters;
613
import net.corda.testing.node.StartedMockNode;
@@ -9,10 +16,16 @@
916
import org.junit.Before;
1017
import org.junit.Test;
1118

19+
import java.util.Arrays;
20+
21+
import static org.junit.Assert.*;
22+
1223
public class FlowTests {
1324
private MockNetwork network;
1425
private StartedMockNode a;
1526
private StartedMockNode b;
27+
private StartedMockNode c;
28+
private StartedMockNode d;
1629

1730
@Before
1831
public void setup() {
@@ -21,6 +34,8 @@ public void setup() {
2134
TestCordapp.findCordapp("net.corda.samples.lending.flows"))));
2235
a = network.createPartyNode(null);
2336
b = network.createPartyNode(null);
37+
c = network.createPartyNode(null);
38+
d = network.createPartyNode(null);
2439
network.runNetwork();
2540
}
2641

@@ -29,8 +44,62 @@ public void tearDown() {
2944
network.stopNodes();
3045
}
3146

47+
private ProjectState createProject() throws Exception{
48+
SubmitProjectProposalFlow.Initiator flow = new SubmitProjectProposalFlow.Initiator(
49+
Arrays.asList(
50+
b.getInfo().getLegalIdentities().get(0),
51+
c.getInfo().getLegalIdentities().get(0)),
52+
"Test Project", 10000000, 8000000);
53+
CordaFuture<SignedTransaction> future = a.startFlow(flow);
54+
network.runNetwork();
55+
SignedTransaction transaction = future.get();
56+
ProjectState projectState = (ProjectState) transaction.getTx().getOutput(0);
57+
return projectState;
58+
}
59+
60+
private LoanBidState submitLoanBid(ProjectState projectState) throws Exception{
61+
SubmitLoanBidFlow.Initiator flow = new SubmitLoanBidFlow.Initiator(
62+
projectState.getBorrower(),
63+
8000000, 5, 8, 20000,
64+
projectState.getLinearId()
65+
);
66+
CordaFuture<SignedTransaction> future = b.startFlow(flow);
67+
network.runNetwork();
68+
SignedTransaction transaction = future.get();
69+
LoanBidState loanBidState = (LoanBidState) transaction.getTx().getOutput(0);
70+
return loanBidState;
71+
}
72+
73+
private LoanBidState approveLoanBid(LoanBidState loanBidState) throws Exception{
74+
ApproveLoanBidFlow.Initiator flow = new ApproveLoanBidFlow.Initiator(loanBidState.getLinearId());
75+
CordaFuture<SignedTransaction> future = a.startFlow(flow);
76+
network.runNetwork();
77+
SignedTransaction transaction = future.get();
78+
LoanBidState loanBidStateUpdated = (LoanBidState) transaction.getTx().getOutput(0);
79+
return loanBidStateUpdated;
80+
}
81+
3282
@Test
33-
public void dummyTest() {
83+
public void testSubmitProjectProposalFlow() throws Exception{
84+
ProjectState projectState = createProject();
85+
assertNotNull(projectState);
86+
}
3487

88+
@Test
89+
public void testSubmitLoanBidFlow() throws Exception{
90+
ProjectState projectState = createProject();
91+
LoanBidState loanBidState = submitLoanBid(projectState);
92+
assertNotNull(loanBidState);
3593
}
94+
95+
@Test
96+
public void testApproveLoanBidFlow() throws Exception{
97+
ProjectState projectState = createProject();
98+
LoanBidState loanBidState = submitLoanBid(projectState);
99+
LoanBidState loanBidStateApproved = approveLoanBid(loanBidState);
100+
assertNotNull(loanBidStateApproved);
101+
assertEquals("APPROVED", loanBidStateApproved.getStatus());
102+
}
103+
104+
36105
}

0 commit comments

Comments
 (0)