| 1 |
|
|
| 2 |
|
|
| 3 |
|
|
| 4 |
|
|
| 5 |
|
|
| 6 |
|
|
| 7 |
|
|
| 8 |
|
|
| 9 |
|
|
| 10 |
|
|
| 11 |
|
|
| 12 |
|
|
| 13 |
|
|
| 14 |
|
|
| 15 |
|
|
| 16 |
|
|
| 17 |
|
|
| 18 |
|
|
| 19 |
|
|
| 20 |
|
|
| 21 |
|
|
| 22 |
|
|
| 23 |
|
|
| 24 |
|
|
| 25 |
|
|
| 26 |
|
|
| 27 |
|
|
| 28 |
|
|
| 29 |
|
|
| 30 |
|
|
| 31 |
|
|
| 32 |
|
package net.sourceforge.pebble.decorator; |
| 33 |
|
|
| 34 |
|
import net.sourceforge.pebble.domain.*; |
| 35 |
|
import net.sourceforge.pebble.util.SecurityUtils; |
| 36 |
|
import net.sourceforge.pebble.api.decorator.ContentDecorator; |
| 37 |
|
import net.sourceforge.pebble.api.decorator.ContentDecoratorContext; |
| 38 |
|
|
| 39 |
|
|
| 40 |
|
|
| 41 |
|
|
| 42 |
|
@author |
| 43 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (66) |
Complexity: 5 |
Complexity Density: 0,08 |
|
| 44 |
|
public class HideUnapprovedResponsesDecoratorTest extends SingleBlogTestCase { |
| 45 |
|
|
| 46 |
|
private ContentDecorator decorator; |
| 47 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
|
| 48 |
8
|
protected void setUp() throws Exception {... |
| 49 |
8
|
super.setUp(); |
| 50 |
|
|
| 51 |
8
|
decorator = new HideUnapprovedResponsesDecorator(); |
| 52 |
|
} |
| 53 |
|
|
| 54 |
|
|
| 55 |
|
|
| 56 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0,05 |
1
PASS
|
|
| 57 |
2
|
public void testUnapprovedResponsesRemovedWhenNotLoggedIn() throws Exception {... |
| 58 |
2
|
BlogEntry blogEntry = new BlogEntry(blog); |
| 59 |
2
|
Comment comment1 = blogEntry.createComment("title", "body", "author", "email", "website", "127.0.0.1"); |
| 60 |
2
|
comment1.setPending(); |
| 61 |
2
|
blogEntry.addComment(comment1); |
| 62 |
2
|
Comment comment2 = blogEntry.createComment("title", "body", "author", "email", "website", "127.0.0.1"); |
| 63 |
2
|
comment2.setApproved(); |
| 64 |
2
|
blogEntry.addComment(comment2); |
| 65 |
|
|
| 66 |
2
|
TrackBack trackBack1 = blogEntry.createTrackBack("title", "excerpt", "url", "blogName", "127.0.0.1"); |
| 67 |
2
|
trackBack1.setPending(); |
| 68 |
2
|
blogEntry.addTrackBack(trackBack1); |
| 69 |
2
|
TrackBack trackBack2 = blogEntry.createTrackBack("title", "excerpt", "url", "blogName", "127.0.0.1"); |
| 70 |
2
|
trackBack2.setApproved(); |
| 71 |
2
|
blogEntry.addTrackBack(trackBack2); |
| 72 |
|
|
| 73 |
2
|
SecurityUtils.runAsAnonymous(); |
| 74 |
|
|
| 75 |
2
|
ContentDecoratorContext context = new ContentDecoratorContext(); |
| 76 |
2
|
decorator.decorate(context, blogEntry); |
| 77 |
2
|
assertEquals(1, blogEntry.getComments().size()); |
| 78 |
2
|
assertEquals(1, blogEntry.getTrackBacks().size()); |
| 79 |
|
|
| 80 |
2
|
assertSame(comment2, blogEntry.getComments().get(0)); |
| 81 |
2
|
assertSame(trackBack2, blogEntry.getTrackBacks().get(0)); |
| 82 |
|
} |
| 83 |
|
|
| 84 |
|
|
| 85 |
|
|
| 86 |
|
|
| 87 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0,08 |
1
PASS
|
|
| 88 |
2
|
public void testUnapprovedResponsesRemovedWhenLoggedIn() throws Exception {... |
| 89 |
2
|
BlogEntry blogEntry = new BlogEntry(blog); |
| 90 |
2
|
Comment comment = blogEntry.createComment("title", "body", "author", "email", "website", "127.0.0.1"); |
| 91 |
2
|
comment.setPending(); |
| 92 |
2
|
blogEntry.addComment(comment); |
| 93 |
|
|
| 94 |
2
|
TrackBack trackBack = blogEntry.createTrackBack("title", "excerpt", "url", "blogName", "127.0.0.1"); |
| 95 |
2
|
trackBack.setPending(); |
| 96 |
2
|
blogEntry.addTrackBack(trackBack); |
| 97 |
|
|
| 98 |
2
|
SecurityUtils.runAsBlogContributor(); |
| 99 |
2
|
blog.setProperty(Blog.BLOG_CONTRIBUTORS_KEY, "some_contributor"); |
| 100 |
|
|
| 101 |
2
|
ContentDecoratorContext context = new ContentDecoratorContext(); |
| 102 |
2
|
decorator.decorate(context, blogEntry); |
| 103 |
2
|
assertEquals(0, blogEntry.getComments().size()); |
| 104 |
2
|
assertEquals(0, blogEntry.getTrackBacks().size()); |
| 105 |
|
} |
| 106 |
|
|
| 107 |
|
|
| 108 |
|
|
| 109 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0,08 |
1
PASS
|
|
| 110 |
2
|
public void testUnapprovedResponsesNotRemovedWhenLoggedIn() throws Exception {... |
| 111 |
2
|
BlogEntry blogEntry = new BlogEntry(blog); |
| 112 |
2
|
Comment comment = blogEntry.createComment("title", "body", "author", "email", "website", "127.0.0.1"); |
| 113 |
2
|
comment.setPending(); |
| 114 |
2
|
blogEntry.addComment(comment); |
| 115 |
|
|
| 116 |
2
|
TrackBack trackBack = blogEntry.createTrackBack("title", "excerpt", "url", "blogName", "127.0.0.1"); |
| 117 |
2
|
trackBack.setPending(); |
| 118 |
2
|
blogEntry.addTrackBack(trackBack); |
| 119 |
|
|
| 120 |
2
|
ContentDecoratorContext context = new ContentDecoratorContext(); |
| 121 |
|
|
| 122 |
2
|
SecurityUtils.runAsBlogContributor(); |
| 123 |
|
|
| 124 |
2
|
decorator.decorate(context, blogEntry); |
| 125 |
2
|
assertEquals(1, blogEntry.getComments().size()); |
| 126 |
2
|
assertEquals(1, blogEntry.getTrackBacks().size()); |
| 127 |
|
} |
| 128 |
|
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0,07 |
1
PASS
|
|
| 129 |
2
|
public void testUnapprovedNestedResponsesRemovedWhenNotLoggedIn() throws Exception {... |
| 130 |
2
|
BlogEntry blogEntry = new BlogEntry(blog); |
| 131 |
2
|
Comment comment1 = blogEntry.createComment("title", "body", "author", "email", "website", "127.0.0.1"); |
| 132 |
2
|
comment1.setPending(); |
| 133 |
2
|
blogEntry.addComment(comment1); |
| 134 |
|
|
| 135 |
2
|
Comment comment2 = blogEntry.createComment("title", "body", "author", "email", "website", "127.0.0.1"); |
| 136 |
2
|
comment2.setPending(); |
| 137 |
2
|
comment2.setParent(comment1); |
| 138 |
2
|
blogEntry.addComment(comment2); |
| 139 |
|
|
| 140 |
2
|
SecurityUtils.runAsAnonymous(); |
| 141 |
|
|
| 142 |
2
|
blogEntry = (BlogEntry)blogEntry.clone(); |
| 143 |
|
|
| 144 |
2
|
ContentDecoratorContext context = new ContentDecoratorContext(); |
| 145 |
2
|
decorator.decorate(context, blogEntry); |
| 146 |
2
|
assertEquals(0, blogEntry.getComments().size()); |
| 147 |
2
|
assertEquals(0, blogEntry.getTrackBacks().size()); |
| 148 |
|
} |
| 149 |
|
|
| 150 |
|
} |