Skip to content

Commit

Permalink
Merge pull request #15 from SRGSSR/develop
Browse files Browse the repository at this point in the history
Set host domain in recommendation id
  • Loading branch information
pyby authored Oct 4, 2018
2 parents d1c9671 + 91e6b01 commit b3f517f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

<groupId>com.example</groupId>
<artifactId>pfff</artifactId>
<version>4</version>
<version>5</version>
<packaging>jar</packaging>

<name>pfff</name>
Expand Down
13 changes: 11 additions & 2 deletions src/main/java/com/example/pfff/model/RecommendedList.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
import com.fasterxml.jackson.annotation.JsonInclude;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

/**
Expand All @@ -16,8 +18,15 @@ public class RecommendedList {
private String recommendationId;
private List<String> urns;

public RecommendedList(String recommendationId, List<String> urns) {
this.recommendationId = recommendationId;
public RecommendedList(String host, String recommendationId, List<String> urns) {
if (host != null && recommendationId != null) {
List<String> components = Arrays.asList(host.split("\\."));
Collections.reverse(components);
String domain = String.join(".", components.toArray(new String[0]));
this.recommendationId = domain + ":" + recommendationId;
} else {
this.recommendationId = recommendationId;
}
this.urns = urns;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ public RecommendedList getRecommendedUrns(String purpose, String urn, boolean st
System.out.println(url.toUriString());

RecommendationResult recommendationResult = restTemplate.exchange(url.toUriString(), HttpMethod.GET, null, RecommendationResult.class).getBody();
return new RecommendedList(recommendationResult.getRecommendationId(), recommendationResult.getUrns());
return new RecommendedList(url.getHost(), recommendationResult.getRecommendationId(), recommendationResult.getUrns());
}
else {
return new RecommendedList();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ public void getRecommendedUrnsContinuousplaybackRTSTest() {
RecommendedList recommendedList = recommendationService.getRecommendedUrns(purpose, mediaURN, standalone);

Assert.assertNotNull(recommendedList.getRecommendationId());
Assert.assertTrue(recommendedList.getRecommendationId().startsWith("io.ebu.peach:"));
Assert.assertNotNull(recommendedList.getUrns());
}

Expand All @@ -37,6 +38,7 @@ public void getRecommendedUrnsContinuousplaybackStandaloneRTSTest() {
RecommendedList recommendedList = recommendationService.getRecommendedUrns(purpose, mediaURN, standalone);

Assert.assertNotNull(recommendedList.getRecommendationId());
Assert.assertTrue(recommendedList.getRecommendationId().startsWith("io.ebu.peach:"));
Assert.assertNotNull(recommendedList.getUrns());
}

Expand Down

0 comments on commit b3f517f

Please sign in to comment.