Skip to content

Commit

Permalink
100% Application coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
SMadani committed Jan 15, 2025
1 parent 1e0c22a commit c60599f
Showing 1 changed file with 31 additions and 0 deletions.
31 changes: 31 additions & 0 deletions src/test/java/com/vonage/client/application/ApplicationTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,30 @@ public void testRemoveCapabilityThatDoesntExist() {
testJsonableBaseObject(application);
}

@Test
public void testRemoveCapabilityThatDoesExist() {
String json = "{\"capabilities\":{\"verify\":{},\"network_apis\":{}}}";
Application application = Application.builder()
.addCapability(NetworkApis.builder().build())
.addCapability(Messages.builder().build())
.addCapability(Verify.builder().build())
.removeCapability(Type.MESSAGES)
.build();

assertEquals(json, application.toJson());
testJsonableBaseObject(application);

json = "{\"capabilities\":{\"network_apis\":{}}}";
application = Application.builder()
.addCapability(NetworkApis.builder().build())
.addCapability(Verify.builder().build())
.removeCapability(Type.VERIFY)
.build();

assertEquals(json, application.toJson());
testJsonableBaseObject(application);
}

@Test
public void testRemoveNullCapability() {
assertThrows(NullPointerException.class, () -> Application.builder()
Expand All @@ -174,6 +198,13 @@ public void testRemoveLastRemainingCapability() {
testJsonableBaseObject(application);
}

@Test
public void testRemoveWebhookWhenThereAreNone() {
var voice = Voice.builder().removeWebhook(Webhook.Type.FALLBACK_ANSWER).build();
assertNotNull(voice);
assertNull(voice.getWebhooks());
}

@Test
public void testAddMessagesCapabilityWithInboundAndStatusWebhooks() {
String json = "{\"capabilities\":{\"messages\":{\"webhooks\":{\"inbound_url\":{\"address\":\"https://example.com/inbound\",\"http_method\":\"POST\"},\"status_url\":{\"address\":\"https://example.com/status\",\"http_method\":\"GET\"}}}}}";
Expand Down

0 comments on commit c60599f

Please sign in to comment.