Skip to content

Commit b0f8dca

Browse files
fixed #87, fixed #200, fixed #215, fixed #216, fixed #217, fixed #219, fixed #222
1 parent 3f6b657 commit b0f8dca

File tree

3 files changed

+60
-17
lines changed

3 files changed

+60
-17
lines changed

src/main/java/org/woehlke/twitterwall/oodm/service/UserService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,4 @@ public interface UserService extends DomainObjectWithEntitiesService<User>,Domai
4646

4747
Page<Object2Entity> findAllUser2TickerSymbol(Pageable pageRequest);
4848

49-
50-
5149
}

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

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -83,16 +83,17 @@ public void fetchTestData() throws Exception {
8383
public void findByIdTwitter() throws Exception {
8484
String msg = "findByIdTwitter: ";
8585
int page=1;
86-
int size=1;
86+
int size=20;
8787
Pageable pageRequest = new PageRequest(page,size);
8888
Page<Tweet> myPage = tweetService.getAll(pageRequest);
8989
if(myPage.getTotalElements()>0){
90-
Tweet myMedia = myPage.getContent().iterator().next();
91-
long expectedIdTwitter = myMedia.getIdTwitter();
92-
Tweet myFoundMedia = tweetService.findByIdTwitter(expectedIdTwitter);
93-
long foundIdTwitter = myFoundMedia.getIdTwitter();
94-
Assert.assertEquals(msg, expectedIdTwitter,foundIdTwitter);
95-
log.info(msg+" found: "+myMedia.getUniqueId());
90+
for(Tweet tweet: myPage.getContent()){
91+
long expectedIdTwitter = tweet.getIdTwitter();
92+
Tweet myFoundTweet = tweetService.findByIdTwitter(expectedIdTwitter);
93+
long foundIdTwitter = myFoundTweet.getIdTwitter();
94+
Assert.assertEquals(msg, expectedIdTwitter,foundIdTwitter);
95+
log.info(msg+" found: "+myFoundTweet.getUniqueId());
96+
}
9697
} else {
9798
log.error(msg+" found: myPage.getTotalElements() == 0");
9899
}
@@ -104,7 +105,6 @@ public void findByIdTwitter() throws Exception {
104105
@Test
105106
public void findTweetsForHashTag() throws Exception {
106107
String msg = "findTweetsForHashTag: ";
107-
108108
int page=1;
109109
int size=10;
110110
Pageable pageRequest = new PageRequest(page,size);
@@ -113,12 +113,10 @@ public void findTweetsForHashTag() throws Exception {
113113
log.debug(msg+" found HashTag: "+hashTag.getUniqueId());
114114
Page<Tweet> tweets = tweetService.findTweetsForHashTag(hashTag,pageRequest);
115115
for(Tweet tweet: tweets.getContent()){
116-
log.debug(msg+" found Tweet: "+tweet.getUniqueId());
117116
Assert.assertTrue(tweet.getEntities().getHashTags().contains(hashTag));
117+
log.debug(msg+" found Tweet: "+tweet.getUniqueId()+" found HashTag: "+hashTag.getUniqueId());
118118
}
119119
}
120-
121-
122120
log.info(msg);
123121
}
124122

@@ -140,12 +138,11 @@ public void findTweetsForUser() throws Exception {
140138
Assert.assertTrue(msg,user.getTweeting());
141139
Page<Tweet> foundTweets = tweetService.findTweetsForUser(user,pageRequest);
142140
Assert.assertNotNull(msg,foundTweets);
143-
//Assert.assertTrue(foundTweets.getTotalElements()>0);
144141
for(Tweet tweet : foundTweets.getContent()) {
145142
loopTweet++;
146143
Assert.assertNotNull(msg,tweet.getUser());
147144
Assert.assertEquals(msg,tweet.getUser().getUniqueId(), user.getUniqueId());
148-
log.info(msg);
145+
log.info(msg+" tweet: "+tweet.getUniqueId()+" user: "+tweet.getUser().getUniqueId());
149146
}
150147
log.info(msg+" RUNNING TEST. Tested Users "+loopUser+" and Tweets "+loopTweet);
151148
}
@@ -173,6 +170,7 @@ public void findAllTweet2HashTag() throws Exception {
173170
Assert.assertNull(objectInfo);
174171
Assert.assertNull(entityInfo);
175172
Assert.assertTrue(msg,foundObject.getEntities().getHashTags().contains(foundEntity));
173+
log.info(msg+" tweet: "+foundObject.getUniqueId()+" HashTag: "+foundEntity.getUniqueId());
176174
}
177175
}
178176
}
@@ -200,6 +198,7 @@ public void findAllTweet2Media() throws Exception {
200198
Set<Media> media = foundObject.getEntities().getMedia();
201199
Assert.assertTrue(msg,media.size()>0);
202200
Assert.assertTrue(msg,media.contains(foundEntity));
201+
log.info(msg+" tweet: "+foundObject.getUniqueId()+" Media: "+foundEntity.getUniqueId());
203202
}
204203
}
205204

