diff --git a/partial-response/pom.xml b/partial-response/pom.xml index 0afd5bddc..e4f4db4ae 100644 --- a/partial-response/pom.xml +++ b/partial-response/pom.xml @@ -10,6 +10,12 @@ 4.0.0 partial-response + + + junit + junit + + \ No newline at end of file diff --git a/partial-response/src/main/java/com/iluwatar/partialresponse/Video.java b/partial-response/src/main/java/com/iluwatar/partialresponse/Video.java index 656ab091b..2879b96ed 100644 --- a/partial-response/src/main/java/com/iluwatar/partialresponse/Video.java +++ b/partial-response/src/main/java/com/iluwatar/partialresponse/Video.java @@ -52,4 +52,16 @@ public class Video { this.publisher = publisher; this.status = status; } + + @Override + public String toString() { + return "Video{" + + "id='" + id + '\'' + + ", title='" + title + '\'' + + ", length=" + length + + ", description='" + description + '\'' + + ", publisher='" + publisher + '\'' + + ", status='" + status + '\'' + + '}'; + } } diff --git a/partial-response/src/main/java/com/iluwatar/partialresponse/VideoResource.java b/partial-response/src/main/java/com/iluwatar/partialresponse/VideoResource.java index c3d526187..546377b16 100644 --- a/partial-response/src/main/java/com/iluwatar/partialresponse/VideoResource.java +++ b/partial-response/src/main/java/com/iluwatar/partialresponse/VideoResource.java @@ -1,4 +1,39 @@ +/* + * The MIT License (MIT) + * + * Copyright (c) 2017 Gopinath Langote + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + package com.iluwatar.partialresponse; +import java.util.Map; + public class VideoResource { + private Map videos; + + public VideoResource(Map videos) { + this.videos = videos; + } + + public String getDenials(String id) { + return videos.get(id).toString(); + } } diff --git a/partial-response/src/test/java/com/iluwatar/partialresponse/VideoResourceTest.java b/partial-response/src/test/java/com/iluwatar/partialresponse/VideoResourceTest.java index cd304c81d..43d670f9f 100644 --- a/partial-response/src/test/java/com/iluwatar/partialresponse/VideoResourceTest.java +++ b/partial-response/src/test/java/com/iluwatar/partialresponse/VideoResourceTest.java @@ -1,5 +1,50 @@ -import static org.junit.Assert.*; +/* + * The MIT License (MIT) + * + * Copyright (c) 2017 Gopinath Langote + * + * Permission is hereby granted, free of charge, to any person obtaining a copy + * of this software and associated documentation files (the "Software"), to deal + * in the Software without restriction, including without limitation the rights + * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell + * copies of the Software, and to permit persons to whom the Software is + * furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included in all + * copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE + * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, + * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE + * SOFTWARE. + */ + +package com.iluwatar.partialresponse; + +import org.junit.Before; +import org.junit.Test; + +import java.util.HashMap; +import java.util.Map; public class VideoResourceTest { + private VideoResource resource; + @Before + public void setUp() { + Map videos = new HashMap<>(); + videos.put("1", new Video("1", "title 1", 100L, "", "", "")); + videos.put("1", new Video("2", "title 2", 100L, "", "", "")); + videos.put("1", new Video("3", "title 3", 100L, "", "", "")); + resource = new VideoResource(videos); + } + + @Test + public void shouldGiveVideoDetailsById() { + String details = resource.getDenials("1"); + System.out.println(details); + } } \ No newline at end of file