Skip to content

Commit a852ba3

Browse files
Added Extra Asserts To Verify ID lengths
Created checks to monitor ID lengths as a courtesy
1 parent 8371998 commit a852ba3

File tree

5 files changed

+18
-2
lines changed

5 files changed

+18
-2
lines changed

src/test/java/com/bandwidth/MessagingApiTests.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,9 @@ public void testCreateMessage() throws Exception {
4949
ApiResponse<BandwidthMessage> apiResponse = controller.createMessage(ACCOUNT_ID, body);
5050
assertEquals("Response Code is not 202", 202, apiResponse.getStatusCode());
5151
BandwidthMessage response = apiResponse.getResult();
52+
assertNotNull("Message ID is null", response.getId());
53+
assertFalse("Message ID is empty", response.getId().isEmpty());
54+
assertEquals("Message ID is not 29 characters", 29, response.getId().length());
5255
assertEquals("Application ID not equal", MESSAGING_APPLICATION_ID, response.getApplicationId());
5356
assertEquals("To phone number not equal", USER_NUMBER, response.getTo().get(0));
5457
assertEquals("From phone number not equal", BW_NUMBER, response.getFrom());

src/test/java/com/bandwidth/MfaApiTests.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public void testMfaMessaging() throws Exception {
4444
TwoFactorMessagingResponse response = apiResponse.getResult();
4545
assertNotNull("MessageID is null", response.getMessageId());
4646
assertFalse("MessageID is empty", response.getMessageId().isEmpty());
47+
assertEquals("MessageID is not 29 characters", 29, response.getMessageId().length());
4748
}
4849

4950
@Test
@@ -63,6 +64,7 @@ public void testMfaVoice() throws Exception {
6364
TwoFactorVoiceResponse response = apiResponse.getResult();
6465
assertNotNull("CallID is null", response.getCallId());
6566
assertFalse("CallID is empty", response.getCallId().isEmpty());
67+
assertEquals("CallID is not 47 characters", 47, response.getCallId().length());
6668
}
6769

6870
@Test

src/test/java/com/bandwidth/TnLookupApiTests.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ public void testPhoneNumberLookup() throws Exception {
3939
OrderResponse orderResponse = orderApiResponse.getResult();
4040
assertNotNull("RequestID is null", orderResponse.getRequestId());
4141
assertFalse("RequestID is empty", orderResponse.getRequestId().isEmpty());
42+
assertEquals("Request ID is not 36 characters", 36, orderResponse.getRequestId().length());
4243
assertTrue(
4344
"Status is not a valid value",
4445
orderResponse.getStatus().equals("COMPLETE") ||
@@ -52,6 +53,7 @@ public void testPhoneNumberLookup() throws Exception {
5253
OrderStatus statusResponse = statusApiResponse.getResult();
5354
assertNotNull("RequestID is null", statusResponse.getRequestId());
5455
assertFalse("RequestId is empty", statusResponse.getRequestId().isEmpty());
56+
assertEquals("Request ID is not 36 characters", 36, statusResponse.getRequestId().length());
5557
assertTrue(
5658
"Status is not a valid value",
5759
statusResponse.getStatus().equals("COMPLETE") ||
@@ -60,4 +62,4 @@ public void testPhoneNumberLookup() throws Exception {
6062
statusResponse.getStatus().equals("IN_PROGRESS")
6163
);
6264
}
63-
}
65+
}

src/test/java/com/bandwidth/VoiceApiTests.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ public void testCreateCallAndGetCallState() throws Exception {
4141
assertEquals("Response Code is not 201", 201, createCallApiResponse.getStatusCode());
4242

4343
CreateCallResponse createCallResponse = createCallApiResponse.getResult();
44+
assertNotNull("Call ID is null", createCallResponse.getCallId());
45+
assertFalse("Call ID is empty", createCallResponse.getCallId().isEmpty());
46+
assertEquals("Call ID is not 47 characters", 47, createCallResponse.getCallId().length());
4447
assertEquals("Application ID for create call not equal", VOICE_APPLICATION_ID, createCallResponse.getApplicationId());
4548
assertEquals("To phone number for create call not equal", USER_NUMBER, createCallResponse.getTo());
4649
assertEquals("From phone number for create call not equal", BW_NUMBER, createCallResponse.getFrom());
@@ -84,6 +87,9 @@ public void testCreateCallWithAmdAndGetCallState() throws Exception {
8487
assertEquals("Response Code is not 201", 201, createCallApiResponse.getStatusCode());
8588

8689
CreateCallResponse createCallResponse = createCallApiResponse.getResult();
90+
assertNotNull("Call ID is null", createCallResponse.getCallId());
91+
assertFalse("Call ID is empty", createCallResponse.getCallId().isEmpty());
92+
assertEquals("Call ID is not 36 characters", 36, createCallResponse.getCallId().length());
8793
assertEquals("Application ID for create call not equal", VOICE_APPLICATION_ID, createCallResponse.getApplicationId());
8894
assertEquals("To phone number for create call not equal", USER_NUMBER, createCallResponse.getTo());
8995
assertEquals("From phone number for create call not equal", BW_NUMBER, createCallResponse.getFrom());

src/test/java/com/bandwidth/WebRtcApiTests.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ public void initTest(){
2929
controller = client.getWebRtcClient().getAPIController();
3030
}
3131

32-
// Break this into multiple tests when we have a proper test environment and there aren't dependency issues
32+
// Break this into multiple tests when our test environment is more robust and there aren't dependency issues
3333
@Test
3434
public void testWebRtcParticipantSessionManagement() throws Exception {
3535
// Create a participant
@@ -48,6 +48,7 @@ public void testWebRtcParticipantSessionManagement() throws Exception {
4848
assertNotNull("Participant is null", participantCreationResponse.getParticipant());
4949
assertNotNull("Participant ID is null", participantCreationResponse.getParticipant().getId());
5050
assertFalse("Participant ID is empty", participantCreationResponse.getParticipant().getId().isEmpty());
51+
assertEquals("Participant ID is not 36 characters", 36, participantCreationResponse.getParticipant().getId().length());
5152
assertEquals(
5253
"Publish Permissions do not match",
5354
participantCreationRequest.getPublishPermissions(),
@@ -75,6 +76,7 @@ public void testWebRtcParticipantSessionManagement() throws Exception {
7576
assertNotNull("Participant is null", participantFetchResponse);
7677
assertNotNull("Participant ID is null", participantFetchResponse.getId());
7778
assertFalse("Participant ID is empty", participantFetchResponse.getId().isEmpty());
79+
assertEquals("Participant ID is not 36 characters", participantFetchResponse.getId().length());
7880
assertEquals(
7981
"Publish Permissions do not match",
8082
participantCreationRequest.getPublishPermissions(),
@@ -102,6 +104,7 @@ public void testWebRtcParticipantSessionManagement() throws Exception {
102104
Session sessionCreationResponse = sessionCreationApiResponse.getResult();
103105
assertNotNull("Session ID is null", sessionCreationResponse.getId());
104106
assertFalse("Session ID is empty", sessionCreationResponse.getId().isEmpty());
107+
assertEquals("Session ID is not 36 characters", sessionCreationResponse.getId().length());
105108
assertEquals("Session Tags do not match", sessionCreationRequest.getTag(), sessionCreationResponse.getTag());
106109

107110
// Get a session

0 commit comments

Comments
 (0)