/** * Adds a member, which is a name-value pair, to self. The name must be a String, but the value * can be an arbitrary JsonElement, thereby allowing you to build a full tree of JsonElements * rooted at this node. * * @param property name of the member. * @param value the member object. */ public void add(String property, JsonElement value) { if (value == null) { value = JsonNull.INSTANCE; } members.put(property, value); }
/** * Adds a member, which is a name-value pair, to self. The name must be a String, but the value * can be an arbitrary JsonElement, thereby allowing you to build a full tree of JsonElements * rooted at this node. * * @param property name of the member. * @param value the member object. */ public void add(String property, JsonElement value) { if (value == null) { value = JsonNull.INSTANCE; } members.put(property, value); }
/** * Adds a member, which is a name-value pair, to self. The name must be a String, but the value * can be an arbitrary JsonElement, thereby allowing you to build a full tree of JsonElements * rooted at this node. * * @param property name of the member. * @param value the member object. */ public void add(String property, JsonElement value) { if (value == null) { value = JsonNull.INSTANCE; } members.put(property, value); }
/** * Adds a member, which is a name-value pair, to self. The name must be a String, but the value * can be an arbitrary JsonElement, thereby allowing you to build a full tree of JsonElements * rooted at this node. * * @param property name of the member. * @param value the member object. */ public void add(String property, JsonElement value) { if (value == null) { value = JsonNull.INSTANCE; } members.put(property, value); }
/** * Adds a member, which is a name-value pair, to self. The name must be a String, but the value * can be an arbitrary JsonElement, thereby allowing you to build a full tree of JsonElements * rooted at this node. * * @param property name of the member. * @param value the member object. */ public void add(String property, JsonElement value) { if (value == null) { value = JsonNull.INSTANCE; } members.put(property, value); }
/** * Adds a member, which is a name-value pair, to self. The name must be a String, but the value * can be an arbitrary JsonElement, thereby allowing you to build a full tree of JsonElements * rooted at this node. * * @param property name of the member. * @param value the member object. */ public void add(String property, JsonElement value) { if (value == null) { value = JsonNull.INSTANCE; } members.put(property, value); }
value.put("id", item.getKey());
final String randomValue = TestUtilities.randomString(); final LinkedTreeMap settings = new LinkedTreeMap(); settings.put(key, randomValue); final HookSettings updateHook = HookSettings.of(settings); final HookSettings hookSettings = api().update(projectKey, settings.put(key, randomValueAgain); final HookSettings hookSettingsAgain = HookSettings.of(settings); final HookSettings hookSettingsUpdated = api().update(projectKey,
public void testUpdateHookSettings() throws Exception { final MockWebServer server = mockWebServer(); server.enqueue(new MockResponse().setBody(payloadFromResource("/hook-settings.json")).setResponseCode(200)); final BitbucketApi baseApi = api(server.getUrl("/")); final HookApi api = baseApi.hookApi(); try { final LinkedTreeMap settings = new LinkedTreeMap(); settings.put(testKey, testValue); final HookSettings updateHook = HookSettings.of(settings); final String hookKey = qwertyKeyword; final HookSettings hookSettings = api.update(projectKey, repoKey, hookKey, updateHook); assertThat(hookSettings).isNotNull(); assertThat(hookSettings.settings().getAsJsonObject().entrySet()).isNotEmpty(); assertThat(hookSettings.errors()).isEmpty(); final String possibleValue = hookSettings .settings() .getAsJsonObject() .get(testKey) .getAsString(); assertThat(possibleValue).isEqualTo(testValue); assertSent(server, putMethod, restApiPath + BitbucketApiMetadata.API_VERSION + projectsPath + projectKey + reposPath + repoKey + hooksPath + "/" + hookKey + settingsEndpoint); } finally { baseApi.close(); server.shutdown(); } }
public void testUpdateHookSettingsNonExistent() throws Exception { final MockWebServer server = mockWebServer(); server.enqueue(new MockResponse().setResponseCode(204)); final BitbucketApi baseApi = api(server.getUrl("/")); final HookApi api = baseApi.hookApi(); try { final LinkedTreeMap settings = new LinkedTreeMap(); settings.put(testKey, testValue); final HookSettings updateHook = HookSettings.of(settings); final String hookKey = TestUtilities.randomStringLettersOnly(); final HookSettings hookSettings = api.update(projectKey, repoKey, hookKey, updateHook); assertThat(hookSettings).isNotNull(); assertThat(hookSettings.settings().getAsJsonObject().entrySet()).isEmpty(); assertThat(hookSettings.errors()).isEmpty(); assertSent(server, putMethod, restApiPath + BitbucketApiMetadata.API_VERSION + projectsPath + projectKey + reposPath + repoKey + hooksPath + "/" + hookKey + settingsEndpoint); } finally { baseApi.close(); server.shutdown(); } } }