Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use builders in test classes #589

Merged
merged 3 commits into from
May 25, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ All notable changes to this project will be documented in this file.
- Add purge cached task descriptions ability. (#587)
### Bug Fixes
- Prevent race condition on replicate update. (#568)
- Ue builders in test classes. (#589)
jbern0rd marked this conversation as resolved.
Show resolved Hide resolved
### Quality
- Remove unused methods in `IexecHubService`. (#572)
- Clean unused Replicate methods and update tests. (#573)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,10 +103,10 @@ void shouldUpdateLastSeenBlockWhenOneDeal() {

@Test
void shouldUpdateLastSeenBlockWhenOneDealAndCreateTask() {
ChainApp chainApp = new ChainApp();
chainApp.setUri("0x00");
ChainApp chainApp = ChainApp.builder()
.uri("0x00").build();

ChainCategory chainCategory = new ChainCategory();
ChainCategory chainCategory = ChainCategory.builder().build();

ChainDeal chainDeal = ChainDeal.builder()
.botFirst(BigInteger.valueOf(0))
Expand Down Expand Up @@ -146,7 +146,7 @@ void shouldUpdateLastSeenBlockWhenOneDealAndNotCreateTaskSinceDealIsExpired() {
.botFirst(BigInteger.valueOf(0))
.botSize(BigInteger.valueOf(1))
.chainApp(ChainApp.builder().uri("0x00").build())
.chainCategory(new ChainCategory())
.chainCategory(ChainCategory.builder().build())
.params(DealParams.builder().iexecArgs("args").build())
.trust(BigInteger.valueOf(3))
.build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1410,7 +1410,7 @@ void shouldAuthorizeUpdateOnComputedWhenTaskDescriptionIsFilled() {
@Test
void computeUpdateReplicateStatusArgsContributed() {
final int expectedWorkerWeight = 1;
final ChainContribution expectedChainContribution = new ChainContribution();
final ChainContribution expectedChainContribution = ChainContribution.builder().build();
final String unexpectedResultLink = "resultLink";
final String unexpectedChainCallbackData = "chainCallbackData";

Expand All @@ -1426,7 +1426,7 @@ void computeUpdateReplicateStatusArgsContributed() {

when(iexecHubService.getWorkerWeight(WALLET_WORKER_1)).thenReturn(expectedWorkerWeight);
when(iexecHubService.getChainContribution(CHAIN_TASK_ID, WALLET_WORKER_1))
.thenReturn(Optional.of(new ChainContribution()));
.thenReturn(Optional.of(ChainContribution.builder().build()));

assertThat(replicatesService.computeUpdateReplicateStatusArgs(CHAIN_TASK_ID, WALLET_WORKER_1, statusUpdate))
.isEqualTo(UpdateReplicateStatusArgs.builder()
Expand All @@ -1438,7 +1438,7 @@ void computeUpdateReplicateStatusArgsContributed() {
@Test
void computeUpdateReplicateStatusArgsResultUploaded() {
final int unexpectedWorkerWeight = 1;
final ChainContribution unexpectedChainContribution = new ChainContribution();
final ChainContribution unexpectedChainContribution = ChainContribution.builder().build();
final String expectedResultLink = "resultLink";
final String expectedChainCallbackData = "chainCallbackData";
final TaskDescription expectedTaskDescription = TaskDescription.builder().build();
Expand Down Expand Up @@ -1472,7 +1472,7 @@ void computeUpdateReplicateStatusArgsResultUploaded() {
@Test
void computeUpdateReplicateStatusArgsResultUploadFailed() {
final int unexpectedWorkerWeight = 1;
final ChainContribution unexpectedChainContribution = new ChainContribution();
final ChainContribution unexpectedChainContribution = ChainContribution.builder().build();
final String unexpectedResultLink = "resultLink";
final String unexpectedChainCallbackData = "chainCallbackData";
final TaskDescription expectedTaskDescription = TaskDescription.builder().build();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ void shouldNotUpgrade2ReopenedSinceCurrentStatusWrong() {
when(iexecHubService.canReopen(task.getChainTaskId())).thenReturn(true);
when(iexecHubService.hasEnoughGas()).thenReturn(true);
when(taskService.updateTask(task)).thenReturn(Optional.of(task));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(new ChainReceipt()));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(ChainReceipt.builder().build()));

taskUpdateManager.consensusReached2Reopening(task);

Expand All @@ -136,7 +136,7 @@ void shouldNotUpgrade2ReopenedSinceNotAfterRevealDeadline() {
when(iexecHubService.canReopen(task.getChainTaskId())).thenReturn(true);
when(iexecHubService.hasEnoughGas()).thenReturn(true);
when(taskService.updateTask(task)).thenReturn(Optional.of(task));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(new ChainReceipt()));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(ChainReceipt.builder().build()));

taskUpdateManager.consensusReached2Reopening(task);

Expand All @@ -153,7 +153,7 @@ void shouldNotUpgrade2ReopenedSinceNotWeHaveSomeRevealed() {
when(iexecHubService.canReopen(task.getChainTaskId())).thenReturn(true);
when(iexecHubService.hasEnoughGas()).thenReturn(true);
when(taskService.updateTask(task)).thenReturn(Optional.of(task));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(new ChainReceipt()));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(ChainReceipt.builder().build()));

taskUpdateManager.consensusReached2Reopening(task);

Expand All @@ -170,7 +170,7 @@ void shouldNotUpgrade2ReopenedSinceCantReopenOnChain() {
when(iexecHubService.canReopen(task.getChainTaskId())).thenReturn(false);
when(iexecHubService.hasEnoughGas()).thenReturn(true);
when(taskService.updateTask(task)).thenReturn(Optional.of(task));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(new ChainReceipt()));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(ChainReceipt.builder().build()));

taskUpdateManager.consensusReached2Reopening(task);

Expand All @@ -187,7 +187,7 @@ void shouldNotUpgrade2ReopenedSinceNotEnoughtGas() {
when(iexecHubService.canReopen(task.getChainTaskId())).thenReturn(true);
when(iexecHubService.hasEnoughGas()).thenReturn(false);
when(taskService.updateTask(task)).thenReturn(Optional.of(task));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(new ChainReceipt()));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(ChainReceipt.builder().build()));

taskUpdateManager.consensusReached2Reopening(task);

Expand Down Expand Up @@ -224,7 +224,7 @@ void shouldUpgrade2Reopened() {
when(iexecHubService.canReopen(task.getChainTaskId())).thenReturn(true);
when(iexecHubService.hasEnoughGas()).thenReturn(true);
when(taskService.updateTask(task)).thenReturn(Optional.of(task));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(new ChainReceipt()));
when(iexecHubService.reOpen(task.getChainTaskId())).thenReturn(Optional.of(ChainReceipt.builder().build()));
when(iexecHubService.getChainTask(CHAIN_TASK_ID)).thenReturn(Optional.of(ChainTask.builder()
.status(ChainTaskStatus.ACTIVE)
.build()));
Expand Down