Skip to content

Commit b645798

Browse files
author
Jérémy James Toussaint
committed
Added tests for next actions of replicate workflow
1 parent c78ea07 commit b645798

File tree

1 file changed

+93
-0
lines changed

1 file changed

+93
-0
lines changed
Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,93 @@
1+
/*
2+
* Copyright 2020 IEXEC BLOCKCHAIN TECH
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package com.iexec.core.workflow;
18+
19+
import com.iexec.common.notification.TaskNotificationType;
20+
import com.iexec.common.replicate.ReplicateStatus;
21+
import com.iexec.common.replicate.ReplicateStatusCause;
22+
import org.junit.Before;
23+
import org.junit.Test;
24+
import org.mockito.MockitoAnnotations;
25+
26+
import static org.assertj.core.api.Assertions.assertThat;
27+
28+
public class ReplicateWorkflowTests {
29+
30+
private ReplicateWorkflow replicateWorkflow;
31+
32+
@Before
33+
public void setup() {
34+
replicateWorkflow = ReplicateWorkflow.getInstance();
35+
}
36+
37+
@Test
38+
public void shouldGetNextActionOnAppDownloadFailed(){
39+
assertThat(replicateWorkflow
40+
.getNextAction(ReplicateStatus.APP_DOWNLOAD_FAILED,
41+
null))
42+
.isEqualTo(TaskNotificationType.PLEASE_ABORT);
43+
}
44+
45+
@Test
46+
public void shouldGetNextActionOnAppDownloadFailedWithPostComputeFailed(){
47+
assertThat(replicateWorkflow
48+
.getNextAction(ReplicateStatus.APP_DOWNLOAD_FAILED,
49+
ReplicateStatusCause.POST_COMPUTE_FAILED))
50+
.isEqualTo(TaskNotificationType.PLEASE_ABORT);
51+
}
52+
53+
@Test
54+
public void shouldGetNextActionOnAppDownloadFailedWithAppImageDownloadFailed(){
55+
assertThat(replicateWorkflow
56+
.getNextAction(ReplicateStatus.APP_DOWNLOAD_FAILED,
57+
ReplicateStatusCause.APP_IMAGE_DOWNLOAD_FAILED))
58+
.isEqualTo(TaskNotificationType.PLEASE_CONTRIBUTE);
59+
}
60+
61+
@Test
62+
public void shouldGetNextActionOnDataDownloadFailed(){
63+
assertThat(replicateWorkflow
64+
.getNextAction(ReplicateStatus.DATA_DOWNLOAD_FAILED,
65+
null))
66+
.isEqualTo(TaskNotificationType.PLEASE_ABORT);
67+
}
68+
69+
@Test
70+
public void shouldGetNextActionOnDataDownloadFailedWithPostComputeFailed(){
71+
assertThat(replicateWorkflow
72+
.getNextAction(ReplicateStatus.DATA_DOWNLOAD_FAILED,
73+
ReplicateStatusCause.POST_COMPUTE_FAILED))
74+
.isEqualTo(TaskNotificationType.PLEASE_ABORT);
75+
}
76+
77+
@Test
78+
public void shouldGetNextActionOnDataDownloadFailedWithDatasetDownloadFailed(){
79+
assertThat(replicateWorkflow
80+
.getNextAction(ReplicateStatus.DATA_DOWNLOAD_FAILED,
81+
ReplicateStatusCause.DATASET_FILE_DOWNLOAD_FAILED))
82+
.isEqualTo(TaskNotificationType.PLEASE_CONTRIBUTE);
83+
}
84+
85+
@Test
86+
public void shouldGetNextActionOnDataDownloadFailedWithInputFilesDownloadFailed(){
87+
assertThat(replicateWorkflow
88+
.getNextAction(ReplicateStatus.DATA_DOWNLOAD_FAILED,
89+
ReplicateStatusCause.INPUT_FILES_DOWNLOAD_FAILED))
90+
.isEqualTo(TaskNotificationType.PLEASE_CONTRIBUTE);
91+
}
92+
93+
}

0 commit comments

Comments
 (0)