1
1
package org .jbake .app ;
2
2
3
- import static org .assertj .core .api .Assertions .assertThat ;
4
-
5
3
import java .io .File ;
6
4
import java .io .IOException ;
7
5
import java .net .URISyntaxException ;
10
8
import java .util .List ;
11
9
import java .util .Map ;
12
10
11
+ import com .orientechnologies .orient .core .record .impl .ODocument ;
12
+
13
13
import org .apache .commons .configuration .CompositeConfiguration ;
14
14
import org .apache .commons .configuration .ConfigurationException ;
15
+
16
+ import org .jbake .app .ConfigUtil .Keys ;
17
+
15
18
import org .apache .commons .configuration .MapConfiguration ;
16
19
import org .apache .commons .io .FilenameUtils ;
17
20
import org .hamcrest .BaseMatcher ;
18
21
import org .hamcrest .Description ;
19
- import org .jbake .app .ConfigUtil .Keys ;
20
22
import org .junit .After ;
21
23
import org .junit .Assert ;
22
24
import org .junit .Before ;
23
25
import org .junit .Test ;
24
26
25
- import com . orientechnologies . orient . core .record . impl . ODocument ;
27
+ import static org . assertj . core .api . Assertions .* ;
26
28
27
29
public class CrawlerTest {
28
30
private CompositeConfiguration config ;
29
31
private ContentStore db ;
30
32
private File sourceFolder ;
31
-
33
+
32
34
@ Before
33
35
public void setup () throws Exception , IOException , URISyntaxException {
34
36
URL sourceUrl = this .getClass ().getResource ("/" );
@@ -37,7 +39,7 @@ public void setup() throws Exception, IOException, URISyntaxException {
37
39
if (!sourceFolder .exists ()) {
38
40
throw new Exception ("Cannot find sample data structure!" );
39
41
}
40
-
42
+
41
43
config = ConfigUtil .load (new File (this .getClass ().getResource ("/" ).getFile ()));
42
44
Assert .assertEquals (".html" , config .getString (Keys .OUTPUT_EXTENSION ));
43
45
db = DBUtil .createDataStore ("memory" , "documents" +System .currentTimeMillis ());
@@ -66,6 +68,14 @@ public void crawl() throws ConfigurationException {
66
68
.containsValue ("../../" );
67
69
}
68
70
71
+ List <ODocument > draftPosts = db .getAllContent ("post" );
72
+ DocumentList draftList = DocumentList .wrap (draftPosts .iterator ());
73
+ for (Map <String ,Object > content : list ) {
74
+ if (content .get (Crawler .Attributes .TITLE ).equals ("Draft Post" )) {
75
+ assertThat (content ).containsKey (Crawler .Attributes .DATE );
76
+ }
77
+ }
78
+
69
79
// covers bug #213
70
80
List <ODocument > publishedPostsByTag = db .getPublishedPostsByTag ("blog" );
71
81
Assert .assertEquals (2 , publishedPostsByTag .size ());
0 commit comments