Skip to content

Commit 22e2561

Browse files
authored
[Internal] Test that Jobs API endpoints are pinned to 2.1 (#319)
## Changes <!-- Summary of your changes that are easy to understand --> Adds regression tests to ensure required Jobs endpoints say pinned to API 2.1 ## Tests <!-- How is this tested? --> Unit tests.
1 parent 837415d commit 22e2561

File tree

1 file changed

+89
-0
lines changed

1 file changed

+89
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
package com.databricks.sdk.service.jobs;
2+
3+
import static org.mockito.ArgumentMatchers.*;
4+
import static org.mockito.Mockito.verify;
5+
import static org.mockito.Mockito.when;
6+
7+
import com.databricks.sdk.core.ApiClient;
8+
import org.junit.jupiter.api.Test;
9+
import org.mockito.Mockito;
10+
11+
public class JobsImplTest {
12+
13+
/*
14+
* API 2.1 pinned endpoints check
15+
* See: https://databricks.atlassian.net/browse/JOBS-19304
16+
*/
17+
18+
@Test
19+
public void testJobsCreateUsesApi2_1() {
20+
ApiClient apiClient = Mockito.mock(ApiClient.class);
21+
String expectedPath = "/api/2.1/jobs/create";
22+
when(apiClient.POST(eq(expectedPath), any(), any(), any())).thenReturn(null);
23+
24+
JobsService jobs = new JobsImpl(apiClient);
25+
jobs.create(new CreateJob());
26+
27+
verify(apiClient).POST(eq(expectedPath), any(), any(), any());
28+
}
29+
30+
@Test
31+
public void testJobsGetUsesApi2_1() {
32+
ApiClient apiClient = Mockito.mock(ApiClient.class);
33+
String expectedPath = "/api/2.1/jobs/get";
34+
when(apiClient.GET(eq(expectedPath), any(), any(), any())).thenReturn(null);
35+
36+
JobsService jobs = new JobsImpl(apiClient);
37+
jobs.get(new GetJobRequest());
38+
39+
verify(apiClient).GET(eq(expectedPath), any(), any(), any());
40+
}
41+
42+
@Test
43+
public void testJobsListUsesApi2_1() {
44+
ApiClient apiClient = Mockito.mock(ApiClient.class);
45+
String expectedPath = "/api/2.1/jobs/list";
46+
when(apiClient.GET(eq(expectedPath), any(), any(), any())).thenReturn(null);
47+
48+
JobsService jobs = new JobsImpl(apiClient);
49+
jobs.list(new ListJobsRequest());
50+
51+
verify(apiClient).GET(eq(expectedPath), any(), any(), any());
52+
}
53+
54+
@Test
55+
public void testJobsUpdateUsesApi2_1() {
56+
ApiClient apiClient = Mockito.mock(ApiClient.class);
57+
String expectedPath = "/api/2.1/jobs/update";
58+
when(apiClient.POST(eq(expectedPath), any(), any(), any())).thenReturn(null);
59+
60+
JobsService jobs = new JobsImpl(apiClient);
61+
jobs.update(new UpdateJob());
62+
63+
verify(apiClient).POST(eq(expectedPath), any(), any(), any());
64+
}
65+
66+
@Test
67+
public void testJobsResetUsesApi2_1() {
68+
ApiClient apiClient = Mockito.mock(ApiClient.class);
69+
String expectedPath = "/api/2.1/jobs/reset";
70+
when(apiClient.POST(eq(expectedPath), any(), any(), any())).thenReturn(null);
71+
72+
JobsService jobs = new JobsImpl(apiClient);
73+
jobs.reset(new ResetJob());
74+
75+
verify(apiClient).POST(eq(expectedPath), any(), any(), any());
76+
}
77+
78+
@Test
79+
public void testJobsListRunsUsesApi2_1() {
80+
ApiClient apiClient = Mockito.mock(ApiClient.class);
81+
String expectedPath = "/api/2.1/jobs/runs/list";
82+
when(apiClient.GET(eq(expectedPath), any(), any(), any())).thenReturn(null);
83+
84+
JobsService jobs = new JobsImpl(apiClient);
85+
jobs.listRuns(new ListRunsRequest());
86+
87+
verify(apiClient).GET(eq(expectedPath), any(), any(), any());
88+
}
89+
}

0 commit comments

Comments
 (0)