I am using Google Workflow from Google Cloud. I need to trigger the execution of a given Google Workflow from my java microservice.
My app is a Spring-boot application but I don't know if it matters.
The way I trigger the workflow is the following, based on the google documentation: https://cloud.google.com/workflows/docs/execute-workflow-client-libraries
try (ExecutionsClient executionsClient = ExecutionsClient.create()) {
WorkflowName workflow = WorkflowName.of(workflowProperties.getProjectId(), workflowProperties.getLocation(), workflowProperties.getName());
Execution arguments = Execution.newBuilder().setArgument(String.format("{ \"executionId\": \"%s\" }", executionId)).build();
CreateExecutionRequest request =
CreateExecutionRequest.newBuilder()
.setParent(workflow.toString())
.setExecution(arguments)
.build();
Execution response = executionsClient.createExecution(request);
if (!response.hasError()) {
... LOG everything is fine
} else {
... LOG the error
}
} catch (Exception e) {
... LOG / handle exception
}
In my unit/mockito test I get a 404 error because the test cannot reach google. I need to mock the actual call to Google, and to do this I probably need to mock ExecutionsClient.create().
This is a static call and I don't want to use powerMockito in my test to mock static stuff. Is there any other option?