Skip to content

Commit 4aaa625

Browse files
working on #224
1 parent d5672ed commit 4aaa625

File tree

14 files changed

+89
-491
lines changed

14 files changed

+89
-491
lines changed

src/main/java/org/woehlke/twitterwall/scheduled/service/remote/TwitterApiService.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,6 @@ public interface TwitterApiService {
1414

1515
Tweet findOneTweetById(long tweetTwitterId);
1616

17-
//List<TwitterProfile> getUserProfilesForTwitterIds(long... userProfileTwitterIds);
18-
1917
TwitterProfile getUserProfileForTwitterId(long userProfileTwitterId);
2018

2119
TwitterProfile getUserProfileForScreenName(String screenName);

src/main/java/org/woehlke/twitterwall/scheduled/service/remote/impl/TwitterApiServiceImpl.java

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,6 @@
1010
import org.springframework.social.twitter.api.TwitterProfile;
1111
import org.springframework.social.twitter.api.impl.TwitterTemplate;
1212
import org.springframework.stereotype.Component;
13-
import org.springframework.stereotype.Service;
14-
import org.springframework.transaction.annotation.Propagation;
15-
import org.springframework.transaction.annotation.Transactional;
1613
import org.woehlke.twitterwall.conf.properties.TwitterProperties;
1714
import org.woehlke.twitterwall.scheduled.service.remote.TwitterApiService;
1815

@@ -25,8 +22,6 @@
2522
*/
2623

2724
@Component
28-
//@Service
29-
//@Transactional(propagation = Propagation.REQUIRES_NEW, readOnly = false)
3025
public class TwitterApiServiceImpl implements TwitterApiService {
3126

3227

@@ -47,7 +42,6 @@ public List<Tweet> findTweetsForSearchQuery() {
4742
}
4843
} catch (Exception e) {
4944
log.error(msg + e.getMessage());
50-
//e.printStackTrace();
5145
return new ArrayList<>();
5246
}
5347

@@ -71,25 +65,6 @@ public Tweet findOneTweetById(long tweetTwitterId) {
7165
}
7266
}
7367

74-
/*
75-
@Override
76-
public List<TwitterProfile> getUserProfilesForTwitterIds(long... userProfileTwitterIds) {
77-
String msg = MSG+"getUserProfileForTwitterId: "+userProfileTwitterIds+" : ";
78-
log.debug(msg);
79-
List<TwitterProfile> result;
80-
try {
81-
result = getTwitterProxy().userOperations().getUsers(userProfileTwitterIds);
82-
msg += " result: ";
83-
log.debug(msg+" size: "+result.size());
84-
} catch (Exception e){
85-
result = null;
86-
log.error(msg + e.getMessage());
87-
e.printStackTrace();
88-
}
89-
return result;
90-
}
91-
*/
92-
9368
@Override
9469
public TwitterProfile getUserProfileForTwitterId(long userProfileTwitterId) {
9570
String msg = MSG+"getUserProfileForTwitterId: "+userProfileTwitterId+" : ";
@@ -104,7 +79,6 @@ public TwitterProfile getUserProfileForTwitterId(long userProfileTwitterId) {
10479
return result;
10580
} catch (Exception e) {
10681
log.error(msg + e.getMessage());
107-
//e.printStackTrace();
10882
return null;
10983
}
11084
}
@@ -126,7 +100,6 @@ public TwitterProfile getUserProfileForScreenName(String screenName) {
126100
} catch (Exception e) {
127101
log.debug(msg + e.getMessage());
128102
return null;
129-
//e.printStackTrace();
130103
}
131104
}
132105

@@ -140,9 +113,7 @@ public List<TwitterProfile> findUsersFromDefinedList(String screenName,String fe
140113
log.debug(msg + " result.size: " + result.size());
141114
return result;
142115
} catch (Exception e) {
143-
result = new ArrayList<>();
144116
log.debug(msg + e.getMessage());
145-
//e.printStackTrace();
146117
return new ArrayList<>();
147118
}
148119
}

