Skip to content

Commit b754ed1

Browse files
smoghe-bwclaude
andcommitted
Add equalTo value assertions to unit model tests
Add equalTo assertions alongside existing instanceOf checks in 12 model test files to verify actual field values, not just types. Store OffsetDateTime values in static final constants for timestamp assertions. Update ErrorResponseTest to use nullValue() matcher instead of == null. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent f2ce936 commit b754ed1

12 files changed

Lines changed: 92 additions & 12 deletions

src/test/java/com/bandwidth/sdk/unit/models/CreateEndpointResponseDataTest.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,17 +25,21 @@
2525

2626
import static org.hamcrest.MatcherAssert.assertThat;
2727
import static org.hamcrest.CoreMatchers.instanceOf;
28+
import static org.hamcrest.CoreMatchers.equalTo;
2829

2930
/**
3031
* Model tests for CreateEndpointResponseData
3132
*/
3233
public class CreateEndpointResponseDataTest {
34+
private static final OffsetDateTime TEST_CREATION_TIMESTAMP = OffsetDateTime.now();
35+
private static final OffsetDateTime TEST_EXPIRATION_TIMESTAMP = OffsetDateTime.now();
36+
3337
private final CreateEndpointResponseData model = new CreateEndpointResponseData()
3438
.endpointId("endpointId")
3539
.type(EndpointTypeEnum.WEBRTC)
3640
.status(EndpointStatusEnum.CONNECTED)
37-
.creationTimestamp(OffsetDateTime.now())
38-
.expirationTimestamp(OffsetDateTime.now())
41+
.creationTimestamp(TEST_CREATION_TIMESTAMP)
42+
.expirationTimestamp(TEST_EXPIRATION_TIMESTAMP)
3943
.tag("tag")
4044
.devices(new ArrayList<Device>(Arrays.asList(new Device())))
4145
.token("token");
@@ -54,6 +58,7 @@ public void testCreateEndpointResponseData() {
5458
@Test
5559
public void endpointIdTest() {
5660
assertThat(model.getEndpointId(), instanceOf(String.class));
61+
assertThat(model.getEndpointId(), equalTo("endpointId"));
5762
}
5863

5964
/**
@@ -62,6 +67,7 @@ public void endpointIdTest() {
6267
@Test
6368
public void typeTest() {
6469
assertThat(model.getType(), instanceOf(EndpointTypeEnum.class));
70+
assertThat(model.getType(), equalTo(EndpointTypeEnum.WEBRTC));
6571
}
6672

6773
/**
@@ -70,6 +76,7 @@ public void typeTest() {
7076
@Test
7177
public void statusTest() {
7278
assertThat(model.getStatus(), instanceOf(EndpointStatusEnum.class));
79+
assertThat(model.getStatus(), equalTo(EndpointStatusEnum.CONNECTED));
7380
}
7481

7582
/**
@@ -78,6 +85,7 @@ public void statusTest() {
7885
@Test
7986
public void creationTimestampTest() {
8087
assertThat(model.getCreationTimestamp(), instanceOf(OffsetDateTime.class));
88+
assertThat(model.getCreationTimestamp(), equalTo(TEST_CREATION_TIMESTAMP));
8189
}
8290

8391
/**
@@ -86,6 +94,7 @@ public void creationTimestampTest() {
8694
@Test
8795
public void expirationTimestampTest() {
8896
assertThat(model.getExpirationTimestamp(), instanceOf(OffsetDateTime.class));
97+
assertThat(model.getExpirationTimestamp(), equalTo(TEST_EXPIRATION_TIMESTAMP));
8998
}
9099

91100
/**
@@ -94,6 +103,7 @@ public void expirationTimestampTest() {
94103
@Test
95104
public void tagTest() {
96105
assertThat(model.getTag(), instanceOf(String.class));
106+
assertThat(model.getTag(), equalTo("tag"));
97107
}
98108

99109
/**
@@ -102,6 +112,7 @@ public void tagTest() {
102112
@Test
103113
public void devicesTest() {
104114
assertThat(model.getDevices(), instanceOf(List.class));
115+
assertThat(model.getDevices().size(), equalTo(1));
105116
}
106117

107118
/**
@@ -110,6 +121,7 @@ public void devicesTest() {
110121
@Test
111122
public void tokenTest() {
112123
assertThat(model.getToken(), instanceOf(String.class));
124+
assertThat(model.getToken(), equalTo("token"));
113125
}
114126

115127
}

src/test/java/com/bandwidth/sdk/unit/models/CreateEndpointResponseTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import static org.hamcrest.MatcherAssert.assertThat;
2626
import static org.hamcrest.CoreMatchers.instanceOf;
27+
import static org.hamcrest.CoreMatchers.equalTo;
2728

2829
/**
2930
* Model tests for CreateEndpointResponse
@@ -48,6 +49,7 @@ public void testCreateEndpointResponse() {
4849
@Test
4950
public void linksTest() {
5051
assertThat(model.getLinks(), instanceOf(List.class));
52+
assertThat(model.getLinks().size(), equalTo(1));
5153
}
5254

5355
/**
@@ -64,6 +66,7 @@ public void dataTest() {
6466
@Test
6567
public void errorsTest() {
6668
assertThat(model.getErrors(), instanceOf(List.class));
69+
assertThat(model.getErrors().size(), equalTo(1));
6770
}
6871

6972
}

src/test/java/com/bandwidth/sdk/unit/models/CreateWebRtcConnectionRequestTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121

2222
import static org.hamcrest.MatcherAssert.assertThat;
2323
import static org.hamcrest.CoreMatchers.instanceOf;
24+
import static org.hamcrest.CoreMatchers.equalTo;
2425

2526
/**
2627
* Model tests for CreateWebRtcConnectionRequest
@@ -48,6 +49,7 @@ public void testCreateWebRtcConnectionRequest() {
4849
@Test
4950
public void typeTest() {
5051
assertThat(model.getType(), instanceOf(EndpointTypeEnum.class));
52+
assertThat(model.getType(), equalTo(EndpointTypeEnum.WEBRTC));
5153
}
5254

5355
/**
@@ -56,6 +58,7 @@ public void typeTest() {
5658
@Test
5759
public void directionTest() {
5860
assertThat(model.getDirection(), instanceOf(EndpointDirectionEnum.class));
61+
assertThat(model.getDirection(), equalTo(EndpointDirectionEnum.BIDIRECTIONAL));
5962
}
6063

6164
/**
@@ -64,6 +67,7 @@ public void directionTest() {
6467
@Test
6568
public void eventCallbackUrlTest() {
6669
assertThat(model.getEventCallbackUrl(), instanceOf(URI.class));
70+
assertThat(model.getEventCallbackUrl(), equalTo(URI.create("https://example.com/callback")));
6771
}
6872

6973
/**
@@ -72,6 +76,7 @@ public void eventCallbackUrlTest() {
7276
@Test
7377
public void eventFallbackUrlTest() {
7478
assertThat(model.getEventFallbackUrl(), instanceOf(URI.class));
79+
assertThat(model.getEventFallbackUrl(), equalTo(URI.create("https://example.com/fallback")));
7580
}
7681

7782
/**
@@ -80,6 +85,7 @@ public void eventFallbackUrlTest() {
8085
@Test
8186
public void tagTest() {
8287
assertThat(model.getTag(), instanceOf(String.class));
88+
assertThat(model.getTag(), equalTo("tag"));
8389
}
8490

8591
/**

src/test/java/com/bandwidth/sdk/unit/models/DeviceTest.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,16 +20,19 @@
2020

2121
import static org.hamcrest.MatcherAssert.assertThat;
2222
import static org.hamcrest.CoreMatchers.instanceOf;
23+
import static org.hamcrest.CoreMatchers.equalTo;
2324

2425
/**
2526
* Model tests for Device
2627
*/
2728
public class DeviceTest {
29+
private static final OffsetDateTime TEST_CREATION_TIMESTAMP = OffsetDateTime.now();
30+
2831
private final Device model = new Device()
2932
.deviceId("deviceId")
3033
.deviceName("deviceName")
3134
.status(DeviceStatusEnum.CONNECTED)
32-
.creationTimestamp(OffsetDateTime.now());
35+
.creationTimestamp(TEST_CREATION_TIMESTAMP);
3336

3437
/**
3538
* Model tests for Device
@@ -45,6 +48,7 @@ public void testDevice() {
4548
@Test
4649
public void deviceIdTest() {
4750
assertThat(model.getDeviceId(), instanceOf(String.class));
51+
assertThat(model.getDeviceId(), equalTo("deviceId"));
4852
}
4953

5054
/**
@@ -53,6 +57,7 @@ public void deviceIdTest() {
5357
@Test
5458
public void deviceNameTest() {
5559
assertThat(model.getDeviceName(), instanceOf(String.class));
60+
assertThat(model.getDeviceName(), equalTo("deviceName"));
5661
}
5762

5863
/**
@@ -61,6 +66,7 @@ public void deviceNameTest() {
6166
@Test
6267
public void statusTest() {
6368
assertThat(model.getStatus(), instanceOf(DeviceStatusEnum.class));
69+
assertThat(model.getStatus(), equalTo(DeviceStatusEnum.CONNECTED));
6470
}
6571

6672
/**
@@ -69,5 +75,6 @@ public void statusTest() {
6975
@Test
7076
public void creationTimestampTest() {
7177
assertThat(model.getCreationTimestamp(), instanceOf(OffsetDateTime.class));
78+
assertThat(model.getCreationTimestamp(), equalTo(TEST_CREATION_TIMESTAMP));
7279
}
7380
}

src/test/java/com/bandwidth/sdk/unit/models/EndpointEventTest.java

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,19 +23,24 @@
2323

2424
import static org.hamcrest.MatcherAssert.assertThat;
2525
import static org.hamcrest.CoreMatchers.instanceOf;
26+
import static org.hamcrest.CoreMatchers.equalTo;
2627

2728
/**
2829
* Model tests for EndpointEvent
2930
*/
3031
public class EndpointEventTest {
32+
private static final OffsetDateTime TEST_CREATION_TIMESTAMP = OffsetDateTime.now();
33+
private static final OffsetDateTime TEST_EXPIRATION_TIMESTAMP = OffsetDateTime.now();
34+
private static final OffsetDateTime TEST_EVENT_TIME = OffsetDateTime.now();
35+
3136
private final EndpointEvent model = new EndpointEvent()
3237
.endpointId("endpointId")
3338
.type(EndpointTypeEnum.WEBRTC)
3439
.status(EndpointStatusEnum.CONNECTED)
35-
.creationTimestamp(OffsetDateTime.now())
36-
.expirationTimestamp(OffsetDateTime.now())
40+
.creationTimestamp(TEST_CREATION_TIMESTAMP)
41+
.expirationTimestamp(TEST_EXPIRATION_TIMESTAMP)
3742
.tag("tag")
38-
.eventTime(OffsetDateTime.now())
43+
.eventTime(TEST_EVENT_TIME)
3944
.eventType(EndpointEventTypeEnum.DEVICE_CONNECTED)
4045
.device(new Device());
4146

@@ -53,6 +58,7 @@ public void testEndpointEvent() {
5358
@Test
5459
public void endpointIdTest() {
5560
assertThat(model.getEndpointId(), instanceOf(String.class));
61+
assertThat(model.getEndpointId(), equalTo("endpointId"));
5662
}
5763

5864
/**
@@ -61,6 +67,7 @@ public void endpointIdTest() {
6167
@Test
6268
public void typeTest() {
6369
assertThat(model.getType(), instanceOf(EndpointTypeEnum.class));
70+
assertThat(model.getType(), equalTo(EndpointTypeEnum.WEBRTC));
6471
}
6572

6673
/**
@@ -69,6 +76,7 @@ public void typeTest() {
6976
@Test
7077
public void statusTest() {
7178
assertThat(model.getStatus(), instanceOf(EndpointStatusEnum.class));
79+
assertThat(model.getStatus(), equalTo(EndpointStatusEnum.CONNECTED));
7280
}
7381

7482
/**
@@ -77,6 +85,7 @@ public void statusTest() {
7785
@Test
7886
public void creationTimestampTest() {
7987
assertThat(model.getCreationTimestamp(), instanceOf(OffsetDateTime.class));
88+
assertThat(model.getCreationTimestamp(), equalTo(TEST_CREATION_TIMESTAMP));
8089
}
8190

8291
/**
@@ -85,6 +94,7 @@ public void creationTimestampTest() {
8594
@Test
8695
public void expirationTimestampTest() {
8796
assertThat(model.getExpirationTimestamp(), instanceOf(OffsetDateTime.class));
97+
assertThat(model.getExpirationTimestamp(), equalTo(TEST_EXPIRATION_TIMESTAMP));
8898
}
8999

90100
/**
@@ -93,6 +103,7 @@ public void expirationTimestampTest() {
93103
@Test
94104
public void tagTest() {
95105
assertThat(model.getTag(), instanceOf(String.class));
106+
assertThat(model.getTag(), equalTo("tag"));
96107
}
97108

98109
/**
@@ -101,6 +112,7 @@ public void tagTest() {
101112
@Test
102113
public void eventTimeTest() {
103114
assertThat(model.getEventTime(), instanceOf(OffsetDateTime.class));
115+
assertThat(model.getEventTime(), equalTo(TEST_EVENT_TIME));
104116
}
105117

106118
/**
@@ -109,6 +121,7 @@ public void eventTimeTest() {
109121
@Test
110122
public void eventTypeTest() {
111123
assertThat(model.getEventType(), instanceOf(EndpointEventTypeEnum.class));
124+
assertThat(model.getEventType(), equalTo(EndpointEventTypeEnum.DEVICE_CONNECTED));
112125
}
113126

114127
/**

src/test/java/com/bandwidth/sdk/unit/models/EndpointResponseTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import static org.hamcrest.MatcherAssert.assertThat;
2626
import static org.hamcrest.CoreMatchers.instanceOf;
27+
import static org.hamcrest.CoreMatchers.equalTo;
2728

2829
/**
2930
* Model tests for EndpointResponse
@@ -48,6 +49,7 @@ public void testEndpointResponse() {
4849
@Test
4950
public void linksTest() {
5051
assertThat(model.getLinks(), instanceOf(List.class));
52+
assertThat(model.getLinks().size(), equalTo(1));
5153
}
5254

5355
/**
@@ -64,6 +66,7 @@ public void dataTest() {
6466
@Test
6567
public void errorsTest() {
6668
assertThat(model.getErrors(), instanceOf(List.class));
69+
assertThat(model.getErrors().size(), equalTo(1));
6770
}
6871

6972
}

0 commit comments

Comments
 (0)