Skip to content

Commit 4a04ef9

Browse files
fixed broken Tests
1 parent d4f9f3e commit 4a04ef9

File tree

1 file changed

+26
-5
lines changed

1 file changed

+26
-5
lines changed

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

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
import org.woehlke.twitterwall.oodm.model.tasks.TaskSendType;
2121
import org.woehlke.twitterwall.oodm.model.tasks.TaskType;
2222

23+
import java.util.Date;
24+
2325
@RunWith(SpringRunner.class)
2426
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE)
2527
public class MentionServiceTest implements DomainObjectMinimalServiceTest,DomainServiceWithTaskTest,DomainServiceWithScreenNameTest,DomainServiceWithIdTwitterTest {
@@ -68,12 +70,22 @@ public void createTestData() throws Exception {
6870
"Java"
6971
};
7072

73+
int pageNr=1;
74+
int pageSize=1;
75+
Pageable pageRequest = new PageRequest(pageNr,pageSize);
76+
7177
for(int i=0;i<4;i++){
72-
Mention mentionTest = new Mention(createdBy,updatedBy,idTwitter[i], screenName[i], name[i]);
73-
mentionTest = mentionService.store(mentionTest,createdBy);
74-
Assert.assertNotNull(mentionTest);
75-
Assert.assertNotNull(mentionTest.getId());
76-
Assert.assertTrue(mentionTest.isValid());
78+
Page<Mention> foundMentionsPage = mentionService.findAllByScreenName(screenName[i],pageRequest);
79+
if(foundMentionsPage.getTotalElements() == 0){
80+
waitFor500ms();
81+
Date now = new Date();
82+
long myIdTwitter = idTwitter[i] + now.getTime();
83+
Mention mentionTest = new Mention(createdBy,updatedBy,myIdTwitter, screenName[i], name[i]);
84+
mentionTest = mentionService.store(mentionTest,createdBy);
85+
Assert.assertNotNull(mentionTest);
86+
Assert.assertNotNull(mentionTest.getId());
87+
Assert.assertTrue(mentionTest.isValid());
88+
}
7789
}
7890
}
7991

@@ -234,4 +246,13 @@ public void findAllByScreenName() throws Exception {
234246
public void findByIdTwitterOfUser() throws Exception {
235247

236248
}
249+
250+
private void waitFor500ms(){
251+
int millisToWait = 500;
252+
log.debug("### waiting now for (ms): "+millisToWait);
253+
try {
254+
Thread.sleep(millisToWait);
255+
} catch (InterruptedException e) {
256+
}
257+
}
237258
}

0 commit comments

Comments
 (0)