From 188b5405e155501af46c0ac34996d268dc39728b Mon Sep 17 00:00:00 2001 From: x_gruszma1 Date: Wed, 14 Apr 2021 10:02:06 +0200 Subject: [PATCH] PB-65429 [Virtual Room] Setting up a virtual room via SDK --- .../silanis/esl/api/model/VirtualRoom.java | 70 ++++++++++ .../java/com/silanis/esl/sdk/EslClient.java | 11 ++ .../java/com/silanis/esl/sdk/VirtualRoom.java | 45 +++++++ .../esl/sdk/builder/VirtualRoomBuilder.java | 85 ++++++++++++ .../esl/sdk/examples/VirtualRoomExample.java | 64 +++++++++ .../silanis/esl/sdk/internal/UrlTemplate.java | 3 + .../converter/VirtualRoomConverter.java | 49 +++++++ .../esl/sdk/service/VirtualRoomService.java | 68 ++++++++++ .../sdk/builder/VirtualRoomBuilderTest.java | 32 +++++ .../converter/VirtualRoomConverterTest.java | 122 ++++++++++++++++++ .../sdk/examples/VirtualRoomExampleTest.java | 37 ++++++ 11 files changed, 586 insertions(+) create mode 100644 sdk/src/main/java/com/silanis/esl/api/model/VirtualRoom.java create mode 100644 sdk/src/main/java/com/silanis/esl/sdk/VirtualRoom.java create mode 100644 sdk/src/main/java/com/silanis/esl/sdk/builder/VirtualRoomBuilder.java create mode 100644 sdk/src/main/java/com/silanis/esl/sdk/examples/VirtualRoomExample.java create mode 100644 sdk/src/main/java/com/silanis/esl/sdk/internal/converter/VirtualRoomConverter.java create mode 100644 sdk/src/main/java/com/silanis/esl/sdk/service/VirtualRoomService.java create mode 100644 sdk/src/test/java/com/silanis/esl/sdk/builder/VirtualRoomBuilderTest.java create mode 100644 sdk/src/test/java/com/silanis/esl/sdk/internal/converter/VirtualRoomConverterTest.java create mode 100644 tester/src/test/java/com/silanis/esl/sdk/examples/VirtualRoomExampleTest.java diff --git a/sdk/src/main/java/com/silanis/esl/api/model/VirtualRoom.java b/sdk/src/main/java/com/silanis/esl/api/model/VirtualRoom.java new file mode 100644 index 000000000..c5e610659 --- /dev/null +++ b/sdk/src/main/java/com/silanis/esl/api/model/VirtualRoom.java @@ -0,0 +1,70 @@ +package com.silanis.esl.api.model; + +import com.fasterxml.jackson.annotation.JsonIgnore; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; +import com.fasterxml.jackson.databind.annotation.JsonSerialize; +import com.silanis.esl.api.util.JsonDateSerializer; + +import java.util.Date; + +import static com.silanis.esl.api.util.SchemaSanitizer.throwOnNull; +import static com.silanis.esl.api.util.SchemaSanitizer.trim; + +@JsonIgnoreProperties(ignoreUnknown=true) +public class VirtualRoom extends Model { + + @JsonIgnore + private static final String FIELD_VIDEO = "video"; + @JsonIgnore + private static final String FIELD_VIDEO_RECORDING = "videoRecording"; + @JsonIgnore + private static final String FIELD_START_DATETIME = "startDatetime"; + @JsonIgnore + private static final String FIELD_HOST_UID = "hostUid"; + + private boolean video; + private boolean videoRecording; + private Date startDatetime; + private String hostUid; + + public boolean getVideo() { + return video; + } + + public VirtualRoom setVideo(boolean value) { + this.video = value; + setDirty(FIELD_VIDEO); + return this; + } + + public boolean getVideoRecording() { + return videoRecording; + } + + public VirtualRoom setVideoRecording(boolean value) { + this.videoRecording = value; + setDirty(FIELD_VIDEO_RECORDING); + return this; + } + + @JsonSerialize(using = JsonDateSerializer.class) + public Date getStartDatetime() { + return startDatetime; + } + + public VirtualRoom setStartDatetime(Date value) { + this.startDatetime = value; + setDirty(FIELD_START_DATETIME); + return this; + } + + public String getHostUid() { + return hostUid; + } + + public VirtualRoom setHostUid(String hostUid) { + this.hostUid = hostUid; + setDirty(FIELD_HOST_UID); + return this; + } +} diff --git a/sdk/src/main/java/com/silanis/esl/sdk/EslClient.java b/sdk/src/main/java/com/silanis/esl/sdk/EslClient.java index 5e20a9f38..c524084d1 100644 --- a/sdk/src/main/java/com/silanis/esl/sdk/EslClient.java +++ b/sdk/src/main/java/com/silanis/esl/sdk/EslClient.java @@ -65,6 +65,7 @@ public class EslClient { private SignerVerificationService signerVerificationService; private SigningStyleService signingStyleService; private DataRetentionSettingsService dataRetentionSettingsService; + private VirtualRoomService virtualRoomService; private ProxyConfiguration proxyConfiguration; @@ -167,6 +168,7 @@ private void init(RestClient client) { signerVerificationService = new SignerVerificationService(client, baseURL); signingStyleService = new SigningStyleService(client, baseURL); dataRetentionSettingsService = new DataRetentionSettingsService(client, baseURL); + virtualRoomService = new VirtualRoomService(client, baseURL); } /** @@ -208,6 +210,15 @@ public DataRetentionSettingsService getDataRetentionSettingsService() { return dataRetentionSettingsService; } + /** + * Gets the virtual room config service + * + * @return the virtual room config service + */ + public VirtualRoomService getVirtualRoomService() { + return virtualRoomService; + } + /** * Gets the report service * diff --git a/sdk/src/main/java/com/silanis/esl/sdk/VirtualRoom.java b/sdk/src/main/java/com/silanis/esl/sdk/VirtualRoom.java new file mode 100644 index 000000000..0a03eacd7 --- /dev/null +++ b/sdk/src/main/java/com/silanis/esl/sdk/VirtualRoom.java @@ -0,0 +1,45 @@ +package com.silanis.esl.sdk; + +import java.io.Serializable; +import java.util.Date; + +public class VirtualRoom implements Serializable { + + private boolean video; + private boolean videoRecording; + private Date startDatetime; + private String hostUid; + + public boolean getVideo() { + return video; + } + + public void setVideo(boolean video) { + this.video = video; + } + + public boolean getVideoRecording() { + return videoRecording; + } + + public void setVideoRecording(boolean videoRecording) { + this.videoRecording = videoRecording; + } + + public Date getStartDatetime() { + return startDatetime; + } + + public void setStartDatetime(Date startDatetime) { + this.startDatetime = startDatetime; + } + + public String getHostUid() { + return hostUid; + } + + public void setHostUid(String hostUid) { + this.hostUid = hostUid; + } + +} diff --git a/sdk/src/main/java/com/silanis/esl/sdk/builder/VirtualRoomBuilder.java b/sdk/src/main/java/com/silanis/esl/sdk/builder/VirtualRoomBuilder.java new file mode 100644 index 000000000..f44d096c3 --- /dev/null +++ b/sdk/src/main/java/com/silanis/esl/sdk/builder/VirtualRoomBuilder.java @@ -0,0 +1,85 @@ +package com.silanis.esl.sdk.builder; + +import com.silanis.esl.sdk.VirtualRoom; + +import java.util.Date; + +public class VirtualRoomBuilder { + + private boolean video; + private boolean videoRecording; + private Date startDatetime; + private String hostUid; + + private VirtualRoomBuilder() { + } + + /** + * Create a new Virtual Room. + * + * @return the Virtual Room builder itself + */ + public static VirtualRoomBuilder newVirtualRoom() { + return new VirtualRoomBuilder(); + } + + /** + * Set if video is on + * + * @param video + * @return This + */ + public VirtualRoomBuilder withVideo(boolean video) { + this.video = video; + return this; + } + + /** + * Set if videoRecording is on + * + * @param videoRecording + * @return This + */ + public VirtualRoomBuilder withVideoRecording(boolean videoRecording) { + this.videoRecording = videoRecording; + return this; + } + + /** + * Set startDatetime of virtual room meeting + * + * @param startDatetime + * @return This + */ + + public VirtualRoomBuilder withStartDateTime(Date startDatetime) { + this.startDatetime = startDatetime; + return this; + } + + /** + * Set hostUid for meeting + * + * @param hostUid + * @return This + */ + + public VirtualRoomBuilder withHostUid(String hostUid) { + this.hostUid = hostUid; + return this; + } + + /** + * Builds the actual VirtualRoom with the specified values + * + * @return the VirtualRoom object + */ + public VirtualRoom build() { + VirtualRoom result = new VirtualRoom(); + result.setVideo(video); + result.setStartDatetime(startDatetime); + result.setVideoRecording(videoRecording); + result.setHostUid(hostUid); + return result; + } +} diff --git a/sdk/src/main/java/com/silanis/esl/sdk/examples/VirtualRoomExample.java b/sdk/src/main/java/com/silanis/esl/sdk/examples/VirtualRoomExample.java new file mode 100644 index 000000000..996b834ca --- /dev/null +++ b/sdk/src/main/java/com/silanis/esl/sdk/examples/VirtualRoomExample.java @@ -0,0 +1,64 @@ +package com.silanis.esl.sdk.examples; + +import com.silanis.esl.sdk.DocumentPackage; +import com.silanis.esl.sdk.DocumentType; +import com.silanis.esl.sdk.PackageId; +import com.silanis.esl.sdk.Signer; +import com.silanis.esl.sdk.VirtualRoom; +import com.silanis.esl.sdk.builder.PackageBuilder; +import com.silanis.esl.sdk.builder.SignerBuilder; + +import java.util.Calendar; +import java.util.Date; + +import static com.silanis.esl.sdk.builder.DocumentBuilder.newDocumentWithName; +import static com.silanis.esl.sdk.builder.VirtualRoomBuilder.newVirtualRoom; + +public class VirtualRoomExample extends SDKSample { + + public VirtualRoom packageVirtualRoomRoomAfterUpdate; + + public String hostUid; + public Date startDateTime; + + public static void main(String... args) { + new VirtualRoomExample().run(); + } + + @Override + protected void execute() { + + Signer signer = SignerBuilder.newSignerWithEmail(email1) + .withFirstName("Patty") + .withLastName("Galant") + .build(); + + hostUid = signer.getId(); + Calendar cal = Calendar.getInstance(); + cal.add(Calendar.DAY_OF_MONTH, 7); + startDateTime = cal.getTime(); + + VirtualRoom virtualRoom = newVirtualRoom() + .withHostUid(hostUid) + .withVideo(true) + .withVideoRecording(true) + .withStartDateTime(startDateTime) + .build(); + + DocumentPackage superDuperPackage = PackageBuilder.newPackageNamed(getPackageName()) + .describedAs("Description") + .withSigner(SignerBuilder.newSignerWithEmail(email1) + .withFirstName("Patty") + .withLastName("Galant")) + .withDocument(newDocumentWithName("Document") + .withId("DocumentId") + .fromStream(documentInputStream1, DocumentType.PDF)) + .build(); + + PackageId packageId = eslClient.createPackageOneStep(superDuperPackage); + retrievedPackage = eslClient.getPackage(packageId); + + eslClient.getVirtualRoomService().setVirtualRoom(packageId, virtualRoom); + packageVirtualRoomRoomAfterUpdate = eslClient.getVirtualRoomService().getVirtualRoom(packageId); + } +} diff --git a/sdk/src/main/java/com/silanis/esl/sdk/internal/UrlTemplate.java b/sdk/src/main/java/com/silanis/esl/sdk/internal/UrlTemplate.java index b974ef341..92d5a2e0c 100644 --- a/sdk/src/main/java/com/silanis/esl/sdk/internal/UrlTemplate.java +++ b/sdk/src/main/java/com/silanis/esl/sdk/internal/UrlTemplate.java @@ -158,6 +158,9 @@ public class UrlTemplate { public static final String EXPIRY_TIME_CONFIGURATION_PATH = "/dataRetentionSettings/expiryTimeConfiguration"; public static final String DATA_MANAGEMENT_POLICY_PATH = "/dataRetentionSettings/dataManagementPolicy"; + //VirtualRoomService + public static final String VIRTUAL_ROOM_CONFIG_PATH = "/packages/{packageId}/virtual-room/config"; + // QR Code Service public static final String QRCODE_PATH = "/packages/{packageId}/documents/{documentId}/fields"; public static final String QRCODE_ID_PATH = "/packages/{packageId}/documents/{documentId}/fields/{fieldId}"; diff --git a/sdk/src/main/java/com/silanis/esl/sdk/internal/converter/VirtualRoomConverter.java b/sdk/src/main/java/com/silanis/esl/sdk/internal/converter/VirtualRoomConverter.java new file mode 100644 index 000000000..92ca5426e --- /dev/null +++ b/sdk/src/main/java/com/silanis/esl/sdk/internal/converter/VirtualRoomConverter.java @@ -0,0 +1,49 @@ +package com.silanis.esl.sdk.internal.converter; + +public class VirtualRoomConverter { + + private com.silanis.esl.sdk.VirtualRoom sdkVirtualRoom = null; + private com.silanis.esl.api.model.VirtualRoom apiVirtualRoom = null; + + /** + * Construct with API VirtualRoom object involved in conversion. + * + * @param apiVirtualRoom + */ + public VirtualRoomConverter(com.silanis.esl.api.model.VirtualRoom apiVirtualRoom) { + this.apiVirtualRoom = apiVirtualRoom; + } + + /** + * Construct with SDK VirtualRoom object involved in conversion. + * + * @param sdkVirtualRoom + */ + public VirtualRoomConverter(com.silanis.esl.sdk.VirtualRoom sdkVirtualRoom) { + this.sdkVirtualRoom = sdkVirtualRoom; + } + + public com.silanis.esl.sdk.VirtualRoom toSDKVirtualRoom() { + if (apiVirtualRoom == null) { + return sdkVirtualRoom; + } + com.silanis.esl.sdk.VirtualRoom sdkVirtualRoom = new com.silanis.esl.sdk.VirtualRoom(); + sdkVirtualRoom.setVideo(apiVirtualRoom.getVideo()); + sdkVirtualRoom.setHostUid(apiVirtualRoom.getHostUid()); + sdkVirtualRoom.setStartDatetime(apiVirtualRoom.getStartDatetime()); + sdkVirtualRoom.setVideoRecording(apiVirtualRoom.getVideoRecording()); + return sdkVirtualRoom; + } + + public com.silanis.esl.api.model.VirtualRoom toAPIVirtualRoom() { + if (sdkVirtualRoom == null) { + return apiVirtualRoom; + } + com.silanis.esl.api.model.VirtualRoom apiVirtualRoom = new com.silanis.esl.api.model.VirtualRoom(); + apiVirtualRoom.setVideo(sdkVirtualRoom.getVideo()); + apiVirtualRoom.setHostUid(sdkVirtualRoom.getHostUid()); + apiVirtualRoom.setStartDatetime(sdkVirtualRoom.getStartDatetime()); + apiVirtualRoom.setVideoRecording(sdkVirtualRoom.getVideoRecording()); + return apiVirtualRoom; + } +} diff --git a/sdk/src/main/java/com/silanis/esl/sdk/service/VirtualRoomService.java b/sdk/src/main/java/com/silanis/esl/sdk/service/VirtualRoomService.java new file mode 100644 index 000000000..edc89deb1 --- /dev/null +++ b/sdk/src/main/java/com/silanis/esl/sdk/service/VirtualRoomService.java @@ -0,0 +1,68 @@ +package com.silanis.esl.sdk.service; + +import com.silanis.esl.api.model.VirtualRoom; +import com.silanis.esl.sdk.EslException; +import com.silanis.esl.sdk.PackageId; +import com.silanis.esl.sdk.internal.EslServerException; +import com.silanis.esl.sdk.internal.RequestException; +import com.silanis.esl.sdk.internal.RestClient; +import com.silanis.esl.sdk.internal.Serialization; +import com.silanis.esl.sdk.internal.UrlTemplate; +import com.silanis.esl.sdk.internal.converter.VirtualRoomConverter; + +public class VirtualRoomService { + + private final UrlTemplate template; + private final RestClient client; + + public VirtualRoomService(RestClient client, String baseUrl) { + this.client = client; + template = new UrlTemplate(baseUrl); + } + + /** + * Gets the virtual room configuration for package. + * + * @param packageId + * @return VirtualRoom + */ + public com.silanis.esl.sdk.VirtualRoom getVirtualRoom(PackageId packageId) { + String path = template.urlFor(UrlTemplate.VIRTUAL_ROOM_CONFIG_PATH) + .replace("{packageId}", packageId.getId()) + .build(); + String stringResponse; + try { + stringResponse = client.get(path); + } catch (RequestException e) { + throw new EslServerException("Could not get virtual room configuration.", e); + } catch (Exception e) { + throw new EslException("Could not get virtual room configuration.", e); + } + + VirtualRoom virtualRoom = Serialization.fromJson(stringResponse, VirtualRoom.class); + VirtualRoomConverter converter = new VirtualRoomConverter(virtualRoom); + return converter.toSDKVirtualRoom(); + } + + /** + * Update virtual room configuration for package. + * + * @param packageId + * @param virtualRoom + */ + public void setVirtualRoom(PackageId packageId, com.silanis.esl.sdk.VirtualRoom virtualRoom) { + String path = template.urlFor(UrlTemplate.VIRTUAL_ROOM_CONFIG_PATH) + .replace("{packageId}", packageId.getId()) + .build(); + VirtualRoomConverter converter = new VirtualRoomConverter(virtualRoom); + String virtualRoomJson = Serialization.toJson(converter.toAPIVirtualRoom()); + + try { + client.put(path, virtualRoomJson); + } catch (RequestException e) { + throw new EslServerException("Could not update virtualRoom", e); + } catch (Exception e) { + throw new EslException("Could not update virtualRoom", e); + } + } +} diff --git a/sdk/src/test/java/com/silanis/esl/sdk/builder/VirtualRoomBuilderTest.java b/sdk/src/test/java/com/silanis/esl/sdk/builder/VirtualRoomBuilderTest.java new file mode 100644 index 000000000..1e899c94c --- /dev/null +++ b/sdk/src/test/java/com/silanis/esl/sdk/builder/VirtualRoomBuilderTest.java @@ -0,0 +1,32 @@ +package com.silanis.esl.sdk.builder; + +import com.silanis.esl.sdk.VirtualRoom; +import com.silanis.esl.sdk.TransactionRetention; +import org.hamcrest.Matchers; +import org.junit.Test; + +import java.util.Date; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.core.Is.is; + +public class VirtualRoomBuilderTest { + + @Test + public void withSpecifiedValues() { + Date startDateTime = new Date(); + VirtualRoomBuilder builder = VirtualRoomBuilder.newVirtualRoom() + .withVideo(true) + .withVideoRecording(true) + .withStartDateTime(startDateTime) + .withHostUid("hostUid"); + + VirtualRoom result = builder.build(); + + assertThat(result, is(Matchers.notNullValue())); + assertThat(result.getVideo(), is(true)); + assertThat(result.getVideoRecording(), is(true)); + assertThat(result.getStartDatetime(), is(startDateTime)); + assertThat(result.getHostUid(), is("hostUid")); + } +} diff --git a/sdk/src/test/java/com/silanis/esl/sdk/internal/converter/VirtualRoomConverterTest.java b/sdk/src/test/java/com/silanis/esl/sdk/internal/converter/VirtualRoomConverterTest.java new file mode 100644 index 000000000..297830175 --- /dev/null +++ b/sdk/src/test/java/com/silanis/esl/sdk/internal/converter/VirtualRoomConverterTest.java @@ -0,0 +1,122 @@ +package com.silanis.esl.sdk.internal.converter; + +import com.silanis.esl.sdk.VirtualRoom; +import org.junit.Test; + +import java.util.Date; + +import static org.hamcrest.MatcherAssert.assertThat; +import static org.hamcrest.Matchers.notNullValue; +import static org.hamcrest.Matchers.nullValue; +import static org.hamcrest.core.Is.is; +import static org.hamcrest.core.IsEqual.equalTo; + +public class VirtualRoomConverterTest implements ConverterTest { + + private com.silanis.esl.sdk.VirtualRoom sdkVirtualRoom1 = null; + private com.silanis.esl.sdk.VirtualRoom sdkVirtualRoom2 = null; + private com.silanis.esl.api.model.VirtualRoom apiVirtualRoom1 = null; + private com.silanis.esl.api.model.VirtualRoom apiVirtualRoom2 = null; + private VirtualRoomConverter converter = null; + + @Override + @Test + public void convertNullSDKToAPI() { + sdkVirtualRoom1 = null; + converter = new VirtualRoomConverter(sdkVirtualRoom1); + assertThat("Converter didn't return a null sdk object for a null api object", converter.toAPIVirtualRoom(), is(nullValue())); + + } + + @Override + @Test + public void convertNullAPIToSDK() { + apiVirtualRoom1 = null; + converter = new VirtualRoomConverter(apiVirtualRoom1); + assertThat("Converter didn't return a null api object for a null sdk object", converter.toSDKVirtualRoom(), is(nullValue())); + + } + + @Override + @Test + public void convertNullSDKToSDK() { + sdkVirtualRoom1 = null; + converter = new VirtualRoomConverter(sdkVirtualRoom1); + assertThat("Converter didn't return a null sdk object for a null sdk object", converter.toSDKVirtualRoom(), is(nullValue())); + + } + + @Override + @Test + public void convertNullAPIToAPI() { + apiVirtualRoom1 = null; + converter = new VirtualRoomConverter(apiVirtualRoom1); + assertThat("Converter didn't return a null api object for a null api object", converter.toAPIVirtualRoom(), is(nullValue())); + + } + + @Override + @Test + public void convertSDKToSDK() { + sdkVirtualRoom1 = new VirtualRoom(); + sdkVirtualRoom2 = new VirtualRoomConverter(sdkVirtualRoom1).toSDKVirtualRoom(); + assertThat("Converter returned a null sdk object for a non null sdk object", sdkVirtualRoom2, is(notNullValue())); + assertThat("Converter didn't return the same non-null sdk object it was given", sdkVirtualRoom2, is(equalTo(sdkVirtualRoom1))); + } + + @Override + @Test + public void convertAPIToAPI() { + apiVirtualRoom1 = new com.silanis.esl.api.model.VirtualRoom(); + apiVirtualRoom2 = new VirtualRoomConverter(apiVirtualRoom1).toAPIVirtualRoom(); + + assertThat("Converter returned a null api object for a non null api object", apiVirtualRoom2, is(notNullValue())); + assertThat("Converter didn't return the same non-null api object it was given", apiVirtualRoom2, is(equalTo(apiVirtualRoom1))); + + } + + @Override + @Test + public void convertAPIToSDK() { + apiVirtualRoom1 = buildApiVirtualRoom(); + sdkVirtualRoom1 = new VirtualRoomConverter(apiVirtualRoom1).toSDKVirtualRoom(); + + assertThat("Converter returned a null api object for a non null sdk object", sdkVirtualRoom1, is(notNullValue())); + assertThat("Video Value was not correctly set", sdkVirtualRoom1.getVideo(), is(apiVirtualRoom1.getVideo())); + assertThat("VideoRecording Value was not correctly set", sdkVirtualRoom1.getVideoRecording(), is(apiVirtualRoom1.getVideoRecording())); + assertThat("HostUid Value was not correctly set", sdkVirtualRoom1.getHostUid(), is(apiVirtualRoom1.getHostUid())); + assertThat("StartDatetime Value was not correctly set", sdkVirtualRoom1.getStartDatetime(), is(apiVirtualRoom1.getStartDatetime())); + } + + @Override + @Test + public void convertSDKToAPI() { + sdkVirtualRoom1 = buildSdkVirtualRoom(); + apiVirtualRoom1 = new VirtualRoomConverter(sdkVirtualRoom1).toAPIVirtualRoom(); + + assertThat("Converter returned a null api object for a non null sdk object", apiVirtualRoom1, is(notNullValue())); + assertThat("Video Value was not correctly set", apiVirtualRoom1.getVideo(), is(sdkVirtualRoom1.getVideo())); + assertThat("VideoRecording Value was not correctly set", apiVirtualRoom1.getVideoRecording(), is(sdkVirtualRoom1.getVideoRecording())); + assertThat("HostUid Value was not correctly set", apiVirtualRoom1.getHostUid(), is(sdkVirtualRoom1.getHostUid())); + assertThat("StartDatetime Value was not correctly set", apiVirtualRoom1.getStartDatetime(), is(sdkVirtualRoom1.getStartDatetime())); + } + + private VirtualRoom buildSdkVirtualRoom() { + VirtualRoom result = new VirtualRoom(); + result.setVideo(true); + result.setVideoRecording(true); + result.setHostUid("hostUid"); + result.setStartDatetime(new Date()); + return result; + } + + + private com.silanis.esl.api.model.VirtualRoom buildApiVirtualRoom() { + com.silanis.esl.api.model.VirtualRoom result = new com.silanis.esl.api.model.VirtualRoom(); + result.setVideo(true); + result.setVideoRecording(true); + result.setHostUid("hostUid"); + result.setStartDatetime(new Date()); + return result; + } +} \ No newline at end of file diff --git a/tester/src/test/java/com/silanis/esl/sdk/examples/VirtualRoomExampleTest.java b/tester/src/test/java/com/silanis/esl/sdk/examples/VirtualRoomExampleTest.java new file mode 100644 index 000000000..886403df7 --- /dev/null +++ b/tester/src/test/java/com/silanis/esl/sdk/examples/VirtualRoomExampleTest.java @@ -0,0 +1,37 @@ +package com.silanis.esl.sdk.examples; + +import org.junit.Test; + +import java.text.SimpleDateFormat; +import java.util.Date; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.MatcherAssert.assertThat; +import static org.junit.Assert.fail; + +public class VirtualRoomExampleTest { + + @Test + public void verifyResult() { + VirtualRoomExample example = new VirtualRoomExample(); + example.run(); + + // Verify if the VirtualRoom was updated correctly. + assertThat(example.packageVirtualRoomRoomAfterUpdate.getHostUid(), is(example.hostUid)); + assertDate(example.packageVirtualRoomRoomAfterUpdate.getStartDatetime(), example.startDateTime); + assertThat(example.packageVirtualRoomRoomAfterUpdate.getVideo(), is(true)); + assertThat(example.packageVirtualRoomRoomAfterUpdate.getVideoRecording(), is(true)); + } + + private void assertDate(Date actual, Date expected) { + if (actual == null) { + if (expected == null) + return; + else + fail(); + } + + SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm"); + assertThat(sdf.format(actual), is(sdf.format(expected))); + } +}