Skip to content

Commit 9a85dea

Browse files
working on #204
1 parent 397108a commit 9a85dea

File tree

7 files changed

+356
-40
lines changed

7 files changed

+356
-40
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -88,8 +88,8 @@ public void findByUrl() throws Exception {
8888
Media myMedia = myPage.getContent().iterator().next();
8989
String expectedUrl = myMedia.getUrl();
9090
Media myFoundMedia = mediaService.findByUrl(expectedUrl);
91-
String foundUrl = myMedia.getUrl();
92-
Assert.assertEquals(msg, expectedUrl, myFoundMedia);
91+
String foundUrl = myFoundMedia.getUrl();
92+
Assert.assertEquals(msg, expectedUrl, foundUrl);
9393
log.debug(msg+" found: "+foundUrl);
9494
} else {
9595
log.debug(msg+" found: myPage.getTotalElements() == 0");

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

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

2120
@RunWith(SpringRunner.class)
2221
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)

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

Lines changed: 2 additions & 3 deletions
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.Media;
2019
import org.woehlke.twitterwall.oodm.entities.TickerSymbol;
2120

2221
@RunWith(SpringRunner.class)
@@ -70,8 +69,8 @@ public void findByUrl() throws Exception {
7069
TickerSymbol myMedia = myPage.getContent().iterator().next();
7170
String expectedUrl = myMedia.getUrl();
7271
TickerSymbol myFoundMedia = tickerSymbolService.findByUrl(expectedUrl);
73-
String foundUrl = myMedia.getUrl();
74-
Assert.assertEquals(msg, expectedUrl, myFoundMedia);
72+
String foundUrl = myFoundMedia.getUrl();
73+
Assert.assertEquals(msg, expectedUrl, foundUrl);
7574
log.debug(msg+" found: "+foundUrl);
7675
} else {
7776
log.debug(msg+" found: myPage.getTotalElements() == 0");

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

Lines changed: 142 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package org.woehlke.twitterwall.oodm.service;
22

33
import org.junit.Assert;
4+
import org.junit.Ignore;
45
import org.junit.Test;
56
import org.junit.runner.RunWith;
67
import org.slf4j.Logger;
@@ -15,9 +16,8 @@
1516
import org.springframework.transaction.annotation.Propagation;
1617
import org.springframework.transaction.annotation.Transactional;
1718
import org.woehlke.twitterwall.conf.properties.TestdataProperties;
18-
import org.woehlke.twitterwall.oodm.entities.Media;
19-
import org.woehlke.twitterwall.oodm.entities.TickerSymbol;
20-
import org.woehlke.twitterwall.oodm.entities.Tweet;
19+
import org.woehlke.twitterwall.oodm.entities.*;
20+
import org.woehlke.twitterwall.oodm.entities.transients.Object2Entity;
2121

2222
@RunWith(SpringRunner.class)
2323
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@@ -29,6 +29,24 @@ public class TweetServiceTest {
2929
@Autowired
3030
private TweetService tweetService;
3131

32+
@Autowired
33+
private HashTagService hashTagService;
34+
35+
@Autowired
36+
private MediaService mediaService;
37+
38+
@Autowired
39+
private MentionService mentionService;
40+
41+
@Autowired
42+
private UrlService urlService;
43+
44+
@Autowired
45+
private TickerSymbolService tickerSymbolService;
46+
47+
@Autowired
48+
private UserService userService;
49+
3250
//TODO: #198 https://github.com/phasenraum2010/twitterwall2/issues/198
3351
@Autowired
3452
private TestdataProperties testdataProperties;
@@ -74,50 +92,163 @@ public void findByIdTwitter() throws Exception {
7492
Assert.assertEquals(msg, expectedIdTwitter,foundIdTwitter);
7593
log.debug(msg+" found: "+myMedia.getUniqueId());
7694
} else {
77-
log.debug(msg+" found: myPage.getTotalElements() == 0");
95+
log.error(msg+" found: myPage.getTotalElements() == 0");
7896
}
7997
}
8098

99+
100+
//TODO: #160 https://github.com/phasenraum2010/twitterwall2/issues/160
81101
@Commit
82102
@Test
83103
public void findTweetsForHashTag() throws Exception {
84-
104+
String msg = "findTweetsForHashTag: ";
105+
log.debug(msg);
85106
}
86107

108+
//TODO: #216 https://github.com/phasenraum2010/twitterwall2/issues/216
109+
@Ignore
87110
@Commit
88111
@Test
89112
public void findTweetsForUser() throws Exception {
90-
113+
String msg = "findTweetsForUser: ";
114+
int page=1;
115+
int size=10;
116+
Pageable pageRequest = new PageRequest(page,size);
117+
Page<User> foundTweetingUsers = userService.getTweetingUsers(pageRequest);
118+
for(User user : foundTweetingUsers.getContent()){
119+
Page<Tweet> foundTweets = tweetService.findTweetsForUser(user,pageRequest);
120+
Assert.assertTrue(foundTweets.getTotalElements()>0);
121+
for(Tweet tweet : foundTweets.getContent()) {
122+
Assert.assertNotNull(tweet.getUser());
123+
Assert.assertEquals(tweet.getUser().getUniqueId(), user.getUniqueId());
124+
}
125+
}
126+
log.debug(msg);
91127
}
92128

93129
@Commit
94130
@Test
95131
public void findAllTweet2HashTag() throws Exception {
96-
132+
String msg = "findAllTweet2HashTag: ";
133+
int page=1;
134+
int size=10;
135+
Pageable pageRequest = new PageRequest(page,size);
136+
Page<Object2Entity> foundPage = tweetService.findAllTweet2HashTag(pageRequest);
137+
if(foundPage.getTotalElements()>0){
138+
for(Object2Entity object2Entity:foundPage.getContent()){
139+
long objectId = object2Entity.getObjectId();
140+
String objectInfo = object2Entity.getObjectInfo();
141+
long entityId = object2Entity.getEntityId();
142+
String entityInfo = object2Entity.getObjectInfo();
143+
Tweet foundObject = tweetService.findById(objectId);
144+
HashTag foundEntity = hashTagService.findById(entityId);
145+
Assert.assertNotNull(msg,foundObject);
146+
Assert.assertNotNull(msg,foundEntity);
147+
Assert.assertNull(objectInfo);
148+
Assert.assertNull(entityInfo);
149+
Assert.assertTrue(msg,foundObject.getEntities().getHashTags().contains(foundEntity));
150+
}
151+
}
97152
}
98153

99154
@Commit
100155
@Test
101156
public void findAllTweet2Media() throws Exception {
102-
157+
String msg = "findAllTweet2Media: ";
158+
int page=1;
159+
int size=10;
160+
Pageable pageRequest = new PageRequest(page,size);
161+
Page<Object2Entity> foundPage = tweetService.findAllTweet2Media(pageRequest);
162+
if(foundPage.getTotalElements()>0){
163+
for(Object2Entity object2Entity:foundPage.getContent()){
164+
long objectId = object2Entity.getObjectId();
165+
String objectInfo = object2Entity.getObjectInfo();
166+
long entityId = object2Entity.getEntityId();
167+
String entityInfo = object2Entity.getObjectInfo();
168+
Tweet foundObject = tweetService.findById(objectId);
169+
Media foundEntity = mediaService.findById(entityId);
170+
Assert.assertNotNull(msg,foundObject);
171+
Assert.assertNotNull(msg,foundEntity);
172+
Assert.assertNull(objectInfo);
173+
Assert.assertNull(entityInfo);
174+
Assert.assertTrue(msg,foundObject.getEntities().getMedia().contains(foundEntity));
175+
}
176+
}
103177
}
104178

105179
@Commit
106180
@Test
107181
public void findAllTweet2Mention() throws Exception {
108-
182+
String msg = "findAllTweet2Mention: ";
183+
int page=1;
184+
int size=10;
185+
Pageable pageRequest = new PageRequest(page,size);
186+
Page<Object2Entity> foundPage = tweetService.findAllTweet2Mention(pageRequest);
187+
if(foundPage.getTotalElements()>0){
188+
for(Object2Entity object2Entity:foundPage.getContent()){
189+
long objectId = object2Entity.getObjectId();
190+
String objectInfo = object2Entity.getObjectInfo();
191+
long entityId = object2Entity.getEntityId();
192+
String entityInfo = object2Entity.getObjectInfo();
193+
Tweet foundObject = tweetService.findById(objectId);
194+
Mention foundEntity = mentionService.findById(entityId);
195+
Assert.assertNotNull(msg,foundObject);
196+
Assert.assertNotNull(msg,foundEntity);
197+
Assert.assertNull(objectInfo);
198+
Assert.assertNull(entityInfo);
199+
Assert.assertTrue(msg,foundObject.getEntities().getMentions().contains(foundEntity));
200+
}
201+
}
109202
}
110203

111204
@Commit
112205
@Test
113206
public void findAllTweet2Url() throws Exception {
114-
207+
String msg = "findAllTweet2Url: ";
208+
int page=1;
209+
int size=10;
210+
Pageable pageRequest = new PageRequest(page,size);
211+
Page<Object2Entity> foundPage = tweetService.findAllTweet2Url(pageRequest);
212+
if(foundPage.getTotalElements()>0){
213+
for(Object2Entity object2Entity:foundPage.getContent()){
214+
long objectId = object2Entity.getObjectId();
215+
String objectInfo = object2Entity.getObjectInfo();
216+
long entityId = object2Entity.getEntityId();
217+
String entityInfo = object2Entity.getObjectInfo();
218+
Tweet foundObject = tweetService.findById(objectId);
219+
Url foundEntity = urlService.findById(entityId);
220+
Assert.assertNotNull(msg,foundObject);
221+
Assert.assertNotNull(msg,foundEntity);
222+
Assert.assertNull(objectInfo);
223+
Assert.assertNull(entityInfo);
224+
Assert.assertTrue(msg,foundObject.getEntities().getUrls().contains(foundEntity));
225+
}
226+
}
115227
}
116228

117229
@Commit
118230
@Test
119231
public void findAllTweet2TickerSymbol() throws Exception {
120-
232+
String msg = "findAllTweet2TickerSymbol: ";
233+
int page=1;
234+
int size=10;
235+
Pageable pageRequest = new PageRequest(page,size);
236+
Page<Object2Entity> foundPage = tweetService.findAllTweet2TickerSymbol(pageRequest);
237+
if(foundPage.getTotalElements()>0){
238+
for(Object2Entity object2Entity:foundPage.getContent()){
239+
long objectId = object2Entity.getObjectId();
240+
String objectInfo = object2Entity.getObjectInfo();
241+
long entityId = object2Entity.getEntityId();
242+
String entityInfo = object2Entity.getObjectInfo();
243+
Tweet foundObject = tweetService.findById(objectId);
244+
TickerSymbol foundEntity = tickerSymbolService.findById(entityId);
245+
Assert.assertNotNull(msg,foundObject);
246+
Assert.assertNotNull(msg,foundEntity);
247+
Assert.assertNull(objectInfo);
248+
Assert.assertNull(entityInfo);
249+
Assert.assertTrue(msg,foundObject.getEntities().getTickerSymbols().contains(foundEntity));
250+
}
251+
}
121252
}
122253

123254
}

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@
1515
import org.springframework.transaction.annotation.Propagation;
1616
import org.springframework.transaction.annotation.Transactional;
1717
import org.woehlke.twitterwall.conf.properties.TestdataProperties;
18-
import org.woehlke.twitterwall.oodm.entities.Media;
19-
import org.woehlke.twitterwall.oodm.entities.Tweet;
2018
import org.woehlke.twitterwall.oodm.entities.UrlCache;
2119

