1
+ /*
2
+ * Copyright 2021 Google Inc.
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
+
1
17
package com .example .workflows ;
2
18
3
- import com .google .api .gax .longrunning .OperationFuture ;
4
- import com .google .cloud .workflows .v1 .OperationMetadata ;
19
+ import static com .example .workflows .WorkflowsQuickstart .workflowsQuickstart ;
20
+ import static org .junit .Assert .assertNotEquals ;
21
+ import static org .junit .Assert .assertNotNull ;
22
+
5
23
import com .google .cloud .workflows .v1 .Workflow ;
24
+ import com .google .cloud .workflows .v1 .WorkflowName ;
6
25
import com .google .cloud .workflows .v1 .WorkflowsClient ;
26
+ import java .io .IOException ;
7
27
import org .junit .BeforeClass ;
8
28
import org .junit .Test ;
9
29
10
- import com .google .cloud .workflows .v1 .WorkflowName ;
11
-
12
- import java .io .IOException ;
13
-
14
- import static com .example .workflows .WorkflowsQuickstart .workflowsQuickstart ;
15
- import static org .junit .Assert .*;
16
-
17
30
public class WorkflowsQuickstartTest {
18
31
19
32
private static String projectId ;
@@ -29,7 +42,8 @@ public static void beforeClass() {
29
42
final String ENV_GOOGLE_CLOUD_PROJECT = "GOOGLE_CLOUD_PROJECT" ;
30
43
projectId = System .getenv (ENV_GOOGLE_CLOUD_PROJECT );
31
44
assertNotNull (
32
- String .format ("Environment variable '%s' is required to perform these tests." , ENV_GOOGLE_CLOUD_PROJECT ),
45
+ String .format ("Environment variable '%s' is required to perform these tests." ,
46
+ ENV_GOOGLE_CLOUD_PROJECT ),
33
47
projectId );
34
48
}
35
49
@@ -48,7 +62,8 @@ public void testQuickstart() throws IOException, InterruptedException {
48
62
assertNotEquals ("Result should not be empty" , res , "" );
49
63
}
50
64
51
- private boolean deployWorkflow (String projectId , String location , String workflowId ) throws IOException , InterruptedException {
65
+ private boolean deployWorkflow (String projectId , String location , String workflowId )
66
+ throws IOException , InterruptedException {
52
67
// Create a new workflow if it doesn't exist
53
68
if (!workflowExists (projectId , location , workflowId )) {
54
69
System .out .println ("START DEPLOY" );
@@ -73,7 +88,8 @@ private boolean deployWorkflow(String projectId, String location, String workflo
73
88
.setWorkflow (workflowId )
74
89
.build ());
75
90
Thread .sleep (2_000 );
76
- } while (deployedWorkflow == null || deployedWorkflow .getState ().equals (Workflow .State .ACTIVE ));
91
+ } while (deployedWorkflow == null
92
+ || deployedWorkflow .getState ().equals (Workflow .State .ACTIVE ));
77
93
78
94
// Return true if the workflow is now active
79
95
return deployedWorkflow .getState () != Workflow .State .ACTIVE ;
@@ -83,6 +99,7 @@ private boolean deployWorkflow(String projectId, String location, String workflo
83
99
84
100
/**
85
101
* Returns true if the workflow exists.
102
+ *
86
103
* @return {boolean} True if the workflow exists already.
87
104
*/
88
105
private boolean workflowExists (String projectId , String location , String workflow ) {
0 commit comments