Permalink
Browse files

cleanup

  • Loading branch information...
1 parent cd8d531 commit 019054746b600d8b78dd2029039a3ddddbd09ccb @leadVisionary committed Apr 27, 2012
Showing with 44 additions and 417 deletions.
  1. 0 src/{src → }/com/visionarysoftwaresolutions/reviewable/Rating.java
  2. +2 −1 src/com/visionarysoftwaresolutions/reviewable/RatingScale.java
  3. +15 −0 src/com/visionarysoftwaresolutions/reviewable/ReviewDecorator.java
  4. +1 −1 src/com/visionarysoftwaresolutions/reviewable/Reviewer.java
  5. +0 −16 src/src/com/visionarysoftwaresolutions/reviewable/RatedReview.java
  6. +0 −13 src/src/com/visionarysoftwaresolutions/reviewable/RatingScale.java
  7. +0 −16 src/src/com/visionarysoftwaresolutions/reviewable/Review.java
  8. +0 −24 src/src/com/visionarysoftwaresolutions/reviewable/ReviewDecorator.java
  9. +0 −14 src/src/com/visionarysoftwaresolutions/reviewable/Reviewable.java
  10. +0 −14 src/src/com/visionarysoftwaresolutions/reviewable/Reviewer.java
  11. +0 −16 test/com/visionarysoftwaresolutions/reviewable/FiveStarRatingScale.java
  12. +0 −14 test/com/visionarysoftwaresolutions/reviewable/Food.java
  13. +0 −29 test/com/visionarysoftwaresolutions/reviewable/FoodReview.java
  14. +26 −12 test/com/visionarysoftwaresolutions/reviewable/ReviewableTests.java
  15. +0 −19 test/com/visionarysoftwaresolutions/reviewable/User.java
  16. 0 test/{test → }/com/visionarysoftwaresolutions/reviewable/stubs/BasicFoodReview.java
  17. 0 test/{test → }/com/visionarysoftwaresolutions/reviewable/stubs/DatedReview.java
  18. 0 test/{test → }/com/visionarysoftwaresolutions/reviewable/stubs/FiveStarRatingScale.java
  19. 0 test/{test → }/com/visionarysoftwaresolutions/reviewable/stubs/Food.java
  20. 0 test/{test → }/com/visionarysoftwaresolutions/reviewable/stubs/FoodReview.java
  21. 0 test/{test → }/com/visionarysoftwaresolutions/reviewable/stubs/NumericalRating.java
  22. 0 test/{test → }/com/visionarysoftwaresolutions/reviewable/stubs/RatedFoodReview.java
  23. 0 test/{test → }/com/visionarysoftwaresolutions/reviewable/stubs/User.java
  24. +0 −8 test/test/com/visionarysoftwaresolutions/reviewable/BasicFoodReview.java
  25. +0 −47 test/test/com/visionarysoftwaresolutions/reviewable/FiveStarRatingScale.java
  26. +0 −14 test/test/com/visionarysoftwaresolutions/reviewable/Food.java
  27. +0 −28 test/test/com/visionarysoftwaresolutions/reviewable/FoodReview.java
  28. +0 −35 test/test/com/visionarysoftwaresolutions/reviewable/NumericalRating.java
  29. +0 −23 test/test/com/visionarysoftwaresolutions/reviewable/RatedFoodReview.java
  30. +0 −54 test/test/com/visionarysoftwaresolutions/reviewable/ReviewableTests.java
  31. +0 −19 test/test/com/visionarysoftwaresolutions/reviewable/User.java
