From e2d1d289ab88a4d93fa04535611a6ea36a92a69a Mon Sep 17 00:00:00 2001 From: Stephanie Sterling Date: Thu, 29 Sep 2022 12:38:25 -0700 Subject: [PATCH 1/4] Fix tests --- src/test/java/AuthFailureTest.java | 2 +- src/test/java/CustomRequestTest.java | 123 +++--- src/test/java/DownloadImagesTest.java | 84 ++-- src/test/java/DownloadVideosTest.java | 52 ++- src/test/java/ImagesTest.java | 42 +- src/test/java/SearchImagesCreativeTest.java | 322 ++++++++------- src/test/java/SearchImagesEditorialTest.java | 392 +++++++++---------- src/test/java/SearchImagesTest.java | 350 ++++++++--------- src/test/java/SearchVideosCreativeTest.java | 210 +++++----- src/test/java/SearchVideosEditorialTest.java | 238 ++++++----- src/test/java/SearchVideosTest.java | 238 ++++++----- src/test/java/VideosTest.java | 42 +- 12 files changed, 1025 insertions(+), 1070 deletions(-) diff --git a/src/test/java/AuthFailureTest.java b/src/test/java/AuthFailureTest.java index 86172b3..1dc853c 100644 --- a/src/test/java/AuthFailureTest.java +++ b/src/test/java/AuthFailureTest.java @@ -1,4 +1,4 @@ -import static org.junit.Assert.assertEquals; +import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertThrows; import static org.mockserver.integration.ClientAndServer.startClientAndServer; import static org.mockserver.model.HttpRequest.request; diff --git a/src/test/java/CustomRequestTest.java b/src/test/java/CustomRequestTest.java index 24e3f0b..12ae0cb 100644 --- a/src/test/java/CustomRequestTest.java +++ b/src/test/java/CustomRequestTest.java @@ -37,10 +37,6 @@ public static void startProxy() throws Exception { field.setAccessible(true); field.set(null, "http://127.0.0.1:1080/"); mockServer = startClientAndServer(1080); - } - - @BeforeEach - public void createMock(){ MockServerClient client = new MockServerClient("127.0.0.1", 1080); client @@ -53,81 +49,80 @@ public void createMock(){ .withBody("{ access_token: 'client_credentials_access_token', token_type: 'Bearer', expires_in: '1800' }") ); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("phrase", "cat"), - new Parameter("compositions", "abstract,full_frame") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("phrase", "cat"), + new Parameter("compositions", "abstract,full_frame") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("POST") - .withPath("/downloads/images/12345") - .withQueryStringParameters( - new Parameter("auto_download", "false") - ) - ) + request() + .withMethod("POST") + .withPath("/downloads/images/12345") + .withQueryStringParameters( + new Parameter("auto_download", "false") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("POST") - .withPath("/boards") - .withBody( - json("{" + System.lineSeparator() + - " \"name\": \"new board\"," + System.lineSeparator() + - " \"description\": \"new description\"" + System.lineSeparator() + - "}", - MatchType.STRICT + request() + .withMethod("POST") + .withPath("/boards") + .withBody( + json("{" + System.lineSeparator() + + " \"name\": \"new board\"," + System.lineSeparator() + + " \"description\": \"new description\"" + System.lineSeparator() + + "}", + MatchType.STRICT + ) ) - ) - ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("PUT") - .withPath("/asset-changes/change-sets") - .withQueryStringParameters( - new Parameter("channel_id", "3") - ) - ) + request() + .withMethod("PUT") + .withPath("/asset-changes/change-sets") + .withQueryStringParameters( + new Parameter("channel_id", "3") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("PUT") - .withPath("/boards/111") - .withBody( - json("{" + System.lineSeparator() + - " \"name\": \"new board\"," + System.lineSeparator() + - " \"description\": \"new description\"" + System.lineSeparator() + - "}", - MatchType.STRICT + request() + .withMethod("PUT") + .withPath("/boards/111") + .withBody( + json("{" + System.lineSeparator() + + " \"name\": \"new board\"," + System.lineSeparator() + + " \"description\": \"new description\"" + System.lineSeparator() + + "}", + MatchType.STRICT + ) ) - ) - ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("DELETE") - .withPath("/boards/333") - .withQueryStringParameters( - new Parameter("asset_ids", "1234,5678") - ) - ) + request() + .withMethod("DELETE") + .withPath("/boards/333") + .withQueryStringParameters( + new Parameter("asset_ids", "1234,5678") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("phrase", "cat") - ) - .withHeader("Accept-Language", "de") - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("phrase", "cat") + ) + .withHeader("Accept-Language", "de") + ) .respond(response().withStatusCode(200).withBody("success")); - } @Test diff --git a/src/test/java/DownloadImagesTest.java b/src/test/java/DownloadImagesTest.java index 63aac36..08558bf 100644 --- a/src/test/java/DownloadImagesTest.java +++ b/src/test/java/DownloadImagesTest.java @@ -28,10 +28,6 @@ public static void startProxy() throws Exception { field.setAccessible(true); field.set(null, "http://127.0.0.1:1080/"); mockServer = startClientAndServer(1080); - } - - @BeforeEach - public void createMock(){ MockServerClient client = new MockServerClient("127.0.0.1", 1080); client @@ -44,54 +40,54 @@ public void createMock(){ .withBody("{ access_token: 'client_credentials_access_token', token_type: 'Bearer', expires_in: '1800' }") ); client.when( - request() - .withMethod("POST") - .withPath("/downloads/images/12345") - .withQueryStringParameters( - new Parameter("auto_download", "false") - ) - .withHeader("Accept-Language", "de") - ) + request() + .withMethod("POST") + .withPath("/downloads/images/12345") + .withQueryStringParameters( + new Parameter("auto_download", "false") + ) + .withHeader("Accept-Language", "de") + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("POST") - .withPath("/downloads/images/12345") - .withQueryStringParameters( - new Parameter("file_type", "jpg"), - new Parameter("auto_download", "false") - ) - ) + request() + .withMethod("POST") + .withPath("/downloads/images/12345") + .withQueryStringParameters( + new Parameter("file_type", "jpg"), + new Parameter("auto_download", "false") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("POST") - .withPath("/downloads/images/12345") - .withQueryStringParameters( - new Parameter("auto_download", "false"), - new Parameter("height", "592") - ) - ) + request() + .withMethod("POST") + .withPath("/downloads/images/12345") + .withQueryStringParameters( + new Parameter("auto_download", "false"), + new Parameter("height", "592") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("POST") - .withPath("/downloads/images/12345") - .withQueryStringParameters( - new Parameter("product_id", "9876"), - new Parameter("auto_download", "false") - ) - ) + request() + .withMethod("POST") + .withPath("/downloads/images/12345") + .withQueryStringParameters( + new Parameter("product_id", "9876"), + new Parameter("auto_download", "false") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("POST") - .withPath("/downloads/images/12345") - .withQueryStringParameters( - new Parameter("product_type", "easyaccess"), - new Parameter("auto_download", "false") - ) - ) + request() + .withMethod("POST") + .withPath("/downloads/images/12345") + .withQueryStringParameters( + new Parameter("product_type", "easyaccess"), + new Parameter("auto_download", "false") + ) + ) .respond(response().withStatusCode(200).withBody("success")); } diff --git a/src/test/java/DownloadVideosTest.java b/src/test/java/DownloadVideosTest.java index 6fdb9d7..4143e8c 100644 --- a/src/test/java/DownloadVideosTest.java +++ b/src/test/java/DownloadVideosTest.java @@ -26,10 +26,6 @@ public static void startProxy() throws Exception { field.setAccessible(true); field.set(null, "http://127.0.0.1:1080/"); mockServer = startClientAndServer(1080); - } - - @BeforeEach - public void createMock(){ MockServerClient client = new MockServerClient("127.0.0.1", 1080); client @@ -42,34 +38,34 @@ public void createMock(){ .withBody("{ access_token: 'client_credentials_access_token', token_type: 'Bearer', expires_in: '1800' }") ); client.when( - request() - .withMethod("POST") - .withPath("/downloads/videos/12345") - .withQueryStringParameters( - new Parameter("auto_download", "false") - ) - .withHeader("Accept-Language", "de") - ) + request() + .withMethod("POST") + .withPath("/downloads/videos/12345") + .withQueryStringParameters( + new Parameter("auto_download", "false") + ) + .withHeader("Accept-Language", "de") + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("POST") - .withPath("/downloads/videos/12345") - .withQueryStringParameters( - new Parameter("product_id", "9876"), - new Parameter("auto_download", "false") - ) - ) + request() + .withMethod("POST") + .withPath("/downloads/videos/12345") + .withQueryStringParameters( + new Parameter("product_id", "9876"), + new Parameter("auto_download", "false") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("POST") - .withPath("/downloads/videos/12345") - .withQueryStringParameters( - new Parameter("size", "size"), - new Parameter("auto_download", "false") - ) - ) + request() + .withMethod("POST") + .withPath("/downloads/videos/12345") + .withQueryStringParameters( + new Parameter("size", "size"), + new Parameter("auto_download", "false") + ) + ) .respond(response().withStatusCode(200).withBody("success")); } diff --git a/src/test/java/ImagesTest.java b/src/test/java/ImagesTest.java index c481cc1..571b8c8 100644 --- a/src/test/java/ImagesTest.java +++ b/src/test/java/ImagesTest.java @@ -27,10 +27,6 @@ public static void startProxy() throws Exception { field.setAccessible(true); field.set(null, "http://127.0.0.1:1080/"); mockServer = startClientAndServer(1080); - } - - @BeforeEach - public void createMock(){ MockServerClient client = new MockServerClient("127.0.0.1", 1080); client @@ -43,29 +39,29 @@ public void createMock(){ .withBody("{ access_token: 'client_credentials_access_token', token_type: 'Bearer', expires_in: '1800' }") ); client.when( - request() - .withMethod("GET") - .withPath("/images/12345") - .withHeader("Accept-Language", "de") - ) + request() + .withMethod("GET") + .withPath("/images/12345") + .withHeader("Accept-Language", "de") + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/images/12345") - .withQueryStringParameters( - new Parameter("fields", "country,id") - ) - ) + request() + .withMethod("GET") + .withPath("/images/12345") + .withQueryStringParameters( + new Parameter("fields", "country,id") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/images") - .withQueryStringParameters( - new Parameter("ids", "12345,678910") - ) - ) + request() + .withMethod("GET") + .withPath("/images") + .withQueryStringParameters( + new Parameter("ids", "12345,678910") + ) + ) .respond(response().withStatusCode(200).withBody("success")); } diff --git a/src/test/java/SearchImagesCreativeTest.java b/src/test/java/SearchImagesCreativeTest.java index 6bd0cd0..e9162a4 100644 --- a/src/test/java/SearchImagesCreativeTest.java +++ b/src/test/java/SearchImagesCreativeTest.java @@ -28,10 +28,6 @@ public static void startProxy() throws Exception { field.setAccessible(true); field.set(null, "http://127.0.0.1:1080/"); mockServer = startClientAndServer(1080); - } - - @BeforeEach - public void createMock(){ MockServerClient client = new MockServerClient("127.0.0.1", 1080); client @@ -44,209 +40,209 @@ public void createMock(){ .withBody("{ access_token: 'client_credentials_access_token', token_type: 'Bearer', expires_in: '1800' }") ); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withHeader("Accept-Language", "de") - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withHeader("Accept-Language", "de") + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("age_of_people", "baby,child,adult") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("age_of_people", "baby,child,adult") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("artists", "roman makhmutov") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("artists", "roman makhmutov") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("collection_codes", "WRI,ARF") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("collection_codes", "WRI,ARF") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("collections_filter_type", "exclude") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("collections_filter_type", "exclude") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("color", "#002244") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("color", "#002244") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("compositions", "abstract,headshot") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("compositions", "abstract,headshot") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("embed_content_only", "true") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("embed_content_only", "true") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("ethnicity", "black,japanese") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("ethnicity", "black,japanese") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("exclude_nudity", "true") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("exclude_nudity", "true") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("fields", "asset_family,id,uri_oembed") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("fields", "asset_family,id,uri_oembed") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("file_types", "eps,jpg") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("file_types", "eps,jpg") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("graphical_styles", "fine_art,illustration") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("graphical_styles", "fine_art,illustration") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("keyword_ids", "1111,2222,3333") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("keyword_ids", "1111,2222,3333") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("minimum_size", "small") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("minimum_size", "small") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("number_of_people", "one,group") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("number_of_people", "one,group") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("orientations", "Horizontal,Square") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("orientations", "Horizontal,Square") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("page", "3") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("page", "3") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("page_size", "50") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("page_size", "50") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("phrase", "cat") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("phrase", "cat") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("prestige_content_only", "true") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("prestige_content_only", "true") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("product_types", "easyaccess,editorialsubscription") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("product_types", "easyaccess,editorialsubscription") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/creative") - .withQueryStringParameters( - new Parameter("sort_order", "newest") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("sort_order", "newest") + ) + ) .respond(response().withStatusCode(200).withBody("success")); } diff --git a/src/test/java/SearchImagesEditorialTest.java b/src/test/java/SearchImagesEditorialTest.java index 05241ee..5e34616 100644 --- a/src/test/java/SearchImagesEditorialTest.java +++ b/src/test/java/SearchImagesEditorialTest.java @@ -28,10 +28,6 @@ public static void startProxy() throws Exception { field.setAccessible(true); field.set(null, "http://127.0.0.1:1080/"); mockServer = startClientAndServer(1080); - } - - @BeforeEach - public void createMock(){ MockServerClient client = new MockServerClient("127.0.0.1", 1080); client @@ -44,254 +40,254 @@ public void createMock(){ .withBody("{ access_token: 'client_credentials_access_token', token_type: 'Bearer', expires_in: '1800' }") ); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withHeader("Accept-Language", "de") - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withHeader("Accept-Language", "de") + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("age_of_people", "baby,child,adult") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("age_of_people", "baby,child,adult") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("artists", "roman makhmutov") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("artists", "roman makhmutov") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("collection_codes", "WRI,ARF") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("collection_codes", "WRI,ARF") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("collections_filter_type", "exclude") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("collections_filter_type", "exclude") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("compositions", "abstract,headshot") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("compositions", "abstract,headshot") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("editorial_segments", "archival,publicity") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("editorial_segments", "archival,publicity") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("embed_content_only", "true") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("embed_content_only", "true") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("end_date", "2015-04-01") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("end_date", "2015-04-01") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("entity_uris", "uri1,uri2") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("entity_uris", "uri1,uri2") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("ethnicity", "black,japanese") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("ethnicity", "black,japanese") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("event_ids", "123,456,789") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("event_ids", "123,456,789") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("exclude_nudity", "true") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("exclude_nudity", "true") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("fields", "asset_family,id,uri_oembed") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("fields", "asset_family,id,uri_oembed") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("file_types", "eps,jpg") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("file_types", "eps,jpg") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("graphical_styles", "fine_art,illustration") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("graphical_styles", "fine_art,illustration") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("keyword_ids", "1111,2222,3333") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("keyword_ids", "1111,2222,3333") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("minimum_quality_rank", "1") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("minimum_quality_rank", "1") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("minimum_size", "small") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("minimum_size", "small") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("number_of_people", "one,group") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("number_of_people", "one,group") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("orientations", "Horizontal,Square") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("orientations", "Horizontal,Square") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("page", "3") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("page", "3") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("page_size", "50") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("page_size", "50") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("phrase", "cat") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("phrase", "cat") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("product_types", "easyaccess,editorialsubscription") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("product_types", "easyaccess,editorialsubscription") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("sort_order", "newest") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("sort_order", "newest") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("specific_people", "Reggie Jackson") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("specific_people", "Reggie Jackson") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images/editorial") - .withQueryStringParameters( - new Parameter("start_date", "2015-04-01") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("start_date", "2015-04-01") + ) + ) .respond(response().withStatusCode(200).withBody("success")); } diff --git a/src/test/java/SearchImagesTest.java b/src/test/java/SearchImagesTest.java index 3af0225..2fb0b12 100644 --- a/src/test/java/SearchImagesTest.java +++ b/src/test/java/SearchImagesTest.java @@ -28,10 +28,6 @@ public static void startProxy() throws Exception { field.setAccessible(true); field.set(null, "http://127.0.0.1:1080/"); mockServer = startClientAndServer(1080); - } - - @BeforeEach - public void createMock(){ MockServerClient client = new MockServerClient("127.0.0.1", 1080); client @@ -44,227 +40,227 @@ public void createMock(){ .withBody("{ access_token: 'client_credentials_access_token', token_type: 'Bearer', expires_in: '1800' }") ); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withHeader("Accept-Language", "de") - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withHeader("Accept-Language", "de") + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("age_of_people", "baby,child,adult") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("age_of_people", "baby,child,adult") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("artists", "roman makhmutov") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("artists", "roman makhmutov") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("collection_codes", "WRI,ARF") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("collection_codes", "WRI,ARF") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("collections_filter_type", "exclude") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("collections_filter_type", "exclude") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("color", "#002244") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("color", "#002244") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("compositions", "abstract,headshot") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("compositions", "abstract,headshot") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("embed_content_only", "true") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("embed_content_only", "true") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("ethnicity", "black,japanese") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("ethnicity", "black,japanese") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("event_ids", "123,456,789") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("event_ids", "123,456,789") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("exclude_nudity", "true") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("exclude_nudity", "true") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("fields", "asset_family,id,uri_oembed") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("fields", "asset_family,id,uri_oembed") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("file_types", "eps,jpg") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("file_types", "eps,jpg") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("graphical_styles", "fine_art,illustration") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("graphical_styles", "fine_art,illustration") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("keyword_ids", "1111,2222,3333") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("keyword_ids", "1111,2222,3333") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("minimum_size", "small") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("minimum_size", "small") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("number_of_people", "one,group") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("number_of_people", "one,group") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("orientations", "Horizontal,Square") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("orientations", "Horizontal,Square") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("page", "3") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("page", "3") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("page_size", "50") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("page_size", "50") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("phrase", "cat") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("phrase", "cat") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("prestige_content_only", "true") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("prestige_content_only", "true") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("product_types", "easyaccess,editorialsubscription") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("product_types", "easyaccess,editorialsubscription") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("sort_order", "newest") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("sort_order", "newest") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/images") - .withQueryStringParameters( - new Parameter("specific_people", "Reggie Jackson") - ) - ) + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("specific_people", "Reggie Jackson") + ) + ) .respond(response().withStatusCode(200).withBody("success")); } diff --git a/src/test/java/SearchVideosCreativeTest.java b/src/test/java/SearchVideosCreativeTest.java index f5a53fe..d0ad0f5 100644 --- a/src/test/java/SearchVideosCreativeTest.java +++ b/src/test/java/SearchVideosCreativeTest.java @@ -28,10 +28,6 @@ public static void startProxy() throws Exception { field.setAccessible(true); field.set(null, "http://127.0.0.1:1080/"); mockServer = startClientAndServer(1080); - } - - @BeforeEach - public void createMock(){ MockServerClient client = new MockServerClient("127.0.0.1", 1080); client @@ -44,137 +40,137 @@ public void createMock(){ .withBody("{ access_token: 'client_credentials_access_token', token_type: 'Bearer', expires_in: '1800' }") ); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withHeader("Accept-Language", "de") - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withHeader("Accept-Language", "de") + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("age_of_people", "baby,child,adult") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("age_of_people", "baby,child,adult") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("collection_codes", "WRI,ARF") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("collection_codes", "WRI,ARF") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("collections_filter_type", "exclude") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("collections_filter_type", "exclude") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("exclude_nudity", "true") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("exclude_nudity", "true") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("fields", "asset_family,id,uri_oembed") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("fields", "asset_family,id,uri_oembed") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("format_available", "hd") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("format_available", "hd") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("frame_rates", "24,29.97") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("frame_rates", "24,29.97") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("keyword_ids", "1111,2222,3333") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("keyword_ids", "1111,2222,3333") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("license_models", "rightsmanaged") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("license_models", "rightsmanaged") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("page", "3") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("page", "3") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("page_size", "50") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("page_size", "50") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("phrase", "cat") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("phrase", "cat") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("product_types", "easyaccess,editorialsubscription") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("product_types", "easyaccess,editorialsubscription") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/creative") - .withQueryStringParameters( - new Parameter("sort_order", "newest") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("sort_order", "newest") + ) + ) .respond(response().withStatusCode(200).withBody("success")); } diff --git a/src/test/java/SearchVideosEditorialTest.java b/src/test/java/SearchVideosEditorialTest.java index dca65fa..04d73a0 100644 --- a/src/test/java/SearchVideosEditorialTest.java +++ b/src/test/java/SearchVideosEditorialTest.java @@ -28,10 +28,6 @@ public static void startProxy() throws Exception { field.setAccessible(true); field.set(null, "http://127.0.0.1:1080/"); mockServer = startClientAndServer(1080); - } - - @BeforeEach - public void createMock(){ MockServerClient client = new MockServerClient("127.0.0.1", 1080); client @@ -44,155 +40,155 @@ public void createMock(){ .withBody("{ access_token: 'client_credentials_access_token', token_type: 'Bearer', expires_in: '1800' }") ); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withHeader("Accept-Language", "de") - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withHeader("Accept-Language", "de") + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("age_of_people", "baby,child,adult") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("age_of_people", "baby,child,adult") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("collection_codes", "WRI,ARF") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("collection_codes", "WRI,ARF") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("collections_filter_type", "exclude") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("collections_filter_type", "exclude") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("editorial_video_types", "raw,produced") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("editorial_video_types", "raw,produced") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("entity_uris", "uri1,uri2") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("entity_uris", "uri1,uri2") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("exclude_nudity", "true") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("exclude_nudity", "true") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("fields", "asset_family,id,uri_oembed") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("fields", "asset_family,id,uri_oembed") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("format_available", "hd") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("format_available", "hd") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("frame_rates", "24,29.97") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("frame_rates", "24,29.97") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("keyword_ids", "1111,2222,3333") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("keyword_ids", "1111,2222,3333") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("page", "3") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("page", "3") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("page_size", "50") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("page_size", "50") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("phrase", "cat") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("phrase", "cat") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("product_types", "easyaccess,editorialsubscription") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("product_types", "easyaccess,editorialsubscription") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("sort_order", "newest") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("sort_order", "newest") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos/editorial") - .withQueryStringParameters( - new Parameter("specific_people", "Reggie Jackson") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("specific_people", "Reggie Jackson") + ) + ) .respond(response().withStatusCode(200).withBody("success")); } diff --git a/src/test/java/SearchVideosTest.java b/src/test/java/SearchVideosTest.java index 7b5ffea..0596725 100644 --- a/src/test/java/SearchVideosTest.java +++ b/src/test/java/SearchVideosTest.java @@ -28,10 +28,6 @@ public static void startProxy() throws Exception { field.setAccessible(true); field.set(null, "http://127.0.0.1:1080/"); mockServer = startClientAndServer(1080); - } - - @BeforeEach - public void createMock(){ MockServerClient client = new MockServerClient("127.0.0.1", 1080); client @@ -44,155 +40,155 @@ public void createMock(){ .withBody("{ access_token: 'client_credentials_access_token', token_type: 'Bearer', expires_in: '1800' }") ); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withHeader("Accept-Language", "de") - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withHeader("Accept-Language", "de") + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("age_of_people", "baby,child,adult") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("age_of_people", "baby,child,adult") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("collection_codes", "WRI,ARF") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("collection_codes", "WRI,ARF") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("collections_filter_type", "exclude") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("collections_filter_type", "exclude") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("editorial_video_types", "raw,produced") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("editorial_video_types", "raw,produced") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("exclude_nudity", "true") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("exclude_nudity", "true") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("fields", "asset_family,id,uri_oembed") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("fields", "asset_family,id,uri_oembed") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("format_available", "hd") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("format_available", "hd") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("frame_rates", "24,29.97") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("frame_rates", "24,29.97") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("keyword_ids", "1111,2222,3333") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("keyword_ids", "1111,2222,3333") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("license_models", "rightsmanaged") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("license_models", "rightsmanaged") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("page", "3") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("page", "3") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("page_size", "50") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("page_size", "50") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("phrase", "cat") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("phrase", "cat") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("product_types", "easyaccess,editorialsubscription") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("product_types", "easyaccess,editorialsubscription") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("sort_order", "newest") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("sort_order", "newest") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/search/videos") - .withQueryStringParameters( - new Parameter("specific_people", "Reggie Jackson") - ) - ) + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("specific_people", "Reggie Jackson") + ) + ) .respond(response().withStatusCode(200).withBody("success")); } diff --git a/src/test/java/VideosTest.java b/src/test/java/VideosTest.java index 6946543..b6973fc 100644 --- a/src/test/java/VideosTest.java +++ b/src/test/java/VideosTest.java @@ -27,10 +27,6 @@ public static void startProxy() throws Exception { field.setAccessible(true); field.set(null, "http://127.0.0.1:1080/"); mockServer = startClientAndServer(1080); - } - - @BeforeEach - public void createMock(){ MockServerClient client = new MockServerClient("127.0.0.1", 1080); client @@ -43,29 +39,29 @@ public void createMock(){ .withBody("{ access_token: 'client_credentials_access_token', token_type: 'Bearer', expires_in: '1800' }") ); client.when( - request() - .withMethod("GET") - .withPath("/videos/12345") - .withHeader("Accept-Language", "de") - ) + request() + .withMethod("GET") + .withPath("/videos/12345") + .withHeader("Accept-Language", "de") + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/videos/12345") - .withQueryStringParameters( - new Parameter("fields", "country,id") - ) - ) + request() + .withMethod("GET") + .withPath("/videos/12345") + .withQueryStringParameters( + new Parameter("fields", "country,id") + ) + ) .respond(response().withStatusCode(200).withBody("success")); client.when( - request() - .withMethod("GET") - .withPath("/videos") - .withQueryStringParameters( - new Parameter("ids", "12345,678910") - ) - ) + request() + .withMethod("GET") + .withPath("/videos") + .withQueryStringParameters( + new Parameter("ids", "12345,678910") + ) + ) .respond(response().withStatusCode(200).withBody("success")); } From ef8c431017860c47b7e9ea18983246d73ad42d3c Mon Sep 17 00:00:00 2001 From: Stephanie Sterling Date: Thu, 29 Sep 2022 12:39:05 -0700 Subject: [PATCH 2/4] Add custom param and header methods --- .../java/com/gettyimages/api/Search/SearchImages.java | 10 ++++++++++ .../gettyimages/api/Search/SearchImagesCreative.java | 10 ++++++++++ .../gettyimages/api/Search/SearchImagesEditorial.java | 10 ++++++++++ .../java/com/gettyimages/api/Search/SearchVideos.java | 10 ++++++++++ .../gettyimages/api/Search/SearchVideosCreative.java | 10 ++++++++++ .../gettyimages/api/Search/SearchVideosEditorial.java | 10 ++++++++++ 6 files changed, 60 insertions(+) diff --git a/src/main/java/com/gettyimages/api/Search/SearchImages.java b/src/main/java/com/gettyimages/api/Search/SearchImages.java index 57befc9..90b12a5 100644 --- a/src/main/java/com/gettyimages/api/Search/SearchImages.java +++ b/src/main/java/com/gettyimages/api/Search/SearchImages.java @@ -26,6 +26,16 @@ public String executeAsync() throws SdkException { return super.executeAsync(); } + public SearchImages withCustomHeader(String key, String value) { + headers.put(key, value); + return this; + } + + public SearchImages withCustomParameter(String key, String value) { + queryParams.put(key, value); + return this; + } + public SearchImages withAcceptLanguage(String value) { headers.put(Constants.AcceptLanguageString, value); diff --git a/src/main/java/com/gettyimages/api/Search/SearchImagesCreative.java b/src/main/java/com/gettyimages/api/Search/SearchImagesCreative.java index d62f871..3f60f92 100644 --- a/src/main/java/com/gettyimages/api/Search/SearchImagesCreative.java +++ b/src/main/java/com/gettyimages/api/Search/SearchImagesCreative.java @@ -26,6 +26,16 @@ public String executeAsync() throws SdkException { return super.executeAsync(); } + public SearchImagesCreative withCustomHeader(String key, String value) { + headers.put(key, value); + return this; + } + + public SearchImagesCreative withCustomParameter(String key, String value) { + queryParams.put(key, value); + return this; + } + public SearchImagesCreative withAcceptLanguage(String value) { headers.put(Constants.AcceptLanguageString, value); diff --git a/src/main/java/com/gettyimages/api/Search/SearchImagesEditorial.java b/src/main/java/com/gettyimages/api/Search/SearchImagesEditorial.java index a536e4e..4db88ea 100644 --- a/src/main/java/com/gettyimages/api/Search/SearchImagesEditorial.java +++ b/src/main/java/com/gettyimages/api/Search/SearchImagesEditorial.java @@ -26,6 +26,16 @@ public String executeAsync() throws SdkException { return super.executeAsync(); } + public SearchImagesEditorial withCustomHeader(String key, String value) { + headers.put(key, value); + return this; + } + + public SearchImagesEditorial withCustomParameter(String key, String value) { + queryParams.put(key, value); + return this; + } + public SearchImagesEditorial withAcceptLanguage(String value) { headers.put(Constants.AcceptLanguageString, value); diff --git a/src/main/java/com/gettyimages/api/Search/SearchVideos.java b/src/main/java/com/gettyimages/api/Search/SearchVideos.java index 4412bd0..6fe9fc6 100644 --- a/src/main/java/com/gettyimages/api/Search/SearchVideos.java +++ b/src/main/java/com/gettyimages/api/Search/SearchVideos.java @@ -26,6 +26,16 @@ public String executeAsync() throws SdkException { return super.executeAsync(); } + public SearchVideos withCustomHeader(String key, String value) { + headers.put(key, value); + return this; + } + + public SearchVideos withCustomParameter(String key, String value) { + queryParams.put(key, value); + return this; + } + public SearchVideos withAcceptLanguage(String value) { headers.put(Constants.AcceptLanguageString, value); diff --git a/src/main/java/com/gettyimages/api/Search/SearchVideosCreative.java b/src/main/java/com/gettyimages/api/Search/SearchVideosCreative.java index bbb96e4..801f96d 100644 --- a/src/main/java/com/gettyimages/api/Search/SearchVideosCreative.java +++ b/src/main/java/com/gettyimages/api/Search/SearchVideosCreative.java @@ -26,6 +26,16 @@ public String executeAsync() throws SdkException { return super.executeAsync(); } + public SearchVideosCreative withCustomHeader(String key, String value) { + headers.put(key, value); + return this; + } + + public SearchVideosCreative withCustomParameter(String key, String value) { + queryParams.put(key, value); + return this; + } + public SearchVideosCreative withAcceptLanguage(String value) { headers.put(Constants.AcceptLanguageString, value); diff --git a/src/main/java/com/gettyimages/api/Search/SearchVideosEditorial.java b/src/main/java/com/gettyimages/api/Search/SearchVideosEditorial.java index 3709bd3..28c766e 100644 --- a/src/main/java/com/gettyimages/api/Search/SearchVideosEditorial.java +++ b/src/main/java/com/gettyimages/api/Search/SearchVideosEditorial.java @@ -26,6 +26,16 @@ public String executeAsync() throws SdkException { return super.executeAsync(); } + public SearchVideosEditorial withCustomHeader(String key, String value) { + headers.put(key, value); + return this; + } + + public SearchVideosEditorial withCustomParameter(String key, String value) { + queryParams.put(key, value); + return this; + } + public SearchVideosEditorial withAcceptLanguage(String value) { headers.put(Constants.AcceptLanguageString, value); From d1957037de245ac7e6a84ce5ab365e63eee26cc9 Mon Sep 17 00:00:00 2001 From: Stephanie Sterling Date: Thu, 29 Sep 2022 13:01:24 -0700 Subject: [PATCH 3/4] Add tests for custom param and header --- src/test/java/SearchImagesCreativeTest.java | 34 +++++++++++++++++++ src/test/java/SearchImagesEditorialTest.java | 35 ++++++++++++++++++++ src/test/java/SearchImagesTest.java | 35 ++++++++++++++++++++ src/test/java/SearchVideosCreativeTest.java | 35 ++++++++++++++++++++ src/test/java/SearchVideosEditorialTest.java | 35 ++++++++++++++++++++ src/test/java/SearchVideosTest.java | 35 ++++++++++++++++++++ 6 files changed, 209 insertions(+) diff --git a/src/test/java/SearchImagesCreativeTest.java b/src/test/java/SearchImagesCreativeTest.java index e9162a4..443c18f 100644 --- a/src/test/java/SearchImagesCreativeTest.java +++ b/src/test/java/SearchImagesCreativeTest.java @@ -244,6 +244,22 @@ public static void startProxy() throws Exception { ) ) .respond(response().withStatusCode(200).withBody("success")); + client.when( + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withQueryStringParameters( + new Parameter("safe_search", "true") + ) + ) + .respond(response().withStatusCode(200).withBody("success")); + client.when( + request() + .withMethod("GET") + .withPath("/search/images/creative") + .withHeader("gi-country-code", "CAN") + ) + .respond(response().withStatusCode(200).withBody("success")); } @Test @@ -454,6 +470,24 @@ void searchImagesCreativeWithSortOrder() throws Exception { assertEquals("success", result); } + @Test + void searchImagesCreativeWithCustomParameter() throws Exception { + ApiClient client = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret"); + SearchImagesCreative search = client.searchimagescreative() + .withCustomParameter("safe_search", "true"); + String result = search.executeAsync(); + assertEquals("success", result); + } + + @Test + void searchImagesCreativeWithCustomHeader() throws Exception { + ApiClient client = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret"); + SearchImagesCreative search = client.searchimagescreative() + .withCustomHeader("gi-country-code", "CAN"); + String result = search.executeAsync(); + assertEquals("success", result); + } + @AfterAll public static void stopProxy() { mockServer.stop(); diff --git a/src/test/java/SearchImagesEditorialTest.java b/src/test/java/SearchImagesEditorialTest.java index 5e34616..34bf5ba 100644 --- a/src/test/java/SearchImagesEditorialTest.java +++ b/src/test/java/SearchImagesEditorialTest.java @@ -1,6 +1,7 @@ import com.gettyimages.api.ApiClient; import com.gettyimages.api.Filters.*; +import com.gettyimages.api.Search.SearchImagesCreative; import com.gettyimages.api.Search.SearchImagesEditorial; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -289,6 +290,22 @@ public static void startProxy() throws Exception { ) ) .respond(response().withStatusCode(200).withBody("success")); + client.when( + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withQueryStringParameters( + new Parameter("include_related_searches", "true") + ) + ) + .respond(response().withStatusCode(200).withBody("success")); + client.when( + request() + .withMethod("GET") + .withPath("/search/images/editorial") + .withHeader("gi-country-code", "CAN") + ) + .respond(response().withStatusCode(200).withBody("success")); } @Test @@ -545,6 +562,24 @@ void searchImagesEditorialWithStartDate() throws Exception { assertEquals("success", result); } + @Test + void searchImagesEditorialWithCustomParameter() throws Exception { + ApiClient client = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret"); + SearchImagesEditorial search = client.searchimageseditorial() + .withCustomParameter("include_related_searches", "true"); + String result = search.executeAsync(); + assertEquals("success", result); + } + + @Test + void searchImagesEditorialWithCustomHeader() throws Exception { + ApiClient client = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret"); + SearchImagesEditorial search = client.searchimageseditorial() + .withCustomHeader("gi-country-code", "CAN"); + String result = search.executeAsync(); + assertEquals("success", result); + } + @AfterAll public static void stopProxy() { mockServer.stop(); diff --git a/src/test/java/SearchImagesTest.java b/src/test/java/SearchImagesTest.java index 2fb0b12..8e90742 100644 --- a/src/test/java/SearchImagesTest.java +++ b/src/test/java/SearchImagesTest.java @@ -2,6 +2,7 @@ import com.gettyimages.api.ApiClient; import com.gettyimages.api.Filters.*; import com.gettyimages.api.Search.SearchImages; +import com.gettyimages.api.Search.SearchImagesCreative; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; @@ -262,6 +263,22 @@ public static void startProxy() throws Exception { ) ) .respond(response().withStatusCode(200).withBody("success")); + client.when( + request() + .withMethod("GET") + .withPath("/search/images") + .withQueryStringParameters( + new Parameter("include_related_searches", "true") + ) + ) + .respond(response().withStatusCode(200).withBody("success")); + client.when( + request() + .withMethod("GET") + .withPath("/search/images") + .withHeader("gi-country-code", "CAN") + ) + .respond(response().withStatusCode(200).withBody("success")); } @Test @@ -490,6 +507,24 @@ void searchImagesWithSpecificPeople() throws Exception { assertEquals("success", result); } + @Test + void searchImagesWithCustomParameter() throws Exception { + ApiClient client = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret"); + SearchImages search = client.searchimages() + .withCustomParameter("include_related_searches", "true"); + String result = search.executeAsync(); + assertEquals("success", result); + } + + @Test + void searchImagesWithCustomHeader() throws Exception { + ApiClient client = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret"); + SearchImages search = client.searchimages() + .withCustomHeader("gi-country-code", "CAN"); + String result = search.executeAsync(); + assertEquals("success", result); + } + @AfterAll public static void stopProxy() { mockServer.stop(); diff --git a/src/test/java/SearchVideosCreativeTest.java b/src/test/java/SearchVideosCreativeTest.java index d0ad0f5..ee3f9fc 100644 --- a/src/test/java/SearchVideosCreativeTest.java +++ b/src/test/java/SearchVideosCreativeTest.java @@ -1,6 +1,7 @@ import com.gettyimages.api.ApiClient; import com.gettyimages.api.Filters.*; +import com.gettyimages.api.Search.SearchImagesCreative; import com.gettyimages.api.Search.SearchVideosCreative; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -172,6 +173,22 @@ public static void startProxy() throws Exception { ) ) .respond(response().withStatusCode(200).withBody("success")); + client.when( + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withQueryStringParameters( + new Parameter("safe_search", "true") + ) + ) + .respond(response().withStatusCode(200).withBody("success")); + client.when( + request() + .withMethod("GET") + .withPath("/search/videos/creative") + .withHeader("gi-country-code", "CAN") + ) + .respond(response().withStatusCode(200).withBody("success")); } @Test @@ -309,6 +326,24 @@ void searchVideosCreativeWithSortOrder() throws Exception { assertEquals("success", result); } + @Test + void searchVideosCreativeWithCustomParameter() throws Exception { + ApiClient client = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret"); + SearchVideosCreative search = client.searchvideoscreative() + .withCustomParameter("safe_search", "true"); + String result = search.executeAsync(); + assertEquals("success", result); + } + + @Test + void searchVideosCreativeWithCustomHeader() throws Exception { + ApiClient client = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret"); + SearchVideosCreative search = client.searchvideoscreative() + .withCustomHeader("gi-country-code", "CAN"); + String result = search.executeAsync(); + assertEquals("success", result); + } + @AfterAll public static void stopProxy() { mockServer.stop(); diff --git a/src/test/java/SearchVideosEditorialTest.java b/src/test/java/SearchVideosEditorialTest.java index 04d73a0..3ad54b2 100644 --- a/src/test/java/SearchVideosEditorialTest.java +++ b/src/test/java/SearchVideosEditorialTest.java @@ -1,6 +1,7 @@ import com.gettyimages.api.ApiClient; import com.gettyimages.api.Filters.*; +import com.gettyimages.api.Search.SearchVideos; import com.gettyimages.api.Search.SearchVideosEditorial; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -190,6 +191,22 @@ public static void startProxy() throws Exception { ) ) .respond(response().withStatusCode(200).withBody("success")); + client.when( + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withQueryStringParameters( + new Parameter("include_related_searches", "true") + ) + ) + .respond(response().withStatusCode(200).withBody("success")); + client.when( + request() + .withMethod("GET") + .withPath("/search/videos/editorial") + .withHeader("gi-country-code", "CAN") + ) + .respond(response().withStatusCode(200).withBody("success")); } @Test @@ -345,6 +362,24 @@ void searchVideosEditorialWithSpecificPeople() throws Exception { assertEquals("success", result); } + @Test + void searchVideosEditorialWithCustomParameter() throws Exception { + ApiClient client = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret"); + SearchVideosEditorial search = client.searchvideoseditorial() + .withCustomParameter("include_related_searches", "true"); + String result = search.executeAsync(); + assertEquals("success", result); + } + + @Test + void searchVideosEditorialWithCustomHeader() throws Exception { + ApiClient client = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret"); + SearchVideosEditorial search = client.searchvideoseditorial() + .withCustomHeader("gi-country-code", "CAN"); + String result = search.executeAsync(); + assertEquals("success", result); + } + @AfterAll public static void stopProxy() { mockServer.stop(); diff --git a/src/test/java/SearchVideosTest.java b/src/test/java/SearchVideosTest.java index 0596725..d791011 100644 --- a/src/test/java/SearchVideosTest.java +++ b/src/test/java/SearchVideosTest.java @@ -1,6 +1,7 @@ import com.gettyimages.api.ApiClient; import com.gettyimages.api.Filters.*; +import com.gettyimages.api.Search.SearchImages; import com.gettyimages.api.Search.SearchVideos; import org.junit.jupiter.api.AfterAll; import org.junit.jupiter.api.BeforeAll; @@ -190,6 +191,22 @@ public static void startProxy() throws Exception { ) ) .respond(response().withStatusCode(200).withBody("success")); + client.when( + request() + .withMethod("GET") + .withPath("/search/videos") + .withQueryStringParameters( + new Parameter("include_related_searches", "true") + ) + ) + .respond(response().withStatusCode(200).withBody("success")); + client.when( + request() + .withMethod("GET") + .withPath("/search/videos") + .withHeader("gi-country-code", "CAN") + ) + .respond(response().withStatusCode(200).withBody("success")); } @Test @@ -345,6 +362,24 @@ void searchVideosWithSpecificPeople() throws Exception { assertEquals("success", result); } + @Test + void searchVideosWithCustomParameter() throws Exception { + ApiClient client = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret"); + SearchVideos search = client.searchvideos() + .withCustomParameter("include_related_searches", "true"); + String result = search.executeAsync(); + assertEquals("success", result); + } + + @Test + void searchVideosWithCustomHeader() throws Exception { + ApiClient client = ApiClient.GetApiClientWithClientCredentials("apiKey", "apiSecret"); + SearchVideos search = client.searchvideos() + .withCustomHeader("gi-country-code", "CAN"); + String result = search.executeAsync(); + assertEquals("success", result); + } + @AfterAll public static void stopProxy() { mockServer.stop(); From 222716d56f0cf0f36e8e29b2f2db811a6d8ecaae Mon Sep 17 00:00:00 2001 From: Stephanie Sterling Date: Fri, 30 Sep 2022 10:10:36 -0700 Subject: [PATCH 4/4] Add example --- README.md | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/README.md b/README.md index 9bdde6d..3d4b7c4 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,29 @@ $ mvn install } ``` +### Search creative images with phrase, custom parameter, and customer header +```java + String apiKey = "API Key"; + String apiSecret = "API Secret"; + String userName = "Username"; + String userPassword = "Password"; + + ApiClient client = ApiClient.GetApiClientWithResourceOwnerCredentials(apiKey, apiSecret, userName, userPassword); + + try { + SearchImagesCreative search = client.searchimagescreative() + .withPhrase("cat") + .withCustomParameter("safe_search", "true") + .withCustomHeader("gi-country-code", "CAN"); + String result = search.executeAsync(); + System.out.print(result); + + } catch (SdkException e) { + System.out.println("Exception occurred while searching for creative images: " + e.getLocalizedMessage()); + System.exit(-1); + } +``` + ### Custom Request to search images with phrase, fields, and age of people ```java