Skip to content

Commit 3f6b657

Browse files
fixed #222, fixed #217, working on #215, working on #200
1 parent ce3097a commit 3f6b657

File tree

5 files changed

+114
-67
lines changed

5 files changed

+114
-67
lines changed

src/main/java/org/woehlke/twitterwall/oodm/entities/Media.java

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,25 @@ public void setMediaType(String mediaType) {
220220
this.mediaType = mediaType;
221221
}
222222

223+
224+
@Override
225+
public boolean equals(Object o) {
226+
if (this == o) return true;
227+
if (!(o instanceof Media)) return false;
228+
229+
Media media = (Media) o;
230+
231+
if (id != null ? !id.equals(media.id) : media.id != null) return false;
232+
return idTwitter != null ? idTwitter.equals(media.idTwitter) : media.idTwitter == null;
233+
}
234+
235+
@Override
236+
public int hashCode() {
237+
int result = id != null ? id.hashCode() : 0;
238+
result = 31 * result + (idTwitter != null ? idTwitter.hashCode() : 0);
239+
return result;
240+
}
241+
223242
@Override
224243
public String toString() {
225244
return "Media{" +

src/main/java/org/woehlke/twitterwall/oodm/entities/Url.java

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,11 @@ public boolean isValid() {
124124
}
125125
}
126126

