Skip to content

Commit 8fb6684

Browse files
working on #204
1 parent ed03cb2 commit 8fb6684

File tree

6 files changed

+120
-2
lines changed

6 files changed

+120
-2
lines changed

src/test/java/org/woehlke/twitterwall/oodm/service/MediaServiceTest.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,4 +56,15 @@ public void fetchTestData() throws Exception {
5656
}
5757
}
5858

59+
@Commit
60+
@Test
61+
public void findByIdTwitter() throws Exception {
62+
63+
}
64+
65+
@Commit
66+
@Test
67+
public void findByUrl() throws Exception {
68+
69+
}
5970
}

src/test/java/org/woehlke/twitterwall/oodm/service/MentionServiceTest.java

Lines changed: 81 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33

44
import org.junit.Assert;
5+
import org.junit.Ignore;
56
import org.junit.Test;
67
import org.junit.runner.RunWith;
78
import org.slf4j.Logger;
@@ -16,8 +17,11 @@
1617
import org.springframework.transaction.annotation.Propagation;
1718
import org.springframework.transaction.annotation.Transactional;
1819
import org.woehlke.twitterwall.conf.properties.TestdataProperties;
19-
import org.woehlke.twitterwall.oodm.entities.Media;
2020
import org.woehlke.twitterwall.oodm.entities.Mention;
21+
import org.woehlke.twitterwall.oodm.entities.Task;
22+
import org.woehlke.twitterwall.oodm.entities.parts.CountedEntities;
23+
import org.woehlke.twitterwall.oodm.entities.parts.TaskType;
24+
import org.woehlke.twitterwall.scheduled.service.persist.CountedEntitiesService;
2125

2226
@RunWith(SpringRunner.class)
2327
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@@ -29,6 +33,12 @@ public class MentionServiceTest {
2933
@Autowired
3034
private MentionService mentionService;
3135

36+
@Autowired
37+
private TaskService taskService;
38+
39+
@Autowired
40+
private CountedEntitiesService countedEntitiesService;
41+
3242
//TODO: #198 https://github.com/phasenraum2010/twitterwall2/issues/198
3343
@Autowired
3444
private TestdataProperties testdataProperties;
@@ -38,6 +48,7 @@ public class MentionServiceTest {
3848
public void areDependenciesLoaded() throws Exception {
3949
Assert.assertNotNull(mentionService);
4050
Assert.assertNotNull(testdataProperties);
51+
Assert.assertNotNull(countedEntitiesService);
4152
}
4253

4354
@Commit
@@ -48,6 +59,7 @@ public void fetchTestData() throws Exception {
4859
int size=1;
4960
Pageable pageRequest = new PageRequest(page,size);
5061
Page<Mention> myPage = mentionService.getAll(pageRequest);
62+
Assert.assertTrue(msg,myPage.getTotalElements()>0);
5163
if(myPage.getTotalElements()>0){
5264
Mention myMedia = myPage.getContent().iterator().next();
5365
Assert.assertNotNull(msg,myMedia);
@@ -58,9 +70,77 @@ public void fetchTestData() throws Exception {
5870
}
5971
}
6072

73+
@Commit
6174
@Test
6275
public void createProxyMention() throws Exception {
76+
String msg = "createProxyMention: ";
77+
CountedEntities countedEntities = countedEntitiesService.countAll();
78+
TaskType type = TaskType.FETCH_TWEETS_FROM_TWITTER_SEARCH;
79+
Task task = taskService.create("MentionServiceTest."+msg,type,countedEntities);
80+
String mentionString = "ddhgcvdghvsdhg";
81+
Mention mention = new Mention(task,task, mentionString);
82+
Mention createdMention = mentionService.createProxyMention(mention,task);
83+
Assert.assertEquals(mentionString,createdMention.getScreenName());
84+
Assert.assertTrue(createdMention.isProxy());
85+
}
6386

87+
@Commit
88+
@Test
89+
public void getAllWithoutPersistentUser() throws Exception {
90+
String msg = "getAllWithoutPersistentUser: ";
91+
int page=1;
92+
int size=10;
93+
Pageable pageRequest = new PageRequest(page,size);
94+
Page<Mention> pageMention = mentionService.getAllWithoutPersistentUser(pageRequest);
95+
Assert.assertTrue(msg,pageMention.getTotalElements()>0);
96+
if(pageMention.getTotalElements()>0){
97+
for(Mention mention: pageMention.getContent()){
98+
Assert.assertFalse(msg,mention.hasPersistentUser());
99+
Assert.assertNotNull(msg,mention.getIdTwitterOfUser());
100+
}
101+
} else {
102+
log.debug(msg+" found: mentionService.getAllWithoutPersistentUser() == 0");
103+
}
64104
}
65105

106+
//TODO: #215 https://github.com/phasenraum2010/twitterwall2/issues/215
107+
@Ignore
108+
@Commit
109+
@Test
110+
public void findByIdTwitter() throws Exception {
111+
String msg = "findByIdTwitter: ";
112+
int page=1;
113+
int size=1;
114+
Pageable pageRequest = new PageRequest(page,size);
115+
Page<Mention> myPage = mentionService.getAll(pageRequest);
116+
Assert.assertTrue(msg,myPage.getTotalElements()>0);
117+
if(myPage.getTotalElements()>0) {
118+
Mention myMention = myPage.getContent().iterator().next();
119+
long idTwitter = myMention.getIdTwitter();
120+
Mention myFoundMention = mentionService.findByIdTwitter(idTwitter);
121+
Assert.assertNotNull(myFoundMention);
122+
Assert.assertEquals(msg,idTwitter,myFoundMention.getIdTwitter().longValue());
123+
}
124+
}
125+
126+
//TODO: #215 https://github.com/phasenraum2010/twitterwall2/issues/215
127+
@Ignore
128+
@Commit
129+
@Test
130+
public void findByScreenName() throws Exception {
131+
String msg = "findByScreenName: ";
132+
int page=1;
133+
int size=1;
134+
Pageable pageRequest = new PageRequest(page,size);
135+
Page<Mention> myPage = mentionService.getAll(pageRequest);
136+
Assert.assertTrue(msg,myPage.getTotalElements()>0);
137+
if(myPage.getTotalElements()>0) {
138+
Mention myMention = myPage.getContent().iterator().next();
139+
String expectedScreenName = myMention.getScreenName();
140+
Mention myFoundMention = mentionService.findByScreenName(expectedScreenName);
141+
Assert.assertNotNull(myFoundMention);
142+
String foundScreenName =myFoundMention.getScreenName();
143+
Assert.assertEquals(msg,expectedScreenName,foundScreenName);
144+
}
145+
}
66146
}

src/test/java/org/woehlke/twitterwall/oodm/service/TickerSymbolServiceTest.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
import org.springframework.transaction.annotation.Propagation;
1717
import org.springframework.transaction.annotation.Transactional;
1818
import org.woehlke.twitterwall.conf.properties.TestdataProperties;
19-
import org.woehlke.twitterwall.oodm.entities.Task;
2019
import org.woehlke.twitterwall.oodm.entities.TickerSymbol;
2120

2221
@RunWith(SpringRunner.class)
@@ -58,4 +57,10 @@ public void fetchTestData() throws Exception {
5857
}
5958
}
6059

60+
@Commit
61+
@Test
62+
public void findByUrl() throws Exception {
63+
64+
}
65+
6166
}

