From b8cb9a6fd3d6c3e85270cfa5780480b8e12234a9 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Bertholon Date: Wed, 20 Mar 2019 16:33:28 +0100 Subject: [PATCH 1/6] Fix documentation --- docs/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/README.md b/docs/README.md index 059c5ff..ee2c3e6 100644 --- a/docs/README.md +++ b/docs/README.md @@ -56,7 +56,7 @@ A wide list of parameters are available. #### Personnal recommendation for a user -* `/api/v2/playlist/recommendation/personalRecommendation` : get media list object. +* `/api/v2/playlist/personalRecommendation` : get media list object. * `user` (optional, string): `UserId` to use for a personal recommendation. * Returns a `recommendedList` object. From a73f723e8b58351f11576d0873521e26177bb6c2 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Bertholon Date: Mon, 1 Apr 2019 16:31:35 +0200 Subject: [PATCH 2/6] Use the correct query parameter for the personnal recommendation --- docs/README.md | 2 +- .../com/example/pfff/controller/RecommendationController.java | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/docs/README.md b/docs/README.md index ee2c3e6..df3de76 100644 --- a/docs/README.md +++ b/docs/README.md @@ -57,7 +57,7 @@ A wide list of parameters are available. #### Personnal recommendation for a user * `/api/v2/playlist/personalRecommendation` : get media list object. - * `user` (optional, string): `UserId` to use for a personal recommendation. + * `userId` (optional, string): `UserId` to use for a personal recommendation. * Returns a `recommendedList` object. ## Private APIs diff --git a/src/main/java/com/example/pfff/controller/RecommendationController.java b/src/main/java/com/example/pfff/controller/RecommendationController.java index 58cefa7..98a06fa 100644 --- a/src/main/java/com/example/pfff/controller/RecommendationController.java +++ b/src/main/java/com/example/pfff/controller/RecommendationController.java @@ -63,7 +63,7 @@ private RecommendedList getRecommendationList(@PathVariable("purpose") String pu @ResponseBody RecommendedList personalRecommendation( HttpServletRequest request, - @RequestParam(value = "user", required = false, defaultValue = "unknown") String userId) { + @RequestParam(value = "userId", required = false, defaultValue = "unknown") String userId) { return service.rtsPlayHomePersonalRecommendation(userId); } From 27d53f254497c82a2fac5d6ea4721ea7c867eff3 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Bertholon Date: Mon, 1 Apr 2019 16:31:57 +0200 Subject: [PATCH 3/6] Update documentation --- docs/RECOMMENDATION.md | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/docs/RECOMMENDATION.md b/docs/RECOMMENDATION.md index 593e1ef..2a59c9b 100644 --- a/docs/RECOMMENDATION.md +++ b/docs/RECOMMENDATION.md @@ -11,14 +11,14 @@ Since July 2018, Play Android (2.0.207 and more) and Play iOS (2.8.3-272 and mor ## Recommendation type -### Media ecommendation list for a media +### Media recommendation list for a media -The API doesn't not support paginations, so mobile applications didn't implement pagination. The media recommendation list must have at least 49 items, the 50th is the requested media. +The API doesn't not support paginations, therefore mobile applications didn't implement pagination. The media recommendation list must have at least 49 items, the 50th is the requested media. #### RTS `urn.contains(":rts:")` -- For videos `urn.contains(":video:")`, ask Peach recommendation `continuous_playback_mobile` service. -- For audios `urn.contains(":audio:")`, Playfff recommendation. Based on IL requests, without personalization. Here is how it works: +- For videos `urn.contains(":video:")`, it asks Peach recommendation `continuous_playback_mobile` service. +- For audios `urn.contains(":audio:")`, it asks Playfff recommendation. Based on IL requests, without personalization. Here is how it works: - Get `IL-Media`. It returns an empty list if it's a `LIVESTREAM` or a `SCHEDULED_LIVESTREAM`. - Get `IL-EpisodeComposition` with last 100 episodes. Sort episodes with a date ascending order. - Determine if the media is a full length or a clip. @@ -33,6 +33,14 @@ The API doesn't not support paginations, so mobile applications didn't implement #### Other BUs - No recommendation provided. It returns an empty list. + +### Media recommendation list for a user + +The API doesn't not support paginations, therefore mobile applications didn't implement pagination. The media recommendation list must have at least 50 items. + +#### RTS + +- With and without an `userId`, it asks Peach recommendation `play_home_personal_rec` service. ## License From 7f8794e5aada56b35c282ed608081aa393ecc526 Mon Sep 17 00:00:00 2001 From: Pierre-Yves Bertholon Date: Mon, 1 Apr 2019 16:32:40 +0200 Subject: [PATCH 4/6] Add unit test for the personal recommendation --- .../RecommendationIntegrationTest.java | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/test/java/com/example/pfff/controller/RecommendationIntegrationTest.java b/src/test/java/com/example/pfff/controller/RecommendationIntegrationTest.java index ca19ce4..d55a14c 100644 --- a/src/test/java/com/example/pfff/controller/RecommendationIntegrationTest.java +++ b/src/test/java/com/example/pfff/controller/RecommendationIntegrationTest.java @@ -1,6 +1,9 @@ package com.example.pfff.controller; +import com.example.pfff.model.RecommendedList; +import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; +import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Assert; import org.junit.Before; import org.junit.Test; @@ -15,7 +18,9 @@ import org.springframework.web.client.RestTemplate; import org.springframework.web.context.WebApplicationContext; +import java.io.IOException; import java.util.List; +import java.util.concurrent.atomic.AtomicReference; import static org.springframework.security.test.web.servlet.setup.SecurityMockMvcConfigurers.springSecurity; import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get; @@ -142,4 +147,26 @@ private void getRecommendationURNFormat(String mediaURN, boolean isAvailable) th mvc.perform(get("/api/v2/playlist/recommendation/" + purpose + "/" + mediaURN).param("standalone", "true")).andExpect(isAvailable ? jsonPath("$.recommendationId").isNotEmpty() : jsonPath("$.recommendationId").doesNotExist()); } + + @Test + public void getRTSPersonalRecommendation() throws Exception { + AtomicReference anonymousRecommendedListReference = new AtomicReference<>(); + mvc.perform(get("/api/v2/playlist/personalRecommendation")).andExpect(status().isOk()).andExpect(jsonPath("$").isMap()).andExpect(jsonPath("$.recommendationId").isNotEmpty()).andExpect(jsonPath("$.recommendationId").isNotEmpty()).andDo(mvcResult -> { + String json = mvcResult.getResponse().getContentAsString(); + RecommendedList anonymousRecommendedList = (RecommendedList) convertJSONStringToObject(json, RecommendedList.class); + anonymousRecommendedListReference.set(anonymousRecommendedList); + });; + mvc.perform(get("/api/v2/playlist/personalRecommendation").param("userId", "203656")).andExpect(status().isOk()).andExpect(jsonPath("$").isMap()).andExpect(jsonPath("$.recommendationId").isNotEmpty()).andExpect(jsonPath("$.title").isNotEmpty()).andDo(mvcResult -> { + String json = mvcResult.getResponse().getContentAsString(); + RecommendedList userRecommendedList = (RecommendedList) convertJSONStringToObject(json, RecommendedList.class); + + Assert.assertNotEquals(anonymousRecommendedListReference.get().getRecommendationId(), userRecommendedList.getRecommendationId()); + Assert.assertNotEquals(anonymousRecommendedListReference.get().getTitle(), userRecommendedList.getTitle()); + }); + } + + public static Object convertJSONStringToObject(String json, Class objectClass) throws IOException { + ObjectMapper mapper = new ObjectMapper(); + return mapper.readValue(json, objectClass); + } } From 6ec6df85be731237f8a066a269a77d552137731f Mon Sep 17 00:00:00 2001 From: Pierre-Yves Bertholon Date: Mon, 1 Apr 2019 16:46:21 +0200 Subject: [PATCH 5/6] Bump version number --- pom.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pom.xml b/pom.xml index eaf286f..8f21428 100644 --- a/pom.xml +++ b/pom.xml @@ -12,7 +12,7 @@ com.example pfff - 9 + 10 jar pfff From 99338b94e55ef916fb0605e753bfcfe006b94aef Mon Sep 17 00:00:00 2001 From: Pierre-Yves Bertholon Date: Mon, 1 Apr 2019 16:48:31 +0200 Subject: [PATCH 6/6] Clean import --- .../example/pfff/controller/RecommendationIntegrationTest.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/test/java/com/example/pfff/controller/RecommendationIntegrationTest.java b/src/test/java/com/example/pfff/controller/RecommendationIntegrationTest.java index d55a14c..1ef5156 100644 --- a/src/test/java/com/example/pfff/controller/RecommendationIntegrationTest.java +++ b/src/test/java/com/example/pfff/controller/RecommendationIntegrationTest.java @@ -1,7 +1,6 @@ package com.example.pfff.controller; import com.example.pfff.model.RecommendedList; -import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.annotation.JsonProperty; import com.fasterxml.jackson.databind.ObjectMapper; import org.junit.Assert;