@@ -227,6 +226,7 @@ public void findAllTweet2Mention() throws Exception {
227226
Set<Mention> mentions = foundObject.getEntities().getMentions();
228227
Assert.assertTrue(msg,mentions.size() >0);
229228
Assert.assertTrue(msg,mentions.contains(foundEntity));
229+
log.info(msg+" tweet: "+foundObject.getUniqueId()+" Mention: "+foundEntity.getUniqueId());
230230
}
231231
}
232232
}
@@ -254,6 +254,7 @@ public void findAllTweet2Url() throws Exception {
254254
Set<Url> urls = foundObject.getEntities().getUrls();
255255
Assert.assertTrue(msg,urls.size()>0);
256256
Assert.assertTrue(msg,urls.contains(foundEntity));
257+
log.info(msg+" tweet: "+foundObject.getUniqueId()+" Url: "+foundEntity.getUniqueId());
257258
}
258259
}
259260

@@ -278,6 +279,7 @@ public void findAllTweet2TickerSymbol() throws Exception {
278279
Assert.assertNull(objectInfo);
279280
Assert.assertNull(entityInfo);
280281
Assert.assertTrue(msg,foundObject.getEntities().getTickerSymbols().contains(foundEntity));
282+
log.info(msg+" tweet: "+foundObject.getUniqueId()+" TickerSymbol: "+foundEntity.getUniqueId());
281283
}
282284
}
283285
}

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

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,10 @@ public void getTweetingUsers() throws Exception {
155155
int size=10;
156156
Pageable pageRequest = new PageRequest(page,size);
157157
Page<User> foundUser = userService.getTweetingUsers(pageRequest);
158+
for(User user:foundUser.getContent()){
159+
Assert.assertTrue(msg,user.getTweeting());
160+
log.debug(msg+" foundUser: "+user.getUniqueId());
161+
}
158162
log.debug(msg+" foundUser: "+foundUser.getTotalElements());
159163
}
160164

@@ -167,6 +171,10 @@ public void getAllDescriptions() throws Exception {
167171
int size=10;
168172
Pageable pageRequest = new PageRequest(page,size);
169173
Page<String> foundDescriptions = userService.getAllDescriptions(pageRequest);
174+
for(String description:foundDescriptions){
175+
Assert.assertNotNull(description);
176+
log.debug(msg+" description: "+description);
177+
}
170178
log.debug(msg+" foundUser: "+foundDescriptions.getTotalElements());
171179
}
172180

@@ -199,6 +207,7 @@ public void getFriends() throws Exception {
199207
Page<User> foundUser = userService.getFriends(pageRequest);
200208
for(User user : foundUser.getContent()){
201209
Assert.assertTrue(user.getFriend());
210+
log.debug(msg+" foundUser: "+user.getUniqueId());
202211
}
203212
log.debug(msg+" foundUser: "+foundUser.getTotalElements());
204213
}
@@ -213,7 +222,8 @@ public void getNotYetFriendUsers() throws Exception {
213222
Pageable pageRequest = new PageRequest(page,size);
214223
Page<User> foundUser = userService.getNotYetFriendUsers(pageRequest);
215224
for(User user : foundUser.getContent()){
216-
Assert.assertTrue(!user.getFriend());
225+
Assert.assertFalse(user.getFriend());
226+
log.debug(msg+" foundUser: "+user.getUniqueId());
217227
}
218228
log.debug(msg+" foundUser: "+foundUser.getTotalElements());
219229
}
@@ -229,6 +239,7 @@ public void getFollower() throws Exception {
229239
Page<User> foundUser = userService.getFollower(pageRequest);
230240
for(User user : foundUser.getContent()){
231241
Assert.assertTrue(user.getFollower());
242+
log.debug(msg+" foundUser: "+user.getUniqueId());
232243
}
233244
log.debug(msg+" foundUser: "+foundUser.getTotalElements());
234245
}
@@ -243,7 +254,8 @@ public void getNotYetFollower() throws Exception {
243254
Pageable pageRequest = new PageRequest(page,size);
244255
Page<User> foundUser = userService.getNotYetFollower(pageRequest);
245256
for(User user : foundUser.getContent()){
246-
Assert.assertTrue(!user.getFollower());
257+
Assert.assertFalse(user.getFollower());
258+
log.debug(msg+" foundUser: "+user.getUniqueId());
247259
}
248260
log.debug(msg+" foundUser: "+foundUser.getTotalElements());
249261
}
@@ -258,6 +270,10 @@ public void getOnList() throws Exception {
258270
int size=10;
259271
Pageable pageRequest = new PageRequest(page,size);
260272
Page<User> foundUser = userService.getOnList(pageRequest);
273+
for(User user:foundUser.getContent()){
274+
Assert.assertTrue(msg,user.getTaskInfo().getUpdatedByFetchUsersFromDefinedUserList());
275+
log.debug(msg+" foundUser: "+user.getUniqueId());
276+
}
261277
log.debug(msg+" foundUser: "+foundUser.getTotalElements());
262278
}
263279

