Permalink
Browse files

got first test to pass, with basic Reviewer review Reviewable

  • Loading branch information...
1 parent caf7a1e commit 99f1a70db9a69ff21ba4dc0d50567ad93d09fbf3 @leadVisionary committed Apr 27, 2012
@@ -0,0 +1,16 @@
+package com.visionarysoftwaresolutions.reviewable;
+
+/**
+ *
+ * @author Nicholas Vaidyanathan, Lead Visionary of Visionary Software Solutions
+ * @description RatedReview is a simple interface for a review that an entity that
+ * reviews other entities on a scale.
+ * We try to make it as generalizable as possible so it can apply in multiple situations
+ * Scenario: A Reviewer creates a RatedReview for a Reviewable with a description on a RatingScale
+ * Example: Nick creates a RatedReview of YourBody
+ * with a RatingScale of OneToTenRatingScale
+ * with a rating of 10 and a description "It's awesome!"
+ */
+public interface RatedReview extends Review {
+ public RatingScale getRatingScale();
+}
@@ -0,0 +1,12 @@
+package com.visionarysoftwaresolutions.reviewable;
+
+/**
+ *
+ * @author Nicholas Vaidyanathan, Lead Visionary of Visionary Software Solutions
+ * @description RatingScale is a simple interface for a rating scale used in a review.
+ * We try to make it as generalizable as possible so it can apply in multiple situations
+ * Scenario: A Reviewer creates a Review for a Reviewable, rating it on a RatingScale with a Description
+ */
+public interface RatingScale {
+ public abstract String[] getScale();
+}
@@ -0,0 +1,16 @@
+package com.visionarysoftwaresolutions.reviewable;
+
+/**
+ *
+ * @author Nicholas Vaidyanathan, Lead Visionary of Visionary Software Solutions
+ * @description Review is a simple interface for a review that an entity that
+ * reviews other entities would take. We try to make it as generalizable as
+ * possible so it can apply in multiple situations
+ * Scenario: A Reviewer creates a Review for a Reviewable with a description
+ * Example: Nick creates a Review of YourFace with a description "It's awesome!"
+ */
+public interface Review {
+ public abstract String getDescription();
+ public abstract Reviewer getReviewer();
+ public abstract Reviewable getReviewed();
+}
@@ -0,0 +1,9 @@
+package com.visionarysoftwaresolutions.reviewable;
+
+public abstract class ReviewDecorator implements Review {
+ protected final Review decoratedReview;
+
+ public ReviewDecorator(Review toDecorate){
+ this.decoratedReview = toDecorate;
+ }
+}
@@ -0,0 +1,14 @@
+package com.visionarysoftwaresolutions.reviewable;
+
+/**
+ *
+ * @author Nicholas Vaidyanathan, Lead Visionary of Visionary Software Solutions
+ * @description Reviewable is a simple interface for a role that an entity that
+ * is reviewable would take. We try to make it as generalizable as
+ * possible so it can apply in multiple situations.
+ * We assert a reviewable should know about its review from a Reviewer, and should be able to retrieve it.
+ * Scenario: A Reviewer creates a Review for a Reviewable, rating it on a Scale with a Description
+ */
+public interface Reviewable {
+ public abstract Review getReview(Reviewer reviewer);
+}
@@ -0,0 +1,14 @@
+package com.visionarysoftwaresolutions.reviewable;
+
+/**
+ *
+ * @author Nicholas Vaidyanathan, Lead Visionary of Visionary Software Solutions
+ * @description Reviewer is a simple interface for a role that an entity that
+ * reviews other entities would take. We try to make it as generalizable as
+ * possible so it can apply in multiple situations
+ * Scenario: A Reviewer creates a Review for a Reviewable, rating it on a RatingScale with a Description
+ */
+public interface Reviewer {
+ public abstract Review review(Reviewable toReview, String description);
+ public abstract RatedReview rate(Reviewable toReview, RatingScale ratingScale, String description);
+}
@@ -0,0 +1,16 @@
+package com.visionarysoftwaresolutions.reviewable;
+
+class FiveStarRatingScale implements RatingScale {
+
+ static RatingScale five() {
+ throw new UnsupportedOperationException("Not yet implemented");
+ }
+
+ public FiveStarRatingScale() {
+ }
+
+ @Override
+ public String[] getScale() {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+}
@@ -0,0 +1,14 @@
+package com.visionarysoftwaresolutions.reviewable;
+
+class Food implements Reviewable {
+ private String name;
+
+ public Food(String string) {
+ name = string;
+ }
+
+ @Override
+ public Review getReview(Reviewer reviewer) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+}
@@ -0,0 +1,29 @@
+package com.visionarysoftwaresolutions.reviewable;
+
+public class FoodReview implements Review {
+ private String description;
+ private Reviewer reviewer;
+ private Reviewable reviewed;
+
+ public FoodReview(Reviewer reviewer, Reviewable reviewed, String description){
+ this.reviewer = reviewer;
+ this.reviewed = reviewed;
+ this.description = description;
+ }
+
+ @Override
+ public String getDescription() {
+ return description;
+ }
+
+ @Override
+ public Reviewer getReviewer() {
+ return reviewer;
+ }
+
+ @Override
+ public Reviewable getReviewed() {
+ return reviewed;
+ }
+
+}
@@ -0,0 +1,40 @@
+package com.visionarysoftwaresolutions.reviewable;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+public class ReviewableTests {
+ @Test
+ public void testReview() {
+ //Given I have a Reviewer and a Reviewable
+ Reviewer nick = new User("nick");
+ Reviewable food = new Food("Phonecian Cafe Hummus");
+ //When I have the Reviewer rate the Reviewable
+ Review result = nick.review(food,
+ "It is so creamy and delicious!");
+ //Then it is reviewed
+ assertEquals(result.getReviewer(), nick);
+ assertEquals(result.getReviewed(), food);
+ assertEquals(result.getDescription(), "It is so creamy and delicious!");
+ }
+
+ @Test
+ public void testRatedReview(){
+ //Given I have a Reviewer and a Reviewable
+
+ Reviewer nick = new User("nick");
+ Reviewable food = new Food("Phonecian Cafe Hummus");
+ //When I have the Reviewer rate the Reviewable
+ RatedReview result = nick.rate(food,
+ FiveStarRatingScale.five(),
+ "It is so creamy and delicious!");
+ //Then it is rated
+ assertEquals(result.getRatingScale(), FiveStarRatingScale.class);
+ }
+
+ @Test
+ public void testDatedReview(){
+ java.util.Date today = new java.util.Date();
+ fail("do something");
+ }
+}
@@ -0,0 +1,19 @@
+package com.visionarysoftwaresolutions.reviewable;
+
+class User implements Reviewer {
+ private String name;
+
+ public User(String string) {
+ name = string;
+ }
+
+ @Override
+ public Review review(Reviewable toReview, String description) {
+ return new FoodReview(this, toReview, description);
+ }
+
+ @Override
+ public RatedReview rate(Reviewable toReview, RatingScale ratingScale, String description) {
+ throw new UnsupportedOperationException("Not supported yet.");
+ }
+}

0 comments on commit 99f1a70

Please sign in to comment.