Skip to content

Commit f93fa18

Browse files
smoghe-bwclaude
andcommitted
Address PR review feedback: BXML verbs, unit tests, and smoke test fixes
- Add Connect and Endpoint BXML verbs with tests, registered in Bxml and Response - Create EndpointsApi unit/mock test following existing API test patterns - Add missing model unit tests: CreateWebRtcConnectionRequest, Device, DeviceStatusEnum, ErrorResponse, Page, SipConnectionMetadata, SipCredentials - Rename smoke test methods to operationId format (createEndpointTest, etc.) - Use builder-style field initialization instead of setters - Replace notNullValue()/hasProperty() assertions with direct field assertions - Simplify list assertions to check first element directly - Remove unnecessary filter-by-type test Generated from Claude9 with Claude Code Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 948ca2d commit f93fa18

14 files changed

Lines changed: 822 additions & 57 deletions

src/main/java/com/bandwidth/sdk/model/bxml/Bxml.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ public class Bxml {
3434
@XmlElements({
3535
@XmlElement(name = Bridge.TYPE_NAME, type = Bridge.class),
3636
@XmlElement(name = Conference.TYPE_NAME, type = Conference.class),
37+
@XmlElement(name = Connect.TYPE_NAME, type = Connect.class),
3738
@XmlElement(name = Forward.TYPE_NAME, type = Forward.class),
3839
@XmlElement(name = Gather.TYPE_NAME, type = Gather.class),
3940
@XmlElement(name = Hangup.TYPE_NAME, type = Hangup.class),
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
/**
2+
* The {@code <Connect>} verb is used to connect a call to a BRTC endpoint.
3+
*/
4+
5+
package com.bandwidth.sdk.model.bxml;
6+
7+
import static com.bandwidth.sdk.model.bxml.utils.BxmlConstants.DEFAULT_CALLBACK_METHOD;
8+
9+
import jakarta.xml.bind.annotation.XmlAccessType;
10+
import jakarta.xml.bind.annotation.XmlAccessorType;
11+
import jakarta.xml.bind.annotation.XmlAttribute;
12+
import jakarta.xml.bind.annotation.XmlElement;
13+
import jakarta.xml.bind.annotation.XmlElements;
14+
import jakarta.xml.bind.annotation.XmlType;
15+
import java.net.URI;
16+
import java.util.List;
17+
import lombok.AllArgsConstructor;
18+
import lombok.Builder;
19+
import lombok.Builder.Default;
20+
import lombok.EqualsAndHashCode;
21+
import lombok.Getter;
22+
import lombok.NoArgsConstructor;
23+
24+
@XmlAccessorType(XmlAccessType.FIELD)
25+
@XmlType(name = Connect.TYPE_NAME)
26+
@Builder
27+
@NoArgsConstructor
28+
@AllArgsConstructor
29+
@Getter
30+
@EqualsAndHashCode
31+
/**
32+
*
33+
* @param endpoints (list[Endpoint], optional): List of endpoints to connect. Defaults to [].
34+
* @param connectCallbackUrl (str, optional): URL to send the Connect event to. May be a relative URL. Defaults to None.
35+
* @param connectCallbackMethod (str, optional): The HTTP method to use for the request to connectCallbackUrl. GET or POST. Default value is POST. Defaults to None.
36+
* @param connectCallbackFallbackUrl (str, optional): A fallback url which, if provided, will be used to retry the Connect callback delivery in case connectCallbackUrl fails to respond. Defaults to None.
37+
* @param connectCallbackFallbackMethod (str, optional): The HTTP method to use for the request to connectCallbackFallbackUrl. GET or POST. Default value is POST. Defaults to None.
38+
* @param username (str, optional): The username to send in the HTTP request to connectCallbackUrl. Defaults to None.
39+
* @param password (str, optional): The password to send in the HTTP request to connectCallbackUrl. Defaults to None.
40+
* @param fallbackUsername (str, optional): The username to send in the HTTP request to connectCallbackFallbackUrl. Defaults to None.
41+
* @param fallbackPassword (str, optional): The password to send in the HTTP request to connectCallbackFallbackUrl. Defaults to None.
42+
* @param tag (str, optional): A custom string that will be sent with this and all future callbacks unless overwritten by a future tag attribute or cleared. May be cleared by setting tag="" Max length 256 characters. Defaults to None.
43+
*
44+
*/
45+
public class Connect implements Verb {
46+
47+
public static final String TYPE_NAME = "Connect";
48+
49+
@XmlElements({
50+
@XmlElement(name = Endpoint.TYPE_NAME, type = Endpoint.class)
51+
})
52+
protected List<Endpoint> endpoints;
53+
54+
@XmlAttribute
55+
protected URI connectCallbackUrl;
56+
57+
@XmlAttribute
58+
@Default
59+
protected String connectCallbackMethod = DEFAULT_CALLBACK_METHOD;
60+
61+
@XmlAttribute
62+
protected URI connectCallbackFallbackUrl;
63+
64+
@XmlAttribute
65+
@Default
66+
protected String connectCallbackFallbackMethod = DEFAULT_CALLBACK_METHOD;
67+
68+
@XmlAttribute
69+
protected String username;
70+
71+
@XmlAttribute
72+
protected String password;
73+
74+
@XmlAttribute
75+
protected String fallbackUsername;
76+
77+
@XmlAttribute
78+
protected String fallbackPassword;
79+
80+
@XmlAttribute
81+
protected String tag;
82+
83+
@Override
84+
public String getVerbName() {
85+
return TYPE_NAME;
86+
}
87+
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
/**
2+
* The {@code <Endpoint>} element is used within the {@code <Connect>} verb to define the endpoint to connect to.
3+
*/
4+
package com.bandwidth.sdk.model.bxml;
5+
6+
import jakarta.xml.bind.annotation.XmlAccessType;
7+
import jakarta.xml.bind.annotation.XmlAccessorType;
8+
import jakarta.xml.bind.annotation.XmlAttribute;
9+
import jakarta.xml.bind.annotation.XmlType;
10+
import jakarta.xml.bind.annotation.XmlValue;
11+
import jakarta.xml.bind.annotation.adapters.CollapsedStringAdapter;
12+
import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter;
13+
import lombok.AllArgsConstructor;
14+
import lombok.Builder;
15+
import lombok.EqualsAndHashCode;
16+
import lombok.Getter;
17+
import lombok.NoArgsConstructor;
18+
19+
@XmlAccessorType(XmlAccessType.FIELD)
20+
@XmlType(name = Endpoint.TYPE_NAME)
21+
@NoArgsConstructor
22+
@AllArgsConstructor
23+
@Builder
24+
@Getter
25+
@EqualsAndHashCode
26+
/**
27+
*
28+
* @param endpointId (str): The ID of the endpoint to connect to.
29+
* @param type (str, optional): The type of endpoint. Defaults to None.
30+
* @param tag (str, optional): A custom string. Defaults to None.
31+
*
32+
*/
33+
public class Endpoint {
34+
35+
public static final String TYPE_NAME = "Endpoint";
36+
37+
@XmlValue
38+
@XmlJavaTypeAdapter(CollapsedStringAdapter.class)
39+
protected String endpointId;
40+
41+
@XmlAttribute
42+
protected String type;
43+
44+
@XmlAttribute
45+
protected String tag;
46+
}

src/main/java/com/bandwidth/sdk/model/bxml/Response.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ public class Response {
3232
@XmlElements({
3333
@XmlElement(name = Bridge.TYPE_NAME, type = Bridge.class),
3434
@XmlElement(name = Conference.TYPE_NAME, type = Conference.class),
35+
@XmlElement(name = Connect.TYPE_NAME, type = Connect.class),
3536
@XmlElement(name = Forward.TYPE_NAME, type = Forward.class),
3637
@XmlElement(name = Gather.TYPE_NAME, type = Gather.class),
3738
@XmlElement(name = Hangup.TYPE_NAME, type = Hangup.class),

src/test/java/com/bandwidth/sdk/smoke/EndpointsApiTest.java

Lines changed: 35 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,13 @@
66
import com.bandwidth.sdk.ApiClient;
77
import com.bandwidth.sdk.model.CreateWebRtcConnectionRequest;
88
import com.bandwidth.sdk.model.CreateEndpointResponse;
9+
import com.bandwidth.sdk.model.CreateEndpointResponseData;
910
import com.bandwidth.sdk.model.EndpointResponse;
11+
import com.bandwidth.sdk.model.Endpoint;
1012
import com.bandwidth.sdk.model.Endpoints;
1113
import com.bandwidth.sdk.model.EndpointDirectionEnum;
1214
import com.bandwidth.sdk.model.EndpointTypeEnum;
15+
import com.bandwidth.sdk.model.EndpointStatusEnum;
1316
import com.bandwidth.sdk.model.ListEndpointsResponse;
1417
import org.junit.jupiter.api.MethodOrderer;
1518
import org.junit.jupiter.api.Order;
@@ -18,14 +21,13 @@
1821
import org.junit.jupiter.api.TestMethodOrder;
1922
import org.junit.jupiter.api.Assertions;
2023

24+
import java.time.OffsetDateTime;
2125
import java.util.List;
2226

2327
import static org.hamcrest.MatcherAssert.assertThat;
2428
import static org.hamcrest.CoreMatchers.instanceOf;
29+
import static org.hamcrest.CoreMatchers.equalTo;
2530
import static org.hamcrest.Matchers.is;
26-
import static org.hamcrest.Matchers.notNullValue;
27-
import static org.hamcrest.Matchers.hasSize;
28-
import static org.hamcrest.beans.HasPropertyWithValue.hasProperty;
2931

3032
import static com.bandwidth.sdk.utils.TestingEnvironmentVariables.*;
3133

@@ -40,88 +42,64 @@ public class EndpointsApiTest {
4042

4143
@Test
4244
@Order(1)
43-
public void shouldCreateNewEndpoint() throws ApiException {
44-
CreateWebRtcConnectionRequest endpointBody = new CreateWebRtcConnectionRequest();
45-
endpointBody.setType(EndpointTypeEnum.WEBRTC);
46-
endpointBody.setDirection(EndpointDirectionEnum.BIDIRECTIONAL);
45+
public void createEndpointTest() throws ApiException {
46+
CreateWebRtcConnectionRequest endpointBody = new CreateWebRtcConnectionRequest()
47+
.type(EndpointTypeEnum.WEBRTC)
48+
.direction(EndpointDirectionEnum.BIDIRECTIONAL);
4749

4850
ApiResponse<CreateEndpointResponse> response = api.createEndpointWithHttpInfo(BW_ACCOUNT_ID, endpointBody);
4951

5052
assertThat(response.getStatusCode(), is(201));
51-
assertThat(response.getData(), notNullValue());
52-
assertThat(response.getData().getData(), notNullValue());
53-
assertThat(response.getData().getData(), hasProperty("endpointId", is(instanceOf(String.class))));
54-
assertThat(response.getData().getData(), hasProperty("token", is(instanceOf(String.class))));
55-
assertThat(response.getData().getData(), hasProperty("type", is(EndpointTypeEnum.WEBRTC)));
56-
assertThat(response.getData().getData(), hasProperty("status", notNullValue()));
57-
assertThat(response.getData().getData(), hasProperty("creationTimestamp", notNullValue()));
58-
assertThat(response.getData().getData(), hasProperty("expirationTimestamp", notNullValue()));
53+
assertThat(response.getData(), instanceOf(CreateEndpointResponse.class));
54+
assertThat(response.getData().getData(), instanceOf(CreateEndpointResponseData.class));
55+
assertThat(response.getData().getData().getEndpointId(), instanceOf(String.class));
56+
assertThat(response.getData().getData().getToken(), instanceOf(String.class));
57+
assertThat(response.getData().getData().getType(), equalTo(EndpointTypeEnum.WEBRTC));
58+
assertThat(response.getData().getData().getStatus(), instanceOf(EndpointStatusEnum.class));
59+
assertThat(response.getData().getData().getCreationTimestamp(), instanceOf(OffsetDateTime.class));
60+
assertThat(response.getData().getData().getExpirationTimestamp(), instanceOf(OffsetDateTime.class));
5961
assertThat(response.getData().getErrors(), instanceOf(List.class));
60-
assertThat(response.getData().getErrors(), hasSize(0));
6162

6263
endpointId = response.getData().getData().getEndpointId();
6364
}
6465

6566
@Test
6667
@Order(2)
67-
public void shouldListEndpointsForAccount() throws ApiException {
68+
public void listEndpointsTest() throws ApiException {
6869
ApiResponse<ListEndpointsResponse> response = api.listEndpointsWithHttpInfo(BW_ACCOUNT_ID, null, null, null, null);
6970

7071
assertThat(response.getStatusCode(), is(200));
71-
assertThat(response.getData(), notNullValue());
72+
assertThat(response.getData(), instanceOf(ListEndpointsResponse.class));
7273
assertThat(response.getData().getData(), instanceOf(List.class));
73-
assertThat(response.getData().getPage(), notNullValue());
74-
assertThat(response.getData().getPage().getTotalElements(), notNullValue());
7574
assertThat(response.getData().getErrors(), instanceOf(List.class));
7675

77-
Endpoints createdEndpoint = response.getData().getData().stream()
78-
.filter(item -> item.getEndpointId().equals(endpointId))
79-
.findFirst()
80-
.orElse(null);
81-
82-
assertThat(createdEndpoint, notNullValue());
83-
assertThat(createdEndpoint, hasProperty("type", is(EndpointTypeEnum.WEBRTC)));
84-
assertThat(createdEndpoint, hasProperty("status", notNullValue()));
85-
assertThat(createdEndpoint, hasProperty("creationTimestamp", notNullValue()));
86-
assertThat(createdEndpoint, hasProperty("expirationTimestamp", notNullValue()));
76+
Endpoints firstEndpoint = response.getData().getData().get(0);
77+
assertThat(firstEndpoint.getEndpointId(), instanceOf(String.class));
78+
assertThat(firstEndpoint.getType(), instanceOf(EndpointTypeEnum.class));
79+
assertThat(firstEndpoint.getStatus(), instanceOf(EndpointStatusEnum.class));
80+
assertThat(firstEndpoint.getCreationTimestamp(), instanceOf(OffsetDateTime.class));
81+
assertThat(firstEndpoint.getExpirationTimestamp(), instanceOf(OffsetDateTime.class));
8782
}
8883

8984
@Test
9085
@Order(3)
91-
public void shouldListEndpointsFilteredByType() throws ApiException {
92-
ApiResponse<ListEndpointsResponse> response = api.listEndpointsWithHttpInfo(BW_ACCOUNT_ID, EndpointTypeEnum.WEBRTC, null, null, null);
93-
94-
assertThat(response.getStatusCode(), is(200));
95-
assertThat(response.getData().getData(), instanceOf(List.class));
96-
assertThat(response.getData().getErrors(), instanceOf(List.class));
97-
98-
if (response.getData().getData().size() > 0) {
99-
boolean allWebRtc = response.getData().getData().stream()
100-
.allMatch(item -> item.getType() == EndpointTypeEnum.WEBRTC);
101-
assertThat(allWebRtc, is(true));
102-
}
103-
}
104-
105-
@Test
106-
@Order(4)
107-
public void shouldRetrieveDetailsOfSpecificEndpoint() throws ApiException {
86+
public void getEndpointTest() throws ApiException {
10887
ApiResponse<EndpointResponse> response = api.getEndpointWithHttpInfo(BW_ACCOUNT_ID, endpointId);
10988

11089
assertThat(response.getStatusCode(), is(200));
111-
assertThat(response.getData(), notNullValue());
90+
assertThat(response.getData(), instanceOf(EndpointResponse.class));
11291
assertThat(response.getData().getErrors(), instanceOf(List.class));
113-
assertThat(response.getData().getErrors(), hasSize(0));
114-
assertThat(response.getData().getData(), notNullValue());
115-
assertThat(response.getData().getData(), hasProperty("endpointId", is(endpointId)));
116-
assertThat(response.getData().getData(), hasProperty("type", is(EndpointTypeEnum.WEBRTC)));
117-
assertThat(response.getData().getData(), hasProperty("status", notNullValue()));
118-
assertThat(response.getData().getData(), hasProperty("creationTimestamp", notNullValue()));
119-
assertThat(response.getData().getData(), hasProperty("expirationTimestamp", notNullValue()));
92+
assertThat(response.getData().getData(), instanceOf(Endpoint.class));
93+
assertThat(response.getData().getData().getEndpointId(), equalTo(endpointId));
94+
assertThat(response.getData().getData().getType(), equalTo(EndpointTypeEnum.WEBRTC));
95+
assertThat(response.getData().getData().getStatus(), instanceOf(EndpointStatusEnum.class));
96+
assertThat(response.getData().getData().getCreationTimestamp(), instanceOf(OffsetDateTime.class));
97+
assertThat(response.getData().getData().getExpirationTimestamp(), instanceOf(OffsetDateTime.class));
12098
}
12199

122100
@Test
123-
@Order(5)
124-
public void shouldDeleteEndpoint() throws ApiException {
101+
@Order(4)
102+
public void deleteEndpointTest() throws ApiException {
125103
ApiResponse<Void> response = api.deleteEndpointWithHttpInfo(BW_ACCOUNT_ID, endpointId);
126104

127105
assertThat(response.getStatusCode(), is(204));

0 commit comments

Comments
 (0)