Skip to content

Commit 397108a

Browse files
working on #204
1 parent 8fb6684 commit 397108a

File tree

5 files changed

+94
-6
lines changed

5 files changed

+94
-6
lines changed

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

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,12 +59,40 @@ public void fetchTestData() throws Exception {
5959
@Commit
6060
@Test
6161
public void findByIdTwitter() throws Exception {
62-
62+
String msg = "findByIdTwitter: ";
63+
int page=1;
64+
int size=1;
65+
Pageable pageRequest = new PageRequest(page,size);
66+
Page<Media> myPage = mediaService.getAll(pageRequest);
67+
if(myPage.getTotalElements()>0){
68+
Media myMedia = myPage.getContent().iterator().next();
69+
long expectedIdTwitter = myMedia.getIdTwitter();
70+
Media myFoundMedia = mediaService.findByIdTwitter(expectedIdTwitter);
71+
long foundIdTwitter = myFoundMedia.getIdTwitter();
72+
Assert.assertEquals(msg, expectedIdTwitter,foundIdTwitter);
73+
log.debug(msg+" found: "+myMedia.getUniqueId());
74+
} else {
75+
log.debug(msg+" found: myPage.getTotalElements() == 0");
76+
}
6377
}
6478

6579
@Commit
6680
@Test
6781
public void findByUrl() throws Exception {
68-
82+
String msg = "findByUrl: ";
83+
int page=1;
84+
int size=1;
85+
Pageable pageRequest = new PageRequest(page,size);
86+
Page<Media> myPage = mediaService.getAll(pageRequest);
87+
if(myPage.getTotalElements()>0){
88+
Media myMedia = myPage.getContent().iterator().next();
89+
String expectedUrl = myMedia.getUrl();
90+
Media myFoundMedia = mediaService.findByUrl(expectedUrl);
91+
String foundUrl = myMedia.getUrl();
92+
Assert.assertEquals(msg, expectedUrl, myFoundMedia);
93+
log.debug(msg+" found: "+foundUrl);
94+
} else {
95+
log.debug(msg+" found: myPage.getTotalElements() == 0");
96+
}
6997
}
7098
}

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
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;
1920
import org.woehlke.twitterwall.oodm.entities.TickerSymbol;
2021

2122
@RunWith(SpringRunner.class)
@@ -60,7 +61,21 @@ public void fetchTestData() throws Exception {
6061
@Commit
6162
@Test
6263
public void findByUrl() throws Exception {
63-
64+
String msg = "findByUrl: ";
65+
int page=1;
66+
int size=1;
67+
Pageable pageRequest = new PageRequest(page,size);
68+
Page<TickerSymbol> myPage = tickerSymbolService.getAll(pageRequest);
69+
if(myPage.getTotalElements()>0){
70+
TickerSymbol myMedia = myPage.getContent().iterator().next();
71+
String expectedUrl = myMedia.getUrl();
72+
TickerSymbol myFoundMedia = tickerSymbolService.findByUrl(expectedUrl);
73+
String foundUrl = myMedia.getUrl();
74+
Assert.assertEquals(msg, expectedUrl, myFoundMedia);
75+
log.debug(msg+" found: "+foundUrl);
76+
} else {
77+
log.debug(msg+" found: myPage.getTotalElements() == 0");
78+
}
6479
}
6580

6681
}

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +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;
1819
import org.woehlke.twitterwall.oodm.entities.TickerSymbol;
1920
import org.woehlke.twitterwall.oodm.entities.Tweet;
2021

@@ -60,7 +61,21 @@ public void fetchTestData() throws Exception {
6061
@Commit
6162
@Test
6263
public void findByIdTwitter() throws Exception {
63-
64+
String msg = "findByIdTwitter: ";
65+
int page=1;
66+
int size=1;
67+
Pageable pageRequest = new PageRequest(page,size);
68+
Page<Tweet> myPage = tweetService.getAll(pageRequest);
69+
if(myPage.getTotalElements()>0){
70+
Tweet myMedia = myPage.getContent().iterator().next();
71+
long expectedIdTwitter = myMedia.getIdTwitter();
72+
Tweet myFoundMedia = tweetService.findByIdTwitter(expectedIdTwitter);
73+
long foundIdTwitter = myFoundMedia.getIdTwitter();
74+
Assert.assertEquals(msg, expectedIdTwitter,foundIdTwitter);
75+
log.debug(msg+" found: "+myMedia.getUniqueId());
76+
} else {
77+
log.debug(msg+" found: myPage.getTotalElements() == 0");
78+
}
6479
}
6580

6681
@Commit

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +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;
1819
import org.woehlke.twitterwall.oodm.entities.Tweet;
1920
import org.woehlke.twitterwall.oodm.entities.UrlCache;
2021

@@ -60,7 +61,21 @@ public void fetchTestData() throws Exception {
6061
@Commit
6162
@Test
6263
public void findByUrl() throws Exception {
63-
64+
String msg = "findByUrl: ";
65+
int page=1;
66+
int size=1;
67+
Pageable pageRequest = new PageRequest(page,size);
68+
Page<UrlCache> myPage = urlCacheService.getAll(pageRequest);
69+
if(myPage.getTotalElements()>0){
70+
UrlCache myMedia = myPage.getContent().iterator().next();
71+
String expectedUrl = myMedia.getUrl();
72+
UrlCache myFoundMedia = urlCacheService.findByUrl(expectedUrl);
73+
String foundUrl = myMedia.getUrl();
74+
Assert.assertEquals(msg, expectedUrl, myFoundMedia);
75+
log.debug(msg+" found: "+foundUrl);
76+
} else {
77+
log.debug(msg+" found: myPage.getTotalElements() == 0");
78+
}
6479
}
6580

6681
}

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

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,6 +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;
1819
import org.woehlke.twitterwall.oodm.entities.Url;
1920
import org.woehlke.twitterwall.oodm.entities.UrlCache;
2021

@@ -60,7 +61,21 @@ public void fetchTestData() throws Exception {
6061
@Commit
6162
@Test
6263
public void findByUrl() throws Exception {
63-
64+
String msg = "findByUrl: ";
65+
int page=1;
66+
int size=1;
67+
Pageable pageRequest = new PageRequest(page,size);
68+
Page<Url> myPage = urlService.getAll(pageRequest);
69+
if(myPage.getTotalElements()>0){
70+
Url myMedia = myPage.getContent().iterator().next();
71+
String expectedUrl = myMedia.getUrl();
72+
Url myFoundMedia = urlService.findByUrl(expectedUrl);
73+
String foundUrl = myMedia.getUrl();
74+
Assert.assertEquals(msg, expectedUrl, myFoundMedia);
75+
log.debug(msg+" found: "+foundUrl);
76+
} else {
77+
log.debug(msg+" found: myPage.getTotalElements() == 0");
78+
}
6479
}
6580

6681
}

0 commit comments

Comments
 (0)