|
20 | 20 | import org.woehlke.twitterwall.oodm.model.tasks.TaskSendType; |
21 | 21 | import org.woehlke.twitterwall.oodm.model.tasks.TaskType; |
22 | 22 |
|
| 23 | +import java.util.Date; |
| 24 | + |
23 | 25 | @RunWith(SpringRunner.class) |
24 | 26 | @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) |
25 | 27 | public class MentionServiceTest implements DomainObjectMinimalServiceTest,DomainServiceWithTaskTest,DomainServiceWithScreenNameTest,DomainServiceWithIdTwitterTest { |
@@ -68,12 +70,22 @@ public void createTestData() throws Exception { |
68 | 70 | "Java" |
69 | 71 | }; |
70 | 72 |
|
| 73 | + int pageNr=1; |
| 74 | + int pageSize=1; |
| 75 | + Pageable pageRequest = new PageRequest(pageNr,pageSize); |
| 76 | + |
71 | 77 | 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 | + } |
77 | 89 | } |
78 | 90 | } |
79 | 91 |
|
@@ -234,4 +246,13 @@ public void findAllByScreenName() throws Exception { |
234 | 246 | public void findByIdTwitterOfUser() throws Exception { |
235 | 247 |
|
236 | 248 | } |
| 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 | + } |
237 | 258 | } |
0 commit comments