From 81ab25748f4901e15f0b9eddd4807fdc41b857f6 Mon Sep 17 00:00:00 2001 From: Nick Cook Date: Tue, 6 Aug 2024 09:08:09 -0700 Subject: [PATCH 1/3] feat(videostitcher): update other samples using feedback from #9412 --- .../com/example/stitcher/CreateCdnKey.java | 76 +++++----- .../example/stitcher/CreateCdnKeyAkamai.java | 48 +++---- .../example/stitcher/CreateLiveConfig.java | 49 ++++--- .../example/stitcher/CreateLiveSession.java | 9 +- .../com/example/stitcher/CreateSlate.java | 35 ++--- .../example/stitcher/CreateVodSession.java | 2 + .../com/example/stitcher/DeleteCdnKey.java | 26 ++-- .../example/stitcher/DeleteLiveConfig.java | 26 ++-- .../com/example/stitcher/DeleteSlate.java | 26 ++-- .../java/com/example/stitcher/GetCdnKey.java | 7 +- .../example/stitcher/GetLiveAdTagDetail.java | 7 +- .../com/example/stitcher/GetLiveConfig.java | 7 +- .../com/example/stitcher/GetLiveSession.java | 7 +- .../java/com/example/stitcher/GetSlate.java | 7 +- .../com/example/stitcher/ListCdnKeys.java | 10 +- .../stitcher/ListLiveAdTagDetails.java | 10 +- .../com/example/stitcher/ListLiveConfigs.java | 10 +- .../java/com/example/stitcher/ListSlates.java | 10 +- .../com/example/stitcher/UpdateCdnKey.java | 88 ++++++------ .../example/stitcher/UpdateCdnKeyAkamai.java | 54 +++---- .../com/example/stitcher/UpdateSlate.java | 42 +++--- ...{UpdateCdnKeyTest.java => CdnKeyTest.java} | 130 +++++++++++++---- .../stitcher/CreateCdnKeyAkamaiTest.java | 89 ------------ .../example/stitcher/CreateCdnKeyTest.java | 108 -------------- .../stitcher/CreateLiveConfigTest.java | 95 ------------- .../stitcher/CreateLiveSessionTest.java | 96 ------------- .../com/example/stitcher/CreateSlateTest.java | 88 ------------ .../example/stitcher/DeleteCdnKeyTest.java | 115 --------------- .../stitcher/DeleteLiveConfigTest.java | 92 ------------ .../com/example/stitcher/DeleteSlateTest.java | 86 ----------- .../com/example/stitcher/GetCdnKeyTest.java | 129 ----------------- .../example/stitcher/GetLiveSessionTest.java | 111 --------------- .../com/example/stitcher/GetSlateTest.java | 91 ------------ .../com/example/stitcher/ListCdnKeysTest.java | 116 --------------- .../stitcher/ListLiveAdTagDetailsTest.java | 133 ------------------ .../example/stitcher/ListLiveConfigsTest.java | 97 ------------- .../com/example/stitcher/ListSlatesTest.java | 91 ------------ ...iveConfigTest.java => LiveConfigTest.java} | 78 ++++++---- ...agDetailTest.java => LiveSessionTest.java} | 130 ++++++++++------- .../{UpdateSlateTest.java => SlateTest.java} | 77 +++++++--- .../java/com/example/stitcher/TestUtils.java | 10 -- .../stitcher/UpdateCdnKeyAkamaiTest.java | 96 ------------- .../com/example/stitcher/VodConfigTest.java | 3 +- .../com/example/stitcher/VodSessionTest.java | 3 +- 44 files changed, 580 insertions(+), 2040 deletions(-) rename media/stitcher/src/test/java/com/example/stitcher/{UpdateCdnKeyTest.java => CdnKeyTest.java} (53%) delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/CreateCdnKeyAkamaiTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/CreateCdnKeyTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/CreateLiveConfigTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/CreateLiveSessionTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/CreateSlateTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/DeleteCdnKeyTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/DeleteLiveConfigTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/DeleteSlateTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/GetCdnKeyTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/GetLiveSessionTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/GetSlateTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/ListCdnKeysTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/ListLiveAdTagDetailsTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/ListLiveConfigsTest.java delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/ListSlatesTest.java rename media/stitcher/src/test/java/com/example/stitcher/{GetLiveConfigTest.java => LiveConfigTest.java} (62%) rename media/stitcher/src/test/java/com/example/stitcher/{GetLiveAdTagDetailTest.java => LiveSessionTest.java} (56%) rename media/stitcher/src/test/java/com/example/stitcher/{UpdateSlateTest.java => SlateTest.java} (60%) delete mode 100644 media/stitcher/src/test/java/com/example/stitcher/UpdateCdnKeyAkamaiTest.java diff --git a/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKey.java b/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKey.java index 5c33e45e49b..71feefe318d 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKey.java +++ b/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKey.java @@ -51,7 +51,7 @@ public static void main(String[] args) throws Exception { // createCdnKey creates a Media CDN key or a Cloud CDN key. A CDN key is used to retrieve // protected media. - public static void createCdnKey( + public static CdnKey createCdnKey( String projectId, String location, String cdnKeyId, @@ -61,45 +61,45 @@ public static void createCdnKey( Boolean isMediaCdn) throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. After completing all of your requests, call - // the "close" method on the client to safely clean up any remaining background resources. - VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create(); - CdnKey cdnKey; - if (isMediaCdn) { - cdnKey = - CdnKey.newBuilder() - .setHostname(hostname) - .setMediaCdnKey( - MediaCdnKey.newBuilder() - .setKeyName(keyName) - .setPrivateKey(ByteString.copyFromUtf8(privateKey)) - .build()) - .build(); - } else { - cdnKey = - CdnKey.newBuilder() - .setHostname(hostname) - .setGoogleCdnKey( - GoogleCdnKey.newBuilder() - .setKeyName(keyName) - .setPrivateKey(ByteString.copyFromUtf8(privateKey)) - .build()) - .build(); - } + // once, and can be reused for multiple requests. + try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + CdnKey cdnKey; + if (isMediaCdn) { + cdnKey = + CdnKey.newBuilder() + .setHostname(hostname) + .setMediaCdnKey( + MediaCdnKey.newBuilder() + .setKeyName(keyName) + .setPrivateKey(ByteString.copyFromUtf8(privateKey)) + .build()) + .build(); + } else { + cdnKey = + CdnKey.newBuilder() + .setHostname(hostname) + .setGoogleCdnKey( + GoogleCdnKey.newBuilder() + .setKeyName(keyName) + .setPrivateKey(ByteString.copyFromUtf8(privateKey)) + .build()) + .build(); + } - CreateCdnKeyRequest createCdnKeyRequest = - CreateCdnKeyRequest.newBuilder() - .setParent(LocationName.of(projectId, location).toString()) - .setCdnKeyId(cdnKeyId) - .setCdnKey(cdnKey) - .build(); + CreateCdnKeyRequest createCdnKeyRequest = + CreateCdnKeyRequest.newBuilder() + .setParent(LocationName.of(projectId, location).toString()) + .setCdnKeyId(cdnKeyId) + .setCdnKey(cdnKey) + .build(); - CdnKey result = - videoStitcherServiceClient - .createCdnKeyAsync(createCdnKeyRequest) - .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); - System.out.println("Created new CDN key: " + result.getName()); - videoStitcherServiceClient.close(); + CdnKey result = + videoStitcherServiceClient + .createCdnKeyAsync(createCdnKeyRequest) + .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); + System.out.println("Created new CDN key: " + result.getName()); + return result; + } } } // [END videostitcher_create_cdn_key] diff --git a/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKeyAkamai.java b/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKeyAkamai.java index 35932096be9..df74c98bbfa 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKeyAkamai.java +++ b/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKeyAkamai.java @@ -45,35 +45,35 @@ public static void main(String[] args) throws Exception { } // createCdnKeyAkamai creates an Akamai CDN key. A CDN key is used to retrieve protected media. - public static void createCdnKeyAkamai( + public static CdnKey createCdnKeyAkamai( String projectId, String location, String cdnKeyId, String hostname, String akamaiTokenKey) throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. After completing all of your requests, call - // the "close" method on the client to safely clean up any remaining background resources. - VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create(); - CdnKey cdnKey = - CdnKey.newBuilder() - .setHostname(hostname) - .setAkamaiCdnKey( - AkamaiCdnKey.newBuilder() - .setTokenKey(ByteString.copyFromUtf8(akamaiTokenKey)) - .build()) - .build(); + // once, and can be reused for multiple requests. + try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + CdnKey cdnKey = + CdnKey.newBuilder() + .setHostname(hostname) + .setAkamaiCdnKey( + AkamaiCdnKey.newBuilder() + .setTokenKey(ByteString.copyFromUtf8(akamaiTokenKey)) + .build()) + .build(); - CreateCdnKeyRequest createCdnKeyRequest = - CreateCdnKeyRequest.newBuilder() - .setParent(LocationName.of(projectId, location).toString()) - .setCdnKeyId(cdnKeyId) - .setCdnKey(cdnKey) - .build(); + CreateCdnKeyRequest createCdnKeyRequest = + CreateCdnKeyRequest.newBuilder() + .setParent(LocationName.of(projectId, location).toString()) + .setCdnKeyId(cdnKeyId) + .setCdnKey(cdnKey) + .build(); - CdnKey result = - videoStitcherServiceClient - .createCdnKeyAsync(createCdnKeyRequest) - .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); - System.out.println("Created new CDN key: " + result.getName()); - videoStitcherServiceClient.close(); + CdnKey result = + videoStitcherServiceClient + .createCdnKeyAsync(createCdnKeyRequest) + .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); + System.out.println("Created new CDN key: " + result.getName()); + return result; + } } } // [END videostitcher_create_cdn_key_akamai] diff --git a/media/stitcher/src/main/java/com/example/stitcher/CreateLiveConfig.java b/media/stitcher/src/main/java/com/example/stitcher/CreateLiveConfig.java index 1ce28a71553..82364ab4b25 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/CreateLiveConfig.java +++ b/media/stitcher/src/main/java/com/example/stitcher/CreateLiveConfig.java @@ -50,7 +50,10 @@ public static void main(String[] args) throws Exception { createLiveConfig(projectId, location, liveConfigId, sourceUri, adTagUri, slateId); } - public static void createLiveConfig( + // Creates a live config. Live configs are used to configure live sessions. + // For more information, see + // https://cloud.google.com/video-stitcher/docs/how-to/managing-live-configs. + public static LiveConfig createLiveConfig( String projectId, String location, String liveConfigId, @@ -59,29 +62,29 @@ public static void createLiveConfig( String slateId) throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. After completing all of your requests, call - // the "close" method on the client to safely clean up any remaining background resources. - VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create(); - CreateLiveConfigRequest createLiveConfigRequest = - CreateLiveConfigRequest.newBuilder() - .setParent(LocationName.of(projectId, location).toString()) - .setLiveConfigId(liveConfigId) - .setLiveConfig( - LiveConfig.newBuilder() - .setSourceUri(sourceUri) - .setAdTagUri(adTagUri) - .setDefaultSlate(SlateName.format(projectId, location, slateId)) - .setAdTracking(AdTracking.SERVER) - .setStitchingPolicy(StitchingPolicy.CUT_CURRENT) - .build()) - .build(); + // once, and can be reused for multiple requests. + try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + CreateLiveConfigRequest createLiveConfigRequest = + CreateLiveConfigRequest.newBuilder() + .setParent(LocationName.of(projectId, location).toString()) + .setLiveConfigId(liveConfigId) + .setLiveConfig( + LiveConfig.newBuilder() + .setSourceUri(sourceUri) + .setAdTagUri(adTagUri) + .setDefaultSlate(SlateName.format(projectId, location, slateId)) + .setAdTracking(AdTracking.SERVER) + .setStitchingPolicy(StitchingPolicy.CUT_CURRENT) + .build()) + .build(); - LiveConfig response = - videoStitcherServiceClient - .createLiveConfigAsync(createLiveConfigRequest) - .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); - System.out.println("Created new live config: " + response.getName()); - videoStitcherServiceClient.close(); + LiveConfig response = + videoStitcherServiceClient + .createLiveConfigAsync(createLiveConfigRequest) + .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); + System.out.println("Created new live config: " + response.getName()); + return response; + } } } // [END videostitcher_create_live_config] diff --git a/media/stitcher/src/main/java/com/example/stitcher/CreateLiveSession.java b/media/stitcher/src/main/java/com/example/stitcher/CreateLiveSession.java index cc0b3020ba0..ae1422660bf 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/CreateLiveSession.java +++ b/media/stitcher/src/main/java/com/example/stitcher/CreateLiveSession.java @@ -36,11 +36,13 @@ public static void main(String[] args) throws Exception { createLiveSession(projectId, location, liveConfigId); } - public static void createLiveSession(String projectId, String location, String liveConfigId) + // Creates a live session given the parameters in the supplied live config. + // For more information, see + // https://cloud.google.com/video-stitcher/docs/how-to/managing-live-sessions. + public static LiveSession createLiveSession(String projectId, String location, String liveConfigId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. In this example, try-with-resources is used - // which automatically calls close() on the client to clean up resources. + // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { CreateLiveSessionRequest createLiveSessionRequest = @@ -54,6 +56,7 @@ public static void createLiveSession(String projectId, String location, String l LiveSession response = videoStitcherServiceClient.createLiveSession(createLiveSessionRequest); System.out.println("Created live session: " + response.getName()); System.out.println("Play URI: " + response.getPlayUri()); + return response; } } } diff --git a/media/stitcher/src/main/java/com/example/stitcher/CreateSlate.java b/media/stitcher/src/main/java/com/example/stitcher/CreateSlate.java index 31e2a26099d..6ff255ff56d 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/CreateSlate.java +++ b/media/stitcher/src/main/java/com/example/stitcher/CreateSlate.java @@ -42,25 +42,28 @@ public static void main(String[] args) throws Exception { createSlate(projectId, location, slateId, slateUri); } - public static void createSlate(String projectId, String location, String slateId, String slateUri) + // Creates a slate. Slates are content that can be served when there are gaps in a livestream + // ad break that cannot be filled with a dynamically served ad. For more information, see + // https://cloud.google.com/video-stitcher/docs/how-to/managing-slates. + public static Slate createSlate(String projectId, String location, String slateId, String slateUri) throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. After completing all of your requests, call - // the "close" method on the client to safely clean up any remaining background resources. - VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create(); - CreateSlateRequest createSlateRequest = - CreateSlateRequest.newBuilder() - .setParent(LocationName.of(projectId, location).toString()) - .setSlateId(slateId) - .setSlate(Slate.newBuilder().setUri(slateUri).build()) - .build(); + // once, and can be reused for multiple requests. + try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + CreateSlateRequest createSlateRequest = + CreateSlateRequest.newBuilder() + .setParent(LocationName.of(projectId, location).toString()) + .setSlateId(slateId) + .setSlate(Slate.newBuilder().setUri(slateUri).build()) + .build(); - Slate response = - videoStitcherServiceClient - .createSlateAsync(createSlateRequest) - .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); - System.out.println("Created new slate: " + response.getName()); - videoStitcherServiceClient.close(); + Slate response = + videoStitcherServiceClient + .createSlateAsync(createSlateRequest) + .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); + System.out.println("Created new slate: " + response.getName()); + return response; + } } } // [END videostitcher_create_slate] diff --git a/media/stitcher/src/main/java/com/example/stitcher/CreateVodSession.java b/media/stitcher/src/main/java/com/example/stitcher/CreateVodSession.java index 7076c90835e..c85e2ae263f 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/CreateVodSession.java +++ b/media/stitcher/src/main/java/com/example/stitcher/CreateVodSession.java @@ -38,6 +38,8 @@ public static void main(String[] args) throws Exception { } // Creates a video on demand (VOD) session using the parameters in the designated VOD config. + // For more information, see + // https://cloud.google.com/video-stitcher/docs/how-to/creating-vod-sessions. public static VodSession createVodSession(String projectId, String location, String vodConfigId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created diff --git a/media/stitcher/src/main/java/com/example/stitcher/DeleteCdnKey.java b/media/stitcher/src/main/java/com/example/stitcher/DeleteCdnKey.java index 98311e33fb1..b626e1d7011 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/DeleteCdnKey.java +++ b/media/stitcher/src/main/java/com/example/stitcher/DeleteCdnKey.java @@ -39,22 +39,22 @@ public static void main(String[] args) throws Exception { deleteCdnKey(projectId, location, cdnKeyId); } + // Deletes a CDN key. public static void deleteCdnKey(String projectId, String location, String cdnKeyId) throws InterruptedException, ExecutionException, TimeoutException, IOException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. After completing all of your requests, call - // the "close" method on the client to safely clean up any remaining background resources. - VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create(); - DeleteCdnKeyRequest deleteCdnKeyRequest = - DeleteCdnKeyRequest.newBuilder() - .setName(CdnKeyName.of(projectId, location, cdnKeyId).toString()) - .build(); - - videoStitcherServiceClient - .deleteCdnKeyAsync(deleteCdnKeyRequest) - .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); - System.out.println("Deleted CDN key"); - videoStitcherServiceClient.close(); + // once, and can be reused for multiple requests. + try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + DeleteCdnKeyRequest deleteCdnKeyRequest = + DeleteCdnKeyRequest.newBuilder() + .setName(CdnKeyName.of(projectId, location, cdnKeyId).toString()) + .build(); + + videoStitcherServiceClient + .deleteCdnKeyAsync(deleteCdnKeyRequest) + .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); + System.out.println("Deleted CDN key"); + } } } // [END videostitcher_delete_cdn_key] diff --git a/media/stitcher/src/main/java/com/example/stitcher/DeleteLiveConfig.java b/media/stitcher/src/main/java/com/example/stitcher/DeleteLiveConfig.java index efe30973446..5cd2f883d79 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/DeleteLiveConfig.java +++ b/media/stitcher/src/main/java/com/example/stitcher/DeleteLiveConfig.java @@ -39,22 +39,22 @@ public static void main(String[] args) throws Exception { deleteLiveConfig(projectId, location, liveConfigId); } + // Deletes a live config. public static void deleteLiveConfig(String projectId, String location, String liveConfigId) throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. After completing all of your requests, call - // the "close" method on the client to safely clean up any remaining background resources. - VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create(); - DeleteLiveConfigRequest deleteLiveConfigRequest = - DeleteLiveConfigRequest.newBuilder() - .setName(LiveConfigName.of(projectId, location, liveConfigId).toString()) - .build(); - - videoStitcherServiceClient - .deleteLiveConfigAsync(deleteLiveConfigRequest) - .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); - System.out.println("Deleted live config"); - videoStitcherServiceClient.close(); + // once, and can be reused for multiple requests. + try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + DeleteLiveConfigRequest deleteLiveConfigRequest = + DeleteLiveConfigRequest.newBuilder() + .setName(LiveConfigName.of(projectId, location, liveConfigId).toString()) + .build(); + + videoStitcherServiceClient + .deleteLiveConfigAsync(deleteLiveConfigRequest) + .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); + System.out.println("Deleted live config"); + } } } // [END videostitcher_delete_live_config] diff --git a/media/stitcher/src/main/java/com/example/stitcher/DeleteSlate.java b/media/stitcher/src/main/java/com/example/stitcher/DeleteSlate.java index faf5ab091ab..0a083acd6c3 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/DeleteSlate.java +++ b/media/stitcher/src/main/java/com/example/stitcher/DeleteSlate.java @@ -39,22 +39,22 @@ public static void main(String[] args) throws Exception { deleteSlate(projectId, location, slateId); } + // Deletes a slate. public static void deleteSlate(String projectId, String location, String slateId) throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. After completing all of your requests, call - // the "close" method on the client to safely clean up any remaining background resources. - VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create(); - DeleteSlateRequest deleteSlateRequest = - DeleteSlateRequest.newBuilder() - .setName(SlateName.of(projectId, location, slateId).toString()) - .build(); - - videoStitcherServiceClient - .deleteSlateAsync(deleteSlateRequest) - .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); - System.out.println("Deleted slate"); - videoStitcherServiceClient.close(); + // once, and can be reused for multiple requests. + try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + DeleteSlateRequest deleteSlateRequest = + DeleteSlateRequest.newBuilder() + .setName(SlateName.of(projectId, location, slateId).toString()) + .build(); + + videoStitcherServiceClient + .deleteSlateAsync(deleteSlateRequest) + .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); + System.out.println("Deleted slate"); + } } } // [END videostitcher_delete_slate] diff --git a/media/stitcher/src/main/java/com/example/stitcher/GetCdnKey.java b/media/stitcher/src/main/java/com/example/stitcher/GetCdnKey.java index 9b6c7f0401f..10ca42cfe62 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/GetCdnKey.java +++ b/media/stitcher/src/main/java/com/example/stitcher/GetCdnKey.java @@ -35,11 +35,11 @@ public static void main(String[] args) throws Exception { getCdnKey(projectId, location, cdnKeyId); } - public static void getCdnKey(String projectId, String location, String cdnKeyId) + // Gets a CDN key. + public static CdnKey getCdnKey(String projectId, String location, String cdnKeyId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. In this example, try-with-resources is used - // which automatically calls close() on the client to clean up resources. + // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { GetCdnKeyRequest getCdnKeyRequest = @@ -49,6 +49,7 @@ public static void getCdnKey(String projectId, String location, String cdnKeyId) CdnKey response = videoStitcherServiceClient.getCdnKey(getCdnKeyRequest); System.out.println("CDN key: " + response.getName()); + return response; } } } diff --git a/media/stitcher/src/main/java/com/example/stitcher/GetLiveAdTagDetail.java b/media/stitcher/src/main/java/com/example/stitcher/GetLiveAdTagDetail.java index 50fb910c940..482dc74f85c 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/GetLiveAdTagDetail.java +++ b/media/stitcher/src/main/java/com/example/stitcher/GetLiveAdTagDetail.java @@ -36,12 +36,12 @@ public static void main(String[] args) throws Exception { getLiveAdTagDetail(projectId, location, sessionId, adTagDetailId); } - public static void getLiveAdTagDetail( + // Gets a live ad tag detail in a live session. + public static LiveAdTagDetail getLiveAdTagDetail( String projectId, String location, String sessionId, String adTagDetailId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. In this example, try-with-resources is used - // which automatically calls close() on the client to clean up resources. + // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { GetLiveAdTagDetailRequest getLiveAdTagDetailRequest = @@ -53,6 +53,7 @@ public static void getLiveAdTagDetail( LiveAdTagDetail response = videoStitcherServiceClient.getLiveAdTagDetail(getLiveAdTagDetailRequest); System.out.println("Live ad tag detail: " + response.getName()); + return response; } } } diff --git a/media/stitcher/src/main/java/com/example/stitcher/GetLiveConfig.java b/media/stitcher/src/main/java/com/example/stitcher/GetLiveConfig.java index ef608dc2fd2..1acaca23ee3 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/GetLiveConfig.java +++ b/media/stitcher/src/main/java/com/example/stitcher/GetLiveConfig.java @@ -35,11 +35,11 @@ public static void main(String[] args) throws Exception { getLiveConfig(projectId, location, liveConfigId); } - public static void getLiveConfig(String projectId, String location, String liveConfigId) + // Gets a live config. + public static LiveConfig getLiveConfig(String projectId, String location, String liveConfigId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. In this example, try-with-resources is used - // which automatically calls close() on the client to clean up resources. + // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { GetLiveConfigRequest getLiveConfigRequest = @@ -49,6 +49,7 @@ public static void getLiveConfig(String projectId, String location, String liveC LiveConfig response = videoStitcherServiceClient.getLiveConfig(getLiveConfigRequest); System.out.println("Live config: " + response.getName()); + return response; } } } diff --git a/media/stitcher/src/main/java/com/example/stitcher/GetLiveSession.java b/media/stitcher/src/main/java/com/example/stitcher/GetLiveSession.java index 04d77ec8b9e..3f6df3f7fdc 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/GetLiveSession.java +++ b/media/stitcher/src/main/java/com/example/stitcher/GetLiveSession.java @@ -35,11 +35,11 @@ public static void main(String[] args) throws Exception { getLiveSession(projectId, location, sessionId); } - public static void getLiveSession(String projectId, String location, String sessionId) + // Gets a live session. + public static LiveSession getLiveSession(String projectId, String location, String sessionId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. In this example, try-with-resources is used - // which automatically calls close() on the client to clean up resources. + // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { GetLiveSessionRequest getLiveSessionRequest = @@ -49,6 +49,7 @@ public static void getLiveSession(String projectId, String location, String sess LiveSession response = videoStitcherServiceClient.getLiveSession(getLiveSessionRequest); System.out.println("Live session: " + response.getName()); + return response; } } } diff --git a/media/stitcher/src/main/java/com/example/stitcher/GetSlate.java b/media/stitcher/src/main/java/com/example/stitcher/GetSlate.java index 7ae993860ee..6897cda5c92 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/GetSlate.java +++ b/media/stitcher/src/main/java/com/example/stitcher/GetSlate.java @@ -35,11 +35,11 @@ public static void main(String[] args) throws Exception { getSlate(projectId, location, slateId); } - public static void getSlate(String projectId, String location, String slateId) + // Gets a slate. + public static Slate getSlate(String projectId, String location, String slateId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. In this example, try-with-resources is used - // which automatically calls close() on the client to clean up resources. + // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { GetSlateRequest getSlateRequest = @@ -49,6 +49,7 @@ public static void getSlate(String projectId, String location, String slateId) Slate response = videoStitcherServiceClient.getSlate(getSlateRequest); System.out.println("Slate: " + response.getName()); + return response; } } } diff --git a/media/stitcher/src/main/java/com/example/stitcher/ListCdnKeys.java b/media/stitcher/src/main/java/com/example/stitcher/ListCdnKeys.java index 3bd40e02ae4..16f94eb2335 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/ListCdnKeys.java +++ b/media/stitcher/src/main/java/com/example/stitcher/ListCdnKeys.java @@ -22,6 +22,7 @@ import com.google.cloud.video.stitcher.v1.ListCdnKeysRequest; import com.google.cloud.video.stitcher.v1.LocationName; import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient; +import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient.ListCdnKeysPagedResponse; import java.io.IOException; public class ListCdnKeys { @@ -34,10 +35,10 @@ public static void main(String[] args) throws Exception { listCdnKeys(projectId, location); } - public static void listCdnKeys(String projectId, String location) throws IOException { + // Lists the CDN keys for a given project and location. + public static ListCdnKeysPagedResponse listCdnKeys(String projectId, String location) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. In this example, try-with-resources is used - // which automatically calls close() on the client to clean up resources. + // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { ListCdnKeysRequest listCdnKeysRequest = @@ -47,11 +48,12 @@ public static void listCdnKeys(String projectId, String location) throws IOExcep VideoStitcherServiceClient.ListCdnKeysPagedResponse response = videoStitcherServiceClient.listCdnKeys(listCdnKeysRequest); - System.out.println("CDN keys:"); + System.out.println("CDN keys:"); for (CdnKey cdnKey : response.iterateAll()) { System.out.println(cdnKey.getName()); } + return response; } } } diff --git a/media/stitcher/src/main/java/com/example/stitcher/ListLiveAdTagDetails.java b/media/stitcher/src/main/java/com/example/stitcher/ListLiveAdTagDetails.java index 9dae004ad1d..59d9b6a3c66 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/ListLiveAdTagDetails.java +++ b/media/stitcher/src/main/java/com/example/stitcher/ListLiveAdTagDetails.java @@ -22,6 +22,7 @@ import com.google.cloud.video.stitcher.v1.LiveAdTagDetail; import com.google.cloud.video.stitcher.v1.LiveSessionName; import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient; +import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient.ListLiveAdTagDetailsPagedResponse; import java.io.IOException; public class ListLiveAdTagDetails { @@ -35,11 +36,11 @@ public static void main(String[] args) throws Exception { listLiveAdTagDetails(projectId, location, sessionId); } - public static void listLiveAdTagDetails(String projectId, String location, String sessionId) + // Lists the live ad tag details for a given live session. + public static ListLiveAdTagDetailsPagedResponse listLiveAdTagDetails(String projectId, String location, String sessionId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. In this example, try-with-resources is used - // which automatically calls close() on the client to clean up resources. + // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { ListLiveAdTagDetailsRequest listLiveAdTagDetailsRequest = @@ -49,11 +50,12 @@ public static void listLiveAdTagDetails(String projectId, String location, Strin VideoStitcherServiceClient.ListLiveAdTagDetailsPagedResponse response = videoStitcherServiceClient.listLiveAdTagDetails(listLiveAdTagDetailsRequest); - System.out.println("Live ad tag details:"); + System.out.println("Live ad tag details:"); for (LiveAdTagDetail adTagDetail : response.iterateAll()) { System.out.println(adTagDetail.toString()); } + return response; } } } diff --git a/media/stitcher/src/main/java/com/example/stitcher/ListLiveConfigs.java b/media/stitcher/src/main/java/com/example/stitcher/ListLiveConfigs.java index a6fb12e20aa..29e1160d7b7 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/ListLiveConfigs.java +++ b/media/stitcher/src/main/java/com/example/stitcher/ListLiveConfigs.java @@ -22,6 +22,7 @@ import com.google.cloud.video.stitcher.v1.LiveConfig; import com.google.cloud.video.stitcher.v1.LocationName; import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient; +import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient.ListLiveConfigsPagedResponse; import java.io.IOException; public class ListLiveConfigs { @@ -34,10 +35,10 @@ public static void main(String[] args) throws Exception { listLiveConfigs(projectId, location); } - public static void listLiveConfigs(String projectId, String location) throws IOException { + // Lists the live configs for a given project and location. + public static ListLiveConfigsPagedResponse listLiveConfigs(String projectId, String location) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. In this example, try-with-resources is used - // which automatically calls close() on the client to clean up resources. + // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { ListLiveConfigsRequest listLiveConfigsRequest = @@ -47,11 +48,12 @@ public static void listLiveConfigs(String projectId, String location) throws IOE VideoStitcherServiceClient.ListLiveConfigsPagedResponse response = videoStitcherServiceClient.listLiveConfigs(listLiveConfigsRequest); - System.out.println("Live configs:"); + System.out.println("Live configs:"); for (LiveConfig liveConfig : response.iterateAll()) { System.out.println(liveConfig.getName()); } + return response; } } } diff --git a/media/stitcher/src/main/java/com/example/stitcher/ListSlates.java b/media/stitcher/src/main/java/com/example/stitcher/ListSlates.java index af8bd7c46e1..9f19b356c88 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/ListSlates.java +++ b/media/stitcher/src/main/java/com/example/stitcher/ListSlates.java @@ -22,6 +22,7 @@ import com.google.cloud.video.stitcher.v1.LocationName; import com.google.cloud.video.stitcher.v1.Slate; import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient; +import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient.ListSlatesPagedResponse; import java.io.IOException; public class ListSlates { @@ -34,10 +35,10 @@ public static void main(String[] args) throws Exception { listSlates(projectId, location); } - public static void listSlates(String projectId, String location) throws IOException { + // Lists the slates for a given project and location. + public static ListSlatesPagedResponse listSlates(String projectId, String location) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. In this example, try-with-resources is used - // which automatically calls close() on the client to clean up resources. + // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { ListSlatesRequest listSlatesRequest = @@ -47,11 +48,12 @@ public static void listSlates(String projectId, String location) throws IOExcept VideoStitcherServiceClient.ListSlatesPagedResponse response = videoStitcherServiceClient.listSlates(listSlatesRequest); - System.out.println("Slates:"); + System.out.println("Slates:"); for (Slate slate : response.iterateAll()) { System.out.println(slate.getName()); } + return response; } } } diff --git a/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKey.java b/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKey.java index 9743d937464..64352ba7262 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKey.java +++ b/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKey.java @@ -52,7 +52,7 @@ public static void main(String[] args) throws Exception { // updateCdnKey updates the hostname and key fields for an existing Media CDN key or Cloud // CDN key. - public static void updateCdnKey( + public static CdnKey updateCdnKey( String projectId, String location, String cdnKeyId, @@ -62,51 +62,51 @@ public static void updateCdnKey( Boolean isMediaCdn) throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. After completing all of your requests, call - // the "close" method on the client to safely clean up any remaining background resources. - VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create(); - CdnKey cdnKey; - String path; - if (isMediaCdn) { - path = "media_cdn_key"; - cdnKey = - CdnKey.newBuilder() - .setName(CdnKeyName.of(projectId, location, cdnKeyId).toString()) - .setHostname(hostname) - .setMediaCdnKey( - MediaCdnKey.newBuilder() - .setKeyName(keyName) - .setPrivateKey(ByteString.copyFromUtf8(privateKey)) - .build()) - .build(); - } else { - path = "google_cdn_key"; - cdnKey = - CdnKey.newBuilder() - .setName(CdnKeyName.of(projectId, location, cdnKeyId).toString()) - .setHostname(hostname) - .setGoogleCdnKey( - GoogleCdnKey.newBuilder() - .setKeyName(keyName) - .setPrivateKey(ByteString.copyFromUtf8(privateKey)) - .build()) - .build(); - } + // once, and can be reused for multiple requests. + try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + CdnKey cdnKey; + String path; + if (isMediaCdn) { + path = "media_cdn_key"; + cdnKey = + CdnKey.newBuilder() + .setName(CdnKeyName.of(projectId, location, cdnKeyId).toString()) + .setHostname(hostname) + .setMediaCdnKey( + MediaCdnKey.newBuilder() + .setKeyName(keyName) + .setPrivateKey(ByteString.copyFromUtf8(privateKey)) + .build()) + .build(); + } else { + path = "google_cdn_key"; + cdnKey = + CdnKey.newBuilder() + .setName(CdnKeyName.of(projectId, location, cdnKeyId).toString()) + .setHostname(hostname) + .setGoogleCdnKey( + GoogleCdnKey.newBuilder() + .setKeyName(keyName) + .setPrivateKey(ByteString.copyFromUtf8(privateKey)) + .build()) + .build(); + } - UpdateCdnKeyRequest updateCdnKeyRequest = - UpdateCdnKeyRequest.newBuilder() - .setCdnKey(cdnKey) - // Update the hostname field and the fields for the specific key type (Media CDN - // or Cloud CDN). You must set the mask to the fields you want to update. - .setUpdateMask(FieldMask.newBuilder().addPaths("hostname").addPaths(path).build()) - .build(); + UpdateCdnKeyRequest updateCdnKeyRequest = + UpdateCdnKeyRequest.newBuilder() + .setCdnKey(cdnKey) + // Update the hostname field and the fields for the specific key type (Media CDN + // or Cloud CDN). You must set the mask to the fields you want to update. + .setUpdateMask(FieldMask.newBuilder().addPaths("hostname").addPaths(path).build()) + .build(); - CdnKey response = - videoStitcherServiceClient - .updateCdnKeyAsync(updateCdnKeyRequest) - .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); - System.out.println("Updated CDN key: " + response.getName()); - videoStitcherServiceClient.close(); + CdnKey response = + videoStitcherServiceClient + .updateCdnKeyAsync(updateCdnKeyRequest) + .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); + System.out.println("Updated CDN key: " + response.getName()); + return response; + } } } // [END videostitcher_update_cdn_key] diff --git a/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKeyAkamai.java b/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKeyAkamai.java index a3192857124..79e1f8b8b57 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKeyAkamai.java +++ b/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKeyAkamai.java @@ -46,38 +46,38 @@ public static void main(String[] args) throws Exception { } // updateCdnKeyAkamai u/**/pdates the hostname and key fields for an existing CDN key. - public static void updateCdnKeyAkamai( + public static CdnKey updateCdnKeyAkamai( String projectId, String location, String cdnKeyId, String hostname, String akamaiTokenKey) throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. After completing all of your requests, call - // the "close" method on the client to safely clean up any remaining background resources. - VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create(); - CdnKey cdnKey = - CdnKey.newBuilder() - .setName(CdnKeyName.of(projectId, location, cdnKeyId).toString()) - .setHostname(hostname) - .setAkamaiCdnKey( - AkamaiCdnKey.newBuilder() - .setTokenKey(ByteString.copyFromUtf8(akamaiTokenKey)) - .build()) - .build(); + // once, and can be reused for multiple requests. + try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + CdnKey cdnKey = + CdnKey.newBuilder() + .setName(CdnKeyName.of(projectId, location, cdnKeyId).toString()) + .setHostname(hostname) + .setAkamaiCdnKey( + AkamaiCdnKey.newBuilder() + .setTokenKey(ByteString.copyFromUtf8(akamaiTokenKey)) + .build()) + .build(); - UpdateCdnKeyRequest updateCdnKeyRequest = - UpdateCdnKeyRequest.newBuilder() - .setCdnKey(cdnKey) - // Update the hostname field and token key field. You must set the mask to the fields - // you want to update. - .setUpdateMask( - FieldMask.newBuilder().addPaths("hostname").addPaths("akamai_cdn_key").build()) - .build(); + UpdateCdnKeyRequest updateCdnKeyRequest = + UpdateCdnKeyRequest.newBuilder() + .setCdnKey(cdnKey) + // Update the hostname field and token key field. You must set the mask to the fields + // you want to update. + .setUpdateMask( + FieldMask.newBuilder().addPaths("hostname").addPaths("akamai_cdn_key").build()) + .build(); - CdnKey response = - videoStitcherServiceClient - .updateCdnKeyAsync(updateCdnKeyRequest) - .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); - System.out.println("Updated CDN key: " + response.getName()); - videoStitcherServiceClient.close(); + CdnKey response = + videoStitcherServiceClient + .updateCdnKeyAsync(updateCdnKeyRequest) + .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); + System.out.println("Updated CDN key: " + response.getName()); + return response; + } } } // [END videostitcher_update_cdn_key_akamai] diff --git a/media/stitcher/src/main/java/com/example/stitcher/UpdateSlate.java b/media/stitcher/src/main/java/com/example/stitcher/UpdateSlate.java index b851e5ed150..29772444779 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/UpdateSlate.java +++ b/media/stitcher/src/main/java/com/example/stitcher/UpdateSlate.java @@ -44,30 +44,30 @@ public static void main(String[] args) throws Exception { } // updateSlate updates the slate URI for an existing slate. - public static void updateSlate(String projectId, String location, String slateId, String slateUri) + public static Slate updateSlate(String projectId, String location, String slateId, String slateUri) throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created - // once, and can be reused for multiple requests. After completing all of your requests, call - // the "close" method on the client to safely clean up any remaining background resources. - VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create(); - UpdateSlateRequest updateSlateRequest = - UpdateSlateRequest.newBuilder() - .setSlate( - Slate.newBuilder() - .setName(SlateName.of(projectId, location, slateId).toString()) - .setUri(slateUri) - .build()) - // Set the update mask to the uri field in the existing slate. You must set the mask - // to the field you want to update. - .setUpdateMask(FieldMask.newBuilder().addPaths("uri").build()) - .build(); + // once, and can be reused for multiple requests. + try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + UpdateSlateRequest updateSlateRequest = + UpdateSlateRequest.newBuilder() + .setSlate( + Slate.newBuilder() + .setName(SlateName.of(projectId, location, slateId).toString()) + .setUri(slateUri) + .build()) + // Set the update mask to the uri field in the existing slate. You must set the mask + // to the field you want to update. + .setUpdateMask(FieldMask.newBuilder().addPaths("uri").build()) + .build(); - Slate response = - videoStitcherServiceClient - .updateSlateAsync(updateSlateRequest) - .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); - System.out.println("Updated slate: " + response.getName()); - videoStitcherServiceClient.close(); + Slate response = + videoStitcherServiceClient + .updateSlateAsync(updateSlateRequest) + .get(TIMEOUT_IN_MINUTES, TimeUnit.MINUTES); + System.out.println("Updated slate: " + response.getName()); + return response; + } } } // [END videostitcher_update_slate] diff --git a/media/stitcher/src/test/java/com/example/stitcher/UpdateCdnKeyTest.java b/media/stitcher/src/test/java/com/example/stitcher/CdnKeyTest.java similarity index 53% rename from media/stitcher/src/test/java/com/example/stitcher/UpdateCdnKeyTest.java rename to media/stitcher/src/test/java/com/example/stitcher/CdnKeyTest.java index f1da6b0c793..661e2dd4df6 100644 --- a/media/stitcher/src/test/java/com/example/stitcher/UpdateCdnKeyTest.java +++ b/media/stitcher/src/test/java/com/example/stitcher/CdnKeyTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,13 +21,15 @@ import static org.junit.Assert.assertNotNull; import com.google.cloud.testing.junit4.MultipleAttemptsRule; +import com.google.cloud.video.stitcher.v1.CdnKey; +import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient.ListCdnKeysPagedResponse; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; @@ -35,22 +37,27 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) -public class UpdateCdnKeyTest { +public class CdnKeyTest { @Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); private static final String CLOUD_CDN_KEY_ID = TestUtils.getCdnKeyId(); private static final String MEDIA_CDN_KEY_ID = TestUtils.getCdnKeyId(); + private static final String AKAMAI_KEY_ID = TestUtils.getCdnKeyId(); + private static String PROJECT_ID; + private static String CLOUD_CDN_KEY_NAME; // resource name for the Cloud CDN key + private static String MEDIA_CDN_KEY_NAME; // resource name for the Media CDN key + private static String AKAMAI_KEY_NAME; // resource name for the Akamai CDN key private static final String UPDATED_CLOUD_CDN_PRIVATE_KEY = "VGhpcyBpcyBhbiB1cGRhdGVkIHRlc3Qgc3RyaW5nLg=="; private static final String UPDATED_MEDIA_CDN_PRIVATE_KEY = "ZZZzNDU2Nzg5MDEyMzQ1Njc4OTAxzg5MDEyMzQ1Njc4OTAxMjM0NTY3DkwMTIZZZ"; + private static final String UPDATED_AKAMAI_TOKEN_KEY = + "VGhpcyBpcyBhbiB1cGRhdGVkIHRlc3Qgc3RyaW5nLg=="; - private static String PROJECT_ID; - private static String CLOUD_CDN_KEY_NAME; // resource name for the Cloud CDN key - private static String MEDIA_CDN_KEY_NAME; // resource name for the Media CDN key private static PrintStream originalOut; - private ByteArrayOutputStream bout; + private static ByteArrayOutputStream bout; + private static String requireEnvVar(String varName) { String varValue = System.getenv(varName); @@ -60,41 +67,86 @@ private static String requireEnvVar(String varName) { } @BeforeClass - public static void checkRequirements() { + public static void beforeTest() + throws IOException, ExecutionException, InterruptedException, TimeoutException { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleCdnKeys(PROJECT_ID, TestUtils.LOCATION); originalOut = System.out; bout = new ByteArrayOutputStream(); System.setOut(new PrintStream(bout)); + TestUtils.cleanStaleCdnKeys(PROJECT_ID, TestUtils.LOCATION); + // Cloud CDN key CLOUD_CDN_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, CLOUD_CDN_KEY_ID); - CreateCdnKey.createCdnKey( + // Media CDN key + MEDIA_CDN_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, + MEDIA_CDN_KEY_ID); + // Akamai CDN key + AKAMAI_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, AKAMAI_KEY_ID); + + // Cloud CDN key + CdnKey response = CreateCdnKey.createCdnKey( PROJECT_ID, TestUtils.LOCATION, CLOUD_CDN_KEY_ID, TestUtils.HOSTNAME, TestUtils.KEYNAME, TestUtils.CLOUD_CDN_PRIVATE_KEY, false); + assertThat(response.getName(), containsString(CLOUD_CDN_KEY_NAME)); // Media CDN key - MEDIA_CDN_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, - MEDIA_CDN_KEY_ID); - CreateCdnKey.createCdnKey( + response = CreateCdnKey.createCdnKey( PROJECT_ID, TestUtils.LOCATION, MEDIA_CDN_KEY_ID, TestUtils.HOSTNAME, TestUtils.KEYNAME, TestUtils.MEDIA_CDN_PRIVATE_KEY, true); + assertThat(response.getName(), containsString(MEDIA_CDN_KEY_NAME)); - bout.reset(); + // Akamai CDN key + response = CreateCdnKeyAkamai.createCdnKeyAkamai( + PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID, TestUtils.HOSTNAME, + TestUtils.AKAMAI_TOKEN_KEY); + assertThat(response.getName(), containsString(AKAMAI_KEY_NAME)); } @Test - public void test_UpdateCdnKey() + public void testGetCdnKey() throws IOException { + // Cloud CDN key + CdnKey response = GetCdnKey.getCdnKey(PROJECT_ID, TestUtils.LOCATION, CLOUD_CDN_KEY_ID); + assertThat(response.getName(), containsString(CLOUD_CDN_KEY_NAME)); + + // Media CDN key + response = GetCdnKey.getCdnKey(PROJECT_ID, TestUtils.LOCATION, MEDIA_CDN_KEY_ID); + assertThat(response.getName(), containsString(MEDIA_CDN_KEY_NAME)); + + // Akamai CDN key + response = GetCdnKey.getCdnKey(PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID); + assertThat(response.getName(), containsString(AKAMAI_KEY_NAME)); + } + + @Test + public void testListCdnKeys() throws IOException { + // Cloud, Media, and Akamai CDN keys should be present + ListCdnKeysPagedResponse response = + ListCdnKeys.listCdnKeys(PROJECT_ID, TestUtils.LOCATION); + Boolean cloud = false; + Boolean media = false; + Boolean akamai = false; + + for (CdnKey CdnKey : response.iterateAll()) { + if (CdnKey.getName().contains(CLOUD_CDN_KEY_NAME)) { + cloud = true; + } else if (CdnKey.getName().contains(MEDIA_CDN_KEY_NAME)) { + media = true; + } else if (CdnKey.getName().contains(AKAMAI_KEY_NAME)) { + akamai = true; + } + } + assert (cloud && media && akamai); + } + + @Test + public void testUpdateCdnKey() throws IOException, ExecutionException, InterruptedException, TimeoutException { // Cloud CDN key - UpdateCdnKey.updateCdnKey( + CdnKey response = UpdateCdnKey.updateCdnKey( PROJECT_ID, TestUtils.LOCATION, CLOUD_CDN_KEY_ID, @@ -102,12 +154,10 @@ public void test_UpdateCdnKey() TestUtils.KEYNAME, UPDATED_CLOUD_CDN_PRIVATE_KEY, false); - String output = bout.toString(); - assertThat(output, containsString(CLOUD_CDN_KEY_NAME)); - bout.reset(); + assertThat(response.getName(), containsString(CLOUD_CDN_KEY_NAME)); // Media CDN key - UpdateCdnKey.updateCdnKey( + response = UpdateCdnKey.updateCdnKey( PROJECT_ID, TestUtils.LOCATION, MEDIA_CDN_KEY_ID, @@ -115,19 +165,41 @@ public void test_UpdateCdnKey() TestUtils.KEYNAME, UPDATED_MEDIA_CDN_PRIVATE_KEY, true); - output = bout.toString(); - assertThat(output, containsString(MEDIA_CDN_KEY_NAME)); - bout.reset(); + assertThat(response.getName(), containsString(MEDIA_CDN_KEY_NAME)); + + // Akamai CDN key + response = UpdateCdnKeyAkamai.updateCdnKeyAkamai( + PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID, TestUtils.UPDATED_HOSTNAME, + UPDATED_AKAMAI_TOKEN_KEY); + assertThat(response.getName(), containsString(AKAMAI_KEY_NAME)); } @After - public void tearDown() + public void tearDown() { + bout.reset(); + } + + @AfterClass + public static void afterTest() throws IOException, ExecutionException, InterruptedException, TimeoutException { // Cloud CDN key DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, CLOUD_CDN_KEY_ID); + String deleteResponse = bout.toString(); + assertThat(deleteResponse, containsString("Deleted CDN key")); + bout.reset(); + // Media CDN key DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, MEDIA_CDN_KEY_ID); - System.setOut(originalOut); + deleteResponse = bout.toString(); + assertThat(deleteResponse, containsString("Deleted CDN key")); bout.reset(); + + // Akamai CDN key + DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID); + deleteResponse = bout.toString(); + assertThat(deleteResponse, containsString("Deleted CDN key")); + + System.out.flush(); + System.setOut(originalOut); } } diff --git a/media/stitcher/src/test/java/com/example/stitcher/CreateCdnKeyAkamaiTest.java b/media/stitcher/src/test/java/com/example/stitcher/CreateCdnKeyAkamaiTest.java deleted file mode 100644 index adb7fb70a2b..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/CreateCdnKeyAkamaiTest.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class CreateCdnKeyAkamaiTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String AKAMAI_KEY_ID = TestUtils.getCdnKeyId(); - private static String PROJECT_ID; - private static String AKAMAI_KEY_NAME; // resource name for the Akamai CDN key - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() throws IOException { - TestUtils.cleanStaleCdnKeys(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - AKAMAI_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, AKAMAI_KEY_ID); - bout.reset(); - } - - @Test - public void test_CreateCdnKeyAkamai() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - CreateCdnKeyAkamai.createCdnKeyAkamai( - PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID, TestUtils.HOSTNAME, - TestUtils.AKAMAI_TOKEN_KEY); - String output = bout.toString(); - assertThat(output, containsString(AKAMAI_KEY_NAME)); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID); - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/CreateCdnKeyTest.java b/media/stitcher/src/test/java/com/example/stitcher/CreateCdnKeyTest.java deleted file mode 100644 index a9428c60a70..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/CreateCdnKeyTest.java +++ /dev/null @@ -1,108 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class CreateCdnKeyTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String CLOUD_CDN_KEY_ID = TestUtils.getCdnKeyId(); - private static final String MEDIA_CDN_KEY_ID = TestUtils.getCdnKeyId(); - private static String PROJECT_ID; - private static String CLOUD_CDN_KEY_NAME; // resource name for the Cloud CDN key - private static String MEDIA_CDN_KEY_NAME; // resource name for the Media CDN key - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() throws IOException { - TestUtils.cleanStaleCdnKeys(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - // Cloud CDN key - CLOUD_CDN_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, - CLOUD_CDN_KEY_ID); - // Media CDN key - MEDIA_CDN_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, - MEDIA_CDN_KEY_ID); - bout.reset(); - } - - @Test - public void test_CreateCdnKey() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - // Cloud CDN key - CreateCdnKey.createCdnKey( - PROJECT_ID, TestUtils.LOCATION, CLOUD_CDN_KEY_ID, TestUtils.HOSTNAME, TestUtils.KEYNAME, - TestUtils.CLOUD_CDN_PRIVATE_KEY, false); - String output = bout.toString(); - assertThat(output, containsString(CLOUD_CDN_KEY_NAME)); - bout.reset(); - - // Media CDN key - CreateCdnKey.createCdnKey( - PROJECT_ID, TestUtils.LOCATION, MEDIA_CDN_KEY_ID, TestUtils.HOSTNAME, TestUtils.KEYNAME, - TestUtils.MEDIA_CDN_PRIVATE_KEY, true); - output = bout.toString(); - assertThat(output, containsString(MEDIA_CDN_KEY_NAME)); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - // Cloud CDN key - DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, CLOUD_CDN_KEY_ID); - // Media CDN key - DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, MEDIA_CDN_KEY_ID); - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/CreateLiveConfigTest.java b/media/stitcher/src/test/java/com/example/stitcher/CreateLiveConfigTest.java deleted file mode 100644 index 2770dd24249..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/CreateLiveConfigTest.java +++ /dev/null @@ -1,95 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class CreateLiveConfigTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String SLATE_ID = TestUtils.getSlateId(); - private static final String LIVE_CONFIG_ID = TestUtils.getLiveConfigId(); - private static String PROJECT_ID; - private static String LIVE_CONFIG_NAME; - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); - TestUtils.cleanStaleLiveConfigs(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - - LIVE_CONFIG_NAME = String.format("locations/%s/liveConfigs/", TestUtils.LOCATION); - CreateSlate.createSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, TestUtils.SLATE_URI); - bout.reset(); - } - - @Test - public void test_CreateLiveConfig() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - CreateLiveConfig.createLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID, - TestUtils.LIVE_URI, - TestUtils.LIVE_AD_TAG_URI, SLATE_ID); - String output = bout.toString(); - assertThat(output, containsString(LIVE_CONFIG_NAME)); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteLiveConfig.deleteLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); - DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/CreateLiveSessionTest.java b/media/stitcher/src/test/java/com/example/stitcher/CreateLiveSessionTest.java deleted file mode 100644 index 17e374a5f8e..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/CreateLiveSessionTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class CreateLiveSessionTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String SLATE_ID = TestUtils.getSlateId(); - private static final String LIVE_CONFIG_ID = TestUtils.getLiveConfigId(); - private static String PROJECT_ID; - private static String SESSION_NAME; - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); - TestUtils.cleanStaleLiveConfigs(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - - // Project number is always returned in the live session name - SESSION_NAME = String.format("locations/%s/liveSessions/", TestUtils.LOCATION); - CreateSlate.createSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, TestUtils.SLATE_URI); - CreateLiveConfig.createLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID, - TestUtils.LIVE_URI, TestUtils.LIVE_AD_TAG_URI, SLATE_ID); - bout.reset(); - } - - @Test - public void test_CreateLiveSession() throws IOException { - CreateLiveSession.createLiveSession(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); - String output = bout.toString(); - assertThat(output, containsString(SESSION_NAME)); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); - DeleteLiveConfig.deleteLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); - // No delete method for a live session - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/CreateSlateTest.java b/media/stitcher/src/test/java/com/example/stitcher/CreateSlateTest.java deleted file mode 100644 index c9a4bf89922..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/CreateSlateTest.java +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class CreateSlateTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String SLATE_ID = TestUtils.getSlateId(); - private static String PROJECT_ID; - private static String SLATE_NAME; - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() throws IOException { - TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - // Project number is always returned in the slate name - SLATE_NAME = String.format("/locations/%s/slates/%s", TestUtils.LOCATION, SLATE_ID); - bout.reset(); - } - - @Test - public void test_CreateSlate() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - CreateSlate.createSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, TestUtils.SLATE_URI); - String output = bout.toString(); - assertThat(output, containsString(SLATE_NAME)); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/DeleteCdnKeyTest.java b/media/stitcher/src/test/java/com/example/stitcher/DeleteCdnKeyTest.java deleted file mode 100644 index 11ad3987d60..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/DeleteCdnKeyTest.java +++ /dev/null @@ -1,115 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class DeleteCdnKeyTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String CLOUD_CDN_KEY_ID = TestUtils.getCdnKeyId(); - private static final String MEDIA_CDN_KEY_ID = TestUtils.getCdnKeyId(); - private static final String AKAMAI_KEY_ID = TestUtils.getCdnKeyId(); - private static String PROJECT_ID; - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleCdnKeys(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - - // Cloud CDN key - CreateCdnKey.createCdnKey( - PROJECT_ID, TestUtils.LOCATION, CLOUD_CDN_KEY_ID, TestUtils.HOSTNAME, TestUtils.KEYNAME, - TestUtils.CLOUD_CDN_PRIVATE_KEY, false); - - // Media CDN key - CreateCdnKey.createCdnKey( - PROJECT_ID, TestUtils.LOCATION, MEDIA_CDN_KEY_ID, TestUtils.HOSTNAME, TestUtils.KEYNAME, - TestUtils.MEDIA_CDN_PRIVATE_KEY, true); - - // Akamai CDN key - CreateCdnKeyAkamai.createCdnKeyAkamai( - PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID, TestUtils.HOSTNAME, - TestUtils.AKAMAI_TOKEN_KEY); - - bout.reset(); - } - - @Test - public void test_DeleteCdnKey() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - // Cloud CDN key - DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, CLOUD_CDN_KEY_ID); - String output = bout.toString(); - assertThat(output, containsString("Deleted CDN key")); - bout.reset(); - - // Media CDN key - DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, MEDIA_CDN_KEY_ID); - output = bout.toString(); - assertThat(output, containsString("Deleted CDN key")); - bout.reset(); - - // Aakamai CDN key - DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID); - output = bout.toString(); - assertThat(output, containsString("Deleted CDN key")); - bout.reset(); - } - - @After - public void tearDown() throws IOException { - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/DeleteLiveConfigTest.java b/media/stitcher/src/test/java/com/example/stitcher/DeleteLiveConfigTest.java deleted file mode 100644 index 121edd20e65..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/DeleteLiveConfigTest.java +++ /dev/null @@ -1,92 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class DeleteLiveConfigTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String SLATE_ID = TestUtils.getSlateId(); - private static final String LIVE_CONFIG_ID = TestUtils.getLiveConfigId(); - private static String PROJECT_ID; - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); - TestUtils.cleanStaleLiveConfigs(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - - CreateSlate.createSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, TestUtils.SLATE_URI); - CreateLiveConfig.createLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID, - TestUtils.LIVE_URI, TestUtils.LIVE_AD_TAG_URI, SLATE_ID); - bout.reset(); - } - - @Test - public void test_DeleteLiveConfig() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteLiveConfig.deleteLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); - String output = bout.toString(); - assertThat(output, containsString("Deleted live config")); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/DeleteSlateTest.java b/media/stitcher/src/test/java/com/example/stitcher/DeleteSlateTest.java deleted file mode 100644 index 5f2a87d00d5..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/DeleteSlateTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class DeleteSlateTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String SLATE_ID = TestUtils.getSlateId(); - private static String PROJECT_ID; - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - - CreateSlate.createSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, TestUtils.SLATE_URI); - bout.reset(); - } - - @Test - public void test_DeleteSlate() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); - String output = bout.toString(); - assertThat(output, containsString("Deleted slate")); - bout.reset(); - } - - @After - public void tearDown() throws IOException { - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/GetCdnKeyTest.java b/media/stitcher/src/test/java/com/example/stitcher/GetCdnKeyTest.java deleted file mode 100644 index b4ed5edcc5d..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/GetCdnKeyTest.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class GetCdnKeyTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String CLOUD_CDN_KEY_ID = TestUtils.getCdnKeyId(); - private static final String MEDIA_CDN_KEY_ID = TestUtils.getCdnKeyId(); - private static final String AKAMAI_KEY_ID = TestUtils.getCdnKeyId(); - private static String PROJECT_ID; - private static String CLOUD_CDN_KEY_NAME; // resource name for the Cloud CDN key - private static String MEDIA_CDN_KEY_NAME; // resource name for the Media CDN key - private static String AKAMAI_KEY_NAME; // resource name for the Akamai CDN key - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleCdnKeys(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - - // Cloud CDN key - CLOUD_CDN_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, - CLOUD_CDN_KEY_ID); - CreateCdnKey.createCdnKey( - PROJECT_ID, TestUtils.LOCATION, CLOUD_CDN_KEY_ID, TestUtils.HOSTNAME, TestUtils.KEYNAME, - TestUtils.CLOUD_CDN_PRIVATE_KEY, false); - - // Media CDN key - MEDIA_CDN_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, - MEDIA_CDN_KEY_ID); - CreateCdnKey.createCdnKey( - PROJECT_ID, TestUtils.LOCATION, MEDIA_CDN_KEY_ID, TestUtils.HOSTNAME, TestUtils.KEYNAME, - TestUtils.MEDIA_CDN_PRIVATE_KEY, true); - - // Akamai CDN key - AKAMAI_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, AKAMAI_KEY_ID); - CreateCdnKeyAkamai.createCdnKeyAkamai( - PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID, TestUtils.HOSTNAME, - TestUtils.AKAMAI_TOKEN_KEY); - - bout.reset(); - } - - @Test - public void test_GetCdnKey() throws IOException { - // Cloud CDN key - GetCdnKey.getCdnKey(PROJECT_ID, TestUtils.LOCATION, CLOUD_CDN_KEY_ID); - String output = bout.toString(); - assertThat(output, containsString(CLOUD_CDN_KEY_NAME)); - bout.reset(); - - // Media CDN key - GetCdnKey.getCdnKey(PROJECT_ID, TestUtils.LOCATION, MEDIA_CDN_KEY_ID); - output = bout.toString(); - assertThat(output, containsString(MEDIA_CDN_KEY_NAME)); - bout.reset(); - - // Akamai CDN key - GetCdnKey.getCdnKey(PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID); - output = bout.toString(); - assertThat(output, containsString(AKAMAI_KEY_NAME)); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - // Cloud CDN key - DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, CLOUD_CDN_KEY_ID); - // Media CDN key - DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, MEDIA_CDN_KEY_ID); - // Akamai CDN key - DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID); - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/GetLiveSessionTest.java b/media/stitcher/src/test/java/com/example/stitcher/GetLiveSessionTest.java deleted file mode 100644 index 49d899db0d3..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/GetLiveSessionTest.java +++ /dev/null @@ -1,111 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class GetLiveSessionTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String SLATE_ID = TestUtils.getSlateId(); - private static final String LIVE_CONFIG_ID = TestUtils.getLiveConfigId(); - private static String PROJECT_ID; - private static String SESSION_ID; - private static String SESSION_NAME; - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); - TestUtils.cleanStaleLiveConfigs(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - - CreateSlate.createSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, TestUtils.SLATE_URI); - CreateLiveConfig.createLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID, - TestUtils.LIVE_URI, TestUtils.LIVE_AD_TAG_URI, SLATE_ID); - bout.reset(); - - CreateLiveSession.createLiveSession(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); - Matcher idMatcher = - Pattern.compile( - String.format( - "Created live session: projects/.*/locations/%s/liveSessions/(.*)", - TestUtils.LOCATION)) - .matcher(bout.toString()); - if (idMatcher.find()) { - SESSION_ID = idMatcher.group(1); - } - // Project number is always returned in the live session name - SESSION_NAME = String.format("locations/%s/liveSessions/%s", TestUtils.LOCATION, SESSION_ID); - bout.reset(); - } - - @Test - public void test_GetLiveSession() throws IOException { - GetLiveSession.getLiveSession(PROJECT_ID, TestUtils.LOCATION, SESSION_ID); - String output = bout.toString(); - assertThat(output, containsString(SESSION_NAME)); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); - DeleteLiveConfig.deleteLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); - // No delete method for a live session - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/GetSlateTest.java b/media/stitcher/src/test/java/com/example/stitcher/GetSlateTest.java deleted file mode 100644 index d2c10e36b3d..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/GetSlateTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class GetSlateTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String SLATE_ID = TestUtils.getSlateId(); - private static String PROJECT_ID; - private static String SLATE_NAME; - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - - SLATE_NAME = - String.format("projects/%s/locations/%s/slates/%s", PROJECT_ID, TestUtils.LOCATION, - SLATE_ID); - CreateSlate.createSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, TestUtils.SLATE_URI); - bout.reset(); - } - - @Test - public void test_GetSlate() throws IOException { - GetSlate.getSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); - String output = bout.toString(); - assertThat(output, containsString(SLATE_NAME)); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/ListCdnKeysTest.java b/media/stitcher/src/test/java/com/example/stitcher/ListCdnKeysTest.java deleted file mode 100644 index 4cbdef91b34..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/ListCdnKeysTest.java +++ /dev/null @@ -1,116 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class ListCdnKeysTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String CLOUD_CDN_KEY_ID = TestUtils.getCdnKeyId(); - private static final String MEDIA_CDN_KEY_ID = TestUtils.getCdnKeyId(); - private static final String AKAMAI_KEY_ID = TestUtils.getCdnKeyId(); - private static String PROJECT_ID; - private static String CLOUD_CDN_KEY_NAME; // resource name for the Cloud CDN key - private static String MEDIA_CDN_KEY_NAME; // resource name for the Media CDN key - private static String AKAMAI_KEY_NAME; // resource name for the Akamai CDN key - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleCdnKeys(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - - // Cloud CDN key - CLOUD_CDN_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, - CLOUD_CDN_KEY_ID); - CreateCdnKey.createCdnKey( - PROJECT_ID, TestUtils.LOCATION, CLOUD_CDN_KEY_ID, TestUtils.HOSTNAME, TestUtils.KEYNAME, - TestUtils.CLOUD_CDN_PRIVATE_KEY, false); - - // Media CDN key - MEDIA_CDN_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, - MEDIA_CDN_KEY_ID); - CreateCdnKey.createCdnKey( - PROJECT_ID, TestUtils.LOCATION, MEDIA_CDN_KEY_ID, TestUtils.HOSTNAME, TestUtils.KEYNAME, - TestUtils.MEDIA_CDN_PRIVATE_KEY, true); - - // Akamai CDN key - AKAMAI_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, AKAMAI_KEY_ID); - CreateCdnKeyAkamai.createCdnKeyAkamai( - PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID, TestUtils.HOSTNAME, - TestUtils.AKAMAI_TOKEN_KEY); - - bout.reset(); - } - - @Test - public void test_ListCdnKeys() throws IOException { - // Cloud, Media, and Akamai CDN keys should be present - ListCdnKeys.listCdnKeys(PROJECT_ID, TestUtils.LOCATION); - String output = bout.toString(); - assertThat(output, containsString(CLOUD_CDN_KEY_NAME)); - assertThat(output, containsString(MEDIA_CDN_KEY_NAME)); - assertThat(output, containsString(AKAMAI_KEY_NAME)); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, CLOUD_CDN_KEY_ID); - DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, MEDIA_CDN_KEY_ID); - DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID); - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/ListLiveAdTagDetailsTest.java b/media/stitcher/src/test/java/com/example/stitcher/ListLiveAdTagDetailsTest.java deleted file mode 100644 index 414514e0c81..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/ListLiveAdTagDetailsTest.java +++ /dev/null @@ -1,133 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class ListLiveAdTagDetailsTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String SLATE_ID = TestUtils.getSlateId(); - private static final String LIVE_CONFIG_ID = TestUtils.getLiveConfigId(); - private static String PROJECT_ID; - private static String SESSION_ID; - private static String AD_TAG_DETAILS_NAME; - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); - TestUtils.cleanStaleLiveConfigs(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - - CreateSlate.createSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, TestUtils.SLATE_URI); - CreateLiveConfig.createLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID, - TestUtils.LIVE_URI, TestUtils.LIVE_AD_TAG_URI, SLATE_ID); - bout.reset(); - - CreateLiveSession.createLiveSession(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); - String output = bout.toString(); - Matcher idMatcher = - Pattern.compile( - String.format( - "Created live session: projects/.*/locations/%s/liveSessions/(.*)", - TestUtils.LOCATION)) - .matcher(output); - if (idMatcher.find()) { - SESSION_ID = idMatcher.group(1); - } - // Project number is always returned in the live session name - AD_TAG_DETAILS_NAME = - String.format("locations/%s/liveSessions/%s/liveAdTagDetails/", TestUtils.LOCATION, - SESSION_ID); - - // To get ad tag details, you need to curl the main manifest and - // a rendition first. This supplies media player information to the API. - // - // Curl the playUri first. The last line of the response will contain a - // renditions location. Curl the live session name with the rendition - // location appended. - - String playUri = TestUtils.getPlayUri(output); - assertNotNull(playUri); - String renditions = TestUtils.getRenditions(playUri); - assertNotNull(renditions); - - // playUri will be in the following format: - // https://videostitcher.googleapis.com/v1/projects/{project}/locations/{location}/liveSessions/{session-id}/manifest.m3u8?signature=... - // Replace manifest.m3u8?signature=... with the renditions location. - String renditionsUri = - String.format("%s/%s", playUri.substring(0, playUri.lastIndexOf("/")), renditions); - TestUtils.connectToRenditionsUrl(renditionsUri); - bout.reset(); - } - - @Test - public void test_ListLiveAdTagDetails() throws IOException { - ListLiveAdTagDetails.listLiveAdTagDetails(PROJECT_ID, TestUtils.LOCATION, SESSION_ID); - String output = bout.toString(); - assertThat(output, containsString(AD_TAG_DETAILS_NAME)); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); - DeleteLiveConfig.deleteLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); - // No delete method for a live session - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/ListLiveConfigsTest.java b/media/stitcher/src/test/java/com/example/stitcher/ListLiveConfigsTest.java deleted file mode 100644 index cc84097abcf..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/ListLiveConfigsTest.java +++ /dev/null @@ -1,97 +0,0 @@ -/* - * Copyright 2023 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class ListLiveConfigsTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String SLATE_ID = TestUtils.getSlateId(); - private static final String LIVE_CONFIG_ID = TestUtils.getLiveConfigId(); - - private static String PROJECT_ID; - private static String LIVE_CONFIG_NAME; - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); - TestUtils.cleanStaleLiveConfigs(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - - LIVE_CONFIG_NAME = - String.format("projects/%s/locations/%s/liveConfigs/%s", PROJECT_ID, TestUtils.LOCATION, - LIVE_CONFIG_ID); - CreateSlate.createSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, TestUtils.SLATE_URI); - CreateLiveConfig.createLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID, - TestUtils.LIVE_URI, TestUtils.LIVE_AD_TAG_URI, SLATE_ID); - bout.reset(); - } - - @Test - public void test_ListLiveConfigs() throws IOException { - ListLiveConfigs.listLiveConfigs(PROJECT_ID, TestUtils.LOCATION); - String output = bout.toString(); - assertThat(output, containsString(LIVE_CONFIG_NAME)); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteLiveConfig.deleteLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); - DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/ListSlatesTest.java b/media/stitcher/src/test/java/com/example/stitcher/ListSlatesTest.java deleted file mode 100644 index 4492661eff9..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/ListSlatesTest.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class ListSlatesTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String SLATE_ID = TestUtils.getSlateId(); - private static String PROJECT_ID; - private static String SLATE_NAME; - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - - SLATE_NAME = - String.format("projects/%s/locations/%s/slates/%s", PROJECT_ID, TestUtils.LOCATION, - SLATE_ID); - CreateSlate.createSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, TestUtils.SLATE_URI); - bout.reset(); - } - - @Test - public void test_ListSlates() throws IOException { - ListSlates.listSlates(PROJECT_ID, TestUtils.LOCATION); - String output = bout.toString(); - assertThat(output, containsString(SLATE_NAME)); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/GetLiveConfigTest.java b/media/stitcher/src/test/java/com/example/stitcher/LiveConfigTest.java similarity index 62% rename from media/stitcher/src/test/java/com/example/stitcher/GetLiveConfigTest.java rename to media/stitcher/src/test/java/com/example/stitcher/LiveConfigTest.java index c0671a39ab2..44c016ae41f 100644 --- a/media/stitcher/src/test/java/com/example/stitcher/GetLiveConfigTest.java +++ b/media/stitcher/src/test/java/com/example/stitcher/LiveConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2023 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,13 +21,15 @@ import static org.junit.Assert.assertNotNull; import com.google.cloud.testing.junit4.MultipleAttemptsRule; +import com.google.cloud.video.stitcher.v1.LiveConfig; +import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient.ListLiveConfigsPagedResponse; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; @@ -35,17 +37,16 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) -public class GetLiveConfigTest { +public class LiveConfigTest { @Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); private static final String SLATE_ID = TestUtils.getSlateId(); private static final String LIVE_CONFIG_ID = TestUtils.getLiveConfigId(); - - private static String PROJECT_ID; private static String LIVE_CONFIG_NAME; + private static String PROJECT_ID; private static PrintStream originalOut; - private ByteArrayOutputStream bout; + private static ByteArrayOutputStream bout; private static String requireEnvVar(String varName) { String varValue = System.getenv(varName); @@ -55,43 +56,68 @@ private static String requireEnvVar(String varName) { } @BeforeClass - public static void checkRequirements() { + public static void beforeTest() + throws IOException, ExecutionException, InterruptedException, TimeoutException { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); - TestUtils.cleanStaleLiveConfigs(PROJECT_ID, TestUtils.LOCATION); originalOut = System.out; bout = new ByteArrayOutputStream(); System.setOut(new PrintStream(bout)); - LIVE_CONFIG_NAME = - String.format("projects/%s/locations/%s/liveConfigs/%s", PROJECT_ID, TestUtils.LOCATION, - LIVE_CONFIG_ID); + TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); + TestUtils.cleanStaleLiveConfigs(PROJECT_ID, TestUtils.LOCATION); + CreateSlate.createSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, TestUtils.SLATE_URI); - CreateLiveConfig.createLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID, - TestUtils.LIVE_URI, TestUtils.LIVE_AD_TAG_URI, SLATE_ID); - bout.reset(); + + LIVE_CONFIG_NAME = + String.format("locations/%s/liveConfigs/%s", TestUtils.LOCATION, LIVE_CONFIG_ID); + LiveConfig response = + CreateLiveConfig.createLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID, + TestUtils.LIVE_URI, + TestUtils.LIVE_AD_TAG_URI, SLATE_ID); + assertThat(response.getName(), containsString(LIVE_CONFIG_NAME)); } @Test - public void test_GetLiveConfig() throws IOException { - GetLiveConfig.getLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); - String output = bout.toString(); - assertThat(output, containsString(LIVE_CONFIG_NAME)); - bout.reset(); + public void testGetLiveConfig() throws IOException { + LiveConfig response = GetLiveConfig.getLiveConfig(PROJECT_ID, TestUtils.LOCATION, + LIVE_CONFIG_ID); + assertThat(response.getName(), containsString(LIVE_CONFIG_NAME)); + } + + @Test + public void testListLiveConfigs() throws IOException { + ListLiveConfigsPagedResponse response = + ListLiveConfigs.listLiveConfigs(PROJECT_ID, TestUtils.LOCATION); + Boolean pass = false; + for (LiveConfig liveConfig : response.iterateAll()) { + if (liveConfig.getName().contains(LIVE_CONFIG_NAME)) { + pass = true; + break; + } + } + assert (pass); } @After - public void tearDown() + public void tearDown() { + bout.reset(); + } + + @AfterClass + public static void afterTest() throws IOException, ExecutionException, InterruptedException, TimeoutException { DeleteLiveConfig.deleteLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); + String deleteResponse = bout.toString(); + assertThat(deleteResponse, containsString("Deleted live config")); + bout.reset(); + DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); + deleteResponse = bout.toString(); + assertThat(deleteResponse, containsString("Deleted slate")); + + System.out.flush(); System.setOut(originalOut); - bout.reset(); } } diff --git a/media/stitcher/src/test/java/com/example/stitcher/GetLiveAdTagDetailTest.java b/media/stitcher/src/test/java/com/example/stitcher/LiveSessionTest.java similarity index 56% rename from media/stitcher/src/test/java/com/example/stitcher/GetLiveAdTagDetailTest.java rename to media/stitcher/src/test/java/com/example/stitcher/LiveSessionTest.java index f4aeaa69bdf..f5ac325dc49 100644 --- a/media/stitcher/src/test/java/com/example/stitcher/GetLiveAdTagDetailTest.java +++ b/media/stitcher/src/test/java/com/example/stitcher/LiveSessionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,15 +21,16 @@ import static org.junit.Assert.assertNotNull; import com.google.cloud.testing.junit4.MultipleAttemptsRule; +import com.google.cloud.video.stitcher.v1.LiveAdTagDetail; +import com.google.cloud.video.stitcher.v1.LiveSession; +import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient.ListLiveAdTagDetailsPagedResponse; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; -import java.util.regex.Matcher; -import java.util.regex.Pattern; import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; @@ -37,18 +38,23 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) -public class GetLiveAdTagDetailTest { +public class LiveSessionTest { @Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); private static final String SLATE_ID = TestUtils.getSlateId(); private static final String LIVE_CONFIG_ID = TestUtils.getLiveConfigId(); - private static String PROJECT_ID; + private static String LIVE_CONFIG_NAME; + private static String LIVE_SESSION_NAME_PREFIX; + private static String LIVE_SESSION_NAME; private static String SESSION_ID; - private static String AD_TAG_DETAIL_ID; private static String AD_TAG_DETAIL_NAME; + private static String AD_TAG_DETAIL_ID; + private static String STITCH_DETAIL_NAME; + private static String STITCH_DETAIL_ID; + private static String PROJECT_ID; private static PrintStream originalOut; - private ByteArrayOutputStream bout; + private static ByteArrayOutputStream bout; private static String requireEnvVar(String varName) { String varValue = System.getenv(varName); @@ -58,36 +64,33 @@ private static String requireEnvVar(String varName) { } @BeforeClass - public static void checkRequirements() { + public static void beforeTest() + throws IOException, ExecutionException, InterruptedException, TimeoutException { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); - TestUtils.cleanStaleLiveConfigs(PROJECT_ID, TestUtils.LOCATION); originalOut = System.out; bout = new ByteArrayOutputStream(); System.setOut(new PrintStream(bout)); + TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); + TestUtils.cleanStaleLiveConfigs(PROJECT_ID, TestUtils.LOCATION); + + // Project number is always returned in the live session name + LIVE_SESSION_NAME = String.format("locations/%s/liveSessions/", TestUtils.LOCATION); CreateSlate.createSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, TestUtils.SLATE_URI); CreateLiveConfig.createLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID, TestUtils.LIVE_URI, TestUtils.LIVE_AD_TAG_URI, SLATE_ID); - bout.reset(); - CreateLiveSession.createLiveSession(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); - String output = bout.toString(); - Matcher idMatcher = - Pattern.compile( - String.format( - "Created live session: projects/.*/locations/%s/liveSessions/(.*)", - TestUtils.LOCATION)) - .matcher(output); - if (idMatcher.find()) { - SESSION_ID = idMatcher.group(1); - } + // Session IDs are autogenerated. + LIVE_SESSION_NAME_PREFIX = String.format("locations/%s/liveSessions/", TestUtils.LOCATION); + LiveSession sessionResponse = + CreateLiveSession.createLiveSession(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); + assertThat(sessionResponse.getName(), containsString(LIVE_SESSION_NAME_PREFIX)); + + LIVE_SESSION_NAME = sessionResponse.getName(); + String[] id = LIVE_SESSION_NAME.split("/"); + SESSION_ID = id[id.length - 1]; // To get ad tag details, you need to curl the main manifest and // a rendition first. This supplies media player information to the API. @@ -96,7 +99,7 @@ public void beforeTest() // renditions location. Curl the live session name with the rendition // location appended. - String playUri = TestUtils.getPlayUri(output); + String playUri = sessionResponse.getPlayUri(); assertNotNull(playUri); String renditions = TestUtils.getRenditions(playUri); assertNotNull(renditions); @@ -107,40 +110,65 @@ public void beforeTest() String renditionsUri = String.format("%s/%s", playUri.substring(0, playUri.lastIndexOf("/")), renditions); TestUtils.connectToRenditionsUrl(renditionsUri); - bout.reset(); - // Project number is always returned in the live session name - String adTagDetailPrefix = - String.format("locations/%s/liveSessions/%s/liveAdTagDetails/", TestUtils.LOCATION, - SESSION_ID); - ListLiveAdTagDetails.listLiveAdTagDetails(PROJECT_ID, TestUtils.LOCATION, SESSION_ID); - idMatcher = - Pattern.compile(String.format("name: \"projects/.*/%s(.*)\"", adTagDetailPrefix)) - .matcher(bout.toString()); - if (idMatcher.find()) { - AD_TAG_DETAIL_ID = idMatcher.group(1); - AD_TAG_DETAIL_NAME = adTagDetailPrefix + AD_TAG_DETAIL_ID; + ListLiveAdTagDetailsPagedResponse adtagResponse = + ListLiveAdTagDetails.listLiveAdTagDetails(PROJECT_ID, TestUtils.LOCATION, SESSION_ID); + for (LiveAdTagDetail liveAdTagDetail : adtagResponse.iterateAll()) { + AD_TAG_DETAIL_NAME = liveAdTagDetail.getName(); } + id = AD_TAG_DETAIL_NAME.split("/"); + AD_TAG_DETAIL_ID = id[id.length - 1]; + } - bout.reset(); + @Test + public void testGetLiveSession() throws IOException { + LiveSession response = GetLiveSession.getLiveSession(PROJECT_ID, TestUtils.LOCATION, + SESSION_ID); + assertThat(response.getName(), containsString(LIVE_SESSION_NAME)); } @Test - public void test_GetLiveAdTagDetail() throws IOException { - GetLiveAdTagDetail.getLiveAdTagDetail(PROJECT_ID, TestUtils.LOCATION, SESSION_ID, - AD_TAG_DETAIL_ID); - String output = bout.toString(); - assertThat(output, containsString(AD_TAG_DETAIL_NAME)); - bout.reset(); + public void testListLiveAdTagDetailsTest() throws IOException { + ListLiveAdTagDetailsPagedResponse response = + ListLiveAdTagDetails.listLiveAdTagDetails(PROJECT_ID, TestUtils.LOCATION, SESSION_ID); + + Boolean pass = false; + for (LiveAdTagDetail liveAdTagDetail : response.iterateAll()) { + if (liveAdTagDetail.getName().contains(LIVE_SESSION_NAME.concat("/liveAdTagDetails/"))) { + pass = true; + break; + } + } + assert (pass); + } + + @Test + public void testGetLiveAdTagDetailTest() throws IOException { + LiveAdTagDetail response = + GetLiveAdTagDetail.getLiveAdTagDetail( + PROJECT_ID, TestUtils.LOCATION, SESSION_ID, AD_TAG_DETAIL_ID); + assertThat(response.getName(), containsString(AD_TAG_DETAIL_NAME)); } @After - public void tearDown() + public void tearDown() { + bout.reset(); + } + + @AfterClass + public static void afterTest() throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); + // No delete method for live sessions DeleteLiveConfig.deleteLiveConfig(PROJECT_ID, TestUtils.LOCATION, LIVE_CONFIG_ID); - // No delete method for a live session or ad tag detail - System.setOut(originalOut); + String deleteResponse = bout.toString(); + assertThat(deleteResponse, containsString("Deleted live config")); bout.reset(); + + DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); + deleteResponse = bout.toString(); + assertThat(deleteResponse, containsString("Deleted slate")); + + System.out.flush(); + System.setOut(originalOut); } } diff --git a/media/stitcher/src/test/java/com/example/stitcher/UpdateSlateTest.java b/media/stitcher/src/test/java/com/example/stitcher/SlateTest.java similarity index 60% rename from media/stitcher/src/test/java/com/example/stitcher/UpdateSlateTest.java rename to media/stitcher/src/test/java/com/example/stitcher/SlateTest.java index 4fcda493fb1..108fab784f0 100644 --- a/media/stitcher/src/test/java/com/example/stitcher/UpdateSlateTest.java +++ b/media/stitcher/src/test/java/com/example/stitcher/SlateTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2022 Google LLC + * Copyright 2024 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -21,13 +21,15 @@ import static org.junit.Assert.assertNotNull; import com.google.cloud.testing.junit4.MultipleAttemptsRule; +import com.google.cloud.video.stitcher.v1.Slate; +import com.google.cloud.video.stitcher.v1.VideoStitcherServiceClient.ListSlatesPagedResponse; import java.io.ByteArrayOutputStream; import java.io.IOException; import java.io.PrintStream; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeoutException; import org.junit.After; -import org.junit.Before; +import org.junit.AfterClass; import org.junit.BeforeClass; import org.junit.Rule; import org.junit.Test; @@ -35,18 +37,17 @@ import org.junit.runners.JUnit4; @RunWith(JUnit4.class) -public class UpdateSlateTest { +public class SlateTest { @Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); private static final String SLATE_ID = TestUtils.getSlateId(); - private static String PROJECT_ID; private static String SLATE_NAME; - private static final String UPDATED_SLATE_URI = "https://storage.googleapis.com/cloud-samples-data/media/ForBiggerJoyrides.mp4"; + private static String PROJECT_ID; private static PrintStream originalOut; - private ByteArrayOutputStream bout; + private static ByteArrayOutputStream bout; private static String requireEnvVar(String varName) { String varValue = System.getenv(varName); @@ -56,40 +57,70 @@ private static String requireEnvVar(String varName) { } @BeforeClass - public static void checkRequirements() { + public static void beforeTest() + throws IOException, ExecutionException, InterruptedException, TimeoutException { requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); originalOut = System.out; bout = new ByteArrayOutputStream(); System.setOut(new PrintStream(bout)); + TestUtils.cleanStaleSlates(PROJECT_ID, TestUtils.LOCATION); + SLATE_NAME = - String.format("projects/%s/locations/%s/slates/%s", PROJECT_ID, TestUtils.LOCATION, - SLATE_ID); - CreateSlate.createSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, TestUtils.SLATE_URI); - bout.reset(); + String.format("locations/%s/slates/%s", TestUtils.LOCATION, SLATE_ID); + Slate response = + CreateSlate.createSlate( + PROJECT_ID, + TestUtils.LOCATION, + SLATE_ID, + TestUtils.SLATE_URI); + assertThat(response.getName(), containsString(SLATE_NAME)); } @Test - public void test_UpdateSlate() + public void testGetSlate() throws IOException { + Slate response = GetSlate.getSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); + assertThat(response.getName(), containsString(SLATE_NAME)); + } + + @Test + public void testListSlates() throws IOException { + ListSlatesPagedResponse response = + ListSlates.listSlates(PROJECT_ID, TestUtils.LOCATION); + Boolean pass = false; + for (Slate slate : response.iterateAll()) { + if (slate.getName().contains(SLATE_NAME)) { + pass = true; + break; + } + } + assert (pass); + } + + @Test + public void testUpdateSlate() throws IOException, ExecutionException, InterruptedException, TimeoutException { - UpdateSlate.updateSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID, UPDATED_SLATE_URI); - String output = bout.toString(); - assertThat(output, containsString(SLATE_NAME)); - bout.reset(); + Slate response = + UpdateSlate.updateSlate( + PROJECT_ID, TestUtils.LOCATION, SLATE_ID, UPDATED_SLATE_URI); + assertThat(response.getName(), containsString(SLATE_NAME)); + assertThat(response.getUri(), containsString(UPDATED_SLATE_URI)); } @After - public void tearDown() + public void tearDown() { + bout.reset(); + } + + @AfterClass + public static void afterTest() throws IOException, ExecutionException, InterruptedException, TimeoutException { DeleteSlate.deleteSlate(PROJECT_ID, TestUtils.LOCATION, SLATE_ID); + String deleteResponse = bout.toString(); + assertThat(deleteResponse, containsString("Deleted slate")); + System.out.flush(); System.setOut(originalOut); - bout.reset(); } } diff --git a/media/stitcher/src/test/java/com/example/stitcher/TestUtils.java b/media/stitcher/src/test/java/com/example/stitcher/TestUtils.java index ac66dbdbc72..d95241b004f 100644 --- a/media/stitcher/src/test/java/com/example/stitcher/TestUtils.java +++ b/media/stitcher/src/test/java/com/example/stitcher/TestUtils.java @@ -188,16 +188,6 @@ public static void cleanStaleVodConfigs(String projectId, String location) throw } } - // Finds the play URI in the given output. - public static String getPlayUri(String output) { - Matcher uriMatcher = Pattern.compile("Play URI: (.*)").matcher(output); - String playUri = null; - if (uriMatcher.find()) { - playUri = uriMatcher.group(1); - } - return playUri; - } - // Connects to the play URI and returns the renditions information. public static String getRenditions(String playUri) throws IOException { URL url = new URL(playUri); diff --git a/media/stitcher/src/test/java/com/example/stitcher/UpdateCdnKeyAkamaiTest.java b/media/stitcher/src/test/java/com/example/stitcher/UpdateCdnKeyAkamaiTest.java deleted file mode 100644 index 7cf248c9278..00000000000 --- a/media/stitcher/src/test/java/com/example/stitcher/UpdateCdnKeyAkamaiTest.java +++ /dev/null @@ -1,96 +0,0 @@ -/* - * Copyright 2022 Google LLC - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package com.example.stitcher; - -import static org.hamcrest.CoreMatchers.containsString; -import static org.hamcrest.MatcherAssert.assertThat; -import static org.junit.Assert.assertNotNull; - -import com.google.cloud.testing.junit4.MultipleAttemptsRule; -import java.io.ByteArrayOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.concurrent.ExecutionException; -import java.util.concurrent.TimeoutException; -import org.junit.After; -import org.junit.Before; -import org.junit.BeforeClass; -import org.junit.Rule; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.junit.runners.JUnit4; - -@RunWith(JUnit4.class) -public class UpdateCdnKeyAkamaiTest { - - @Rule - public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); - private static final String AKAMAI_KEY_ID = TestUtils.getCdnKeyId(); - private static final String UPDATED_AKAMAI_TOKEN_KEY = - "VGhpcyBpcyBhbiB1cGRhdGVkIHRlc3Qgc3RyaW5nLg=="; - private static String PROJECT_ID; - private static String AKAMAI_KEY_NAME; // resource name for the Akamai CDN key - private static PrintStream originalOut; - private ByteArrayOutputStream bout; - - private static String requireEnvVar(String varName) { - String varValue = System.getenv(varName); - assertNotNull( - String.format("Environment variable '%s' is required to perform these tests.", varName)); - return varValue; - } - - @BeforeClass - public static void checkRequirements() { - requireEnvVar("GOOGLE_APPLICATION_CREDENTIALS"); - PROJECT_ID = requireEnvVar("GOOGLE_CLOUD_PROJECT"); - } - - @Before - public void beforeTest() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - TestUtils.cleanStaleCdnKeys(PROJECT_ID, TestUtils.LOCATION); - originalOut = System.out; - bout = new ByteArrayOutputStream(); - System.setOut(new PrintStream(bout)); - - AKAMAI_KEY_NAME = String.format("/locations/%s/cdnKeys/%s", TestUtils.LOCATION, AKAMAI_KEY_ID); - CreateCdnKeyAkamai.createCdnKeyAkamai( - PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID, TestUtils.HOSTNAME, - TestUtils.AKAMAI_TOKEN_KEY); - bout.reset(); - } - - @Test - public void test_UpdateCdnKeyAkamai() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - UpdateCdnKeyAkamai.updateCdnKeyAkamai( - PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID, TestUtils.UPDATED_HOSTNAME, - UPDATED_AKAMAI_TOKEN_KEY); - String output = bout.toString(); - assertThat(output, containsString(AKAMAI_KEY_NAME)); - bout.reset(); - } - - @After - public void tearDown() - throws IOException, ExecutionException, InterruptedException, TimeoutException { - DeleteCdnKey.deleteCdnKey(PROJECT_ID, TestUtils.LOCATION, AKAMAI_KEY_ID); - System.setOut(originalOut); - bout.reset(); - } -} diff --git a/media/stitcher/src/test/java/com/example/stitcher/VodConfigTest.java b/media/stitcher/src/test/java/com/example/stitcher/VodConfigTest.java index b72b75d2494..5ed9e20f6a5 100644 --- a/media/stitcher/src/test/java/com/example/stitcher/VodConfigTest.java +++ b/media/stitcher/src/test/java/com/example/stitcher/VodConfigTest.java @@ -39,7 +39,8 @@ @RunWith(JUnit4.class) public class VodConfigTest { - @Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); + @Rule + public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); private static final String VOD_CONFIG_ID = TestUtils.getVodConfigId(); private static String VOD_CONFIG_NAME; private static String PROJECT_ID; diff --git a/media/stitcher/src/test/java/com/example/stitcher/VodSessionTest.java b/media/stitcher/src/test/java/com/example/stitcher/VodSessionTest.java index fc1fd4bf82e..007c666b1b2 100644 --- a/media/stitcher/src/test/java/com/example/stitcher/VodSessionTest.java +++ b/media/stitcher/src/test/java/com/example/stitcher/VodSessionTest.java @@ -43,7 +43,8 @@ @RunWith(JUnit4.class) public class VodSessionTest { - @Rule public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); + @Rule + public final MultipleAttemptsRule multipleAttemptsRule = new MultipleAttemptsRule(5); private static final String VOD_CONFIG_ID = TestUtils.getVodConfigId(); private static String VOD_CONFIG_NAME; private static String VOD_SESSION_NAME_PREFIX; From be8b4fbd195692fcd89976c1beb76a5039b44bf9 Mon Sep 17 00:00:00 2001 From: Nick Cook Date: Tue, 6 Aug 2024 09:34:18 -0700 Subject: [PATCH 2/3] fix checkstyle errors --- .../src/main/java/com/example/stitcher/CreateCdnKey.java | 3 ++- .../java/com/example/stitcher/CreateCdnKeyAkamai.java | 3 ++- .../main/java/com/example/stitcher/CreateLiveConfig.java | 3 ++- .../main/java/com/example/stitcher/CreateLiveSession.java | 4 ++-- .../src/main/java/com/example/stitcher/CreateSlate.java | 6 ++++-- .../src/main/java/com/example/stitcher/DeleteCdnKey.java | 3 ++- .../main/java/com/example/stitcher/DeleteLiveConfig.java | 3 ++- .../src/main/java/com/example/stitcher/DeleteSlate.java | 3 ++- .../src/main/java/com/example/stitcher/ListCdnKeys.java | 3 ++- .../java/com/example/stitcher/ListLiveAdTagDetails.java | 4 ++-- .../main/java/com/example/stitcher/ListLiveConfigs.java | 3 ++- .../src/main/java/com/example/stitcher/ListSlates.java | 3 ++- .../src/main/java/com/example/stitcher/UpdateCdnKey.java | 3 ++- .../java/com/example/stitcher/UpdateCdnKeyAkamai.java | 5 +++-- .../src/main/java/com/example/stitcher/UpdateSlate.java | 6 ++++-- .../src/test/java/com/example/stitcher/CdnKeyTest.java | 8 ++++---- 16 files changed, 39 insertions(+), 24 deletions(-) diff --git a/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKey.java b/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKey.java index 71feefe318d..7bdee260d98 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKey.java +++ b/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKey.java @@ -62,7 +62,8 @@ public static CdnKey createCdnKey( throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. - try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + try (VideoStitcherServiceClient videoStitcherServiceClient = + VideoStitcherServiceClient.create()) { CdnKey cdnKey; if (isMediaCdn) { cdnKey = diff --git a/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKeyAkamai.java b/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKeyAkamai.java index df74c98bbfa..bc1bfbde318 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKeyAkamai.java +++ b/media/stitcher/src/main/java/com/example/stitcher/CreateCdnKeyAkamai.java @@ -50,7 +50,8 @@ public static CdnKey createCdnKeyAkamai( throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. - try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + try (VideoStitcherServiceClient videoStitcherServiceClient = + VideoStitcherServiceClient.create()) { CdnKey cdnKey = CdnKey.newBuilder() .setHostname(hostname) diff --git a/media/stitcher/src/main/java/com/example/stitcher/CreateLiveConfig.java b/media/stitcher/src/main/java/com/example/stitcher/CreateLiveConfig.java index 82364ab4b25..6b5500cd02e 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/CreateLiveConfig.java +++ b/media/stitcher/src/main/java/com/example/stitcher/CreateLiveConfig.java @@ -63,7 +63,8 @@ public static LiveConfig createLiveConfig( throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. - try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + try (VideoStitcherServiceClient videoStitcherServiceClient = + VideoStitcherServiceClient.create()) { CreateLiveConfigRequest createLiveConfigRequest = CreateLiveConfigRequest.newBuilder() .setParent(LocationName.of(projectId, location).toString()) diff --git a/media/stitcher/src/main/java/com/example/stitcher/CreateLiveSession.java b/media/stitcher/src/main/java/com/example/stitcher/CreateLiveSession.java index ae1422660bf..7e84d8d02af 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/CreateLiveSession.java +++ b/media/stitcher/src/main/java/com/example/stitcher/CreateLiveSession.java @@ -39,8 +39,8 @@ public static void main(String[] args) throws Exception { // Creates a live session given the parameters in the supplied live config. // For more information, see // https://cloud.google.com/video-stitcher/docs/how-to/managing-live-sessions. - public static LiveSession createLiveSession(String projectId, String location, String liveConfigId) - throws IOException { + public static LiveSession createLiveSession( + String projectId, String location, String liveConfigId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = diff --git a/media/stitcher/src/main/java/com/example/stitcher/CreateSlate.java b/media/stitcher/src/main/java/com/example/stitcher/CreateSlate.java index 6ff255ff56d..c051507d7ac 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/CreateSlate.java +++ b/media/stitcher/src/main/java/com/example/stitcher/CreateSlate.java @@ -45,11 +45,13 @@ public static void main(String[] args) throws Exception { // Creates a slate. Slates are content that can be served when there are gaps in a livestream // ad break that cannot be filled with a dynamically served ad. For more information, see // https://cloud.google.com/video-stitcher/docs/how-to/managing-slates. - public static Slate createSlate(String projectId, String location, String slateId, String slateUri) + public static Slate createSlate( + String projectId, String location, String slateId, String slateUri) throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. - try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + try (VideoStitcherServiceClient videoStitcherServiceClient = + VideoStitcherServiceClient.create()) { CreateSlateRequest createSlateRequest = CreateSlateRequest.newBuilder() .setParent(LocationName.of(projectId, location).toString()) diff --git a/media/stitcher/src/main/java/com/example/stitcher/DeleteCdnKey.java b/media/stitcher/src/main/java/com/example/stitcher/DeleteCdnKey.java index b626e1d7011..bc97822710d 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/DeleteCdnKey.java +++ b/media/stitcher/src/main/java/com/example/stitcher/DeleteCdnKey.java @@ -44,7 +44,8 @@ public static void deleteCdnKey(String projectId, String location, String cdnKey throws InterruptedException, ExecutionException, TimeoutException, IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. - try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + try (VideoStitcherServiceClient videoStitcherServiceClient = + VideoStitcherServiceClient.create()) { DeleteCdnKeyRequest deleteCdnKeyRequest = DeleteCdnKeyRequest.newBuilder() .setName(CdnKeyName.of(projectId, location, cdnKeyId).toString()) diff --git a/media/stitcher/src/main/java/com/example/stitcher/DeleteLiveConfig.java b/media/stitcher/src/main/java/com/example/stitcher/DeleteLiveConfig.java index 5cd2f883d79..69d3f04cbd2 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/DeleteLiveConfig.java +++ b/media/stitcher/src/main/java/com/example/stitcher/DeleteLiveConfig.java @@ -44,7 +44,8 @@ public static void deleteLiveConfig(String projectId, String location, String li throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. - try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + try (VideoStitcherServiceClient videoStitcherServiceClient = + VideoStitcherServiceClient.create()) { DeleteLiveConfigRequest deleteLiveConfigRequest = DeleteLiveConfigRequest.newBuilder() .setName(LiveConfigName.of(projectId, location, liveConfigId).toString()) diff --git a/media/stitcher/src/main/java/com/example/stitcher/DeleteSlate.java b/media/stitcher/src/main/java/com/example/stitcher/DeleteSlate.java index 0a083acd6c3..875ff4dd2dc 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/DeleteSlate.java +++ b/media/stitcher/src/main/java/com/example/stitcher/DeleteSlate.java @@ -44,7 +44,8 @@ public static void deleteSlate(String projectId, String location, String slateId throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. - try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + try (VideoStitcherServiceClient videoStitcherServiceClient = + VideoStitcherServiceClient.create()) { DeleteSlateRequest deleteSlateRequest = DeleteSlateRequest.newBuilder() .setName(SlateName.of(projectId, location, slateId).toString()) diff --git a/media/stitcher/src/main/java/com/example/stitcher/ListCdnKeys.java b/media/stitcher/src/main/java/com/example/stitcher/ListCdnKeys.java index 16f94eb2335..dfd9d407b81 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/ListCdnKeys.java +++ b/media/stitcher/src/main/java/com/example/stitcher/ListCdnKeys.java @@ -36,7 +36,8 @@ public static void main(String[] args) throws Exception { } // Lists the CDN keys for a given project and location. - public static ListCdnKeysPagedResponse listCdnKeys(String projectId, String location) throws IOException { + public static ListCdnKeysPagedResponse listCdnKeys(String projectId, String location) + throws IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = diff --git a/media/stitcher/src/main/java/com/example/stitcher/ListLiveAdTagDetails.java b/media/stitcher/src/main/java/com/example/stitcher/ListLiveAdTagDetails.java index 59d9b6a3c66..a03ef0b1b3a 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/ListLiveAdTagDetails.java +++ b/media/stitcher/src/main/java/com/example/stitcher/ListLiveAdTagDetails.java @@ -37,8 +37,8 @@ public static void main(String[] args) throws Exception { } // Lists the live ad tag details for a given live session. - public static ListLiveAdTagDetailsPagedResponse listLiveAdTagDetails(String projectId, String location, String sessionId) - throws IOException { + public static ListLiveAdTagDetailsPagedResponse listLiveAdTagDetails( + String projectId, String location, String sessionId) throws IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = diff --git a/media/stitcher/src/main/java/com/example/stitcher/ListLiveConfigs.java b/media/stitcher/src/main/java/com/example/stitcher/ListLiveConfigs.java index 29e1160d7b7..557c0fab8be 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/ListLiveConfigs.java +++ b/media/stitcher/src/main/java/com/example/stitcher/ListLiveConfigs.java @@ -36,7 +36,8 @@ public static void main(String[] args) throws Exception { } // Lists the live configs for a given project and location. - public static ListLiveConfigsPagedResponse listLiveConfigs(String projectId, String location) throws IOException { + public static ListLiveConfigsPagedResponse listLiveConfigs(String projectId, String location) + throws IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = diff --git a/media/stitcher/src/main/java/com/example/stitcher/ListSlates.java b/media/stitcher/src/main/java/com/example/stitcher/ListSlates.java index 9f19b356c88..c3a5c4fe721 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/ListSlates.java +++ b/media/stitcher/src/main/java/com/example/stitcher/ListSlates.java @@ -36,7 +36,8 @@ public static void main(String[] args) throws Exception { } // Lists the slates for a given project and location. - public static ListSlatesPagedResponse listSlates(String projectId, String location) throws IOException { + public static ListSlatesPagedResponse listSlates(String projectId, String location) + throws IOException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. try (VideoStitcherServiceClient videoStitcherServiceClient = diff --git a/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKey.java b/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKey.java index 64352ba7262..ae158fa57e8 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKey.java +++ b/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKey.java @@ -63,7 +63,8 @@ public static CdnKey updateCdnKey( throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. - try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + try (VideoStitcherServiceClient videoStitcherServiceClient = + VideoStitcherServiceClient.create()) { CdnKey cdnKey; String path; if (isMediaCdn) { diff --git a/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKeyAkamai.java b/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKeyAkamai.java index 79e1f8b8b57..af73df72ca9 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKeyAkamai.java +++ b/media/stitcher/src/main/java/com/example/stitcher/UpdateCdnKeyAkamai.java @@ -45,13 +45,14 @@ public static void main(String[] args) throws Exception { updateCdnKeyAkamai(projectId, location, cdnKeyId, hostname, akamaiTokenKey); } - // updateCdnKeyAkamai u/**/pdates the hostname and key fields for an existing CDN key. + // updateCdnKeyAkamai updates the hostname and key fields for an existing CDN key. public static CdnKey updateCdnKeyAkamai( String projectId, String location, String cdnKeyId, String hostname, String akamaiTokenKey) throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. - try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + try (VideoStitcherServiceClient videoStitcherServiceClient = + VideoStitcherServiceClient.create()) { CdnKey cdnKey = CdnKey.newBuilder() .setName(CdnKeyName.of(projectId, location, cdnKeyId).toString()) diff --git a/media/stitcher/src/main/java/com/example/stitcher/UpdateSlate.java b/media/stitcher/src/main/java/com/example/stitcher/UpdateSlate.java index 29772444779..c0f3fbca7ba 100644 --- a/media/stitcher/src/main/java/com/example/stitcher/UpdateSlate.java +++ b/media/stitcher/src/main/java/com/example/stitcher/UpdateSlate.java @@ -44,11 +44,13 @@ public static void main(String[] args) throws Exception { } // updateSlate updates the slate URI for an existing slate. - public static Slate updateSlate(String projectId, String location, String slateId, String slateUri) + public static Slate updateSlate( + String projectId, String location, String slateId, String slateUri) throws IOException, ExecutionException, InterruptedException, TimeoutException { // Initialize client that will be used to send requests. This client only needs to be created // once, and can be reused for multiple requests. - try (VideoStitcherServiceClient videoStitcherServiceClient = VideoStitcherServiceClient.create()) { + try (VideoStitcherServiceClient videoStitcherServiceClient = + VideoStitcherServiceClient.create()) { UpdateSlateRequest updateSlateRequest = UpdateSlateRequest.newBuilder() .setSlate( diff --git a/media/stitcher/src/test/java/com/example/stitcher/CdnKeyTest.java b/media/stitcher/src/test/java/com/example/stitcher/CdnKeyTest.java index 661e2dd4df6..db7d425896a 100644 --- a/media/stitcher/src/test/java/com/example/stitcher/CdnKeyTest.java +++ b/media/stitcher/src/test/java/com/example/stitcher/CdnKeyTest.java @@ -130,12 +130,12 @@ public void testListCdnKeys() throws IOException { Boolean media = false; Boolean akamai = false; - for (CdnKey CdnKey : response.iterateAll()) { - if (CdnKey.getName().contains(CLOUD_CDN_KEY_NAME)) { + for (CdnKey cdnKey : response.iterateAll()) { + if (cdnKey.getName().contains(CLOUD_CDN_KEY_NAME)) { cloud = true; - } else if (CdnKey.getName().contains(MEDIA_CDN_KEY_NAME)) { + } else if (cdnKey.getName().contains(MEDIA_CDN_KEY_NAME)) { media = true; - } else if (CdnKey.getName().contains(AKAMAI_KEY_NAME)) { + } else if (cdnKey.getName().contains(AKAMAI_KEY_NAME)) { akamai = true; } } From 35076142e378a4c646aa568da146776ad9f084fd Mon Sep 17 00:00:00 2001 From: Nick Cook Date: Mon, 12 Aug 2024 12:46:12 -0700 Subject: [PATCH 3/3] retain original year for copyright --- .../stitcher/src/test/java/com/example/stitcher/CdnKeyTest.java | 2 +- .../src/test/java/com/example/stitcher/LiveConfigTest.java | 2 +- .../src/test/java/com/example/stitcher/LiveSessionTest.java | 2 +- .../stitcher/src/test/java/com/example/stitcher/SlateTest.java | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/media/stitcher/src/test/java/com/example/stitcher/CdnKeyTest.java b/media/stitcher/src/test/java/com/example/stitcher/CdnKeyTest.java index db7d425896a..4c847bb312e 100644 --- a/media/stitcher/src/test/java/com/example/stitcher/CdnKeyTest.java +++ b/media/stitcher/src/test/java/com/example/stitcher/CdnKeyTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Google LLC + * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/media/stitcher/src/test/java/com/example/stitcher/LiveConfigTest.java b/media/stitcher/src/test/java/com/example/stitcher/LiveConfigTest.java index 44c016ae41f..a1d34bcd091 100644 --- a/media/stitcher/src/test/java/com/example/stitcher/LiveConfigTest.java +++ b/media/stitcher/src/test/java/com/example/stitcher/LiveConfigTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Google LLC + * Copyright 2023 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/media/stitcher/src/test/java/com/example/stitcher/LiveSessionTest.java b/media/stitcher/src/test/java/com/example/stitcher/LiveSessionTest.java index f5ac325dc49..1c160796913 100644 --- a/media/stitcher/src/test/java/com/example/stitcher/LiveSessionTest.java +++ b/media/stitcher/src/test/java/com/example/stitcher/LiveSessionTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Google LLC + * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. diff --git a/media/stitcher/src/test/java/com/example/stitcher/SlateTest.java b/media/stitcher/src/test/java/com/example/stitcher/SlateTest.java index 108fab784f0..62f7e98f773 100644 --- a/media/stitcher/src/test/java/com/example/stitcher/SlateTest.java +++ b/media/stitcher/src/test/java/com/example/stitcher/SlateTest.java @@ -1,5 +1,5 @@ /* - * Copyright 2024 Google LLC + * Copyright 2022 Google LLC * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License.