src/test/java/org/woehlke/twitterwall/frontend/controller/HashTagControllerTest.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,10 @@
1313
import org.springframework.data.domain.Pageable;
1414
import org.springframework.security.test.context.support.WithAnonymousUser;
1515
import org.springframework.security.test.context.support.WithMockUser;
16-
import org.springframework.test.annotation.Commit;
1716
import org.springframework.test.context.junit4.SpringRunner;
1817
import org.springframework.test.web.servlet.MockMvc;
1918
import org.springframework.test.web.servlet.MvcResult;
2019
import org.woehlke.twitterwall.*;
21-
import org.woehlke.twitterwall.conf.properties.SchedulerProperties;
2220
import org.woehlke.twitterwall.frontend.controller.common.PrepareDataTest;
2321
import org.woehlke.twitterwall.oodm.entities.HashTag;
2422
import org.woehlke.twitterwall.oodm.service.HashTagService;
@@ -52,14 +50,12 @@ public class HashTagControllerTest {
5250
@Autowired
5351
private PrepareDataTest prepareDataTest;
5452

55-
//@Commit
5653
@Test
5754
public void controllerIsPresentTest(){
5855
log.info("controllerIsPresentTest");
5956
assertThat(controller).isNotNull();
6057
}
6158

62-
//@Commit
6359
@Test
6460
public void setupTestData(){
6561
String msg = "setupTestData: ";
@@ -69,7 +65,6 @@ public void setupTestData(){
6965
}
7066

7167
@WithMockUser
72-
//@Commit
7368
@Test
7469
public void getAllTest() throws Exception {
7570
String msg ="getAllTest: ";
@@ -101,7 +96,6 @@ private HashTag findOneHashTag(){
10196
}
10297

10398
@WithAnonymousUser
104-
//@Commit
10599
@Test
106100
public void findByIdTest() throws Exception {
107101
String msg ="findByIdTest: ";
@@ -127,7 +121,6 @@ public void findByIdTest() throws Exception {
127121
}
128122

129123
@WithAnonymousUser
130-
//@Commit
131124
@Test
132125
public void hashTagFromTweetsAndUsersTest() throws Exception {
133126
String msg ="hashTagFromTweetsAndUsersTest: ";
@@ -153,7 +146,6 @@ public void hashTagFromTweetsAndUsersTest() throws Exception {
153146
}
154147

155148
@WithAnonymousUser
156-
//@Commit
157149
@Test
158150
public void hashTagsOverview() throws Exception {
159151
String msg ="hashTagsOverview: ";

src/test/java/org/woehlke/twitterwall/frontend/controller/ImprintControllerTest.java

Lines changed: 1 addition & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,12 @@
99
import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc;
1010
import org.springframework.boot.test.context.SpringBootTest;
1111
import org.springframework.security.test.context.support.WithAnonymousUser;
12-
import org.springframework.test.annotation.Commit;
1312
import org.springframework.test.context.junit4.SpringRunner;
1413
import org.springframework.test.web.servlet.MockMvc;
1514
import org.springframework.test.web.servlet.MvcResult;
1615
import org.woehlke.twitterwall.Application;
17-
import org.woehlke.twitterwall.conf.properties.TwitterProperties;
1816
import org.woehlke.twitterwall.conf.properties.FrontendProperties;
1917
import org.woehlke.twitterwall.frontend.controller.common.PrepareDataTest;
20-
import org.woehlke.twitterwall.test.UserServiceTestHelper;
2118

2219
import static org.assertj.core.api.Java6Assertions.assertThat;
2320
import static org.hamcrest.CoreMatchers.containsString;
@@ -43,28 +40,20 @@ public class ImprintControllerTest {
4340
@Autowired
4441
private MockMvc mockMvc;
4542

46-
//@Autowired
47-
//private UserServiceTestHelper userServiceTestHelper;
48-
49-
//@Autowired
50-
//private TwitterProperties twitterProperties;
51-
5243
@Autowired
5344
private FrontendProperties frontendProperties;
5445

5546
@Autowired
5647
private PrepareDataTest prepareDataTest;
5748

58-
//@Commit
5949
@Test
6050
public void controllerIsPresentTest(){
6151
log.info("controllerIsPresentTest");
6252
assertThat(controller).isNotNull();
6353
}
6454

65-
//@Commit
6655
@Test
67-
public void fetchTweetsFromTwitterSearchTest() throws Exception {
56+
public void prepareDataTest() throws Exception {
6857
log.info("------------------------------------");
6958
log.info("fetchTweetsFromSearchTest: START userServiceTest.createUser("+ frontendProperties.getImprintScreenName()+")");
7059
prepareDataTest.createUser(frontendProperties.getImprintScreenName());
@@ -74,7 +63,6 @@ public void fetchTweetsFromTwitterSearchTest() throws Exception {
7463
}
7564

7665
@WithAnonymousUser
77-
//@Commit
7866
@Test
7967
public void imprintTest1() throws Exception {
8068
this.mockMvc.perform(get("/imprint")).andDo(print()).andExpect(status().isOk())
@@ -83,7 +71,6 @@ public void imprintTest1() throws Exception {
8371
}
8472

8573
@WithAnonymousUser
86-
//@Commit
8774
@Test
8875
public void imprintTest2() throws Exception {
8976
MvcResult result = this.mockMvc.perform(get("/imprint"))

src/test/java/org/woehlke/twitterwall/frontend/controller/common/PrepareDataTest.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,15 @@
33

44
import org.woehlke.twitterwall.oodm.entities.User;
55

6+
@Deprecated
67
public interface PrepareDataTest {
78

9+
@Deprecated
810
void getTestDataTweets(String msg);
911

12+
@Deprecated
1013
void getTestDataUser(String msg);
1114

15+
@Deprecated
1216
User createUser(String screenName);
1317
}

src/test/java/org/woehlke/twitterwall/frontend/controller/common/impl/PrepareDataTestImpl.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
/**
3434
* Created by tw on 13.07.17.
3535
*/
36+
@Deprecated
3637
@Component
3738
public class PrepareDataTestImpl implements PrepareDataTest {
3839

src/test/java/org/woehlke/twitterwall/scheduled/mq/endpoint/AsyncStartTaskTestImpl.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
import org.woehlke.twitterwall.oodm.entities.Task;
1313
import org.woehlke.twitterwall.oodm.entities.parts.CountedEntities;
1414
import org.woehlke.twitterwall.oodm.service.CountedEntitiesService;
15+
import org.woehlke.twitterwall.scheduled.mq.msg.SendType;
1516

1617
@RunWith(SpringRunner.class)
1718
@SpringBootTest(classes={Application.class})
@@ -27,56 +28,81 @@ public class AsyncStartTaskTestImpl extends AbstractMqEndpointTest implements As
2728

2829
@Test
2930
public void updateTweetsTest() throws Exception {
31+
String msg = "updateTweetsTest: ";
32+
log.info(msg+"START TEST");
3033
CountedEntities beforeTest = countedEntitiesService.countAll();
3134
Task task = this.mqAsyncStartTask.updateTweets();
35+
log.info(msg+"created Task = "+task.getUniqueId());
3236
Assert.assertNotNull(task);
3337
Assert.assertNotNull(task.getUniqueId());
38+
Assert.assertEquals(SendType.FIRE_AND_FORGET,task.getSendType());
3439
CountedEntities afterTest = countedEntitiesService.countAll();
3540
boolean ok = assertCountedEntities(beforeTest,afterTest);
3641
Assert.assertTrue(ok);
42+
log.info(msg+"FINISHED TEST");
3743
}
3844

3945
@Test
4046
public void updateUsersTest() throws Exception {
47+
String msg = "updateUsersTest: ";
48+
log.info(msg+"START TEST");
4149
CountedEntities beforeTest = countedEntitiesService.countAll();
4250
Task task = this.mqAsyncStartTask.updateUsers();
51+
log.info(msg+"created Task = "+task.getUniqueId());
4352
Assert.assertNotNull(task);
4453
Assert.assertNotNull(task.getUniqueId());
54+
Assert.assertEquals(SendType.FIRE_AND_FORGET,task.getSendType());
4555
CountedEntities afterTest = countedEntitiesService.countAll();
4656
boolean ok = assertCountedEntities(beforeTest,afterTest);
4757
Assert.assertTrue(ok);
58+
log.info(msg+"FINISHED TEST");
4859
}
4960

5061
@Test
5162
public void updateUsersFromMentionsTest() throws Exception {
63+
String msg = "updateUsersFromMentionsTest: ";
64+
log.info(msg+"START TEST");
5265
CountedEntities beforeTest = countedEntitiesService.countAll();
5366
Task task = this.mqAsyncStartTask.updateUsersFromMentions();
67+
log.info(msg+"created Task = "+task.getUniqueId());
5468
Assert.assertNotNull(task);
5569
Assert.assertNotNull(task.getUniqueId());
70+
Assert.assertEquals(SendType.FIRE_AND_FORGET,task.getSendType());
5671
CountedEntities afterTest = countedEntitiesService.countAll();
5772
boolean ok = assertCountedEntities(beforeTest,afterTest);
5873
Assert.assertTrue(ok);
74+
log.info(msg+"FINISHED TEST");
5975
}
6076

6177
@Test
6278
public void fetchTweetsFromSearchTest() throws Exception {
79+
String msg = "fetchTweetsFromSearchTest: ";
80+
log.info(msg+"START TEST");
6381
CountedEntities beforeTest = countedEntitiesService.countAll();
6482
Task task = this.mqAsyncStartTask.fetchTweetsFromSearch();
83+
log.info(msg+"created Task = "+task.getUniqueId());
6584
Assert.assertNotNull(task);
6685
Assert.assertNotNull(task.getUniqueId());
86+
Assert.assertEquals(SendType.FIRE_AND_FORGET,task.getSendType());
6787
CountedEntities afterTest = countedEntitiesService.countAll();
6888
boolean ok = assertCountedEntities(beforeTest,afterTest);
6989
Assert.assertTrue(ok);
90+
log.info(msg+"FINISHED TEST");
7091
}
7192

7293
@Test
7394
public void fetchUsersFromListTest() throws Exception {
95+
String msg = "fetchTweetsFromSearchTest: ";
96+
log.info(msg+"START TEST");
7497
CountedEntities beforeTest = countedEntitiesService.countAll();
7598
Task task = this.mqAsyncStartTask.fetchUsersFromList();
99+
log.info(msg+"created Task = "+task.getUniqueId());
76100
Assert.assertNotNull(task);
77101
Assert.assertNotNull(task.getUniqueId());
102+
Assert.assertEquals(SendType.FIRE_AND_FORGET,task.getSendType());
78103
CountedEntities afterTest = countedEntitiesService.countAll();
79104
boolean ok = assertCountedEntities(beforeTest,afterTest);
80105
Assert.assertTrue(ok);
106+
log.info(msg+"FINISHED TEST");
81107
}
82108
}

0 commit comments

Comments
 (0)