Fix tests

pull/567/head
pabloFuente 2020-11-19 14:44:52 +01:00
parent b76ec484e5
commit cfc704c665
8 changed files with 175 additions and 50 deletions

View File

@ -203,7 +203,7 @@ public class OpenVidu {
json.addProperty("hasAudio", properties.hasAudio()); json.addProperty("hasAudio", properties.hasAudio());
json.addProperty("hasVideo", properties.hasVideo()); json.addProperty("hasVideo", properties.hasVideo());
if ((Recording.OutputMode.COMPOSED.equals(properties.outputMode()) if ((properties.outputMode() == null || Recording.OutputMode.COMPOSED.equals(properties.outputMode())
|| (Recording.OutputMode.COMPOSED_QUICK_START.equals(properties.outputMode()))) || (Recording.OutputMode.COMPOSED_QUICK_START.equals(properties.outputMode())))
&& properties.hasVideo()) { && properties.hasVideo()) {
json.addProperty("resolution", properties.resolution()); json.addProperty("resolution", properties.resolution());

View File

@ -17,8 +17,6 @@
package io.openvidu.java.client; package io.openvidu.java.client;
import io.openvidu.java.client.Recording.OutputMode;
/** /**
* See * See
* {@link io.openvidu.java.client.OpenVidu#startRecording(String, RecordingProperties)} * {@link io.openvidu.java.client.OpenVidu#startRecording(String, RecordingProperties)}
@ -41,7 +39,7 @@ public class RecordingProperties {
public static class Builder { public static class Builder {
private String name = ""; private String name = "";
private Recording.OutputMode outputMode = Recording.OutputMode.COMPOSED; private Recording.OutputMode outputMode;
private RecordingLayout recordingLayout; private RecordingLayout recordingLayout;
private String customLayout; private String customLayout;
private String resolution; private String resolution;
@ -54,14 +52,6 @@ public class RecordingProperties {
* Builder for {@link io.openvidu.java.client.RecordingProperties} * Builder for {@link io.openvidu.java.client.RecordingProperties}
*/ */
public RecordingProperties build() { public RecordingProperties build() {
if (OutputMode.COMPOSED.equals(this.outputMode)
|| OutputMode.COMPOSED_QUICK_START.equals(this.outputMode)) {
this.recordingLayout = this.recordingLayout != null ? this.recordingLayout : RecordingLayout.BEST_FIT;
this.resolution = this.resolution != null ? this.resolution : "1920x1080";
if (RecordingLayout.CUSTOM.equals(this.recordingLayout)) {
this.customLayout = this.customLayout != null ? this.customLayout : "";
}
}
return new RecordingProperties(this.name, this.outputMode, this.recordingLayout, this.customLayout, return new RecordingProperties(this.name, this.outputMode, this.recordingLayout, this.customLayout,
this.resolution, this.hasAudio, this.hasVideo, this.shmSize, this.mediaNode); this.resolution, this.hasAudio, this.hasVideo, this.shmSize, this.mediaNode);
} }

View File

@ -163,7 +163,10 @@ public class ComposedQuickStartRecordingService extends ComposedRecordingService
runContainer(recorderSession, new RecordingProperties.Builder().name("") runContainer(recorderSession, new RecordingProperties.Builder().name("")
.outputMode(recorderSession.getSessionProperties().defaultOutputMode()) .outputMode(recorderSession.getSessionProperties().defaultOutputMode())
.recordingLayout(recorderSession.getSessionProperties().defaultRecordingLayout()) .recordingLayout(recorderSession.getSessionProperties().defaultRecordingLayout())
.customLayout(recorderSession.getSessionProperties().defaultCustomLayout()).build()); .customLayout(recorderSession.getSessionProperties().defaultCustomLayout())
.resolution(
/* recorderSession.getSessionProperties().defaultRecordingResolution() */"1920x1080")
.build());
log.info("COMPOSED_QUICK_START recording container launched for session: {}", log.info("COMPOSED_QUICK_START recording container launched for session: {}",
recorderSession.getSessionId()); recorderSession.getSessionId());
launched = true; launched = true;

View File

@ -959,11 +959,21 @@ public class SessionRestController {
throw new RuntimeException("Cannot start a recording with both \"hasAudio\" and \"hasVideo\" set to false"); throw new RuntimeException("Cannot start a recording with both \"hasAudio\" and \"hasVideo\" set to false");
} }
// If outputMode is COMPOSED when defaultOutputMode is COMPOSED_QUICK_START,
// change outputMode to COMPOSED_QUICK_START (and vice versa)
OutputMode defaultOutputMode = sessionProperties.defaultOutputMode();
if (OutputMode.COMPOSED_QUICK_START.equals(defaultOutputMode) && OutputMode.COMPOSED.equals(finalOutputMode)) {
finalOutputMode = OutputMode.COMPOSED_QUICK_START;
} else if (OutputMode.COMPOSED.equals(defaultOutputMode)
&& OutputMode.COMPOSED_QUICK_START.equals(finalOutputMode)) {
finalOutputMode = OutputMode.COMPOSED;
}
builder.outputMode(finalOutputMode == null ? sessionProperties.defaultOutputMode() : finalOutputMode); builder.outputMode(finalOutputMode == null ? sessionProperties.defaultOutputMode() : finalOutputMode);
if (RecordingUtils.IS_COMPOSED(finalOutputMode)) { if (RecordingUtils.IS_COMPOSED(finalOutputMode)) {
if (resolution != null) { builder.resolution(resolution != null ? resolution : "1920x1080"); // resolution == null ?
builder.resolution(resolution); // sessionProperties.defaultRecordingResolution)
} // : resolution));
builder.recordingLayout( builder.recordingLayout(
recordingLayout == null ? sessionProperties.defaultRecordingLayout() : recordingLayout); recordingLayout == null ? sessionProperties.defaultRecordingLayout() : recordingLayout);
if (RecordingLayout.CUSTOM.equals(recordingLayout)) { if (RecordingLayout.CUSTOM.equals(recordingLayout)) {

View File

@ -486,17 +486,47 @@ public class OpenViduProTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
log.info("openvidu-java-client PRO test"); log.info("openvidu-java-client PRO test");
// Create default Connection
Session session = OV.createSession(); Session session = OV.createSession();
Assert.assertFalse(session.fetch()); Assert.assertFalse(session.fetch());
Connection connection = session.createConnection(); Connection connectionDefault = session.createConnection();
Assert.assertFalse(session.fetch()); Assert.assertFalse(session.fetch());
Assert.assertEquals("Wrong role property", OpenViduRole.PUBLISHER, connection.getRole()); Assert.assertEquals("Wrong role property", OpenViduRole.PUBLISHER, connectionDefault.getRole());
Assert.assertTrue("Wrong record property", connection.record()); Assert.assertTrue("Wrong record property", connectionDefault.record());
session.updateConnection(connection.getConnectionId(), Assert.assertEquals("Wrong data property", "", connectionDefault.getServerData());
new ConnectionProperties.Builder().role(OpenViduRole.SUBSCRIBER).record(false).build()); // Update Connection
Assert.assertEquals("Wrong role property", OpenViduRole.SUBSCRIBER, connection.getRole()); session.updateConnection(connectionDefault.getConnectionId(), new ConnectionProperties.Builder()
.role(OpenViduRole.SUBSCRIBER).record(false).data("WILL HAVE NO EFFECT").build());
Assert.assertEquals("Wrong role property", OpenViduRole.SUBSCRIBER, connectionDefault.getRole());
Assert.assertFalse("Wrong record property", connectionDefault.record());
Assert.assertEquals("Wrong data property", "", connectionDefault.getServerData());
Assert.assertFalse(session.fetch());
// Create custom properties Connection
long timestamp = System.currentTimeMillis();
Connection connection = session.createConnection(
new ConnectionProperties.Builder().record(false).role(OpenViduRole.MODERATOR).data("SERVER_SIDE_DATA")
.kurentoOptions(new KurentoOptions.Builder().videoMaxRecvBandwidth(555)
.videoMinRecvBandwidth(555).videoMaxSendBandwidth(555).videoMinSendBandwidth(555)
.allowedFilters(new String[] { "555" }).build())
.build());
Assert.assertEquals("Wrong status Connection property", "pending", connection.getStatus());
Assert.assertTrue("Wrong timestamp Connection property", connection.createdAt() > timestamp);
Assert.assertTrue("Wrong activeAt Connection property", connection.activeAt() == null);
Assert.assertTrue("Wrong location Connection property", connection.getLocation() == null);
Assert.assertTrue("Wrong platform Connection property", connection.getPlatform() == null);
Assert.assertTrue("Wrong clientData Connection property", connection.getClientData() == null);
Assert.assertTrue("Wrong publishers Connection property", connection.getPublishers().size() == 0);
Assert.assertTrue("Wrong subscribers Connection property", connection.getSubscribers().size() == 0);
Assert.assertTrue("Wrong token Connection property", connection.getToken().contains(session.getSessionId()));
Assert.assertEquals("Wrong type property", ConnectionType.WEBRTC, connection.getType());
Assert.assertEquals("Wrong data property", "SERVER_SIDE_DATA", connection.getServerData());
Assert.assertFalse("Wrong record property", connection.record()); Assert.assertFalse("Wrong record property", connection.record());
Assert.assertFalse(session.fetch()); Assert.assertEquals("Wrong role property", OpenViduRole.MODERATOR, connection.getRole());
Assert.assertTrue("Wrong rtspUri property", connection.getRtspUri() == null);
Assert.assertTrue("Wrong adaptativeBitrate property", connection.adaptativeBitrate() == null);
Assert.assertTrue("Wrong onlyPlayWithSubscribers property", connection.onlyPlayWithSubscribers() == null);
Assert.assertTrue("Wrong networkCache property", connection.getNetworkCache() == null);
} }
@Test @Test

View File

@ -2295,7 +2295,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
// Verify publisher properties // Verify publisher properties
Publisher pub = connectionModerator.getPublishers().get(0); Publisher pub = connectionModerator.getPublishers().get(0);
Assert.assertEquals("{\"width\":640,\"height\":480}", pub.getVideoDimensions()); Assert.assertEquals("{\"width\":640,\"height\":480}", pub.getVideoDimensions());
Assert.assertEquals(new Integer(30), pub.getFrameRate()); Assert.assertEquals(Integer.valueOf(30), pub.getFrameRate());
Assert.assertEquals("CAMERA", pub.getTypeOfVideo()); Assert.assertEquals("CAMERA", pub.getTypeOfVideo());
Assert.assertTrue(pub.hasVideo()); Assert.assertTrue(pub.hasVideo());
Assert.assertTrue(pub.isVideoActive()); Assert.assertTrue(pub.isVideoActive());
@ -2341,7 +2341,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
Assert.assertEquals( Assert.assertEquals(
"{\"width\":" + obj.get("width").getAsLong() + ",\"height\":" + obj.get("height").getAsLong() + "}", "{\"width\":" + obj.get("width").getAsLong() + ",\"height\":" + obj.get("height").getAsLong() + "}",
pub.getVideoDimensions()); pub.getVideoDimensions());
Assert.assertEquals(new Integer(30), pub.getFrameRate()); Assert.assertEquals(Integer.valueOf(30), pub.getFrameRate());
Assert.assertEquals("SCREEN", pub.getTypeOfVideo()); Assert.assertEquals("SCREEN", pub.getTypeOfVideo());
Assert.assertTrue(pub.hasVideo()); Assert.assertTrue(pub.hasVideo());
Assert.assertTrue(pub.isVideoActive()); Assert.assertTrue(pub.isVideoActive());
@ -2352,6 +2352,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
RecordingProperties recordingProperties; RecordingProperties recordingProperties;
try { try {
OV.startRecording("NOT_EXISTS"); OV.startRecording("NOT_EXISTS");
Assert.fail("Expected OpenViduHttpException");
} catch (OpenViduHttpException e) { } catch (OpenViduHttpException e) {
Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 404, e.getStatus()); Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 404, e.getStatus());
} }
@ -2359,6 +2360,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
Assert.assertFalse("OpenVidu.fetch() should return false", OV.fetch()); Assert.assertFalse("OpenVidu.fetch() should return false", OV.fetch());
try { try {
OV.startRecording(sessionAux.getSessionId()); OV.startRecording(sessionAux.getSessionId());
Assert.fail("Expected OpenViduHttpException");
} catch (OpenViduHttpException e) { } catch (OpenViduHttpException e) {
Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 406, e.getStatus()); Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 406, e.getStatus());
} finally { } finally {
@ -2366,25 +2368,49 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
sessionAux.close(); sessionAux.close();
try { try {
sessionAux.fetch(); sessionAux.fetch();
Assert.fail("Expected OpenViduHttpException");
} catch (OpenViduHttpException e2) { } catch (OpenViduHttpException e2) {
Assert.assertEquals("Wrong HTTP status on Session.fetch()", 404, e2.getStatus()); Assert.assertEquals("Wrong HTTP status on Session.fetch()", 404, e2.getStatus());
} }
Assert.assertFalse("OpenVidu.fetch() should return false", OV.fetch()); Assert.assertFalse("OpenVidu.fetch() should return false", OV.fetch());
} }
// Not recorded session
Session notRecordedSession = OV.createSession();
notRecordedSession.createConnection(new ConnectionProperties.Builder().type(ConnectionType.IPCAM)
.rtspUri("rtsp://does-not-matter.com").build());
try { try {
recordingProperties = new RecordingProperties.Builder().hasAudio(false).hasVideo(false).build(); recordingProperties = new RecordingProperties.Builder().hasAudio(false).hasVideo(false).build();
OV.startRecording(session.getSessionId(), recordingProperties); OV.startRecording(notRecordedSession.getSessionId(), recordingProperties);
Assert.fail("Expected OpenViduHttpException");
} catch (OpenViduHttpException e) { } catch (OpenViduHttpException e) {
Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 422, e.getStatus()); Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 422, e.getStatus());
} }
try { try {
recordingProperties = new RecordingProperties.Builder().resolution("99x1080").build(); recordingProperties = new RecordingProperties.Builder().resolution("99x1080").build();
OV.startRecording(session.getSessionId(), recordingProperties); OV.startRecording(notRecordedSession.getSessionId(), recordingProperties);
Assert.fail("Expected OpenViduHttpException");
} catch (OpenViduHttpException e) { } catch (OpenViduHttpException e) {
Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 422, e.getStatus()); Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 422, e.getStatus());
} }
notRecordedSession.close();
// Recorded session
try {
recordingProperties = new RecordingProperties.Builder().hasAudio(false).hasVideo(false).build();
OV.startRecording(session.getSessionId(), recordingProperties);
Assert.fail("Expected OpenViduHttpException");
} catch (OpenViduHttpException e) {
Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 409, e.getStatus());
}
try {
recordingProperties = new RecordingProperties.Builder().resolution("99x1080").build();
OV.startRecording(session.getSessionId(), recordingProperties);
Assert.fail("Expected OpenViduHttpException");
} catch (OpenViduHttpException e) {
Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 409, e.getStatus());
}
try { try {
OV.startRecording(session.getSessionId()); OV.startRecording(session.getSessionId());
Assert.fail("Expected OpenViduHttpException");
} catch (OpenViduHttpException e) { } catch (OpenViduHttpException e) {
Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 409, e.getStatus()); Assert.assertEquals("Wrong HTTP status on OpenVidu.startRecording()", 409, e.getStatus());
} }
@ -2580,7 +2606,7 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
Assert.assertEquals("Wrong property rtspUri", rtsp, ipcamera.getRtspUri()); Assert.assertEquals("Wrong property rtspUri", rtsp, ipcamera.getRtspUri());
Assert.assertFalse("Wrong property adaptativeBitrate", ipcamera.adaptativeBitrate()); Assert.assertFalse("Wrong property adaptativeBitrate", ipcamera.adaptativeBitrate());
Assert.assertFalse("Wrong property onlyPlayWithSubscribers", ipcamera.onlyPlayWithSubscribers()); Assert.assertFalse("Wrong property onlyPlayWithSubscribers", ipcamera.onlyPlayWithSubscribers());
Assert.assertEquals("Wrong property networkCache", 50, ipcamera.getNetworkCache()); Assert.assertEquals("Wrong property networkCache", Integer.valueOf(50), ipcamera.getNetworkCache());
gracefullyLeaveParticipants(2); gracefullyLeaveParticipants(2);
} }
@ -2751,26 +2777,12 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
// 400 // 400
body = "{}"; body = "{}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_BAD_REQUEST); restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_BAD_REQUEST);
body = "{'session': true}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_BAD_REQUEST);
body = "{'session':'SESSION_ID','name':999}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_BAD_REQUEST);
body = "{'session':'SESSION_ID','name':'NAME','outputMode':'NOT_EXISTS'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_BAD_REQUEST);
body = "{'session':'SESSION_ID','name':'NAME','outputMode':'COMPOSED','recordingLayout':'NOT_EXISTS'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_BAD_REQUEST);
body = "{'session':'SESSION_ID','name':'NAME','outputMode':'COMPOSED','recordingLayout':'BEST_FIT','customLayout':'CUSTOM_LAYOUT','hasAudio':true,'hasVideo':true,'resolution':999}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_BAD_REQUEST);
// 422
body = "{'session':'SESSION_ID','name':'NAME','outputMode':'COMPOSED','recordingLayout':'BEST_FIT','customLayout':'CUSTOM_LAYOUT','hasAudio':false,'hasVideo':false}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_UNPROCESSABLE_ENTITY);
body = "{'session':'SESSION_ID','name':'NAME','outputMode':'COMPOSED','recordingLayout':'BEST_FIT','customLayout':'CUSTOM_LAYOUT','hasAudio':true,'hasVideo':true,'resolution':'1920x2000'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_UNPROCESSABLE_ENTITY);
// 404 // 404
body = "{'session':'SESSION_ID'}"; body = "{'session':'SESSION_ID'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_NOT_FOUND); restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_NOT_FOUND);
body = "{'session':'SESSION_ID','name':999}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_NOT_FOUND);
// 406 // 406
body = "{'session':'CUSTOM_SESSION_ID'}"; body = "{'session':'CUSTOM_SESSION_ID'}";
@ -2839,6 +2851,24 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
"{'count':0,'items':[]}"); "{'count':0,'items':[]}");
/** POST /openvidu/api/recordings/start (ACTIVE SESSION) **/ /** POST /openvidu/api/recordings/start (ACTIVE SESSION) **/
// 400
body = "{'session': true}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_BAD_REQUEST);
body = "{'session':'CUSTOM_SESSION_ID','name':999}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_BAD_REQUEST);
body = "{'session':'CUSTOM_SESSION_ID','name':'NAME','outputMode':'NOT_EXISTS'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_BAD_REQUEST);
body = "{'session':'CUSTOM_SESSION_ID','name':'NAME','outputMode':'COMPOSED','recordingLayout':'NOT_EXISTS'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_BAD_REQUEST);
body = "{'session':'CUSTOM_SESSION_ID','name':'NAME','outputMode':'COMPOSED','recordingLayout':'BEST_FIT','customLayout':'CUSTOM_LAYOUT','hasAudio':true,'hasVideo':true,'resolution':999}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_BAD_REQUEST);
// 422
body = "{'session':'CUSTOM_SESSION_ID','name':'NAME','outputMode':'COMPOSED','recordingLayout':'BEST_FIT','customLayout':'CUSTOM_LAYOUT','hasAudio':false,'hasVideo':false}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_UNPROCESSABLE_ENTITY);
body = "{'session':'CUSTOM_SESSION_ID','name':'NAME','outputMode':'COMPOSED','recordingLayout':'BEST_FIT','customLayout':'CUSTOM_LAYOUT','hasAudio':true,'hasVideo':true,'resolution':'1920x2000'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_UNPROCESSABLE_ENTITY);
// 200 // 200
body = "{'session':'CUSTOM_SESSION_ID'}"; body = "{'session':'CUSTOM_SESSION_ID'}";
restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_OK, true, false, true, restClient.rest(HttpMethod.POST, "/openvidu/api/recordings/start", body, HttpStatus.SC_OK, true, false, true,
@ -3653,6 +3683,16 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
checkNodeFetchChanged(true, true); checkNodeFetchChanged(true, true);
checkNodeFetchChanged(true, false); checkNodeFetchChanged(true, false);
// OpenVidu CE does not support Session#updateConnection method
try {
session.updateConnection(connection.getConnectionId(), new ConnectionProperties.Builder().build());
Assert.fail("Expected exception was not thrown by OpenVidu Java Client");
} catch (OpenViduHttpException e) {
Assert.assertEquals("Wrong OpenViduException status", HttpStatus.SC_METHOD_NOT_ALLOWED, e.getStatus());
} catch (Exception e) {
Assert.fail("Wrong exception type thrown by OpenVidu Java Client");
}
restClient.rest(HttpMethod.POST, "/openvidu/api/tokens", "{'session':'REST_SESSION'}", HttpStatus.SC_OK); restClient.rest(HttpMethod.POST, "/openvidu/api/tokens", "{'session':'REST_SESSION'}", HttpStatus.SC_OK);
Assert.assertFalse("Fetch should be true", session.fetch()); Assert.assertFalse("Fetch should be true", session.fetch());
Assert.assertTrue("Fetch should be false", OV.fetch()); Assert.assertTrue("Fetch should be false", OV.fetch());
@ -3692,18 +3732,62 @@ public class OpenViduTestAppE2eTest extends AbstractOpenViduTestAppE2eTest {
checkNodeFetchChanged(true, false); checkNodeFetchChanged(true, false);
checkNodeFetchChanged(true, false); checkNodeFetchChanged(true, false);
// Create and delete connection with openvidu-node-client // Modify connection properties
user.getDriver().findElement(By.id("record-checkbox")).click();
user.getDriver().findElement(By.id("token-role-select")).click();
Thread.sleep(500);
user.getDriver().findElement(By.id("option-MODERATOR")).click();
Thread.sleep(500);
user.getDriver().findElement(By.id("connection-data-field")).sendKeys("MY_SERVER_DATA");
// Create Connection with openvidu-node-client
long timestamp = System.currentTimeMillis();
final String successMessage = "Connection created: "; final String successMessage = "Connection created: ";
user.getDriver().findElement(By.id("crate-connection-api-btn")).click(); user.getDriver().findElement(By.id("crate-connection-api-btn")).click();
user.getWaiter() user.getWaiter()
.until(ExpectedConditions.attributeContains(By.id("api-response-text-area"), "value", successMessage)); .until(ExpectedConditions.attributeContains(By.id("api-response-text-area"), "value", successMessage));
String value = user.getDriver().findElement(By.id("api-response-text-area")).getAttribute("value"); String value = user.getDriver().findElement(By.id("api-response-text-area")).getAttribute("value");
String connectionId = value.substring(value.lastIndexOf(successMessage) + successMessage.length()); // Check openvidu-node-client Connection properties
JsonObject connectionJson = JsonParser
.parseString(value.substring(value.lastIndexOf(successMessage) + successMessage.length()))
.getAsJsonObject();
JsonObject connectionProperties = connectionJson.get("connectionProperties").getAsJsonObject();
String connectionId = connectionJson.get("connectionId").getAsString();
Assert.assertEquals("Wrong status Connection property", "pending", connectionJson.get("status").getAsString());
Assert.assertTrue("Wrong timestamp Connection property",
connectionJson.get("createdAt").getAsLong() > timestamp);
Assert.assertTrue("Wrong activeAt Connection property", connectionJson.get("activeAt").isJsonNull());
Assert.assertTrue("Wrong location Connection property", connectionJson.get("location").isJsonNull());
Assert.assertTrue("Wrong platform Connection property", connectionJson.get("platform").isJsonNull());
Assert.assertTrue("Wrong clientData Connection property", connectionJson.get("clientData").isJsonNull());
Assert.assertTrue("Wrong publishers Connection property",
connectionJson.get("publishers").getAsJsonArray().size() == 0);
Assert.assertTrue("Wrong subscribers Connection property",
connectionJson.get("subscribers").getAsJsonArray().size() == 0);
Assert.assertTrue("Wrong token Connection property",
connectionJson.get("token").getAsString().contains(session.getSessionId()));
Assert.assertEquals("Wrong number of keys in connectionProperties", 9, connectionProperties.keySet().size());
Assert.assertEquals("Wrong type property", ConnectionType.WEBRTC.name(),
connectionProperties.get("type").getAsString());
Assert.assertEquals("Wrong data property", "MY_SERVER_DATA", connectionProperties.get("data").getAsString());
Assert.assertTrue("Wrong record property", connectionProperties.get("record").getAsBoolean()); // Is true in CE
Assert.assertEquals("Wrong role property", OpenViduRole.MODERATOR.name(),
connectionProperties.get("role").getAsString());
Assert.assertTrue("Wrong kurentoOptions property", connectionProperties.get("kurentoOptions").isJsonNull());
Assert.assertTrue("Wrong rtspUri property", connectionProperties.get("rtspUri").isJsonNull());
Assert.assertTrue("Wrong adaptativeBitrate property",
connectionProperties.get("adaptativeBitrate").isJsonNull());
Assert.assertTrue("Wrong onlyPlayWithSubscribers property",
connectionProperties.get("onlyPlayWithSubscribers").isJsonNull());
Assert.assertTrue("Wrong networkCache property", connectionProperties.get("networkCache").isJsonNull());
Assert.assertTrue("Java fetch should be true", session.fetch()); Assert.assertTrue("Java fetch should be true", session.fetch());
Assert.assertFalse("Java fetch should be false", OV.fetch()); Assert.assertFalse("Java fetch should be false", OV.fetch());
checkNodeFetchChanged(true, false); checkNodeFetchChanged(true, false);
checkNodeFetchChanged(false, false); checkNodeFetchChanged(false, false);
checkNodeFetchChanged(true, false); checkNodeFetchChanged(true, false);
// Delete Connection with openvidu-node-client
user.getDriver().findElement(By.id("connection-id-field")).clear(); user.getDriver().findElement(By.id("connection-id-field")).clear();
user.getDriver().findElement(By.id("connection-id-field")).sendKeys(connectionId); user.getDriver().findElement(By.id("connection-id-field")).sendKeys(connectionId);
user.getDriver().findElement(By.id("force-disconnect-api-btn")).click(); user.getDriver().findElement(By.id("force-disconnect-api-btn")).click();

View File

@ -19,13 +19,16 @@
<div style="margin-left:9px"> <div style="margin-left:9px">
<mat-checkbox class="checkbox-form" [(ngModel)]="connectionProperties.record" id="record-checkbox">Record <mat-checkbox class="checkbox-form" [(ngModel)]="connectionProperties.record" id="record-checkbox">Record
</mat-checkbox> </mat-checkbox>
<mat-form-field class="inner-text-input" [style.fontSize.px]=14> <mat-form-field class="inner-text-input" [style.fontSize.px]=14 style="width:33%">
<mat-select [(ngModel)]="connectionProperties.role" id="token-role-select"> <mat-select [(ngModel)]="connectionProperties.role" id="token-role-select">
<mat-option *ngFor="let enumerator of enumToArray(openviduRoles)" [value]="enumerator"> <mat-option *ngFor="let enumerator of enumToArray(openviduRoles)" [value]="enumerator">
<span [attr.id]="'option-' + enumerator">{{ enumerator }}</span> <span [attr.id]="'option-' + enumerator">{{ enumerator }}</span>
</mat-option> </mat-option>
</mat-select> </mat-select>
</mat-form-field> </mat-form-field>
<mat-form-field class="inner-text-input" [style.fontSize.px]=14 style="width:40%">
<input matInput id="connection-data-field" placeholder="data" [(ngModel)]="connectionProperties.data">
</mat-form-field>
</div> </div>
<div> <div>
<button mat-button id="crate-connection-api-btn" (click)="createConnection()">Create connection</button> <button mat-button id="crate-connection-api-btn" (click)="createConnection()">Create connection</button>

View File

@ -28,7 +28,8 @@ export class SessionApiDialogComponent {
connectionProperties: ConnectionProperties = { connectionProperties: ConnectionProperties = {
record: true, record: true,
role: OpenViduRole.PUBLISHER role: OpenViduRole.PUBLISHER,
data: ''
}; };
constructor(public dialogRef: MatDialogRef<SessionApiDialogComponent>, constructor(public dialogRef: MatDialogRef<SessionApiDialogComponent>,
@ -176,7 +177,7 @@ export class SessionApiDialogComponent {
console.log('Creating connection'); console.log('Creating connection');
this.session.createConnection(this.connectionProperties) this.session.createConnection(this.connectionProperties)
.then(connection => { .then(connection => {
this.response = 'Connection created: ' + connection.connectionId; this.response = 'Connection created: ' + JSON.stringify(connection);
}) })
.catch(error => { .catch(error => {
this.response = 'Error [' + error.message + ']'; this.response = 'Error [' + error.message + ']';
@ -187,7 +188,11 @@ export class SessionApiDialogComponent {
console.log('Updating connection'); console.log('Updating connection');
this.session.updateConnection(this.connectionId, this.connectionProperties) this.session.updateConnection(this.connectionId, this.connectionProperties)
.then(modifiedConnection => { .then(modifiedConnection => {
this.response = 'Connection updated: ' + JSON.stringify({ role: modifiedConnection.connectionProperties.role, record: modifiedConnection.connectionProperties.record }); this.response = 'Connection updated: ' + JSON.stringify({
role: modifiedConnection.connectionProperties.role,
record: modifiedConnection.connectionProperties.record,
data: modifiedConnection.connectionProperties.data
});
}) })
.catch(error => { .catch(error => {
this.response = 'Error [' + error.message + ']'; this.response = 'Error [' + error.message + ']';