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.domain; |
33 |
|
|
34 |
|
import java.beans.PropertyChangeEvent; |
35 |
|
import java.text.DecimalFormat; |
36 |
|
import java.util.*; |
37 |
|
|
38 |
|
|
39 |
|
|
40 |
|
|
41 |
|
@author |
42 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (586) |
Complexity: 53 |
Complexity Density: 0,1 |
|
43 |
|
public class BlogEntryTest extends SingleBlogTestCase { |
44 |
|
|
45 |
|
private BlogEntry blogEntry; |
46 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (8) |
Complexity: 1 |
Complexity Density: 0,12 |
|
47 |
104
|
protected void setUp() throws Exception {... |
48 |
104
|
super.setUp(); |
49 |
104
|
blogEntry = new BlogEntry(blog); |
50 |
104
|
blogEntry.setTitle("A title"); |
51 |
104
|
blogEntry.setBody("Some body"); |
52 |
104
|
blogEntry.setExcerpt("Some excerpt"); |
53 |
104
|
blogEntry.setAuthor("An author"); |
54 |
104
|
blogEntry.setDate(new Date()); |
55 |
104
|
blogEntry.setEventsEnabled(true); |
56 |
|
} |
57 |
|
|
58 |
|
|
59 |
|
|
60 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (15) |
Complexity: 1 |
Complexity Density: 0,07 |
1
PASS
|
|
61 |
2
|
public void testConstruction() {... |
62 |
2
|
assertNotNull(blogEntry.getId()); |
63 |
2
|
assertEquals("A title", blogEntry.getTitle()); |
64 |
2
|
assertEquals("Some body", blogEntry.getBody()); |
65 |
|
|
66 |
2
|
assertNotNull(blogEntry.getCategories()); |
67 |
2
|
assertEquals(0, blogEntry.getCategories().size()); |
68 |
2
|
assertTrue(blogEntry.isCommentsEnabled()); |
69 |
2
|
assertNotNull(blogEntry.getComments()); |
70 |
2
|
assertEquals(0, blogEntry.getComments().size()); |
71 |
2
|
assertNotNull(blogEntry.getTrackBacks()); |
72 |
2
|
assertEquals(0, blogEntry.getTrackBacks().size()); |
73 |
|
|
74 |
2
|
assertNotNull(blogEntry.getDate()); |
75 |
2
|
assertNotNull(blogEntry.getAuthor()); |
76 |
2
|
assertFalse(blogEntry.isAggregated()); |
77 |
2
|
assertNotNull(blogEntry.getTags()); |
78 |
2
|
assertEquals(0, blogEntry.getTagsAsList().size()); |
79 |
|
} |
80 |
|
|
81 |
|
|
82 |
|
|
83 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
84 |
2
|
public void testGetRootBlog() {... |
85 |
2
|
assertEquals(blog, blogEntry.getBlog()); |
86 |
|
} |
87 |
|
|
88 |
|
|
89 |
|
|
90 |
|
|
|
|
| - |
Uncovered Elements: 0 (0) |
Complexity: 1 |
Complexity Density: - |
1
PASS
|
|
91 |
2
|
public void testDay() {... |
92 |
|
|
93 |
|
} |
94 |
|
|
95 |
|
|
96 |
|
|
97 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
98 |
2
|
public void testId() {... |
99 |
2
|
String id = "" + blogEntry.getDate().getTime(); |
100 |
2
|
assertEquals(id, blogEntry.getId()); |
101 |
|
} |
102 |
|
|
103 |
|
|
104 |
|
|
105 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
106 |
2
|
public void testTitle() {... |
107 |
2
|
blogEntry.setTitle("A new title"); |
108 |
2
|
assertEquals("A new title", blogEntry.getTitle()); |
109 |
|
} |
110 |
|
|
111 |
|
|
112 |
|
|
113 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
114 |
2
|
public void testSubtitle() {... |
115 |
2
|
blogEntry.setSubtitle("A new subtitle"); |
116 |
2
|
assertEquals("A new subtitle", blogEntry.getSubtitle()); |
117 |
|
} |
118 |
|
|
119 |
|
|
120 |
|
|
121 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
122 |
2
|
public void testBody() {... |
123 |
2
|
blogEntry.setBody("A new body"); |
124 |
2
|
assertEquals("A new body", blogEntry.getBody()); |
125 |
|
} |
126 |
|
|
127 |
|
|
128 |
|
|
129 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
130 |
2
|
public void testExcerpt() {... |
131 |
2
|
blogEntry.setExcerpt("An excerpt"); |
132 |
2
|
assertEquals("An excerpt", blogEntry.getExcerpt()); |
133 |
|
} |
134 |
|
|
135 |
|
|
136 |
|
|
137 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (7) |
Complexity: 1 |
Complexity Density: 0,14 |
1
PASS
|
|
138 |
2
|
public void testCategories() {... |
139 |
2
|
assertEquals(0, blogEntry.getCategories().size()); |
140 |
|
|
141 |
2
|
Category category = new Category("1", "One"); |
142 |
2
|
blogEntry.addCategory(category); |
143 |
2
|
assertEquals(1, blogEntry.getCategories().size()); |
144 |
2
|
assertTrue(blogEntry.getCategories().contains(category)); |
145 |
|
|
146 |
|
|
147 |
2
|
blogEntry.addCategory(null); |
148 |
2
|
assertFalse(blogEntry.getCategories().contains(null)); |
149 |
|
} |
150 |
|
|
151 |
|
|
152 |
|
|
153 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (16) |
Complexity: 1 |
Complexity Density: 0,06 |
1
PASS
|
|
154 |
2
|
public void testInCategory() {... |
155 |
2
|
CategoryBuilder builder = new CategoryBuilder(blog); |
156 |
2
|
Category apple = new Category("/apple", "Apple"); |
157 |
2
|
Category java = new Category("/java", "Java"); |
158 |
2
|
Category junit = new Category("/java/junit", "JUnit"); |
159 |
2
|
builder.addCategory(apple); |
160 |
2
|
builder.addCategory(java); |
161 |
2
|
builder.addCategory(junit); |
162 |
|
|
163 |
2
|
blogEntry.addCategory(apple); |
164 |
2
|
assertTrue(blogEntry.inCategory(apple)); |
165 |
2
|
assertFalse(blogEntry.inCategory(java)); |
166 |
2
|
assertFalse(blogEntry.inCategory(junit)); |
167 |
2
|
assertTrue(blogEntry.inCategory(null)); |
168 |
|
|
169 |
2
|
blogEntry.addCategory(junit); |
170 |
2
|
assertTrue(blogEntry.inCategory(apple)); |
171 |
2
|
assertTrue(blogEntry.inCategory(java)); |
172 |
2
|
assertTrue(blogEntry.inCategory(junit)); |
173 |
|
} |
174 |
|
|
175 |
|
|
176 |
|
|
177 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0,09 |
1
PASS
|
|
178 |
2
|
public void testAllCategoriesCanBeRemoved() {... |
179 |
2
|
CategoryBuilder builder = new CategoryBuilder(blog); |
180 |
2
|
Category apple = new Category("/apple", "Apple"); |
181 |
2
|
Category java = new Category("/java", "Java"); |
182 |
2
|
Category junit = new Category("/java/junit", "JUnit"); |
183 |
2
|
builder.addCategory(apple); |
184 |
2
|
builder.addCategory(java); |
185 |
2
|
builder.addCategory(junit); |
186 |
|
|
187 |
2
|
blogEntry.addCategory(apple); |
188 |
2
|
blogEntry.addCategory(junit); |
189 |
|
|
190 |
2
|
blogEntry.removeAllCategories(); |
191 |
2
|
assertEquals(0, blogEntry.getCategories().size()); |
192 |
|
} |
193 |
|
|
194 |
|
|
195 |
|
|
196 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
197 |
2
|
public void testTagsSeparatedByCommas() {... |
198 |
2
|
blogEntry.setTags("some, tags"); |
199 |
2
|
assertEquals("some tags", blogEntry.getTags()); |
200 |
2
|
List tags = blogEntry.getTagsAsList(); |
201 |
2
|
assertEquals(2, tags.size()); |
202 |
2
|
assertEquals(blog.getTag("some"), tags.get(0)); |
203 |
2
|
assertEquals(blog.getTag("tags"), tags.get(1)); |
204 |
|
} |
205 |
|
|
206 |
|
|
207 |
|
|
208 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
209 |
2
|
public void testTagsSeparatedByWhitespace() {... |
210 |
2
|
blogEntry.setTags("some tags"); |
211 |
2
|
assertEquals("some tags", blogEntry.getTags()); |
212 |
2
|
List tags = blogEntry.getTagsAsList(); |
213 |
2
|
assertEquals(2, tags.size()); |
214 |
2
|
assertEquals(blog.getTag("some"), tags.get(0)); |
215 |
2
|
assertEquals(blog.getTag("tags"), tags.get(1)); |
216 |
|
} |
217 |
|
|
218 |
|
|
219 |
|
|
220 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (1) |
Complexity: 1 |
Complexity Density: 1 |
1
PASS
|
|
221 |
2
|
public void testDate() {... |
222 |
2
|
assertNotNull(blogEntry.getDate()); |
223 |
|
} |
224 |
|
|
225 |
|
|
226 |
|
|
227 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
228 |
2
|
public void testAuthor() {... |
229 |
2
|
blogEntry.setAuthor("A new author"); |
230 |
2
|
assertEquals("A new author", blogEntry.getAuthor()); |
231 |
|
} |
232 |
|
|
233 |
|
|
234 |
|
|
235 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (6) |
Complexity: 1 |
Complexity Density: 0,17 |
1
PASS
|
|
236 |
2
|
public void testAggregated() {... |
237 |
2
|
blogEntry.setOriginalPermalink("http://www.simongbrown.com/blog/2003/04/01.html#a123456789"); |
238 |
2
|
assertTrue(blogEntry.isAggregated()); |
239 |
|
|
240 |
2
|
blogEntry.setOriginalPermalink(null); |
241 |
2
|
assertFalse(blogEntry.isAggregated()); |
242 |
|
|
243 |
2
|
blogEntry.setOriginalPermalink(""); |
244 |
2
|
assertFalse(blogEntry.isAggregated()); |
245 |
|
} |
246 |
|
|
247 |
|
|
248 |
|
|
249 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (3) |
Complexity: 1 |
Complexity Density: 0,33 |
1
PASS
|
|
250 |
2
|
public void testCommentsEnabled() {... |
251 |
2
|
assertTrue(blogEntry.isCommentsEnabled()); |
252 |
2
|
blogEntry.setCommentsEnabled(false); |
253 |
2
|
assertFalse(blogEntry.isCommentsEnabled()); |
254 |
|
} |
255 |
|
|
256 |
|
|
257 |
|
|
258 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1
PASS
|
|
259 |
2
|
public void testLinks() {... |
260 |
2
|
DecimalFormat format = new DecimalFormat("00"); |
261 |
2
|
Calendar cal = blog.getCalendar(); |
262 |
2
|
cal.setTime(blogEntry.getDate()); |
263 |
2
|
int year = cal.get(Calendar.YEAR); |
264 |
2
|
int month = cal.get(Calendar.MONTH) + 1; |
265 |
2
|
int day = cal.get(Calendar.DAY_OF_MONTH); |
266 |
2
|
assertEquals("http://www.yourdomain.com/blog/" + |
267 |
|
year + "/" + format.format(month) + "/" + format.format(day) + "/" + |
268 |
|
blogEntry.getId() + ".html", blogEntry.getPermalink()); |
269 |
2
|
assertEquals("http://www.yourdomain.com/blog/" + |
270 |
|
year + "/" + format.format(month) + "/" + format.format(day) + "/" + |
271 |
|
blogEntry.getId() + ".html", blogEntry.getLocalPermalink()); |
272 |
2
|
assertEquals(blogEntry.getLocalPermalink() + "#comments", blogEntry.getCommentsLink()); |
273 |
2
|
assertEquals(blogEntry.getLocalPermalink() + "#trackbacks" , blogEntry.getTrackBacksLink()); |
274 |
|
} |
275 |
|
|
276 |
|
|
277 |
|
|
278 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (43) |
Complexity: 1 |
Complexity Density: 0,02 |
1
PASS
|
|
279 |
2
|
public void testComments() {... |
280 |
2
|
Comment blogComment1, blogComment2; |
281 |
2
|
Calendar cal1, cal2; |
282 |
2
|
cal1 = blog.getCalendar(); |
283 |
2
|
cal1.set(Calendar.DAY_OF_MONTH, 1); |
284 |
2
|
cal2 = blog.getCalendar(); |
285 |
2
|
cal2.set(Calendar.DAY_OF_MONTH, 2); |
286 |
|
|
287 |
|
|
288 |
2
|
assertEquals(0, blogEntry.getNumberOfComments()); |
289 |
2
|
assertEquals(0, blogEntry.getComments().size()); |
290 |
|
|
291 |
|
|
292 |
2
|
blogComment1 = blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1", cal1.getTime(), State.APPROVED); |
293 |
2
|
assertNotNull(blogComment1); |
294 |
2
|
assertEquals("Re: " + blogEntry.getTitle(), blogComment1.getTitle()); |
295 |
2
|
assertEquals("Body", blogComment1.getBody()); |
296 |
2
|
assertEquals("Author", blogComment1.getAuthor()); |
297 |
2
|
assertEquals("http://www.google.com", blogComment1.getWebsite()); |
298 |
2
|
assertNotNull(blogComment1.getDate()); |
299 |
2
|
assertEquals(blogEntry, blogComment1.getBlogEntry()); |
300 |
|
|
301 |
|
|
302 |
2
|
assertEquals(0, blogEntry.getNumberOfComments()); |
303 |
2
|
assertEquals(0, blogEntry.getComments().size()); |
304 |
2
|
assertFalse(blogEntry.getComments().contains(blogComment1)); |
305 |
|
|
306 |
|
|
307 |
2
|
blogEntry.addComment(blogComment1); |
308 |
2
|
assertEquals(1, blogEntry.getNumberOfComments()); |
309 |
2
|
assertEquals(1, blogEntry.getComments().size()); |
310 |
2
|
assertTrue(blogEntry.getComments().contains(blogComment1)); |
311 |
|
|
312 |
|
|
313 |
2
|
blogComment2 = blogEntry.createComment("Title 2", "Body 2", "Author 2", "me2@somedomain.com", "http://www.yahoo.com", "127.0.0.1", cal2.getTime(), State.APPROVED); |
314 |
2
|
assertEquals("Title 2", blogComment2.getTitle()); |
315 |
2
|
assertEquals(1, blogEntry.getNumberOfComments()); |
316 |
2
|
assertTrue(blogEntry.getComments().contains(blogComment1)); |
317 |
2
|
assertFalse(blogEntry.getComments().contains(blogComment2)); |
318 |
2
|
blogEntry.addComment(blogComment2); |
319 |
2
|
assertEquals(2, blogEntry.getNumberOfComments()); |
320 |
2
|
assertEquals(2, blogEntry.getComments().size()); |
321 |
2
|
assertTrue(blogEntry.getComments().contains(blogComment1)); |
322 |
2
|
assertTrue(blogEntry.getComments().contains(blogComment2)); |
323 |
|
|
324 |
|
|
325 |
2
|
blogEntry.addComment(blogComment2); |
326 |
2
|
assertEquals(2, blogEntry.getNumberOfComments()); |
327 |
|
|
328 |
|
|
329 |
2
|
blogEntry.removeComment(blogComment1.getId()); |
330 |
2
|
assertFalse(blogEntry.getComments().contains(blogComment1)); |
331 |
2
|
assertTrue(blogEntry.getComments().contains(blogComment2)); |
332 |
2
|
assertEquals(1, blogEntry.getNumberOfComments()); |
333 |
2
|
blogEntry.removeComment(blogComment2.getId()); |
334 |
2
|
assertFalse(blogEntry.getComments().contains(blogComment1)); |
335 |
2
|
assertFalse(blogEntry.getComments().contains(blogComment2)); |
336 |
2
|
assertEquals(0, blogEntry.getNumberOfComments()); |
337 |
|
} |
338 |
|
|
339 |
|
|
340 |
|
|
341 |
|
|
342 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0,08 |
1
PASS
|
|
343 |
2
|
public void testTwoCommentsAddedAtTheSameTime() {... |
344 |
2
|
Comment blogComment1, blogComment2; |
345 |
2
|
blogComment1 = blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1"); |
346 |
2
|
blogComment2 = (Comment)blogComment1.clone(); |
347 |
2
|
assertEquals(blogComment1.getId(), blogComment2.getId()); |
348 |
2
|
blogEntry.addComment(blogComment1); |
349 |
2
|
assertEquals(1, blogEntry.getNumberOfComments()); |
350 |
2
|
assertEquals(1, blogEntry.getComments().size()); |
351 |
2
|
assertTrue(blogEntry.getComments().contains(blogComment1)); |
352 |
2
|
blogEntry.addComment(blogComment2); |
353 |
2
|
assertEquals(2, blogEntry.getNumberOfComments()); |
354 |
2
|
assertEquals(2, blogEntry.getComments().size()); |
355 |
2
|
assertTrue(blogEntry.getComments().contains(blogComment1)); |
356 |
2
|
assertTrue(blogEntry.getComments().contains(blogComment2)); |
357 |
|
} |
358 |
|
|
359 |
|
|
360 |
|
|
361 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0,08 |
1
PASS
|
|
362 |
2
|
public void testNestedComments() {... |
363 |
2
|
Comment comment1, comment2; |
364 |
2
|
Date date1 = new Date(0); |
365 |
2
|
Date date2 = new Date(1000); |
366 |
|
|
367 |
2
|
comment1 = blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1", date1, State.APPROVED); |
368 |
2
|
blogEntry.addComment(comment1); |
369 |
|
|
370 |
2
|
comment2 = blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1", date2, State.APPROVED); |
371 |
2
|
comment2.setParent(comment1); |
372 |
2
|
blogEntry.addComment(comment2); |
373 |
|
|
374 |
2
|
assertEquals(2, blogEntry.getComments().size()); |
375 |
2
|
assertEquals(comment1, blogEntry.getComments().get(0)); |
376 |
2
|
assertEquals(comment2, blogEntry.getComments().get(1)); |
377 |
|
|
378 |
2
|
assertEquals(comment1, blogEntry.getComment(comment1.getId())); |
379 |
2
|
assertEquals(comment2, blogEntry.getComment(comment2.getId())); |
380 |
|
} |
381 |
|
|
382 |
|
|
383 |
|
|
384 |
|
|
385 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (12) |
Complexity: 1 |
Complexity Density: 0,08 |
1
PASS
|
|
386 |
2
|
public void testNumberOfCommentsCorrectWhenNestedCommentsPresent() {... |
387 |
2
|
Comment comment1, comment2; |
388 |
2
|
Calendar cal1, cal2; |
389 |
2
|
cal1 = blog.getCalendar(); |
390 |
2
|
cal1.set(Calendar.DAY_OF_MONTH, 1); |
391 |
2
|
cal2 = blog.getCalendar(); |
392 |
2
|
cal2.set(Calendar.DAY_OF_MONTH, 2); |
393 |
|
|
394 |
2
|
comment1 = blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1", cal1.getTime(), State.APPROVED); |
395 |
2
|
blogEntry.addComment(comment1); |
396 |
|
|
397 |
2
|
comment2 = blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1", cal2.getTime(), State.APPROVED); |
398 |
2
|
comment2.setParent(comment1); |
399 |
2
|
blogEntry.addComment(comment2); |
400 |
|
|
401 |
2
|
assertEquals(2, blogEntry.getNumberOfComments()); |
402 |
|
} |
403 |
|
|
404 |
|
|
405 |
|
|
406 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1
PASS
|
|
407 |
2
|
public void testRemovingCommentRemovesAllChildren() {... |
408 |
2
|
Comment comment1, comment2; |
409 |
2
|
Date date1 = new Date(0); |
410 |
2
|
Date date2 = new Date(1000); |
411 |
|
|
412 |
2
|
comment1 = blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1", date1, State.APPROVED); |
413 |
2
|
blogEntry.addComment(comment1); |
414 |
|
|
415 |
2
|
comment2 = blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1", date2, State.APPROVED); |
416 |
2
|
comment2.setParent(comment1); |
417 |
2
|
blogEntry.addComment(comment2); |
418 |
|
|
419 |
|
|
420 |
2
|
blogEntry.removeComment(comment1.getId()); |
421 |
2
|
assertEquals(0, blogEntry.getNumberOfComments()); |
422 |
|
} |
423 |
|
|
424 |
|
|
425 |
|
|
426 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0,09 |
1
PASS
|
|
427 |
2
|
public void testNestedCommentCanBeRemoved() {... |
428 |
2
|
Comment comment1, comment2; |
429 |
2
|
Date date1 = new Date(0); |
430 |
2
|
Date date2 = new Date(1000); |
431 |
|
|
432 |
2
|
comment1 = blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1", date1, State.APPROVED); |
433 |
2
|
blogEntry.addComment(comment1); |
434 |
|
|
435 |
2
|
comment2 = blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1", date2, State.APPROVED); |
436 |
2
|
comment2.setParent(comment1); |
437 |
2
|
blogEntry.addComment(comment2); |
438 |
|
|
439 |
|
|
440 |
2
|
blogEntry.removeComment(comment2.getId()); |
441 |
2
|
assertEquals(1, blogEntry.getNumberOfComments()); |
442 |
2
|
assertNull(blogEntry.getComment(comment2.getId())); |
443 |
|
} |
444 |
|
|
445 |
|
|
446 |
|
|
447 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
448 |
2
|
public void testCommentPermalink() {... |
449 |
2
|
Comment blogComment; |
450 |
|
|
451 |
2
|
blogComment = blogEntry.createComment("Title", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1"); |
452 |
2
|
blogEntry.addComment(blogComment); |
453 |
2
|
assertEquals(blogEntry.getLocalPermalink() + "#comment" + blogComment.getId(), blogComment.getPermalink()); |
454 |
|
} |
455 |
|
|
456 |
|
|
457 |
|
|
458 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (2) |
Complexity: 1 |
Complexity Density: 0,5 |
1
PASS
|
|
459 |
2
|
public void testTrackBacks() {... |
460 |
|
|
461 |
2
|
assertEquals(0, blogEntry.getNumberOfTrackBacks()); |
462 |
2
|
assertEquals(0, blogEntry.getTrackBacks().size()); |
463 |
|
} |
464 |
|
|
465 |
|
|
466 |
|
|
467 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (29) |
Complexity: 1 |
Complexity Density: 0,03 |
1
PASS
|
|
468 |
2
|
public void testCloneableNormalBlogEntry() {... |
469 |
2
|
blogEntry.setTitle("An old title"); |
470 |
2
|
blogEntry.setSubtitle("An old subtitle"); |
471 |
2
|
blogEntry.setBody("An old body"); |
472 |
2
|
blogEntry.setAuthor("An old author"); |
473 |
2
|
blogEntry.setPersistent(true); |
474 |
2
|
blogEntry.setCommentsEnabled(false); |
475 |
2
|
blogEntry.setTrackBacksEnabled(false); |
476 |
2
|
blogEntry.setTimeZoneId("Europe/Paris"); |
477 |
|
|
478 |
2
|
Category category1 = blog.getCategory("/testCategory1"); |
479 |
2
|
Category category2 = blog.getCategory("/testCategory2"); |
480 |
2
|
Category category3 = blog.getCategory("/testCategory3"); |
481 |
2
|
blogEntry.addCategory(category1); |
482 |
2
|
blogEntry.addCategory(category2); |
483 |
2
|
blogEntry.setTags("some+tag"); |
484 |
|
|
485 |
2
|
BlogEntry clonedBlogEntry = (BlogEntry)blogEntry.clone(); |
486 |
|
|
487 |
2
|
assertEquals(blogEntry.getTitle(), clonedBlogEntry.getTitle()); |
488 |
2
|
assertEquals(blogEntry.getSubtitle(), clonedBlogEntry.getSubtitle()); |
489 |
2
|
assertEquals(blogEntry.getBody(), clonedBlogEntry.getBody()); |
490 |
2
|
assertEquals(blogEntry.getAuthor(), clonedBlogEntry.getAuthor()); |
491 |
2
|
assertEquals(blogEntry.getPermalink(), clonedBlogEntry.getPermalink()); |
492 |
2
|
assertEquals(blogEntry.inCategory(category1), clonedBlogEntry.inCategory(category1)); |
493 |
2
|
assertEquals(blogEntry.inCategory(category2), clonedBlogEntry.inCategory(category2)); |
494 |
2
|
assertEquals(blogEntry.inCategory(category3), clonedBlogEntry.inCategory(category3)); |
495 |
2
|
assertEquals("some+tag", clonedBlogEntry.getTags()); |
496 |
2
|
assertEquals(blogEntry.isPersistent(), clonedBlogEntry.isPersistent()); |
497 |
2
|
assertFalse(clonedBlogEntry.isCommentsEnabled()); |
498 |
2
|
assertFalse(clonedBlogEntry.isTrackBacksEnabled()); |
499 |
2
|
assertNull(clonedBlogEntry.getAttachment()); |
500 |
2
|
assertEquals(blogEntry.getTimeZoneId(), clonedBlogEntry.getTimeZoneId()); |
501 |
|
} |
502 |
|
|
503 |
|
|
504 |
|
|
505 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (18) |
Complexity: 1 |
Complexity Density: 0,06 |
1
PASS
|
|
506 |
2
|
public void testCloneableAggregatedBlogEntry() {... |
507 |
2
|
blogEntry.setTitle("An old title"); |
508 |
2
|
blogEntry.setBody("An old body"); |
509 |
2
|
blogEntry.setAuthor("An old author"); |
510 |
2
|
blogEntry.setOriginalPermalink("An old alternative permalink"); |
511 |
|
|
512 |
2
|
Category category1 = blog.getCategory("/testCategory1"); |
513 |
2
|
Category category2 = blog.getCategory("/testCategory2"); |
514 |
2
|
Category category3 = blog.getCategory("/testCategory3"); |
515 |
2
|
blogEntry.addCategory(category1); |
516 |
2
|
blogEntry.addCategory(category2); |
517 |
|
|
518 |
2
|
BlogEntry clonedBlogEntry = (BlogEntry)blogEntry.clone(); |
519 |
|
|
520 |
2
|
assertEquals(blogEntry.getTitle(), clonedBlogEntry.getTitle()); |
521 |
2
|
assertEquals(blogEntry.getBody(), clonedBlogEntry.getBody()); |
522 |
2
|
assertEquals(blogEntry.getAuthor(), clonedBlogEntry.getAuthor()); |
523 |
2
|
assertEquals(blogEntry.getOriginalPermalink(), clonedBlogEntry.getOriginalPermalink()); |
524 |
2
|
assertEquals(blogEntry.inCategory(category1), clonedBlogEntry.inCategory(category1)); |
525 |
2
|
assertEquals(blogEntry.inCategory(category2), clonedBlogEntry.inCategory(category2)); |
526 |
2
|
assertEquals(blogEntry.inCategory(category3), clonedBlogEntry.inCategory(category3)); |
527 |
2
|
assertNull(clonedBlogEntry.getAttachment()); |
528 |
|
} |
529 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
530 |
2
|
public void testTopLevelCommentsClonedProperly() {... |
531 |
2
|
Comment comment = blogEntry.createComment("Title", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1"); |
532 |
2
|
blogEntry.addComment(comment); |
533 |
|
|
534 |
2
|
BlogEntry clonedBlogEntry = (BlogEntry)blogEntry.clone(); |
535 |
2
|
Comment clonedComment = clonedBlogEntry.getComments().get(0); |
536 |
2
|
assertSame(clonedBlogEntry, clonedComment.getBlogEntry()); |
537 |
|
|
538 |
|
} |
539 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (11) |
Complexity: 1 |
Complexity Density: 0,09 |
1
PASS
|
|
540 |
2
|
public void testNestedCommentsClonedProperly() {... |
541 |
2
|
Comment comment1 = blogEntry.createComment("Title", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1"); |
542 |
2
|
blogEntry.addComment(comment1); |
543 |
2
|
Comment comment2 = blogEntry.createComment("Title", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1"); |
544 |
2
|
comment2.setParent(comment1); |
545 |
2
|
blogEntry.addComment(comment2); |
546 |
|
|
547 |
2
|
BlogEntry clonedBlogEntry = (BlogEntry)blogEntry.clone(); |
548 |
2
|
Comment clonedComment1 = clonedBlogEntry.getComments().get(0); |
549 |
2
|
Comment clonedComment2 = clonedBlogEntry.getComments().get(1); |
550 |
2
|
assertSame(clonedComment1, clonedComment2.getParent()); |
551 |
2
|
assertSame(clonedBlogEntry, clonedComment1.getBlogEntry()); |
552 |
2
|
assertSame(clonedBlogEntry, clonedComment2.getBlogEntry()); |
553 |
|
} |
554 |
|
|
555 |
|
|
556 |
|
|
557 |
|
|
558 |
|
|
559 |
|
|
560 |
|
|
561 |
|
|
562 |
|
|
563 |
|
|
564 |
|
|
565 |
|
|
566 |
|
|
567 |
|
|
568 |
|
|
569 |
|
|
570 |
|
|
571 |
|
|
572 |
|
|
573 |
|
|
574 |
|
|
575 |
|
|
576 |
|
|
577 |
|
|
578 |
|
|
579 |
|
|
580 |
|
|
581 |
|
|
582 |
|
|
583 |
|
|
584 |
|
|
585 |
|
|
586 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 1 |
Complexity Density: 0,05 |
1
PASS
|
|
587 |
2
|
public void testGetNextBlogEntry() throws Exception {... |
588 |
2
|
BlogService service = new BlogService(); |
589 |
2
|
Day today = blog.getBlogForToday(); |
590 |
2
|
Day oneDayAgo = today.getPreviousDay(); |
591 |
2
|
Day twoDaysAgo = today.getPreviousDay().getPreviousDay(); |
592 |
|
|
593 |
2
|
BlogEntry b1 = new BlogEntry(blog); |
594 |
2
|
b1.setDate(twoDaysAgo.getDate()); |
595 |
2
|
b1.setPublished(true); |
596 |
|
|
597 |
2
|
BlogEntry b2 = new BlogEntry(blog); |
598 |
2
|
b2.setDate(oneDayAgo.getDate()); |
599 |
2
|
b2.setPublished(true); |
600 |
|
|
601 |
2
|
BlogEntry b3 = new BlogEntry(blog); |
602 |
2
|
b3.setDate(today.getDate()); |
603 |
2
|
b3.setPublished(true); |
604 |
|
|
605 |
2
|
service.putBlogEntry(b1); |
606 |
2
|
service.putBlogEntry(b2); |
607 |
2
|
service.putBlogEntry(b3); |
608 |
|
|
609 |
2
|
assertNull(b3.getNextBlogEntry()); |
610 |
2
|
assertEquals(b3, b2.getNextBlogEntry()); |
611 |
2
|
assertEquals(b2, b1.getNextBlogEntry()); |
612 |
|
} |
613 |
|
|
614 |
|
|
615 |
|
|
616 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (19) |
Complexity: 1 |
Complexity Density: 0,05 |
1
PASS
|
|
617 |
2
|
public void testGetPreviousBlogEntry() throws Exception {... |
618 |
2
|
BlogService service = new BlogService(); |
619 |
2
|
Day today = blog.getBlogForToday(); |
620 |
2
|
Day oneDayAgo = today.getPreviousDay(); |
621 |
2
|
Day twoDaysAgo = today.getPreviousDay().getPreviousDay(); |
622 |
|
|
623 |
2
|
BlogEntry b1 = new BlogEntry(blog); |
624 |
2
|
b1.setDate(twoDaysAgo.getDate()); |
625 |
2
|
b1.setPublished(true); |
626 |
|
|
627 |
2
|
BlogEntry b2 = new BlogEntry(blog); |
628 |
2
|
b2.setDate(oneDayAgo.getDate()); |
629 |
2
|
b2.setPublished(true); |
630 |
|
|
631 |
2
|
BlogEntry b3 = new BlogEntry(blog); |
632 |
2
|
b3.setDate(today.getDate()); |
633 |
2
|
b3.setPublished(true); |
634 |
|
|
635 |
2
|
service.putBlogEntry(b1); |
636 |
2
|
service.putBlogEntry(b2); |
637 |
2
|
service.putBlogEntry(b3); |
638 |
|
|
639 |
2
|
assertNull(b1.getPreviousBlogEntry()); |
640 |
2
|
assertEquals(b1, b2.getPreviousBlogEntry()); |
641 |
2
|
assertEquals(b2, b3.getPreviousBlogEntry()); |
642 |
|
} |
643 |
|
|
644 |
|
|
645 |
|
|
646 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
647 |
2
|
public void testAttachment() {... |
648 |
2
|
Attachment a = new Attachment("url", 1024, "image/jpeg"); |
649 |
2
|
blogEntry.setAttachment(a); |
650 |
2
|
assertEquals(a, blogEntry.getAttachment()); |
651 |
|
|
652 |
2
|
BlogEntry clonedBlogEntry = (BlogEntry)blogEntry.clone(); |
653 |
2
|
assertEquals(a, clonedBlogEntry.getAttachment()); |
654 |
|
} |
655 |
|
|
656 |
|
|
657 |
|
|
658 |
|
|
659 |
|
|
660 |
|
|
661 |
|
|
662 |
|
|
663 |
|
|
664 |
|
|
665 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
666 |
2
|
public void testCommentListenersNotFiredFromClone() {... |
667 |
2
|
final Comment comment = blogEntry.createComment("title", "body", "author", "email", "website", "127.0.0.1"); |
668 |
2
|
blogEntry = (BlogEntry)blogEntry.clone(); |
669 |
2
|
blogEntry.addComment(comment); |
670 |
2
|
assertTrue(blogEntry.getEvents().isEmpty()); |
671 |
|
} |
672 |
|
|
673 |
|
|
674 |
|
|
675 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
676 |
2
|
public void testTrackBackListenersNotFiredFromClone() {... |
677 |
2
|
final TrackBack trackBack = blogEntry.createTrackBack("title", "excerpt", "url", "blogName", "127.0.0.1"); |
678 |
2
|
blogEntry = (BlogEntry)blogEntry.clone(); |
679 |
2
|
blogEntry.addTrackBack(trackBack); |
680 |
2
|
blogEntry.removeTrackBack(trackBack.getId()); |
681 |
2
|
assertTrue(blogEntry.getEvents().isEmpty()); |
682 |
|
} |
683 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (4) |
Complexity: 1 |
Complexity Density: 0,25 |
1
PASS
|
|
684 |
2
|
public void testPropertyChangedEventsNotFiredWhenEventsDisabled() {... |
685 |
2
|
assertFalse(blogEntry.isDirty()); |
686 |
2
|
blogEntry.setEventsEnabled(false); |
687 |
2
|
blogEntry.setBody("New body"); |
688 |
2
|
assertFalse(blogEntry.isDirty()); |
689 |
|
} |
690 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1
PASS
|
|
691 |
2
|
public void testPropertyChangedEventsFiredForBodyProperty() {... |
692 |
2
|
assertFalse(blogEntry.isDirty()); |
693 |
|
|
694 |
2
|
blogEntry.setBody(blogEntry.getBody()); |
695 |
2
|
assertFalse(blogEntry.isDirty()); |
696 |
|
|
697 |
2
|
blogEntry.setBody("New body"); |
698 |
2
|
assertTrue(blogEntry.isDirty()); |
699 |
2
|
PropertyChangeEvent event = (PropertyChangeEvent)blogEntry.getPropertyChangeEvents().get(0); |
700 |
2
|
assertEquals(blogEntry, event.getSource()); |
701 |
2
|
assertEquals(BlogEntry.BODY_PROPERTY, event.getPropertyName()); |
702 |
2
|
assertEquals("Some body", event.getOldValue()); |
703 |
2
|
assertEquals("New body", event.getNewValue()); |
704 |
|
} |
705 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1
PASS
|
|
706 |
2
|
public void testPropertyChangedEventsFiredForExcerptProperty() {... |
707 |
2
|
assertFalse(blogEntry.isDirty()); |
708 |
|
|
709 |
2
|
blogEntry.setExcerpt(blogEntry.getExcerpt()); |
710 |
2
|
assertFalse(blogEntry.isDirty()); |
711 |
|
|
712 |
2
|
blogEntry.setExcerpt("New excerpt"); |
713 |
2
|
assertTrue(blogEntry.isDirty()); |
714 |
2
|
PropertyChangeEvent event = (PropertyChangeEvent)blogEntry.getPropertyChangeEvents().get(0); |
715 |
2
|
assertEquals(blogEntry, event.getSource()); |
716 |
2
|
assertEquals(BlogEntry.EXCERPT_PROPERTY, event.getPropertyName()); |
717 |
2
|
assertEquals("Some excerpt", event.getOldValue()); |
718 |
2
|
assertEquals("New excerpt", event.getNewValue()); |
719 |
|
} |
720 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1
PASS
|
|
721 |
2
|
public void testPropertyChangedEventsFiredForTitleProperty() {... |
722 |
2
|
assertFalse(blogEntry.isDirty()); |
723 |
|
|
724 |
2
|
blogEntry.setTitle(blogEntry.getTitle()); |
725 |
2
|
assertFalse(blogEntry.isDirty()); |
726 |
|
|
727 |
2
|
blogEntry.setTitle("New title"); |
728 |
2
|
assertTrue(blogEntry.isDirty()); |
729 |
2
|
PropertyChangeEvent event = (PropertyChangeEvent)blogEntry.getPropertyChangeEvents().get(0); |
730 |
2
|
assertEquals(blogEntry, event.getSource()); |
731 |
2
|
assertEquals(BlogEntry.TITLE_PROPERTY, event.getPropertyName()); |
732 |
2
|
assertEquals("A title", event.getOldValue()); |
733 |
2
|
assertEquals("New title", event.getNewValue()); |
734 |
|
} |
735 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
736 |
2
|
public void testPropertyChangedEventsNotFiredForAuthorProperty() {... |
737 |
2
|
assertFalse(blogEntry.isDirty()); |
738 |
|
|
739 |
2
|
blogEntry.setAuthor(blogEntry.getAuthor()); |
740 |
2
|
assertFalse(blogEntry.isDirty()); |
741 |
|
|
742 |
2
|
blogEntry.setAuthor("New author"); |
743 |
2
|
assertFalse(blogEntry.isDirty()); |
744 |
|
|
745 |
|
|
746 |
|
|
747 |
|
|
748 |
|
|
749 |
|
} |
750 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (13) |
Complexity: 1 |
Complexity Density: 0,08 |
1
PASS
|
|
751 |
2
|
public void testPropertyChangedEventsFiredForOriginalPermalinkProperty() {... |
752 |
2
|
assertFalse(blogEntry.isDirty()); |
753 |
|
|
754 |
2
|
blogEntry.setOriginalPermalink(null); |
755 |
2
|
assertFalse(blogEntry.isDirty()); |
756 |
|
|
757 |
2
|
blogEntry.setOriginalPermalink("New permalink"); |
758 |
2
|
assertTrue(blogEntry.isDirty()); |
759 |
2
|
PropertyChangeEvent event = (PropertyChangeEvent)blogEntry.getPropertyChangeEvents().get(0); |
760 |
2
|
assertEquals(blogEntry, event.getSource()); |
761 |
2
|
assertEquals(BlogEntry.ORIGINAL_PERMALINK_PROPERTY, event.getPropertyName()); |
762 |
2
|
assertNull(event.getOldValue()); |
763 |
2
|
assertEquals("New permalink", event.getNewValue()); |
764 |
|
|
765 |
2
|
blogEntry.clearPropertyChangeEvents(); |
766 |
2
|
blogEntry.setOriginalPermalink(blogEntry.getOriginalPermalink()); |
767 |
2
|
assertFalse(blogEntry.isDirty()); |
768 |
|
} |
769 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (14) |
Complexity: 1 |
Complexity Density: 0,07 |
1
PASS
|
|
770 |
2
|
public void testPropertyChangedEventsFiredForAttachmentProperty() {... |
771 |
2
|
assertFalse(blogEntry.isDirty()); |
772 |
|
|
773 |
2
|
blogEntry.setAttachment(null); |
774 |
2
|
assertFalse(blogEntry.isDirty()); |
775 |
|
|
776 |
2
|
Attachment newAttachment = new Attachment("url", 1234, "image/jpeg"); |
777 |
2
|
blogEntry.setAttachment(newAttachment); |
778 |
2
|
assertTrue(blogEntry.isDirty()); |
779 |
2
|
PropertyChangeEvent event = (PropertyChangeEvent)blogEntry.getPropertyChangeEvents().get(0); |
780 |
2
|
assertEquals(blogEntry, event.getSource()); |
781 |
2
|
assertEquals(BlogEntry.ATTACHMENT_PROPERTY, event.getPropertyName()); |
782 |
2
|
assertNull(event.getOldValue()); |
783 |
2
|
assertEquals(newAttachment, event.getNewValue()); |
784 |
|
|
785 |
2
|
blogEntry.clearPropertyChangeEvents(); |
786 |
2
|
blogEntry.setAttachment(newAttachment); |
787 |
2
|
assertFalse(blogEntry.isDirty()); |
788 |
|
} |
789 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1
PASS
|
|
790 |
2
|
public void testPropertyChangedEventsFiredForCommentsEnabledProperty() {... |
791 |
2
|
assertFalse(blogEntry.isDirty()); |
792 |
|
|
793 |
2
|
blogEntry.setCommentsEnabled(true); |
794 |
2
|
assertFalse(blogEntry.isDirty()); |
795 |
|
|
796 |
2
|
blogEntry.setCommentsEnabled(false); |
797 |
2
|
assertTrue(blogEntry.isDirty()); |
798 |
2
|
PropertyChangeEvent event = (PropertyChangeEvent)blogEntry.getPropertyChangeEvents().get(0); |
799 |
2
|
assertEquals(blogEntry, event.getSource()); |
800 |
2
|
assertEquals(BlogEntry.COMMENTS_ENABLED_PROPERTY, event.getPropertyName()); |
801 |
2
|
assertEquals(Boolean.TRUE, event.getOldValue()); |
802 |
2
|
assertEquals(Boolean.FALSE, event.getNewValue()); |
803 |
|
} |
804 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1
PASS
|
|
805 |
2
|
public void testPropertyChangedEventsFiredForTrackBacksEnabledProperty() {... |
806 |
2
|
assertFalse(blogEntry.isDirty()); |
807 |
|
|
808 |
2
|
blogEntry.setTrackBacksEnabled(true); |
809 |
2
|
assertFalse(blogEntry.isDirty()); |
810 |
|
|
811 |
2
|
blogEntry.setTrackBacksEnabled(false); |
812 |
2
|
assertTrue(blogEntry.isDirty()); |
813 |
2
|
PropertyChangeEvent event = (PropertyChangeEvent)blogEntry.getPropertyChangeEvents().get(0); |
814 |
2
|
assertEquals(blogEntry, event.getSource()); |
815 |
2
|
assertEquals(BlogEntry.TRACKBACKS_ENABLED_PROPERTY, event.getPropertyName()); |
816 |
2
|
assertEquals(Boolean.TRUE, event.getOldValue()); |
817 |
2
|
assertEquals(Boolean.FALSE, event.getNewValue()); |
818 |
|
} |
819 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (47) |
Complexity: 1 |
Complexity Density: 0,02 |
1
PASS
|
|
820 |
2
|
public void testPropertyChangedEventsFiredForCategoriesProperty() {... |
821 |
2
|
assertFalse(blogEntry.isDirty()); |
822 |
|
|
823 |
2
|
blogEntry.removeAllCategories(); |
824 |
2
|
assertFalse(blogEntry.isDirty()); |
825 |
|
|
826 |
2
|
Category c1 = new Category("/c1", "Category 1"); |
827 |
2
|
blog.addCategory(c1); |
828 |
2
|
Category c2 = new Category("/c2", "Category 2"); |
829 |
2
|
blog.addCategory(c1); |
830 |
2
|
blogEntry.addCategory(c1); |
831 |
2
|
assertTrue(blogEntry.isDirty()); |
832 |
2
|
PropertyChangeEvent event = (PropertyChangeEvent)blogEntry.getPropertyChangeEvents().get(0); |
833 |
2
|
assertEquals(blogEntry, event.getSource()); |
834 |
2
|
assertEquals(BlogEntry.CATEGORIES_PROPERTY, event.getPropertyName()); |
835 |
2
|
assertTrue(((Set)event.getOldValue()).isEmpty()); |
836 |
2
|
assertTrue(((Set)event.getNewValue()).contains(c1)); |
837 |
|
|
838 |
2
|
blogEntry.clearPropertyChangeEvents(); |
839 |
2
|
blogEntry.addCategory(c2); |
840 |
2
|
assertTrue(blogEntry.isDirty()); |
841 |
2
|
event = (PropertyChangeEvent)blogEntry.getPropertyChangeEvents().get(0); |
842 |
2
|
assertEquals(blogEntry, event.getSource()); |
843 |
2
|
assertEquals(BlogEntry.CATEGORIES_PROPERTY, event.getPropertyName()); |
844 |
2
|
assertTrue(((Set)event.getOldValue()).contains(c1)); |
845 |
2
|
assertTrue(((Set)event.getNewValue()).contains(c1)); |
846 |
2
|
assertTrue(((Set)event.getNewValue()).contains(c2)); |
847 |
|
|
848 |
2
|
blogEntry.removeAllCategories(); |
849 |
2
|
blogEntry.clearPropertyChangeEvents(); |
850 |
2
|
Set categories = new HashSet(); |
851 |
2
|
categories.add(c1); |
852 |
2
|
categories.add(c2); |
853 |
2
|
blogEntry.setCategories(categories); |
854 |
2
|
assertTrue(blogEntry.isDirty()); |
855 |
2
|
event = (PropertyChangeEvent)blogEntry.getPropertyChangeEvents().get(0); |
856 |
2
|
assertEquals(blogEntry, event.getSource()); |
857 |
2
|
assertEquals(BlogEntry.CATEGORIES_PROPERTY, event.getPropertyName()); |
858 |
2
|
assertTrue(((Set)event.getOldValue()).isEmpty()); |
859 |
2
|
assertTrue(((Set)event.getNewValue()).contains(c1)); |
860 |
2
|
assertTrue(((Set)event.getNewValue()).contains(c2)); |
861 |
|
|
862 |
2
|
blogEntry.clearPropertyChangeEvents(); |
863 |
2
|
categories = new HashSet(); |
864 |
2
|
categories.add(c2); |
865 |
2
|
blogEntry.setCategories(categories); |
866 |
2
|
assertTrue(blogEntry.isDirty()); |
867 |
2
|
event = (PropertyChangeEvent)blogEntry.getPropertyChangeEvents().get(0); |
868 |
2
|
assertEquals(blogEntry, event.getSource()); |
869 |
2
|
assertEquals(BlogEntry.CATEGORIES_PROPERTY, event.getPropertyName()); |
870 |
2
|
assertTrue(((Set)event.getOldValue()).contains(c1)); |
871 |
2
|
assertTrue(((Set)event.getOldValue()).contains(c2)); |
872 |
2
|
assertTrue(((Set)event.getNewValue()).contains(c2)); |
873 |
|
} |
874 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (10) |
Complexity: 1 |
Complexity Density: 0,1 |
1
PASS
|
|
875 |
2
|
public void testPropertyChangedEventsFiredForTagsProperty() {... |
876 |
2
|
assertFalse(blogEntry.isDirty()); |
877 |
|
|
878 |
2
|
blogEntry.setTags(blogEntry.getTags()); |
879 |
2
|
assertFalse(blogEntry.isDirty()); |
880 |
|
|
881 |
2
|
blogEntry.setTags("some tags"); |
882 |
2
|
assertTrue(blogEntry.isDirty()); |
883 |
2
|
PropertyChangeEvent event = (PropertyChangeEvent)blogEntry.getPropertyChangeEvents().get(0); |
884 |
2
|
assertEquals(blogEntry, event.getSource()); |
885 |
2
|
assertEquals(BlogEntry.TAGS_PROPERTY, event.getPropertyName()); |
886 |
2
|
assertEquals("", event.getOldValue()); |
887 |
2
|
assertEquals("some tags", event.getNewValue()); |
888 |
|
} |
889 |
|
|
890 |
|
|
891 |
|
|
892 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (21) |
Complexity: 1 |
Complexity Density: 0,05 |
1
PASS
|
|
893 |
2
|
public void testGetAllTags() {... |
894 |
2
|
CategoryBuilder builder = new CategoryBuilder(blog); |
895 |
2
|
Category apple = new Category("/apple", "Apple"); |
896 |
2
|
Category java = new Category("/java", "Java"); |
897 |
2
|
Category junit = new Category("/java/junit", "JUnit"); |
898 |
2
|
builder.getRootCategory().setTags("myblog"); |
899 |
2
|
builder.addCategory(apple); |
900 |
2
|
apple.setTags("apple"); |
901 |
2
|
builder.addCategory(java); |
902 |
2
|
java.setTags("java"); |
903 |
2
|
builder.addCategory(junit); |
904 |
2
|
junit.setTags("junit automated+testing"); |
905 |
|
|
906 |
2
|
blogEntry.addCategory(apple); |
907 |
2
|
blogEntry.addCategory(junit); |
908 |
2
|
blogEntry.setTags("entry+specific+tag"); |
909 |
|
|
910 |
2
|
List tags = blogEntry.getAllTags(); |
911 |
2
|
assertTrue(tags.contains(blog.getTag("entry+specific+tag"))); |
912 |
2
|
assertTrue(tags.contains(blog.getTag("junit"))); |
913 |
2
|
assertTrue(tags.contains(blog.getTag("automated+testing"))); |
914 |
2
|
assertTrue(tags.contains(blog.getTag("java"))); |
915 |
2
|
assertTrue(tags.contains(blog.getTag("apple"))); |
916 |
2
|
assertTrue(tags.contains(blog.getTag("myblog"))); |
917 |
|
} |
918 |
|
|
919 |
|
|
920 |
|
|
921 |
|
|
922 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
923 |
2
|
public void testGetAllTagsWhenNotAssociatedWithACategory() {... |
924 |
2
|
CategoryBuilder builder = new CategoryBuilder(blog); |
925 |
2
|
builder.getRootCategory().setTags("myblog"); |
926 |
2
|
blog.setRootCategory(builder.getRootCategory()); |
927 |
|
|
928 |
2
|
List tags = blogEntry.getAllTags(); |
929 |
2
|
assertEquals(blog.getTag("myblog"), tags.get(0)); |
930 |
|
} |
931 |
|
|
932 |
|
|
933 |
|
|
934 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (20) |
Complexity: 1 |
Complexity Density: 0,05 |
1
PASS
|
|
935 |
2
|
public void testHasTag() {... |
936 |
2
|
CategoryBuilder builder = new CategoryBuilder(blog); |
937 |
2
|
Category apple = new Category("/apple", "Apple"); |
938 |
2
|
Category java = new Category("/java", "Java"); |
939 |
2
|
Category junit = new Category("/java/junit", "JUnit"); |
940 |
2
|
builder.getRootCategory().setTags("myblog"); |
941 |
2
|
builder.addCategory(apple); |
942 |
2
|
apple.setTags("apple"); |
943 |
2
|
builder.addCategory(java); |
944 |
2
|
java.setTags("java"); |
945 |
2
|
builder.addCategory(junit); |
946 |
2
|
junit.setTags("junit automated+testing"); |
947 |
|
|
948 |
2
|
assertFalse(blogEntry.hasTag(null)); |
949 |
2
|
assertFalse(blogEntry.hasTag("")); |
950 |
2
|
assertFalse(blogEntry.hasTag("java")); |
951 |
|
|
952 |
2
|
blogEntry.setTags("entryspecifictag"); |
953 |
2
|
assertTrue(blogEntry.hasTag("entryspecifictag")); |
954 |
|
|
955 |
2
|
blogEntry.addCategory(apple); |
956 |
2
|
assertTrue(blogEntry.hasTag("apple")); |
957 |
2
|
blogEntry.addCategory(junit); |
958 |
2
|
assertTrue(blogEntry.hasTag("junit")); |
959 |
|
} |
960 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (9) |
Complexity: 1 |
Complexity Density: 0,11 |
1
PASS
|
|
961 |
2
|
public void testLastModifiedDate() {... |
962 |
2
|
blogEntry.setDate(new Date(100)); |
963 |
2
|
blogEntry.addComment(blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1", new Date(123), State.APPROVED)); |
964 |
2
|
blogEntry.addComment(blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1", new Date(456), State.APPROVED)); |
965 |
2
|
blogEntry.addComment(blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1", new Date(789), State.APPROVED)); |
966 |
|
|
967 |
2
|
assertEquals(new Date(789), blogEntry.getLastModified()); |
968 |
|
|
969 |
2
|
blogEntry.addTrackBack(blogEntry.createTrackBack("Title", "Excerpt", "http://www.somedomain.com", "Some blog", "127.0.0.1", new Date(123), State.APPROVED)); |
970 |
2
|
blogEntry.addTrackBack(blogEntry.createTrackBack("Title", "Excerpt", "http://www.somedomain.com", "Some blog", "127.0.0.1", new Date(543), State.APPROVED)); |
971 |
2
|
blogEntry.addTrackBack(blogEntry.createTrackBack("Title", "Excerpt", "http://www.somedomain.com", "Some blog", "127.0.0.1", new Date(987), State.APPROVED)); |
972 |
|
|
973 |
2
|
assertEquals(new Date(987), blogEntry.getLastModified()); |
974 |
|
} |
975 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
976 |
2
|
public void testRemoveCommentViaRemoveResponse() {... |
977 |
2
|
Comment comment = blogEntry.createComment("", "Body", "Author", "me@somedomain.com", "http://www.google.com", "127.0.0.1", new Date(123), State.APPROVED); |
978 |
2
|
blogEntry.addComment(comment); |
979 |
2
|
assertEquals(1, blogEntry.getNumberOfComments()); |
980 |
2
|
blogEntry.removeResponse(comment); |
981 |
2
|
assertEquals(0, blogEntry.getNumberOfComments()); |
982 |
|
} |
983 |
|
|
|
|
| 100% |
Uncovered Elements: 0 (5) |
Complexity: 1 |
Complexity Density: 0,2 |
1
PASS
|
|
984 |
2
|
public void testRemoveTrackBackViaRemoveResponse() {... |
985 |
2
|
TrackBack trackBack = blogEntry.createTrackBack("Title", "Excerpt", "http://www.somedomain.com", "Some blog", "127.0.0.1", new Date(123), State.APPROVED); |
986 |
2
|
blogEntry.addTrackBack(trackBack); |
987 |
2
|
assertEquals(1, blogEntry.getNumberOfTrackBacks()); |
988 |
2
|
blogEntry.removeResponse(trackBack); |
989 |
2
|
assertEquals(0, blogEntry.getNumberOfTrackBacks()); |
990 |
|
} |
991 |
|
|
992 |
|
} |