Skip to content

Commit 6deec1a

Browse files
committed
[WIP] Test webooks
1 parent e2d407d commit 6deec1a

File tree

3 files changed

+28
-20
lines changed

3 files changed

+28
-20
lines changed

src/example/java/com/box/sdk/example/Main.java

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
11
package com.box.sdk.example;
22

33
import com.box.sdk.BoxAPIConnection;
4+
import com.box.sdk.BoxAPIException;
5+
import com.box.sdk.BoxFile;
46
import com.box.sdk.BoxFolder;
57
import com.box.sdk.BoxItem;
68
import com.box.sdk.BoxLogger;
@@ -18,12 +20,7 @@ public static void main(String[] args) {
1820
BoxLogger.defaultLogger().setLevelToWarning();
1921

2022
BoxAPIConnection api = new BoxAPIConnection(DEVELOPER_TOKEN);
21-
22-
BoxUser.Info userInfo = BoxUser.getCurrentUser(api).getInfo();
23-
System.out.format("Welcome, %s <%s>!\n\n", userInfo.getName(), userInfo.getLogin());
24-
2523
BoxFolder rootFolder = BoxFolder.getRootFolder(api);
26-
listFolder(rootFolder, 0);
2724
}
2825

2926
private static void listFolder(BoxFolder folder, int depth) {

src/intTest/java/com/box/sdk/BoxWebHookIT.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,17 @@ public void createWebHookSignRequestOnFolderSucceeds() throws IOException {
207207
}
208208
}
209209

210+
@Test
211+
public void listAllWebhooks() throws IOException {
212+
BoxAPIConnection api = jwtApiForServiceAccount();
213+
Iterable<BoxWebHook.Info> webhooks = BoxWebHook.all(api);
214+
for (BoxWebHook.Info info : webhooks) {
215+
System.out.println("WebHook ID: " + info.getID());
216+
}
217+
218+
throw new BoxAPIException("Just for test for test");
219+
}
220+
210221
private <T> Set<T> toSet(T[] values) {
211222
return new HashSet<>(Arrays.asList(values));
212223
}

src/test/java/com/box/sdk/BoxUserTest.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -243,11 +243,11 @@ public void testCreateManagedUserSucceedsWithFields() {
243243
String result = TestUtils.getFixture("BoxUser/CreateManagedUser201");
244244

245245
wireMockRule.stubFor(WireMock.post(WireMock.urlPathEqualTo(userURL))
246-
.withQueryParam("fields", WireMock.equalTo("name,login,timezone"))
247-
.willReturn(WireMock.okForContentType(APPLICATION_JSON, result)));
246+
.withQueryParam("fields", WireMock.equalTo("name,login,timezone"))
247+
.willReturn(WireMock.okForContentType(APPLICATION_JSON, result)));
248248

249249
BoxUser.Info createdUserInfo = BoxUser.createEnterpriseUser(
250-
this.api, userLogin, userName, "name", "login", "timezone"
250+
this.api, userLogin, userName, "name", "login", "timezone"
251251
);
252252

253253
assertEquals(userID, createdUserInfo.getID());
@@ -266,9 +266,9 @@ public void testCreateManagedUserDoesNotIncludeNotdefinedOptionalFields() {
266266
String result = TestUtils.getFixture("BoxUser/CreateManagedUser201");
267267

268268
JsonObject createBody = new JsonObject()
269-
.add("name", userName)
270-
.add("login", userLogin)
271-
.add("is_sync_enabled", isSyncEnabled);
269+
.add("name", userName)
270+
.add("login", userLogin)
271+
.add("is_sync_enabled", isSyncEnabled);
272272

273273
wireMockRule.stubFor(WireMock.post(WireMock.urlPathEqualTo(userURL))
274274
.withRequestBody(WireMock.equalToJson(createBody.toString()))
@@ -325,17 +325,17 @@ public void testUpdateUserInfoSucceedsWithFields() {
325325
final String userPhone = "650-123-4567";
326326

327327
JsonObject userObject = new JsonObject()
328-
.add("name", userName)
329-
.add("login", userLogin)
330-
.add("job_title", userJob)
331-
.add("phone", userPhone);
328+
.add("name", userName)
329+
.add("login", userLogin)
330+
.add("job_title", userJob)
331+
.add("phone", userPhone);
332332

333333
String result = TestUtils.getFixture("BoxUser/UpdateUserInfo200");
334334

335335
wireMockRule.stubFor(WireMock.put(WireMock.urlPathEqualTo(userURL))
336-
.withQueryParam("fields", WireMock.equalTo("name,login,job_title,phone"))
337-
.withRequestBody(WireMock.equalToJson(userObject.toString()))
338-
.willReturn(WireMock.okForContentType(APPLICATION_JSON, result)));
336+
.withQueryParam("fields", WireMock.equalTo("name,login,job_title,phone"))
337+
.withRequestBody(WireMock.equalToJson(userObject.toString()))
338+
.willReturn(WireMock.okForContentType(APPLICATION_JSON, result)));
339339

340340
BoxUser user = new BoxUser(this.api, userID);
341341
BoxUser.Info info = user.new Info();
@@ -358,8 +358,8 @@ public void testDeleteUserWithParamsSucceeds() {
358358
final String userURL = "/2.0/users/" + userID;
359359

360360
wireMockRule.stubFor(WireMock.delete(WireMock.urlPathEqualTo(userURL))
361-
.withQueryParam("force", new EqualToPattern("false"))
362-
.withQueryParam("notify", new EqualToPattern("false"))
361+
.withQueryParam("force", new EqualToPattern("false"))
362+
.withQueryParam("notify", new EqualToPattern("false"))
363363
.willReturn(WireMock.noContent()));
364364

365365
BoxUser user = new BoxUser(this.api, userID);

0 commit comments

Comments
 (0)