@@ -8,5 +8,6 @@
* Scenario: A Reviewer creates a Review for a Reviewable, rating it on a RatingScale with a Description
*/
public interface RatingScale {
- public abstract String[] getScale();
+ public abstract String[] range();
+ public abstract Rating getRating();
}
@@ -6,4 +6,19 @@
public ReviewDecorator(Review toDecorate){
this.decoratedReview = toDecorate;
}
+
+ @Override
+ public String getDescription() {
+ return decoratedReview.getDescription();
+ }
+
+ @Override
+ public Reviewer getReviewer() {
+ return decoratedReview.getReviewer();
+ }
+
+ @Override
+ public Reviewable getReviewed() {
+ return decoratedReview.getReviewed();
+ }
}
@@ -10,5 +10,5 @@
*/
public interface Reviewer {
public abstract Review review(Reviewable toReview, String description);
- public abstract RatedReview rate(Reviewable toReview, RatingScale ratingScale, String description);
+ public abstract RatedReview rate(Reviewable toReview, String description, RatingScale scale);
}
@@ -1,16 +0,0 @@
-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();
-}
@@ -1,13 +0,0 @@
-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[] range();
- public abstract Rating getRating();
-}
@@ -1,16 +0,0 @@
-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();
-}
@@ -1,24 +0,0 @@
-package com.visionarysoftwaresolutions.reviewable;
-
-public abstract class ReviewDecorator implements Review {
- protected final Review decoratedReview;
-
- public ReviewDecorator(Review toDecorate){
- this.decoratedReview = toDecorate;
- }
-
- @Override
- public String getDescription() {
- return decoratedReview.getDescription();
- }
-
- @Override
- public Reviewer getReviewer() {
- return decoratedReview.getReviewer();
- }
-
- @Override
- public Reviewable getReviewed() {
- return decoratedReview.getReviewed();
- }
-}
@@ -1,14 +0,0 @@
-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);
-}
@@ -1,14 +0,0 @@
-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, String description, RatingScale scale);
-}
@@ -1,16 +0,0 @@
-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.");
- }
-}
@@ -1,14 +0,0 @@
-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.");
- }
-}
@@ -1,29 +0,0 @@
-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;
- }
-
-}
@@ -1,15 +1,16 @@
package com.visionarysoftwaresolutions.reviewable;
+import com.visionarysoftwaresolutions.reviewable.stubs.*;
import org.junit.Test;
import static org.junit.Assert.*;
public class ReviewableTests {
+ Reviewer nick = new User("nick");
+ Reviewable food = new Food("Phonecian Cafe Hummus");
+
@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
+ //When I have the Reviewer review the Reviewable
Review result = nick.review(food,
"It is so creamy and delicious!");
//Then it is reviewed
@@ -20,21 +21,34 @@ public void testReview() {
@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!");
+ "It is so creamy and delicious!",
+ FiveStarRatingScale.five());
//Then it is rated
- assertEquals(result.getRatingScale(), FiveStarRatingScale.class);
+ assertEquals(result.getReviewer(), nick);
+ assertEquals(result.getReviewed(), food);
+ RatingScale howRated = result.getRatingScale();
+ assertEquals(howRated.getRating(), new NumericalRating(5,howRated));
+ assertArrayEquals(howRated.range(),
+ new String[] { "0", "1", "2", "3", "4", "5" });
}
@Test
public void testDatedReview(){
+ //Given I'm reviewing something today
java.util.Date today = new java.util.Date();
- fail("do something");
+ //When I have a reviewer rate a reviewable
+ RatedReview result = nick.rate(food,
+ "It is so creamy and delicious!",
+ FiveStarRatingScale.five());
+ //And I want a Dated Review
+ DatedReview datedResult = new DatedReview(result);
+ //Then it is rated
+ assertEquals(datedResult.getReviewer(), nick);
+ assertEquals(datedResult.getReviewed(), food);
+ assertTrue(today.equals(datedResult.getDate()));
+ assertEquals("It is so creamy and delicious! on " + today,
+ datedResult.getDescription());
}
}
@@ -1,19 +0,0 @@
-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.");
- }
-}
@@ -1,8 +0,0 @@
-package com.visionarysoftwaresolutions.reviewable;
-
-public class BasicFoodReview extends FoodReview {
-
- public BasicFoodReview(Reviewer reviewer, Reviewable reviewed, String description){
- super(reviewer, reviewed, description);
- }
-}
@@ -1,47 +0,0 @@
-package com.visionarysoftwaresolutions.reviewable;
-
-class FiveStarRatingScale implements RatingScale {
- private Rating stars;
-
- static RatingScale five() {
- FiveStarRatingScale five = new FiveStarRatingScale(5);
- return five;
- }
-
- private FiveStarRatingScale(int i) {
- rate(i);
- }
-
- public final void rate(int stars){
- if(stars < 0){
- throw new IllegalArgumentException("Must be greater than 0 stars");
- }
- if(stars > 5){
- throw new IllegalArgumentException("Can't be more than 5 stars");
- }
- this.stars = new NumericalRating(stars, this);
- }
-
- @Override
- public String[] range() {
- return new String[] { "0", "1", "2", "3", "4", "5" };
- }
-
- @Override
- public Rating getRating() {
- return stars;
- }
-
- @Override
- public boolean equals(Object object) {
- return !(object instanceof FiveStarRatingScale) &&
- stars == ((FiveStarRatingScale) object).stars;
- }
-
- @Override
- public int hashCode() {
- int hash = 3;
- hash = 17 * hash + this.stars.hashCode();
- return hash;
- }
-}
@@ -1,14 +0,0 @@
-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.");
- }
-}
@@ -1,28 +0,0 @@
-package com.visionarysoftwaresolutions.reviewable;
-
-public abstract 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 Reviewable getReviewed() {
- return reviewed;
- }
-
- @Override
- public Reviewer getReviewer() {
- return reviewer;
- }
-}
Oops, something went wrong.

0 comments on commit 0190547

Please sign in to comment.