Skip to content

Commit 84810ef

Browse files
committed
Increase test coverage
1 parent a69f79a commit 84810ef

File tree

3 files changed

+48
-5
lines changed

3 files changed

+48
-5
lines changed

src/main/java/com/opentok/Archive.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,6 @@ public String toString() {
259259
} catch (Exception e) {
260260
return "";
261261
}
262-
263262
}
264263

265264
}

src/main/java/com/opentok/Broadcast.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
1212
import com.fasterxml.jackson.annotation.JsonProperty;
1313
import com.fasterxml.jackson.annotation.JsonValue;
14+
import com.fasterxml.jackson.core.JsonProcessingException;
1415
import com.fasterxml.jackson.databind.ObjectMapper;
1516

1617
import java.util.ArrayList;
@@ -160,7 +161,7 @@ public List<Rtmp> getRtmpList() {
160161
public String toString() {
161162
try {
162163
return new ObjectMapper().writeValueAsString(this);
163-
} catch (Exception e) {
164+
} catch (JsonProcessingException e) {
164165
return "";
165166
}
166167
}

src/test/java/com/opentok/test/OpenTokTest.java

Lines changed: 46 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,13 @@ public void testSignalAllConnections() throws OpenTokException {
105105
stubFor(post(urlEqualTo(path))
106106
.willReturn(aResponse()
107107
.withStatus(204)));
108-
SignalProperties properties = new SignalProperties.Builder().type("test").data("Signal test string").build();
108+
SignalProperties properties = new SignalProperties.Builder()
109+
.type("test")
110+
.data("Signal test string")
111+
.build();
112+
113+
properties.toMap();
114+
109115
sdk.signal(sessionId, properties);
110116
verify(postRequestedFor(urlMatching(path)));
111117
verify(postRequestedFor(urlMatching(path))
@@ -560,6 +566,12 @@ public void testGetArchive() throws OpenTokException {
560566
Archive archive = sdk.getArchive(archiveId);
561567

562568
assertNotNull(archive);
569+
assertNotNull(archive.toString());
570+
assertNull(archive.getPassword());
571+
assertNotNull(archive.getStreamMode());
572+
assertNotNull(archive.getReason());
573+
assertTrue(archive.hasAudio());
574+
assertTrue(archive.hasVideo());
563575
assertEquals(apiKey, archive.getPartnerId());
564576
assertEquals(archiveId, archive.getId());
565577
assertEquals(1395187836000L, archive.getCreatedAt());
@@ -948,7 +960,17 @@ public void testStartArchive() throws OpenTokException {
948960
" \"status\" : \"started\",\n" +
949961
" \"url\" : null\n" +
950962
" }")));
951-
ArchiveProperties properties = new ArchiveProperties.Builder().name(null).build();
963+
ArchiveProperties properties = new ArchiveProperties.Builder()
964+
.name(null)
965+
.hasAudio(true)
966+
.hasVideo(false)
967+
.outputMode(OutputMode.COMPOSED)
968+
.streamMode(Archive.StreamMode.AUTO)
969+
.resolution("1920x1080")
970+
.build();
971+
972+
properties.toMap();
973+
952974
Archive archive = sdk.startArchive(sessionId, properties);
953975
assertNotNull(archive);
954976
assertEquals(sessionId, archive.getSessionId());
@@ -982,7 +1004,12 @@ public void testStartArchiveWithScreenshareType() throws OpenTokException {
9821004
String expectedJson = String.format("{\"sessionId\":\"%s\",\"streamMode\":\"auto\",\"hasVideo\":true,\"hasAudio\":true,\"outputMode\":\"composed\",\"layout\":{\"type\":\"bestFit\",\"screenshareType\":\"pip\"}}",sessionId);
9831005
ValueMatchingStrategy valueMatchingStrategy = new ValueMatchingStrategy();
9841006
valueMatchingStrategy.setEqualToJson(expectedJson);
985-
ArchiveLayout layout = new ArchiveLayout(ScreenShareLayoutType.PIP);
1007+
1008+
ArchiveLayout layout = new ArchiveLayout(ScreenShareLayoutType.BESTFIT);
1009+
assertEquals(ScreenShareLayoutType.BESTFIT, layout.getScreenshareType());
1010+
layout.setScreenshareType(ScreenShareLayoutType.PIP);
1011+
assertEquals(ScreenShareLayoutType.PIP, layout.getScreenshareType());
1012+
9861013
ArchiveProperties properties = new ArchiveProperties.Builder().name(null).layout(layout).build();
9871014
Archive archive = sdk.startArchive(sessionId, properties);
9881015
assertNotNull(archive);
@@ -1702,17 +1729,33 @@ public void testStartBroadcast() throws OpenTokException {
17021729
RtmpProperties rtmpProps = new RtmpProperties.Builder().id("foo").serverUrl("rtmp://myfooserver/myfooapp").streamName("myfoostream").build();
17031730
RtmpProperties rtmpNextProps = new RtmpProperties.Builder().id("bar").serverUrl("rtmp://mybarserver/mybarapp").streamName("mybarstream").build();
17041731
BroadcastLayout layout = new BroadcastLayout(BroadcastLayout.Type.PIP);
1732+
new BroadcastLayout(ArchiveLayout.Type.BESTFIT, "style.css");
1733+
17051734
BroadcastProperties properties = new BroadcastProperties.Builder()
17061735
.hasHls(true)
17071736
.addRtmpProperties(rtmpProps)
17081737
.addRtmpProperties(rtmpNextProps)
17091738
.maxDuration(1000)
17101739
.resolution("640x480")
17111740
.layout(layout)
1741+
.streamMode(Broadcast.StreamMode.AUTO)
17121742
.build();
1743+
17131744
Broadcast broadcast = sdk.startBroadcast(sessionId, properties);
17141745
assertNotNull(broadcast);
1746+
Rtmp rtmp = broadcast.getRtmpList().get(0);
1747+
assertNotNull(rtmp);
1748+
assertNotNull(rtmp.getId());
1749+
assertNotNull(rtmp.getServerUrl());
1750+
assertNotNull(rtmp.getStreamName());
1751+
assertNotNull(broadcast.toString());
1752+
assertNotNull(broadcast.getStatus());
1753+
assertEquals("1280x720", broadcast.getResolution());
1754+
assertTrue(broadcast.getCreatedAt() > 0);
1755+
assertTrue(broadcast.getUpdatedAt() > -1);
1756+
assertTrue(broadcast.getProjectId() > -1);
17151757
assertEquals(sessionId, broadcast.getSessionId());
1758+
assertEquals(Broadcast.StreamMode.AUTO, broadcast.getStreamMode());
17161759
assertNotNull(broadcast.getId());
17171760
verify(postRequestedFor(urlMatching(url)));
17181761
assertTrue(Helpers.verifyTokenAuth(apiKey, apiSecret,

0 commit comments

Comments
 (0)