@@ -271,6 +287,11 @@ public void getNotYetOnList() throws Exception {
271287
int size=10;
272288
Pageable pageRequest = new PageRequest(page,size);
273289
Page<User> foundUser = userService.getNotYetOnList(pageRequest);
290+
for(User user:foundUser.getContent()){
291+
Assert.assertTrue(msg,user.getTaskInfo().getUpdatedByFetchTweetsFromTwitterSearch());
292+
Assert.assertFalse(msg,user.getTaskInfo().getUpdatedByFetchUsersFromDefinedUserList());
293+
log.debug(msg+" foundUser: "+user.getUniqueId());
294+
}
274295
log.debug(msg+" foundUser: "+foundUser.getTotalElements());
275296
}
276297

@@ -296,6 +317,7 @@ public void findAllUser2HashTag() throws Exception {
296317
Assert.assertNull(objectInfo);
297318
Assert.assertNull(entityInfo);
298319
Assert.assertTrue(msg,foundObject.getEntities().getHashTags().contains(foundEntity));
320+
log.debug(msg+" found User: "+foundObject.getUniqueId()+" found HashTag: "+foundEntity.getUniqueId());
299321
}
300322
}
301323
}
@@ -322,6 +344,7 @@ public void findAllUser2Media() throws Exception {
322344
Assert.assertNull(objectInfo);
323345
Assert.assertNull(entityInfo);
324346
Assert.assertTrue(msg,foundObject.getEntities().getMedia().contains(foundEntity));
347+
log.debug(msg+" found User: "+foundObject.getUniqueId()+" found Media: "+foundEntity.getUniqueId());
325348
}
326349
}
327350
}
@@ -357,6 +380,7 @@ public void findAllUser2Mentiong() throws Exception {
357380
Assert.assertTrue(msg,mentions.size()>0);
358381
boolean ok = mentions.contains(mentionPers);
359382
Assert.assertTrue(msg,ok);
383+
log.debug(msg+" found User: "+userPers.getUniqueId()+" found Mention: "+mentionPers.getUniqueId());
360384
}
361385
}
362386

@@ -385,6 +409,7 @@ public void findAllUser2Url() throws Exception {
385409
Assert.assertTrue(msg,urls.size()>0);
386410
boolean ok = urls.contains(foundEntity);
387411
Assert.assertTrue(msg,ok);
412+
log.debug(msg+" found User: "+foundObject.getUniqueId()+" found Url: "+foundEntity.getUniqueId());
388413
}
389414
}
390415

@@ -410,7 +435,25 @@ public void findAllUser2TickerSymbol() throws Exception {
410435
Assert.assertNull(objectInfo);
411436
Assert.assertNull(entityInfo);
412437
Assert.assertTrue(msg,foundObject.getEntities().getTickerSymbols().contains(foundEntity));
438+
log.debug(msg+" found User: "+foundObject.getUniqueId()+" found TickerSymbol: "+foundEntity.getUniqueId());
413439
}
414440
}
415441
}
442+
443+
@Test
444+
public void findByidTwitterAndScreenNameUnique() throws Exception {
445+
String msg = "findByidTwitterAndScreenNameUnique: ";
446+
int page=1;
447+
int size=10;
448+
Pageable pageRequest = new PageRequest(page,size);
449+
Page<User> allUsersPage = userService.getAll(pageRequest);
450+
for(User expectedUser:allUsersPage.getContent()){
451+
long idTwitter = expectedUser.getIdTwitter();
452+
String screenNameUnique = expectedUser.getScreenNameUnique();
453+
User foundUser = userService.findByidTwitterAndScreenNameUnique(idTwitter,screenNameUnique);
454+
Assert.assertEquals(msg,expectedUser.getUniqueId(),foundUser.getUniqueId());
455+
Assert.assertEquals(msg,idTwitter,foundUser.getIdTwitter().longValue());
456+
Assert.assertEquals(msg,screenNameUnique,foundUser.getScreenNameUnique());
457+
}
458+
}
416459
}

0 commit comments

Comments
 (0)