openvidu-test-e2e: webhook test extended

pull/375/head
pabloFuente 2019-06-25 10:19:16 +02:00
parent 5c68027257
commit a72804ea99
2 changed files with 34 additions and 5 deletions

View File

@ -2767,7 +2767,20 @@ public class OpenViduTestAppE2eTest {
CustomWebhook.waitForEvent("webrtcConnectionCreated", 2);
JsonObject event = CustomWebhook.waitForEvent("recordingStatusChanged", 10);
Assert.assertEquals("Wrong recording status in webhook event", "started", event.get("status").getAsString());
Assert.assertEquals("Wrong recording status in webhook event", "started",
event.get("status").getAsString());
Assert.assertEquals("Wrong recording outputMode in webhook event", "INDIVIDUAL",
event.get("outputMode").getAsString());
Assert.assertEquals("Wrong recording outputMode in webhook event", 0, event.get("size").getAsLong());
Assert.assertEquals("Wrong recording outputMode in webhook event", 0, event.get("duration").getAsLong());
user.getDriver().findElement(By.id("add-user-btn")).click();
user.getDriver().findElement(By.cssSelector("#openvidu-instance-1 .join-btn")).click();
CustomWebhook.waitForEvent("participantJoined", 2);
CustomWebhook.waitForEvent("webrtcConnectionCreated", 2);
CustomWebhook.waitForEvent("webrtcConnectionCreated", 2);
CustomWebhook.waitForEvent("webrtcConnectionCreated", 2);
user.getDriver().findElement(By.id("session-api-btn-0")).click();
Thread.sleep(1000);
@ -2776,11 +2789,23 @@ public class OpenViduTestAppE2eTest {
Thread.sleep(1000);
CustomWebhook.waitForEvent("webrtcConnectionDestroyed", 2);
CustomWebhook.waitForEvent("webrtcConnectionDestroyed", 2);
CustomWebhook.waitForEvent("webrtcConnectionDestroyed", 2);
CustomWebhook.waitForEvent("webrtcConnectionDestroyed", 2);
CustomWebhook.waitForEvent("participantLeft", 2);
CustomWebhook.waitForEvent("participantLeft", 2);
event = CustomWebhook.waitForEvent("recordingStatusChanged", 2);
Assert.assertEquals("Wrong recording status in webhook event", "processing", event.get("status").getAsString());
Assert.assertEquals("Wrong recording status in webhook event", "processing",
event.get("status").getAsString());
Assert.assertEquals("Wrong recording outputMode in webhook event", 0, event.get("size").getAsLong());
Assert.assertEquals("Wrong recording outputMode in webhook event", 0, event.get("duration").getAsLong());
event = CustomWebhook.waitForEvent("recordingStatusChanged", 2);
Assert.assertEquals("Wrong recording status in webhook event", "stopped", event.get("status").getAsString());
Assert.assertEquals("Wrong recording status in webhook event", "stopped",
event.get("status").getAsString());
Assert.assertTrue("Wrong recording outputMode in webhook event", event.get("size").getAsLong() > 0);
Assert.assertTrue("Wrong recording outputMode in webhook event", event.get("duration").getAsLong() > 0);
CustomWebhook.waitForEvent("sessionDestroyed", 2);

View File

@ -25,6 +25,8 @@ import java.util.concurrent.CountDownLatch;
import java.util.concurrent.LinkedBlockingDeque;
import java.util.concurrent.TimeUnit;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.context.event.ApplicationReadyEvent;
@ -40,6 +42,8 @@ import com.google.gson.JsonParser;
@SpringBootApplication
public class CustomWebhook {
private static final Logger log = LoggerFactory.getLogger(CustomWebhook.class);
private static ConfigurableApplicationContext context;
public static CountDownLatch initLatch;
@ -57,7 +61,7 @@ public class CustomWebhook {
CustomWebhook.context.close();
}
public static JsonObject waitForEvent(String eventName, int maxSecondsWait) throws Exception {
public synchronized static JsonObject waitForEvent(String eventName, int maxSecondsWait) throws Exception {
if (events.get(eventName) == null) {
events.put(eventName, new LinkedBlockingDeque<>());
}
@ -75,7 +79,7 @@ public class CustomWebhook {
public void greeting(@RequestBody String eventString) {
JsonObject event = (JsonObject) jsonParser.parse(eventString);
final String eventName = event.get("event").getAsString();
System.out.println(event.toString());
log.info("Webhook event: {}", event.toString());
if (events.get(eventName) == null) {
events.put(eventName, new LinkedBlockingDeque<>());
}