2220
@RunWith(SpringRunner.class)
@@ -70,8 +68,8 @@ public void findByUrl() throws Exception {
7068
UrlCache myMedia = myPage.getContent().iterator().next();
7169
String expectedUrl = myMedia.getUrl();
7270
UrlCache myFoundMedia = urlCacheService.findByUrl(expectedUrl);
73-
String foundUrl = myMedia.getUrl();
74-
Assert.assertEquals(msg, expectedUrl, myFoundMedia);
71+
String foundUrl = myFoundMedia.getUrl();
72+
Assert.assertEquals(msg, expectedUrl, foundUrl);
7573
log.debug(msg+" found: "+foundUrl);
7674
} else {
7775
log.debug(msg+" found: myPage.getTotalElements() == 0");

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

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,7 @@
1515
import org.springframework.transaction.annotation.Propagation;
1616
import org.springframework.transaction.annotation.Transactional;
1717
import org.woehlke.twitterwall.conf.properties.TestdataProperties;
18-
import org.woehlke.twitterwall.oodm.entities.Media;
1918
import org.woehlke.twitterwall.oodm.entities.Url;
20-
import org.woehlke.twitterwall.oodm.entities.UrlCache;
2119

2220
@RunWith(SpringRunner.class)
2321
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
@@ -70,8 +68,8 @@ public void findByUrl() throws Exception {
7068
Url myMedia = myPage.getContent().iterator().next();
7169
String expectedUrl = myMedia.getUrl();
7270
Url myFoundMedia = urlService.findByUrl(expectedUrl);
73-
String foundUrl = myMedia.getUrl();
74-
Assert.assertEquals(msg, expectedUrl, myFoundMedia);
71+
String foundUrl = myFoundMedia.getUrl();
72+
Assert.assertEquals(msg, expectedUrl, foundUrl);
7573
log.debug(msg+" found: "+foundUrl);
7674
} else {
7775
log.debug(msg+" found: myPage.getTotalElements() == 0");

0 commit comments

Comments
 (0)