127+
@Override
128+
public String getUniqueId() {
129+
return url;
130+
}
131+
127132
public Url(Task createdBy, Task updatedBy,String display, String expanded, String url) {
128133
super(createdBy,updatedBy);
129134
this.display = display;
@@ -163,11 +168,6 @@ public void setId(Long id) {
163168
this.id = id;
164169
}
165170

166-
@Override
167-
public String getUniqueId() {
168-
return url;
169-
}
170-
171171
public String getDisplay() {
172172
return display;
173173
}
@@ -215,19 +215,17 @@ public String toString() {
215215
public boolean equals(Object o) {
216216
if (this == o) return true;
217217
if (!(o instanceof Url)) return false;
218-
if (!super.equals(o)) return false;
219218

220219
Url url1 = (Url) o;
221220

222-
if (getId() != null ? !getId().equals(url1.getId()) : url1.getId() != null) return false;
223-
return getUrl() != null ? getUrl().equals(url1.getUrl()) : url1.getUrl() == null;
221+
if (id != null ? !id.equals(url1.id) : url1.id != null) return false;
222+
return url != null ? url.equals(url1.url) : url1.url == null;
224223
}
225224

226225
@Override
227226
public int hashCode() {
228-
int result = super.hashCode();
229-
result = 31 * result + (getId() != null ? getId().hashCode() : 0);
230-
result = 31 * result + (getUrl() != null ? getUrl().hashCode() : 0);
227+
int result = id != null ? id.hashCode() : 0;
228+
result = 31 * result + (url != null ? url.hashCode() : 0);
231229
return result;
232230
}
233231
}

src/test/java/org/woehlke/twitterwall/oodm/entities/UserDescriptionTest.java

Lines changed: 29 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,22 +2,36 @@
22

33
import org.junit.Ignore;
44
import org.junit.Test;
5+
import org.junit.runner.RunWith;
56
import org.slf4j.Logger;
67
import org.slf4j.LoggerFactory;
8+
import org.springframework.beans.factory.annotation.Autowired;
9+
import org.springframework.boot.test.context.SpringBootTest;
10+
import org.springframework.test.context.junit4.SpringRunner;
11+
import org.woehlke.twitterwall.conf.properties.TestdataProperties;
712
import org.woehlke.twitterwall.oodm.entities.parts.Entities;
13+
import org.woehlke.twitterwall.oodm.entities.parts.TaskStatus;
14+
import org.woehlke.twitterwall.oodm.entities.parts.TaskType;
815

916
import java.util.ArrayList;
17+
import java.util.Date;
1018
import java.util.List;
1119
import java.util.regex.Matcher;
1220
import java.util.regex.Pattern;
1321

1422
/**
1523
* Created by tw on 22.06.17.
1624
*/
25+
@RunWith(SpringRunner.class)
26+
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
1727
public class UserDescriptionTest {
1828

29+
@Autowired
30+
private TestdataProperties testdataProperties;
31+
1932
private static final Logger log = LoggerFactory.getLogger(UserDescriptionTest.class);
2033

34+
/*
2135
private static String descriptions[] = {
2236
"Webentwickler @cron_eu, Stuttgart #T3Rookies #TYP",
2337
"Neos, Flow and TYPO3 development @portachtzig_ Berlin",
@@ -55,15 +69,27 @@ public class UserDescriptionTest {
5569
"Member of TYPO3 Expert Advisory Board, TYPO3 Marketing Team, Magento | web design | content management | secure hosting",
5670
"#TYPO3 #SCRUM #RE #OKR; Independent Consultant, Trainer, Agile Coach; TYPO3 Expert Advisory Board & Head of TYPO3 Education; https://t.co/E6qwHNXcAh",
5771
};
72+
*/
5873

59-
@Ignore
74+
//@Ignore
6075
@Test
6176
public void printDescriptionsTest(){
62-
Task task = null;
77+
78+
String descriptionTask = "Just another Task";
79+
TaskType taskType = TaskType.FETCH_TWEETS_FROM_SEARCH;
80+
TaskStatus taskStatus = TaskStatus.READY;
81+
Date timeStarted = new Date();
82+
Date timeLastUpdate = new Date();
83+
Date timeFinished = null;
84+
85+
Task task = new Task(descriptionTask,taskType,taskStatus,timeStarted,timeLastUpdate,timeFinished);
6386
int lfdNr = 0;
87+
88+
List<String> descriptions = testdataProperties.getOodm().getEntities().getUser().getDescriptions();
89+
6490
log.info("printDescriptionsTest");
6591
log.info("++++++++++++++++++++");
66-
log.info("found "+descriptions.length+" descriptions");
92+
log.info("found "+descriptions.size()+" descriptions");
6793
for(String description:descriptions){
6894
log.info("--------------------");
6995
lfdNr++;

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

Lines changed: 40 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@
1919
import org.woehlke.twitterwall.oodm.entities.*;
2020
import org.woehlke.twitterwall.oodm.entities.transients.Object2Entity;
2121

22+
import java.util.Set;
23+
2224
@RunWith(SpringRunner.class)
2325
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
2426
//@Transactional(propagation= Propagation.REQUIRES_NEW,readOnly=false)
@@ -176,38 +178,38 @@ public void findAllTweet2HashTag() throws Exception {
176178
}
177179

178180
//@Commit
179-
@Ignore
181+
//@Ignore
180182
@Test
181183
public void findAllTweet2Media() throws Exception {
182184
String msg = "findAllTweet2Media: ";
183185
int page=1;
184186
int size=10;
185187
Pageable pageRequest = new PageRequest(page,size);
186188
Page<Object2Entity> foundPage = tweetService.findAllTweet2Media(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-
Media foundEntity = mediaService.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().getMedia().contains(foundEntity));
200-
}
189+
for(Object2Entity object2Entity:foundPage.getContent()){
190+
long objectId = object2Entity.getObjectId();
191+
String objectInfo = object2Entity.getObjectInfo();
192+
long entityId = object2Entity.getEntityId();
193+
String entityInfo = object2Entity.getObjectInfo();
194+
Tweet foundObject = tweetService.findById(objectId);
195+
Media foundEntity = mediaService.findById(entityId);
196+
Assert.assertNotNull(msg,foundObject);
197+
Assert.assertNotNull(msg,foundEntity);
198+
Assert.assertNull(msg,objectInfo);
199+
Assert.assertNull(msg,entityInfo);
200+
Set<Media> media = foundObject.getEntities().getMedia();
201+
Assert.assertTrue(msg,media.size()>0);
202+
Assert.assertTrue(msg,media.contains(foundEntity));
201203
}
202204
}
203205

204206
//@Commit
205-
@Ignore
207+
//@Ignore
206208
@Test
207209
public void findAllTweet2Mention() throws Exception {
208210
String msg = "findAllTweet2Mention: ";
209211
int page=1;
210-
int size=10;
212+
int size=20;
211213
Pageable pageRequest = new PageRequest(page,size);
212214
Page<Object2Entity> foundPage = tweetService.findAllTweet2Mention(pageRequest);
213215
if(foundPage.getTotalElements()>0){
@@ -220,36 +222,38 @@ public void findAllTweet2Mention() throws Exception {
220222
Mention foundEntity = mentionService.findById(entityId);
221223
Assert.assertNotNull(msg,foundObject);
222224
Assert.assertNotNull(msg,foundEntity);
223-
Assert.assertNull(objectInfo);
224-
Assert.assertNull(entityInfo);
225-
Assert.assertTrue(msg,foundObject.getEntities().getMentions().contains(foundEntity));
225+
Assert.assertNull(msg,objectInfo);
226+
Assert.assertNull(msg,entityInfo);
227+
Set<Mention> mentions = foundObject.getEntities().getMentions();
228+
Assert.assertTrue(msg,mentions.size() >0);
229+
Assert.assertTrue(msg,mentions.contains(foundEntity));
226230
}
227231
}
228232
}
229233

230234
//@Commit
231-
@Ignore
235+
//@Ignore
232236
@Test
233237
public void findAllTweet2Url() throws Exception {
234238
String msg = "findAllTweet2Url: ";
235239
int page=1;
236-
int size=10;
240+
int size=20;
237241
Pageable pageRequest = new PageRequest(page,size);
238242
Page<Object2Entity> foundPage = tweetService.findAllTweet2Url(pageRequest);
239-
if(foundPage.getTotalElements()>0){
240-
for(Object2Entity object2Entity:foundPage.getContent()){
241-
long objectId = object2Entity.getObjectId();
242-
String objectInfo = object2Entity.getObjectInfo();
243-
long entityId = object2Entity.getEntityId();
244-
String entityInfo = object2Entity.getObjectInfo();
245-
Tweet foundObject = tweetService.findById(objectId);
246-
Url foundEntity = urlService.findById(entityId);
247-
Assert.assertNotNull(msg,foundObject);
248-
Assert.assertNotNull(msg,foundEntity);
249-
Assert.assertNull(objectInfo);
250-
Assert.assertNull(entityInfo);
251-
Assert.assertTrue(msg,foundObject.getEntities().getUrls().contains(foundEntity));
252-
}
243+
for(Object2Entity object2Entity:foundPage.getContent()){
244+
long objectId = object2Entity.getObjectId();
245+
String objectInfo = object2Entity.getObjectInfo();
246+
long entityId = object2Entity.getEntityId();
247+
String entityInfo = object2Entity.getObjectInfo();
248+
Tweet foundObject = tweetService.findById(objectId);
249+
Url foundEntity = urlService.findById(entityId);
250+
Assert.assertNotNull(msg,foundObject);
251+
Assert.assertNotNull(msg,foundEntity);
252+
Assert.assertNull(msg,objectInfo);
253+
Assert.assertNull(msg,entityInfo);
254+
Set<Url> urls = foundObject.getEntities().getUrls();
255+
Assert.assertTrue(msg,urls.size()>0);
256+
Assert.assertTrue(msg,urls.contains(foundEntity));
253257
}
254258
}
255259

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

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -362,29 +362,29 @@ public void findAllUser2Mentiong() throws Exception {
362362

363363

364364
//@Commit
365-
@Ignore
365+
//@Ignore
366366
@Test
367367
public void findAllUser2Url() throws Exception {
368368
String msg = "findAllUser2Url: ";
369369
int page=1;
370-
int size=10;
370+
int size=20;
371371
Pageable pageRequest = new PageRequest(page,size);
372372
Page<Object2Entity> foundPage = userService.findAllUser2Url(pageRequest);
373-
if(foundPage.getTotalElements()>0){
374-
for(Object2Entity object2Entity:foundPage.getContent()){
375-
long objectId = object2Entity.getObjectId();
376-
String objectInfo = object2Entity.getObjectInfo();
377-
long entityId = object2Entity.getEntityId();
378-
String entityInfo = object2Entity.getObjectInfo();
379-
User foundObject = userService.findById(objectId);
380-
Url foundEntity = urlService.findById(entityId);
381-
Assert.assertNotNull(msg,foundObject);
382-
Assert.assertNotNull(msg,foundEntity);
383-
Assert.assertNull(objectInfo);
384-
Assert.assertNull(entityInfo);
385-
boolean ok = foundObject.getEntities().getUrls().contains(foundEntity);
386-
Assert.assertTrue(msg,ok);
387-
}
373+
for(Object2Entity object2Entity:foundPage.getContent()){
374+
long objectId = object2Entity.getObjectId();
375+
String objectInfo = object2Entity.getObjectInfo();
376+
long entityId = object2Entity.getEntityId();
377+
String entityInfo = object2Entity.getObjectInfo();
378+
User foundObject = userService.findById(objectId);
379+
Url foundEntity = urlService.findById(entityId);
380+
Assert.assertNotNull(msg,foundObject);
381+
Assert.assertNotNull(msg,foundEntity);
382+
Assert.assertNull(msg,objectInfo);
383+
Assert.assertNull(msg,entityInfo);
384+
Set<Url> urls = foundObject.getEntities().getUrls();
385+
Assert.assertTrue(msg,urls.size()>0);
386+
boolean ok = urls.contains(foundEntity);
387+
Assert.assertTrue(msg,ok);
388388
}
389389
}
390390

0 commit comments

Comments
 (0)