Skip to content

Commit

Permalink
feat: Add varargs removeCapabilities method
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Nov 14, 2024
1 parent e10c153 commit 9193f47
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 4 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,11 @@
All notable changes to this project will be documented in this file.
This project adheres to [Semantic Versioning](http://semver.org/).

# [8.14.0] - 2024-11-??
# [8.14.0] - 2024-11-14
- Close HTTP responses to prevent resource leaks
- Added `RedactResponseException` and deprecated `VonageBadRequestException`
- Added `maxBitrate` to `com.vonage.client.video.Archive`
- Added varargs `removeCapabilities` method to `Application.Builder`

# [8.13.0] - 2024-10-28
- Added support for Verify custom templates
Expand Down
15 changes: 15 additions & 0 deletions src/main/java/com/vonage/client/application/Application.java
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,21 @@ public Builder addCapability(Capability capability) {
return this;
}

/**
* Removes the specified capabilities from the application.
*
* @param types The type of capabilities to remove as an array / varargs.
*
* @return This builder.
* @since 8.14.0
*/
public Builder removeCapabilities(Capability.Type... types) {
for (Capability.Type type : types) {
removeCapability(type);
}
return this;
}

/**
* Remove a capability from the application.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,7 @@ public void testRemoveMultipleCapabilities() {
Application application = Application.builder()
.addCapability(Voice.builder().build())
.addCapability(Rtc.builder().build())
.removeCapability(Capability.Type.VOICE)
.removeCapability(Capability.Type.RTC)
.removeCapabilities(Capability.Type.VOICE, Capability.Type.RTC)
.build();

assertEquals(json, application.toJson());
Expand Down
11 changes: 10 additions & 1 deletion src/test/java/com/vonage/client/redact/RedactClientTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,15 @@
import com.vonage.client.AbstractClientTest;
import com.vonage.client.DynamicEndpointTestSpec;
import com.vonage.client.RestEndpoint;
import com.vonage.client.TestUtils;
import com.vonage.client.auth.ApiKeyHeaderAuthMethod;
import com.vonage.client.auth.AuthMethod;
import com.vonage.client.common.HttpMethod;
import static org.junit.jupiter.api.Assertions.assertThrows;
import org.junit.jupiter.api.*;
import java.util.Collection;
import java.util.List;
import java.util.UUID;

public class RedactClientTest extends AbstractClientTest<RedactClient> {

Expand All @@ -43,7 +45,14 @@ public void testSuccessfulResponse() throws Exception {
}

@Test
public void testInvalidRedactRequests() {
public void testRedactResponseException() throws Exception {
assert401ApiResponseException(RedactResponseException.class, () ->
client.redactTransaction(UUID.randomUUID().toString(), RedactRequest.Product.MESSAGES)
);
}

@Test
public void testInvalidRedactRequests() throws Exception {
assertThrows(IllegalArgumentException.class, () -> client.redactTransaction(
"test-id", RedactRequest.Product.SMS
));
Expand Down

0 comments on commit 9193f47

Please sign in to comment.