@@ -336,6 +336,7 @@ void shouldGetCorrectNbReplicatesContainingMultipleStatus() {
336336 assertThat (shouldBe0 ).isZero ();
337337 }
338338
339+ // region getRandomReplicateWithRevealStatus
339340 @ Test
340341 void shouldGetReplicateWithRevealStatus () {
341342 Replicate replicate = new Replicate (WALLET_WORKER_1 , CHAIN_TASK_ID );
@@ -384,7 +385,9 @@ void shouldNotGetReplicateWithRevealStatusWithNonEmptyList() {
384385 Optional <Replicate > optional = replicatesService .getRandomReplicateWithRevealStatus (CHAIN_TASK_ID );
385386 assertThat (optional ).isEmpty ();
386387 }
388+ //endregion
387389
390+ //region updateReplicateStatus
388391 @ Test
389392 void shouldUpdateReplicateStatusWithoutStdout () {
390393 Replicate replicate = new Replicate (WALLET_WORKER_1 , CHAIN_TASK_ID );
@@ -765,8 +768,9 @@ void shouldUpdateToResultUploaded() {
765768 assertThat (capturedEvent .getWalletAddress ()).isEqualTo (WALLET_WORKER_1 );
766769 assertThat (capturedEvent .getReplicateStatusUpdate ().getStatus ()).isEqualTo (RESULT_UPLOADED );
767770 }
771+ // endregion
768772
769- // getReplicateWithResultUploadedStatus
773+ // region getReplicateWithResultUploadedStatus
770774
771775 @ Test
772776 void should () {
@@ -786,8 +790,9 @@ void should() {
786790 .getWalletAddress ())
787791 .isEqualTo (WALLET_WORKER_2 );
788792 }
793+ // endregion
789794
790- // isResultUploaded
795+ // region isResultUploaded
791796
792797 @ Test
793798 void shouldCheckResultServiceAndReturnTrue () {
@@ -860,6 +865,7 @@ void shouldReturnTrueForTeeTask() {
860865 assertThat (isResultUploaded ).isTrue ();
861866 verify (resultService , never ()).isResultUploaded (CHAIN_TASK_ID );
862867 }
868+ // endregion
863869
864870 // didReplicateContributeOnchain
865871
@@ -1343,7 +1349,7 @@ void computeUpdateReplicateStatusArgsContributed() {
13431349
13441350 when (iexecHubService .getWorkerWeight (WALLET_WORKER_1 )).thenReturn (expectedWorkerWeight );
13451351 when (iexecHubService .getChainContribution (CHAIN_TASK_ID , WALLET_WORKER_1 ))
1346- .thenReturn (Optional .of (ChainContribution . builder (). build () ));
1352+ .thenReturn (Optional .of (expectedChainContribution ));
13471353
13481354 assertThat (replicatesService .computeUpdateReplicateStatusArgs (CHAIN_TASK_ID , WALLET_WORKER_1 , statusUpdate ))
13491355 .isEqualTo (UpdateReplicateStatusArgs .builder ()
@@ -1354,8 +1360,6 @@ void computeUpdateReplicateStatusArgsContributed() {
13541360
13551361 @ Test
13561362 void computeUpdateReplicateStatusArgsResultUploaded () {
1357- final int unexpectedWorkerWeight = 1 ;
1358- final ChainContribution unexpectedChainContribution = ChainContribution .builder ().build ();
13591363 final String expectedResultLink = "resultLink" ;
13601364 final String expectedChainCallbackData = "chainCallbackData" ;
13611365 final TaskDescription expectedTaskDescription = TaskDescription .builder ().build ();
@@ -1370,9 +1374,6 @@ void computeUpdateReplicateStatusArgsResultUploaded() {
13701374 .details (details )
13711375 .build ();
13721376
1373- when (iexecHubService .getWorkerWeight (WALLET_WORKER_1 )).thenReturn (unexpectedWorkerWeight );
1374- when (iexecHubService .getChainContribution (CHAIN_TASK_ID , WALLET_WORKER_1 ))
1375- .thenReturn (Optional .of (unexpectedChainContribution ));
13761377 when (iexecHubService .getTaskDescription (CHAIN_TASK_ID ))
13771378 .thenReturn (expectedTaskDescription );
13781379
@@ -1384,6 +1385,42 @@ void computeUpdateReplicateStatusArgsResultUploaded() {
13841385 .chainCallbackData (expectedChainCallbackData )
13851386 .taskDescription (expectedTaskDescription )
13861387 .build ());
1388+
1389+ verify (iexecHubService , never ()).getWorkerWeight (WALLET_WORKER_1 );
1390+ verify (iexecHubService , never ()).getChainContribution (CHAIN_TASK_ID , WALLET_WORKER_1 );
1391+ }
1392+
1393+ @ Test
1394+ void computeUpdateReplicateStatusArgsContributeAndFinalizeDone () {
1395+ final int expectedWorkerWeight = 1 ;
1396+ final ChainContribution expectedChainContribution = ChainContribution .builder ().build ();
1397+ final String expectedResultLink = "resultLink" ;
1398+ final String expectedChainCallbackData = "chainCallbackData" ;
1399+ final TaskDescription expectedTaskDescription = TaskDescription .builder ().build ();
1400+
1401+ final ReplicateStatusDetails details = ReplicateStatusDetails .builder ()
1402+ .resultLink (expectedResultLink )
1403+ .chainCallbackData (expectedChainCallbackData )
1404+ .build ();
1405+ final ReplicateStatusUpdate statusUpdate = ReplicateStatusUpdate .builder ()
1406+ .modifier (WORKER )
1407+ .status (CONTRIBUTE_AND_FINALIZE_DONE )
1408+ .details (details )
1409+ .build ();
1410+
1411+ when (iexecHubService .getTaskDescription (CHAIN_TASK_ID )).thenReturn (expectedTaskDescription );
1412+ when (iexecHubService .getWorkerWeight (WALLET_WORKER_1 )).thenReturn (expectedWorkerWeight );
1413+ when (iexecHubService .getChainContribution (CHAIN_TASK_ID , WALLET_WORKER_1 ))
1414+ .thenReturn (Optional .of (expectedChainContribution ));
1415+
1416+ assertThat (replicatesService .computeUpdateReplicateStatusArgs (CHAIN_TASK_ID , WALLET_WORKER_1 , statusUpdate ))
1417+ .isEqualTo (UpdateReplicateStatusArgs .builder ()
1418+ .workerWeight (expectedWorkerWeight )
1419+ .chainContribution (expectedChainContribution )
1420+ .resultLink (expectedResultLink )
1421+ .chainCallbackData (expectedChainCallbackData )
1422+ .taskDescription (expectedTaskDescription )
1423+ .build ());
13871424 }
13881425
13891426 @ Test
0 commit comments