13
13
import hlf .java .rest .client .model .ChannelUpdateParamsDTO ;
14
14
import hlf .java .rest .client .model .ClientResponseModel ;
15
15
import hlf .java .rest .client .model .CommitChannelParamsDTO ;
16
+ import hlf .java .rest .client .model .MSPDTO ;
16
17
import hlf .java .rest .client .service .ChannelConfigDeserialization ;
17
18
import java .util .ArrayList ;
18
19
import java .util .Collections ;
@@ -72,6 +73,7 @@ public class NetworkStatusImplTest {
72
73
@ Mock private ConfigGroup readset ;
73
74
74
75
@ Mock private ConfigGroup writeset ;
76
+ @ Mock private MSPDTO mspdto ;
75
77
76
78
@ Mock private Builder builder ;
77
79
@@ -106,26 +108,15 @@ public void getChannelFromNetworkTest()
106
108
}
107
109
108
110
@ Test
109
- public void generateConfigUpdateTest ()
110
- throws InvalidProtocolBufferException , InvalidArgumentException , TransactionException {
111
+ public void generateConfigUpdateTest () throws InvalidProtocolBufferException {
111
112
ResponseEntity <ClientResponseModel > responseEntity =
112
113
new ResponseEntity <>(
113
114
new ClientResponseModel (ErrorConstants .NO_ERROR , "dGhlX2NvbmZpZw==" ), HttpStatus .OK );
114
115
Mockito .when (gateway .getNetwork (Mockito .anyString ())).thenReturn (network );
115
- Mockito .when (network .getChannel ()).thenReturn (channel );
116
-
117
- Mockito .when (channel .getChannelConfigurationBytes ()).thenReturn (new byte [0 ]);
118
116
staticConfigUpdate
119
117
.when (() -> ConfigUpdate .parseFrom (Mockito .any (byte [].class )))
120
118
.thenReturn (configUpdate );
121
119
staticConfigUpdate .when (() -> ConfigUpdate .newBuilder ()).thenReturn (builder );
122
- Mockito .when (configUpdate .getReadSet ()).thenReturn (readset );
123
- Mockito .when (builder .setChannelId (Mockito .anyString ())).thenReturn (builder );
124
- Mockito .when (builder .setReadSet (Mockito .any (ConfigGroup .class ))).thenReturn (builder );
125
- Mockito .when (
126
- updateChannel .buildWriteset (Mockito .any (), Mockito .any (ChannelUpdateParamsDTO .class )))
127
- .thenReturn (readset );
128
- Mockito .when (builder .setWriteSet (Mockito .any (ConfigGroup .class ))).thenReturn (builder );
129
120
Mockito .when (builder .build ()).thenReturn (configUpdate );
130
121
staticJsonFormat .when (JsonFormat ::printer ).thenReturn (printer );
131
122
Mockito .when (printer .print (Mockito .any (MessageOrBuilder .class ))).thenReturn ("the_config" );
@@ -201,7 +192,6 @@ public void addOrgToChannelTest() throws InvalidArgumentException, TransactionEx
201
192
202
193
Mockito .when (gateway .getNetwork (Mockito .anyString ())).thenReturn (network );
203
194
Mockito .when (network .getChannel ()).thenReturn (channel );
204
-
205
195
Mockito .when (channel .getChannelConfigurationBytes ()).thenReturn (new byte [0 ]);
206
196
staticConfigUpdate
207
197
.when (() -> ConfigUpdate .parseFrom (Mockito .any (byte [].class )))
@@ -224,10 +214,12 @@ public void addOrgToChannelTest() throws InvalidArgumentException, TransactionEx
224
214
Mockito .any (UpdateChannelConfiguration .class ), Mockito .any (User .class )))
225
215
.thenReturn (outputByteArray );
226
216
217
+ Mockito .when (channelUpdateParamsDTO .getMspDTO ()).thenReturn (mspdto );
218
+
227
219
assertEquals (
228
220
responseEntity .getBody ().getMessage (),
229
221
networkStatus
230
- .addOrgToChannel ("some_channel_name" , new ChannelUpdateParamsDTO () )
222
+ .addOrgToChannel ("some_channel_name" , channelUpdateParamsDTO )
231
223
.getBody ()
232
224
.getMessage ());
233
225
}
0 commit comments