src/test/java/org/woehlke/twitterwall/oodm/service/TweetServiceTest.java

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,37 +57,49 @@ public void fetchTestData() throws Exception {
5757
}
5858
}
5959

60+
@Commit
61+
@Test
62+
public void findByIdTwitter() throws Exception {
63+
64+
}
6065

66+
@Commit
6167
@Test
6268
public void findTweetsForHashTag() throws Exception {
6369

6470
}
6571

72+
@Commit
6673
@Test
6774
public void findTweetsForUser() throws Exception {
6875

6976
}
7077

78+
@Commit
7179
@Test
7280
public void findAllTweet2HashTag() throws Exception {
7381

7482
}
7583

84+
@Commit
7685
@Test
7786
public void findAllTweet2Media() throws Exception {
7887

7988
}
8089

90+
@Commit
8191
@Test
8292
public void findAllTweet2Mention() throws Exception {
8393

8494
}
8595

96+
@Commit
8697
@Test
8798
public void findAllTweet2Url() throws Exception {
8899

89100
}
90101

102+
@Commit
91103
@Test
92104
public void findAllTweet2TickerSymbol() throws Exception {
93105

src/test/java/org/woehlke/twitterwall/oodm/service/UrlCacheServiceTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,10 @@ public void fetchTestData() throws Exception {
5757
}
5858
}
5959

60+
@Commit
61+
@Test
62+
public void findByUrl() throws Exception {
6063

64+
}
6165

6266
}

src/test/java/org/woehlke/twitterwall/oodm/service/UrlServiceTest.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,4 +57,10 @@ public void fetchTestData() throws Exception {
5757
}
5858
}
5959

60+
@Commit
61+
@Test
62+
public void findByUrl() throws Exception {
63+
64+
}
65+
6066
}

0 commit comments

Comments
 (0)