Skip to content

Commit

Permalink
Update mock code for exception test
Browse files Browse the repository at this point in the history
  • Loading branch information
abhishekmjain committed Sep 5, 2024
1 parent f3f61d6 commit 39b48cb
Showing 1 changed file with 6 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,6 @@ protected void submitJob(List<WorkUnit> workUnits)
public void setUp() throws Exception {
mockServiceStubs = mock(WorkflowServiceStubs.class);
mockClient = mock(WorkflowClient.class);
mockStub = mock(WorkflowStub.class);
mockExecutionInfo = mock(WorkflowExecutionInfo.class);
DescribeWorkflowExecutionResponse mockResponse = mock(DescribeWorkflowExecutionResponse.class);
WorkflowServiceGrpc.WorkflowServiceBlockingStub mockBlockingStub = mock(WorkflowServiceGrpc.WorkflowServiceBlockingStub.class);
Expand All @@ -95,8 +94,6 @@ public void setUp() throws Exception {
.thenReturn(mockServiceStubs);
mockWorkflowClientFactory.when(() -> TemporalWorkflowClientFactory.createClientInstance(Mockito.any(), Mockito.anyString()))
.thenReturn(mockClient);
when(mockClient.newUntypedWorkflowStub(Mockito.anyString())).thenReturn(mockStub);
when(mockStub.getExecution()).thenReturn(WorkflowExecution.getDefaultInstance());

jobProperties = new Properties();
jobProperties.setProperty(ConfigurationKeys.FS_URI_KEY, "file:///");
Expand All @@ -107,6 +104,10 @@ public void setUp() throws Exception {

@BeforeMethod
public void methodSetUp() throws Exception {
mockStub = mock(WorkflowStub.class);
when(mockClient.newUntypedWorkflowStub(Mockito.anyString())).thenReturn(mockStub);
when(mockStub.getExecution()).thenReturn(WorkflowExecution.getDefaultInstance());

File tmpDir = Files.createTempDir();
String basePath = tmpDir.getAbsolutePath();
Path appWorkDir = new Path(basePath, "testAppWorkDir");
Expand Down Expand Up @@ -178,5 +179,7 @@ public void testCancelWorkflowFetchStatusThrowsException() throws Exception {
jobLauncher.executeCancellation();

verify(mockStub, times(1)).cancel();

Mockito.reset(mockExecutionInfo);
}
}

0 comments on commit 39b48cb

Please sign in to comment.