Skip to content

Commit 7da47be

Browse files
committed
add test
1 parent 7b4f18a commit 7da47be

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package com.databricks.sdk.service.apps;
2+
3+
import com.databricks.sdk.core.ApiClient;
4+
import static org.mockito.ArgumentMatchers.*;
5+
import com.databricks.sdk.core.http.Request;
6+
import org.junit.jupiter.api.Test;
7+
import org.mockito.Mockito;
8+
9+
import java.io.IOException;
10+
11+
import static org.mockito.ArgumentMatchers.*;
12+
import static org.mockito.Mockito.verify;
13+
import static org.mockito.Mockito.when;
14+
15+
public class AppsImplTest {
16+
@Test
17+
public void testCreateAppIncludesNoComputeParameter() throws IOException {
18+
ApiClient apiClient = Mockito.mock(ApiClient.class);
19+
String expectedPath = "/api/2.0/apps";
20+
when(apiClient.execute(any(), any())).thenReturn(null);
21+
when(apiClient.serialize(any())).thenReturn("");
22+
23+
AppsService apps = new AppsImpl(apiClient);
24+
apps.create(new CreateAppRequest().setNoCompute(true));
25+
26+
verify(apiClient)
27+
.execute(
28+
argThat(
29+
(Request req) -> {
30+
if (!req.getMethod().equals("POST")) {
31+
return false;
32+
}
33+
if (!req.getUrl().equals(expectedPath)) {
34+
return false;
35+
}
36+
if (!req.getQuery().containsKey("no_compute")) {
37+
return false;
38+
}
39+
if (!req.getQuery().get("no_compute").get(0).equals("true")) {
40+
return false;
41+
}
42+
return true;
43+
}),
44+
eq(App.class));
45+
}
46+
}

0 commit comments

Comments
 (0)