Skip to content

Commit cced0d0

Browse files
committed
Refactor EndpointsApiTest to correct response data assertions and simplify unauthorized exception handling
1 parent 576f572 commit cced0d0

1 file changed

Lines changed: 8 additions & 12 deletions

File tree

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

Lines changed: 8 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,10 @@
99
import com.bandwidth.sdk.model.EndpointResponse;
1010
import com.bandwidth.sdk.model.Endpoints;
1111
import com.bandwidth.sdk.model.EndpointDirectionEnum;
12-
import com.bandwidth.sdk.model.EndpointStatusEnum;
1312
import com.bandwidth.sdk.model.EndpointTypeEnum;
1413
import com.bandwidth.sdk.model.ListEndpointsResponse;
15-
import org.junit.jupiter.api.BeforeAll;
1614
import org.junit.jupiter.api.MethodOrderer;
1715
import org.junit.jupiter.api.Order;
18-
import org.junit.jupiter.api.AfterAll;
1916
import org.junit.jupiter.api.Test;
2017
import org.junit.jupiter.api.TestInstance;
2118
import org.junit.jupiter.api.TestMethodOrder;
@@ -114,11 +111,12 @@ public void shouldRetrieveDetailsOfSpecificEndpoint() throws ApiException {
114111
assertThat(response.getData(), notNullValue());
115112
assertThat(response.getData().getErrors(), instanceOf(List.class));
116113
assertThat(response.getData().getErrors(), hasSize(0));
117-
assertThat(response.getData(), hasProperty("endpointId", is(endpointId)));
118-
assertThat(response.getData(), hasProperty("type", is(EndpointTypeEnum.WEBRTC)));
119-
assertThat(response.getData(), hasProperty("status", notNullValue()));
120-
assertThat(response.getData(), hasProperty("creationTimestamp", notNullValue()));
121-
assertThat(response.getData(), hasProperty("expirationTimestamp", notNullValue()));
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()));
122120
}
123121

124122
@Test
@@ -130,14 +128,12 @@ public void shouldDeleteEndpoint() throws ApiException {
130128
}
131129

132130
@Test
133-
public void shouldThrow401UnauthorizedWithInvalidCredentials() throws ApiException {
131+
public void shouldThrow401UnauthorizedWithInvalidCredentials() {
134132
ApiClient badOauthClient = new ApiClient("invalid-client-id", "invalid-client-secret", null);
135133
EndpointsApi endpointsApiBad = new EndpointsApi(badOauthClient);
136134

137-
ApiException exception = Assertions.assertThrows(ApiException.class,
135+
Assertions.assertThrows(ApiException.class,
138136
() -> endpointsApiBad.listEndpointsWithHttpInfo(BW_ACCOUNT_ID, null, null, null, null));
139-
140-
assertThat(exception.getCode(), is(401));
141137
}
142138

143139
@Test

0 commit comments

Comments
 (0)