From 39b48cbf72d08821beb1814c68c5bb0ffb8eb9e9 Mon Sep 17 00:00:00 2001 From: Abhishek Jain Date: Thu, 5 Sep 2024 09:33:28 +0530 Subject: [PATCH] Update mock code for exception test --- .../joblauncher/GobblinTemporalJobLauncherTest.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/gobblin-temporal/src/test/java/org/apache/gobblin/temporal/joblauncher/GobblinTemporalJobLauncherTest.java b/gobblin-temporal/src/test/java/org/apache/gobblin/temporal/joblauncher/GobblinTemporalJobLauncherTest.java index 85bd5a2bb03..b45dafc6054 100644 --- a/gobblin-temporal/src/test/java/org/apache/gobblin/temporal/joblauncher/GobblinTemporalJobLauncherTest.java +++ b/gobblin-temporal/src/test/java/org/apache/gobblin/temporal/joblauncher/GobblinTemporalJobLauncherTest.java @@ -82,7 +82,6 @@ protected void submitJob(List 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); @@ -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:///"); @@ -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"); @@ -178,5 +179,7 @@ public void testCancelWorkflowFetchStatusThrowsException() throws Exception { jobLauncher.executeCancellation(); verify(mockStub, times(1)).cancel(); + + Mockito.reset(mockExecutionInfo); } } \ No newline at end of file