diff --git a/.gitignore b/.gitignore index 472ae6c3..b14aa67c 100644 --- a/.gitignore +++ b/.gitignore @@ -12,6 +12,7 @@ buildNumber.properties !/.mvn/wrapper/maven-wrapper.jar .idea +*.iml todo.txt tw.txt twitterwall.log diff --git a/.mvn/jvm.config b/.mvn/jvm.config index baa05f11..032df5e7 100644 --- a/.mvn/jvm.config +++ b/.mvn/jvm.config @@ -1 +1 @@ --Xmx1024m +-Xmx350m -Xss512k -Dfile.encoding=UTF-8 diff --git a/.travis.yml b/.travis.yml index 079aaf9a..34643765 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,6 +1,25 @@ -sudo: false language: java jdk: -- oraclejdk8 -script: -- test/run-travis.sh \ No newline at end of file + - oraclejdk8 +addons: + apt: + packages: + - oracle-java8-installer +services: + - postgresql +before_install: + - sudo apt-get update + - sudo apt-get install language-pack-de + - sudo /etc/init.d/postgresql stop + - sudo /etc/init.d/postgresql start 9.6 +before_script: + - psql -c "CREATE USER twitterwall2test WITH PASSWORD 'twitterwall2testpwd' LOGIN SUPERUSER INHERIT CREATEDB CREATEROLE NOREPLICATION;" -U postgres + - psql -c 'GRANT pg_signal_backend, postgres TO twitterwall2test WITH ADMIN OPTION;' -U postgres + - psql -c "CREATE DATABASE twitterwall2test WITH OWNER = twitterwall2test TEMPLATE = template0 ENCODING = 'UTF8' LC_COLLATE = 'de_DE.UTF-8' LC_CTYPE = 'de_DE.UTF-8' CONNECTION LIMIT = -1;" -U postgres + - psql -c '\l' -U postgres + - psql -c '\dg' -U postgres + - psql -c '\dn' -U postgres + - psql -c 'select * from version();' -U postgres + - psql -c 'select * from version();' -U twitterwall2test +sudo: false +script: ./mvnw clean site site:deploy -Ptravis -Dtest=AlphaTopLevelSuiteIT -B -V \ No newline at end of file diff --git a/test/db-count.sql b/etc/db-count.sql similarity index 100% rename from test/db-count.sql rename to etc/db-count.sql index e00e9bb4..0c105b7b 100644 --- a/test/db-count.sql +++ b/etc/db-count.sql @@ -16,7 +16,7 @@ select count(*) from hashtag; select count(*) from tweet; select count(*) from userlist_members; select count(*) from userlist_subcriber; -select count(*) from userprofile; select count(*) from userlist; +select count(*) from userprofile; select count(*) from task_history; select count(*) from task; diff --git a/test/db-drop-tables.sql b/etc/db-drop-tables.sql similarity index 100% rename from test/db-drop-tables.sql rename to etc/db-drop-tables.sql index 15ad5faf..09525cfa 100644 --- a/test/db-drop-tables.sql +++ b/etc/db-drop-tables.sql @@ -14,10 +14,10 @@ drop table mention; drop table media; drop table hashtag; drop table tweet; -drop table userprofile; drop table userlist_members; drop table userlist_subcriber; drop table userlist; +drop table userprofile; drop table task_history; drop table task; drop sequence hibernate_sequence; diff --git a/test/db-reset.sql b/etc/db-reset.sql similarity index 100% rename from test/db-reset.sql rename to etc/db-reset.sql index dda6c62d..f9c9910c 100644 --- a/test/db-reset.sql +++ b/etc/db-reset.sql @@ -14,10 +14,10 @@ delete from mention; delete from media; delete from hashtag; delete from tweet; -delete from userprofile; delete from userlist_members; delete from userlist_subcriber; delete from userlist; +delete from userprofile; delete from task_history; delete from task; diff --git a/test/env-config.sh b/etc/env-config.sh similarity index 100% rename from test/env-config.sh rename to etc/env-config.sh diff --git a/test/run-local.sh b/etc/run-local.sh similarity index 100% rename from test/run-local.sh rename to etc/run-local.sh diff --git a/test/run-travis.sh b/etc/run-travis.sh similarity index 100% rename from test/run-travis.sh rename to etc/run-travis.sh diff --git a/heroku.sh b/heroku.sh new file mode 100755 index 00000000..769a015c --- /dev/null +++ b/heroku.sh @@ -0,0 +1,36 @@ +#!/opt/local/bin/bash + +export PORT=8080 +export JAVA_OPTS='-Xmx350m -Xss512k' + +export DATABASE_URL='jdbc:postgresql://localhost:5432/twitterwall2?user=twitterwall2&password=twitterwall2pwd' +export DATABASE_URL_TEST='jdbc:postgresql://localhost:5432/twitterwall2test?user=twitterwall2test&password=twitterwall2testpwd' +export TWITTERWALL_FRONTEND_MAX_RESULTS=200 +export TWITTERWALL_SHOW_USERS_MENU=true +export TWITTERWALL_CONTEXT_TEST=true +export TWITTER_PAGE_SIZE=500 +export TWITTER_FETCH_TESTDATA=false +export TWITTERWALL_WAIT_FOR_TEST=120000 +export TWITTERWALL_URL_TEST_DATA_VERBOSE=false +export TWITTERWALL_SCHEDULER_ALLOW_UPDATE_TWEETS=false +export TWITTERWALL_SCHEDULER_ALLOW_UPDATE_USERS=false +export TWITTERWALL_SCHEDULER_ALLOW_UPDATE_USERS_FROM_MENTION=false +export TWITTERWALL_SCHEDULER_ALLOW_REMOVE_OLD_DATA_FROM_STORAGE=false +export TWITTERWALL_SCHEDULER_ALLOW_SEARCH=false +export TWITTER_SEARCH_TERM='#hibernate OR #java OR #TYPO3' +export TWITTERWALL_INFO_WEBPAGE=https://github.com/phasenraum2010/twitterwall2 +export TWITTERWALL_THEME=typo3 +export TWITTERWALL_APP_NAME=Twitterwall +export TWITTERWALL_INFO_IMPRINT_SCREEN_NAME=port80guru +export TWITTERWALL_GOOGLE_ANALYTICS_ID=TWITTERWALL_GOOGLE_ANALYTICS_ID +export TWITTERWALL_SCHEDULER_HEROKU_DB_LIMIT=false +export TWITTERWALL_SCHEDULER_USER_LIST_NAME=test-typo3-hibernate-java +export TWITTERWALL_SCHEDULER_USER_LIST_ALLOW=false +export TWITTERWALL_JPA_HIBERNATE_DDL_AUTO=update +#export TWITTERWALL_JPA_HIBERNATE_DDL_AUTO=create-drop +export TWITTERWALL_LOGIN_USERNAME=tw +export TWITTERWALL_LOGIN_PASSWORD=vbfvjdgar64r67tf7a46tf76rgtfgf7d6g + +./mvnw clean install + +java -Dserver.port=$PORT $JAVA_OPTS -jar target/twitterwall2-1.0.28-SNAPSHOT.jar diff --git a/pom.xml b/pom.xml index 7cedb43f..f54b2d37 100644 --- a/pom.xml +++ b/pom.xml @@ -430,14 +430,6 @@ - - org.apache.maven.plugins - maven-failsafe-plugin - - true - - - org.apache.maven.plugins maven-surefire-plugin @@ -450,55 +442,11 @@ - - testing - - - - - org.apache.maven.plugins - maven-failsafe-plugin - - - testing - 1 - 1 - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - testing - 1 - 1 - - - - - - - travis - - org.apache.maven.plugins - maven-failsafe-plugin - - - travis - 1 - 1 - - - - org.apache.maven.plugins maven-surefire-plugin diff --git a/run.sh b/run.sh new file mode 100755 index 00000000..79994498 --- /dev/null +++ b/run.sh @@ -0,0 +1,31 @@ +#!/opt/local/bin/bash + +export DATABASE_URL='jdbc:postgresql://localhost:5432/twitterwall2?user=twitterwall2&password=twitterwall2pwd' +export DATABASE_URL_TEST='jdbc:postgresql://localhost:5432/twitterwall2test?user=twitterwall2test&password=twitterwall2testpwd' +export TWITTERWALL_FRONTEND_MAX_RESULTS=200 +export TWITTERWALL_SHOW_USERS_MENU=true +export TWITTERWALL_CONTEXT_TEST=true +export TWITTER_PAGE_SIZE=500 +export TWITTER_FETCH_TESTDATA=false +export TWITTERWALL_WAIT_FOR_TEST=120000 +export TWITTERWALL_URL_TEST_DATA_VERBOSE=false +export TWITTERWALL_SCHEDULER_ALLOW_UPDATE_TWEETS=false +export TWITTERWALL_SCHEDULER_ALLOW_UPDATE_USERS=false +export TWITTERWALL_SCHEDULER_ALLOW_UPDATE_USERS_FROM_MENTION=false +export TWITTERWALL_SCHEDULER_ALLOW_REMOVE_OLD_DATA_FROM_STORAGE=false +export TWITTERWALL_SCHEDULER_ALLOW_SEARCH=false +export TWITTER_SEARCH_TERM='#hibernate OR #java OR #TYPO3' +export TWITTERWALL_INFO_WEBPAGE=https://github.com/phasenraum2010/twitterwall2 +export TWITTERWALL_THEME=typo3 +export TWITTERWALL_APP_NAME=Twitterwall +export TWITTERWALL_INFO_IMPRINT_SCREEN_NAME=port80guru +export TWITTERWALL_GOOGLE_ANALYTICS_ID=TWITTERWALL_GOOGLE_ANALYTICS_ID +export TWITTERWALL_SCHEDULER_HEROKU_DB_LIMIT=false +export TWITTERWALL_SCHEDULER_USER_LIST_NAME=test-typo3-hibernate-java +export TWITTERWALL_SCHEDULER_USER_LIST_ALLOW=false +export TWITTERWALL_JPA_HIBERNATE_DDL_AUTO=update +#export TWITTERWALL_JPA_HIBERNATE_DDL_AUTO=create-drop +export TWITTERWALL_LOGIN_USERNAME=tw +export TWITTERWALL_LOGIN_PASSWORD=vbfvjdgar64r67tf7a46tf76rgtfgf7d6g + +./mvnw clean spring-boot:run diff --git a/src/main/java/org/woehlke/twitterwall/CronJobs.java b/src/main/java/org/woehlke/twitterwall/CronJobs.java index e0ec4c4d..f6537905 100644 --- a/src/main/java/org/woehlke/twitterwall/CronJobs.java +++ b/src/main/java/org/woehlke/twitterwall/CronJobs.java @@ -21,7 +21,7 @@ public void createImprintUserAsync(){ String msg = "create Imprint User (Async) "; if(!schedulerProperties.getSkipFortesting()) { Task task = mqTaskStartFireAndForget.createImprintUserAsync(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -30,7 +30,7 @@ public void fetchTweetsFromTwitterSearch() { String msg = "fetch Tweets From TwitterSearch "; if((schedulerProperties.getAllowFetchTweetsFromTwitterSearch()) && (!schedulerProperties.getSkipFortesting())) { Task task = mqTaskStartFireAndForget.fetchTweetsFromSearch(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -39,7 +39,7 @@ public void fetchUsersFromDefinedUserList(){ String msg = "fetch Users from Defined User List "; if((schedulerProperties.getFetchUsersFromDefinedUserListAllow()) && (!schedulerProperties.getSkipFortesting())) { Task task = mqTaskStartFireAndForget.fetchUsersFromList(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -48,7 +48,7 @@ public void getHomeTimeline() { String msg = "get Home Timeline Tweets "; if((schedulerProperties.getAllowGetHomeTimeline()) && (!schedulerProperties.getSkipFortesting())) { Task task = mqTaskStartFireAndForget.getHomeTimeline(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -57,7 +57,7 @@ public void getUserTimeline() { String msg = " get User Timeline Tweets "; if((schedulerProperties.getAllowGetUserTimeline()) && (!schedulerProperties.getSkipFortesting())) { Task task = mqTaskStartFireAndForget.getUserTimeline(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -66,7 +66,7 @@ public void getMentions() { String msg = " get Mentions "; if((schedulerProperties.getAllowGetMentions()) && (!schedulerProperties.getSkipFortesting())) { Task task = mqTaskStartFireAndForget.getMentions(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -75,7 +75,7 @@ public void getFavorites() { String msg = " get Favorites "; if((schedulerProperties.getAllowGetFavorites()) && (!schedulerProperties.getSkipFortesting())) { Task task = mqTaskStartFireAndForget.getFavorites(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -84,7 +84,7 @@ public void getRetweetsOfMe() { String msg = " get Retweets Of Me "; if((schedulerProperties.getAllowGetRetweetsOfMe()) && (!schedulerProperties.getSkipFortesting())) { Task task = mqTaskStartFireAndForget.getRetweetsOfMe(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -93,9 +93,9 @@ public void getLists() { String msg = " get Lists "; if((schedulerProperties.getAllowGetLists()) && (!schedulerProperties.getSkipFortesting())) { Task task = mqTaskStartFireAndForget.getLists(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); task = mqTaskStartFireAndForget.fetchUserlistOwners(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -104,7 +104,7 @@ public void fetchFollower(){ String msg = "fetch Follower "; if((schedulerProperties.getFetchFollowerAllow()) && (!schedulerProperties.getSkipFortesting())) { Task task = mqTaskStartFireAndForget.fetchFollower(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -113,7 +113,7 @@ public void fetchFriends(){ String msg = "fetch Friends "; if((schedulerProperties.getFetchFriendsAllow()) && (!schedulerProperties.getSkipFortesting())) { Task task = mqTaskStartFireAndForget.fetchFriends(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -122,7 +122,7 @@ public void removeOldDataFromStorage(){ String msg = "remove Old Data From Storage: "; if((schedulerProperties.getRemoveOldDataFromStorageAllow()) && (!schedulerProperties.getSkipFortesting())) { Task task = mqTaskStartFireAndForget.removeOldDataFromStorage(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -131,7 +131,7 @@ public void updateUserProfilesFromMentions(){ String msg = "update User Profiles From Mentions"; if((schedulerProperties.getAllowUpdateUserProfilesFromMention()) && (!schedulerProperties.getSkipFortesting())) { Task task = mqTaskStartFireAndForget.updateUsersFromMentions(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -140,7 +140,7 @@ public void updateTweets() { String msg = "update Tweets "; if((schedulerProperties.getAllowUpdateTweets()) && (!schedulerProperties.getSkipFortesting())){ Task task = mqTaskStartFireAndForget.updateTweets(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -149,7 +149,7 @@ public void updateUserProfiles() { String msg = "update User Profiles "; if((schedulerProperties.getAllowUpdateUserProfiles()) && (!schedulerProperties.getSkipFortesting())) { Task task = mqTaskStartFireAndForget.updateUsers(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -158,7 +158,7 @@ public void startUpdateUrls(){ String msg = "start UpdateUrls "; if(!schedulerProperties.getSkipFortesting()) { Task task = mqTaskStartFireAndForget.startUpdateUrls(); - log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } @@ -168,7 +168,7 @@ public void startGarbageCollection(){ if(!schedulerProperties.getSkipFortesting()) { //TODO: //Task task = mqTaskStartFireAndForget.startGarbageCollection(); - //log.info(msg+ "SCHEDULED: task "+task.getUniqueId()); + //log.debug(msg+ "SCHEDULED: task "+task.getUniqueId()); } } diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/mentions/endpoint/serviceactivator/impl/MentionFinisherImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/mentions/endpoint/serviceactivator/impl/MentionFinisherImpl.java index e36169f0..5e5088cf 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/mentions/endpoint/serviceactivator/impl/MentionFinisherImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/mentions/endpoint/serviceactivator/impl/MentionFinisherImpl.java @@ -60,7 +60,7 @@ public void finishAsnyc(Message> incomingMessageList) { Task task = taskService.findById(taskId); String msgDone = "Sucessfully finished task "+task.getTaskType()+" via MQ by FIRE_AND_FORGET_SENDER"; taskService.done(msgDone,task,countedEntities); - log.info(msgDone); + log.debug(msgDone); } private final TaskService taskService; diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/mentions/endpoint/serviceactivator/impl/UpdateMentionWithUserImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/mentions/endpoint/serviceactivator/impl/UpdateMentionWithUserImpl.java index 02cac49b..1be798b9 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/mentions/endpoint/serviceactivator/impl/UpdateMentionWithUserImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/mentions/endpoint/serviceactivator/impl/UpdateMentionWithUserImpl.java @@ -1,7 +1,6 @@ package org.woehlke.twitterwall.backend.mq.mentions.endpoint.serviceactivator.impl; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import org.springframework.stereotype.Component; import org.woehlke.twitterwall.oodm.model.Mention; diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/mentions/endpoint/serviceactivator/impl/UserforMentionPersistorImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/mentions/endpoint/serviceactivator/impl/UserforMentionPersistorImpl.java index 9b5a1d50..fd4fb379 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/mentions/endpoint/serviceactivator/impl/UserforMentionPersistorImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/mentions/endpoint/serviceactivator/impl/UserforMentionPersistorImpl.java @@ -1,7 +1,6 @@ package org.woehlke.twitterwall.backend.mq.mentions.endpoint.serviceactivator.impl; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import org.springframework.stereotype.Component; import org.woehlke.twitterwall.oodm.model.Task; diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/tasks/impl/TaskStartFireAndForgetImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/tasks/impl/TaskStartFireAndForgetImpl.java index 2492e8aa..e5b2b233 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/tasks/impl/TaskStartFireAndForgetImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/tasks/impl/TaskStartFireAndForgetImpl.java @@ -156,7 +156,7 @@ public Task startFetchListsForUsers() { private Task send(TaskType taskType){ TaskSendType taskSendType = TaskSendType.FIRE_AND_FORGET; String msg = "START Task "+taskType+" via MQ by "+ taskSendType; - log.info(msg); + log.debug(msg); CountedEntities countedEntities = countedEntitiesService.countAll(); Task task = taskService.create(msg, taskType, taskSendType, countedEntities); diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/tasks/impl/TaskStartImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/tasks/impl/TaskStartImpl.java index 59ed0b58..6b624767 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/tasks/impl/TaskStartImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/tasks/impl/TaskStartImpl.java @@ -160,7 +160,7 @@ public Task startFetchListsForUsers() { private Task sendAndReceiveTask(TaskType taskType){ TaskSendType taskSendType = TaskSendType.SEND_AND_WAIT_FOR_RESULT; String logMsg = "Start task "+taskType+"via MQ by "+ taskSendType; - log.info(logMsg); + log.debug(logMsg); CountedEntities countedEntities = countedEntitiesService.countAll(); Task task = taskService.create("Start via MQ by Scheduler ", taskType, taskSendType,countedEntities); Message mqMessage = taskMessageBuilder.buildTaskMessage(task); @@ -185,7 +185,7 @@ private Task sendAndReceiveTask(TaskType taskType){ private Task sendAndReceiveUrl(TaskType taskType){ TaskSendType taskSendType = TaskSendType.SEND_AND_WAIT_FOR_RESULT; String logMsg = "Start task "+taskType+"via MQ by "+ taskSendType; - log.info(logMsg); + log.debug(logMsg); CountedEntities countedEntities = countedEntitiesService.countAll(); Task task = taskService.create("Start via MQ by Scheduler ", taskType, taskSendType,countedEntities); Message mqMessage = taskMessageBuilder.buildTaskMessage(task); @@ -210,7 +210,7 @@ private Task sendAndReceiveUrl(TaskType taskType){ private Task sendAndReceiveUserList(TaskType taskType){ TaskSendType taskSendType = TaskSendType.SEND_AND_WAIT_FOR_RESULT; String logMsg = "Start task "+taskType+"via MQ by "+ taskSendType; - log.info(logMsg); + log.debug(logMsg); CountedEntities countedEntities = countedEntitiesService.countAll(); Task task = taskService.create("Start via MQ by Scheduler ", taskType, taskSendType,countedEntities); Message mqMessage = taskMessageBuilder.buildTaskMessage(task); @@ -237,7 +237,7 @@ public User createImprintUser() { TaskType taskType = TaskType.CREATE_IMPRINT_USER; TaskSendType taskSendType = TaskSendType.SEND_AND_WAIT_FOR_RESULT; String logMsg = "Start task "+taskType+" via MQ by "+ taskSendType; - log.info(logMsg); + log.debug(logMsg); CountedEntities countedEntities = countedEntitiesService.countAll(); Task task = taskService.create("Start via MQ", taskType, taskSendType, countedEntities); TaskMessage taskMessage = new TaskMessage(task.getId(), taskType, taskSendType, task.getTimeStarted()); @@ -258,7 +258,7 @@ public User createImprintUser() { task = taskService.findById(taskId); logMsg = "Sucessfully finished task "+taskType+" via MQ by "+ taskSendType; taskService.done(logMsg, task, countedEntities); - log.info(logMsg); + log.debug(logMsg); return msg.getUser(); } else { logMsg = "Finished with Error: task "+taskType+" via MQ by "+ taskSendType +": Wrong type of returnedMessage"; @@ -271,7 +271,7 @@ public User createImprintUser() { private Task sendAndReceiveTweet(TaskType taskType){ TaskSendType taskSendType = TaskSendType.SEND_AND_WAIT_FOR_RESULT; String logMsg = "Start task "+taskType+"via MQ by "+ taskSendType; - log.info(logMsg); + log.debug(logMsg); CountedEntities countedEntities = countedEntitiesService.countAll(); Task task = taskService.create("Start via MQ by Scheduler ", taskType, taskSendType,countedEntities); Message mqMessage = taskMessageBuilder.buildTaskMessage(task); @@ -296,7 +296,7 @@ private Task sendAndReceiveTweet(TaskType taskType){ private Task sendAndReceiveUser(TaskType taskType){ TaskSendType taskSendType = TaskSendType.SEND_AND_WAIT_FOR_RESULT; String logMsg = "Start task "+taskType+"via MQ by "+ taskSendType;; - log.info(logMsg); + log.debug(logMsg); CountedEntities countedEntities = countedEntitiesService.countAll(); Task task = taskService.create(logMsg, taskType, taskSendType, countedEntities); Message mqMessage = taskMessageBuilder.buildTaskMessage(task); @@ -310,7 +310,7 @@ private Task sendAndReceiveUser(TaskType taskType){ task = taskService.findById(taskId); logMsg = "Sucessfully finished task "+taskType+"via MQ by "+ taskSendType; taskService.done(logMsg,task,countedEntities); - log.info(logMsg); + log.debug(logMsg); } else { logMsg = "Finished with Error: task "+taskType+"via MQ by "+ taskSendType +": Wrong type of returnedMessage"; taskService.finalError(task,logMsg,countedEntities); diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/tweets/endpoint/serviceactivator/impl/TweetFinisherImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/tweets/endpoint/serviceactivator/impl/TweetFinisherImpl.java index dd27a1c0..ad031094 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/tweets/endpoint/serviceactivator/impl/TweetFinisherImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/tweets/endpoint/serviceactivator/impl/TweetFinisherImpl.java @@ -51,7 +51,7 @@ public void finishAsnyc(Message> incomingMessageList) { Task task = taskService.findById(taskId); String msgDone = "Sucessfully finished task "+task.getTaskType()+" via MQ by FIRE_AND_FORGET_SENDER"; taskService.done(msgDone,task,countedEntities); - log.info(msgDone); + log.debug(msgDone); } @Autowired diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/urls/endpoint/services/impl/UrlFinisherImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/urls/endpoint/services/impl/UrlFinisherImpl.java index 61ec5852..81f17fbd 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/urls/endpoint/services/impl/UrlFinisherImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/urls/endpoint/services/impl/UrlFinisherImpl.java @@ -48,7 +48,7 @@ public void finishAsnyc(Message> incomingMessageList) { Task task = taskService.findById(taskId); String msgDone = "Sucessfully finished task "+task.getTaskType()+" via MQ by FIRE_AND_FORGET_SENDER"; taskService.done(msgDone,task,countedEntities); - log.info(msgDone); + log.debug(msgDone); } private final UrlMessageBuilder urlMessageBuilder; diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/UserListCollector.java b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/UserListCollector.java new file mode 100644 index 00000000..e25c6dee --- /dev/null +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/UserListCollector.java @@ -0,0 +1,13 @@ +package org.woehlke.twitterwall.backend.mq.userlist.endpoint.serviceactivator; + +import org.springframework.messaging.Message; +import org.woehlke.twitterwall.backend.mq.userlist.msg.UserListMessage; +import org.woehlke.twitterwall.backend.mq.users.msg.UserMessage; + +import java.util.List; + + +public interface UserListCollector { + + Message collectList(Message> incomingListOfUserMessage); +} diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/ListFinisherImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/ListFinisherImpl.java index 9d74c2fd..09089d64 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/ListFinisherImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/ListFinisherImpl.java @@ -50,7 +50,7 @@ public void finishAsnyc(Message> incomingMessageList) { Task task = taskService.findById(taskId); String msgDone = "Sucessfully finished task "+task.getTaskType()+" via MQ by FIRE_AND_FORGET_SENDER"; taskService.done(msgDone,task,countedEntities); - log.info(msgDone); + log.debug(msgDone); } @Autowired diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/ListsPersistorImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/ListsPersistorImpl.java index 2a573ae4..f8a1dc98 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/ListsPersistorImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/ListsPersistorImpl.java @@ -28,14 +28,20 @@ public ListsPersistorImpl(TaskService taskService, UserListService userListServi this.userListMessageBuilder = userListMessageBuilder; } - //TODO: #252 https://github.com/phasenraum2010/twitterwall2/issues/252 @Override public Message persistList(Message incomingMessage) { UserListMessage receivedMessage = incomingMessage.getPayload(); long taskId = receivedMessage.getTaskMessage().getTaskId(); Task task = taskService.findById(taskId); UserList userListOut = userListService.store(receivedMessage.getUserList(),task); - UserListMessage newUserListMsg = new UserListMessage(receivedMessage.getTaskMessage(),receivedMessage.getUserListTwitter(),userListOut); + UserListMessage newUserListMsg = new UserListMessage( + receivedMessage.getTaskMessage(), + receivedMessage.getUserListTwitter(), + userListOut, + receivedMessage.getIdTwitterOfThisUserList(), + receivedMessage.getIdTwitterOfListOwningUser(), + receivedMessage.getUserListType() + ); Message mqMessageOut = MessageBuilder.withPayload(newUserListMsg) .copyHeaders(incomingMessage.getHeaders()) .setHeader("persisted",Boolean.TRUE) diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/ListsTransformatorImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/ListsTransformatorImpl.java index 37d4d505..c5be8782 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/ListsTransformatorImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/ListsTransformatorImpl.java @@ -1,19 +1,32 @@ package org.woehlke.twitterwall.backend.mq.userlist.endpoint.serviceactivator.impl; import org.springframework.beans.factory.annotation.Autowired; -import org.springframework.integration.support.MessageBuilder; import org.springframework.messaging.Message; import org.springframework.stereotype.Component; import org.woehlke.twitterwall.oodm.model.Task; +import org.woehlke.twitterwall.oodm.model.parts.UserListType; import org.woehlke.twitterwall.oodm.service.TaskService; import org.woehlke.twitterwall.backend.mq.userlist.endpoint.serviceactivator.ListsTransformator; import org.woehlke.twitterwall.backend.mq.userlist.msg.UserListMessage; import org.woehlke.twitterwall.backend.mq.userlist.msg.UserListMessageBuilder; import org.woehlke.twitterwall.backend.service.transform.UserListTransformService; + @Component("mqUserListTransformator") public class ListsTransformatorImpl implements ListsTransformator { + + @Override + public Message transformList(Message incomingMessage) { + long taskId = incomingMessage.getPayload().getTaskMessage().getTaskId(); + Task task = taskService.findById(taskId); + UserListType userListType = incomingMessage.getPayload().getUserListType(); + org.woehlke.twitterwall.oodm.model.UserList userListOut = userListTransformService.transform(incomingMessage.getPayload().getUserListTwitter(),task); + Message mqMessageOut = userListMessageBuilder.buildUserListMessageForTransformedUser(incomingMessage,userListOut,userListType); + return mqMessageOut; + } + + private final TaskService taskService; private final UserListTransformService userListTransformService; @@ -26,18 +39,4 @@ public ListsTransformatorImpl(TaskService taskService, UserListTransformService this.userListTransformService = userListTransformService; this.userListMessageBuilder = userListMessageBuilder; } - - //TODO: #252 https://github.com/phasenraum2010/twitterwall2/issues/252 - @Override - public Message transformList(Message incomingMessage) { - long taskId = incomingMessage.getPayload().getTaskMessage().getTaskId(); - Task task = taskService.findById(taskId); - org.woehlke.twitterwall.oodm.model.UserList userListOut = userListTransformService.transform(incomingMessage.getPayload().getUserListTwitter(),task); - UserListMessage retVal = new UserListMessage(incomingMessage.getPayload().getTaskMessage(),incomingMessage.getPayload().getUserListTwitter(),userListOut); - Message mqMessageOut = MessageBuilder.withPayload(retVal) - .copyHeaders(incomingMessage.getHeaders()) - .setHeader("transformed",Boolean.TRUE) - .build(); - return mqMessageOut; - } } diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/UserListCollectorImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/UserListCollectorImpl.java new file mode 100644 index 00000000..3d271a78 --- /dev/null +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/serviceactivator/impl/UserListCollectorImpl.java @@ -0,0 +1,78 @@ +package org.woehlke.twitterwall.backend.mq.userlist.endpoint.serviceactivator.impl; + +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.integration.support.MessageBuilder; +import org.springframework.messaging.Message; +import org.springframework.stereotype.Component; +import org.woehlke.twitterwall.backend.mq.tasks.TaskMessage; +import org.woehlke.twitterwall.backend.mq.userlist.endpoint.serviceactivator.UserListCollector; +import org.woehlke.twitterwall.backend.mq.userlist.msg.UserListMessage; +import org.woehlke.twitterwall.backend.mq.users.msg.UserMessage; +import org.woehlke.twitterwall.backend.mq.users.msg.UserMessageBuilder; +import org.woehlke.twitterwall.oodm.model.Task; +import org.woehlke.twitterwall.oodm.model.User; +import org.woehlke.twitterwall.oodm.model.UserList; +import org.woehlke.twitterwall.oodm.model.parts.UserListType; +import org.woehlke.twitterwall.oodm.service.TaskService; +import org.woehlke.twitterwall.oodm.service.UserListService; +import org.woehlke.twitterwall.oodm.service.UserService; + +import java.util.List; + +@Component("mqUserListCollector") +public class UserListCollectorImpl implements UserListCollector { + + + @Override + public Message collectList(Message> incomingListOfUserMessage) { + long idTwitterOfListOwningUser = (Long)incomingListOfUserMessage.getHeaders().get("idTwitterOfListOwningUser"); + long taskId = (Long)incomingListOfUserMessage.getHeaders().get("taskId"); + Task task = taskService.findById(taskId); + User user = userService.findByIdTwitter(idTwitterOfListOwningUser); + TaskMessage incomingTaskMessage = null; + List in = incomingListOfUserMessage.getPayload(); + for(UserListMessage msgIn :in){ + UserListType userListType = msgIn.getUserListType(); + UserList userList = msgIn.getUserList(); + incomingTaskMessage = msgIn.getTaskMessage(); + switch (userListType){ + case USERS_OWN_LIST: + user.getOwnLists().add(userList); + userList.setListOwner(user); + break; + case USER_IS_MEMBER: + user.getUserListMemberships().add(userList); + userList.getMembers().add(user); + break; + case USER_IS_SUBSCRIBER: + user.getUserListSubcriptions().add(userList); + userList.getSubscriber().add(user); + break; + } + userListService.store(userList,task); + } + userService.store(user,task); + UserMessage outMsgPayload = new UserMessage(incomingTaskMessage, idTwitterOfListOwningUser); + Message mqMessageOut = + MessageBuilder.withPayload(outMsgPayload) + .copyHeaders(incomingListOfUserMessage.getHeaders()) + .build(); + return mqMessageOut; + } + + private final UserService userService; + + private final UserListService userListService; + + private final TaskService taskService; + + private final UserMessageBuilder userMessageBuilder; + + @Autowired + public UserListCollectorImpl(UserService userService, UserListService userListService, TaskService taskService, UserMessageBuilder userMessageBuilder) { + this.userService = userService; + this.userListService = userListService; + this.taskService = taskService; + this.userMessageBuilder = userMessageBuilder; + } +} diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/splitter/impl/FetchUserListsForUsersImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/splitter/impl/FetchUserListsForUsersImpl.java index 43d7d458..547e3f5e 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/splitter/impl/FetchUserListsForUsersImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/splitter/impl/FetchUserListsForUsersImpl.java @@ -2,43 +2,53 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.messaging.Message; +import org.springframework.social.twitter.api.UserList; import org.springframework.stereotype.Component; import org.woehlke.twitterwall.backend.mq.userlist.endpoint.splitter.FetchUserListsForUsers; import org.woehlke.twitterwall.backend.mq.userlist.msg.UserListMessage; import org.woehlke.twitterwall.backend.mq.userlist.msg.UserListMessageBuilder; import org.woehlke.twitterwall.backend.mq.users.msg.UserMessage; import org.woehlke.twitterwall.backend.service.remote.TwitterApiService; -import org.woehlke.twitterwall.oodm.service.CountedEntitiesService; -import org.woehlke.twitterwall.oodm.service.TaskService; -import org.woehlke.twitterwall.oodm.service.UserService; +import org.woehlke.twitterwall.oodm.model.parts.User2UserList; +import org.woehlke.twitterwall.oodm.model.parts.UserListType; +import java.util.ArrayList; import java.util.List; @Component("mqFetchUserListsForUsers") public class FetchUserListsForUsersImpl implements FetchUserListsForUsers { - @Override - public List> splitUserListMessage(Message incomingTaskMessage) { - return null; + public List> splitUserListMessage(Message incomingUserMessage) { + List> result = new ArrayList<>(); + UserMessage in = incomingUserMessage.getPayload(); + long userIdTwitter = in.getTwitterProfileId(); + User2UserList user2UserList = twitterApiService.getUserListForUser(userIdTwitter); + for(UserList userList:user2UserList.getOwnLists()){ + UserListType type = UserListType.USERS_OWN_LIST; + Message out = userListMessageBuilder.buildUserListMessageFromUser(incomingUserMessage,userList,userIdTwitter,type); + result.add(out); + } + for(UserList userList:user2UserList.getUserListMemberships()){ + UserListType type = UserListType.USER_IS_MEMBER; + Message out = userListMessageBuilder.buildUserListMessageFromUser(incomingUserMessage,userList,userIdTwitter,type); + result.add(out); + } + for(UserList userList:user2UserList.getUserListSubcriptions()){ + UserListType type = UserListType.USER_IS_SUBSCRIBER; + Message out = userListMessageBuilder.buildUserListMessageFromUser(incomingUserMessage,userList,userIdTwitter,type); + result.add(out); + } + return result; } private final TwitterApiService twitterApiService; - private final TaskService taskService; - - private final UserService userService; - - private final CountedEntitiesService countedEntitiesService; - private final UserListMessageBuilder userListMessageBuilder; @Autowired - public FetchUserListsForUsersImpl(TwitterApiService twitterApiService, TaskService taskService, UserService userService, CountedEntitiesService countedEntitiesService, UserListMessageBuilder userListMessageBuilder) { + public FetchUserListsForUsersImpl(TwitterApiService twitterApiService, UserListMessageBuilder userListMessageBuilder) { this.twitterApiService = twitterApiService; - this.taskService = taskService; - this.userService = userService; - this.countedEntitiesService = countedEntitiesService; this.userListMessageBuilder = userListMessageBuilder; } } diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/splitter/impl/ListsSplitterImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/splitter/impl/ListsSplitterImpl.java index cc3ffb05..f484ecbb 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/splitter/impl/ListsSplitterImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/endpoint/splitter/impl/ListsSplitterImpl.java @@ -6,6 +6,8 @@ import org.springframework.stereotype.Component; import org.woehlke.twitterwall.oodm.model.Task; import org.woehlke.twitterwall.oodm.model.parts.CountedEntities; +import org.woehlke.twitterwall.oodm.model.parts.User2UserList; +import org.woehlke.twitterwall.oodm.model.parts.UserListType; import org.woehlke.twitterwall.oodm.service.CountedEntitiesService; import org.woehlke.twitterwall.oodm.service.TaskService; import org.woehlke.twitterwall.backend.mq.userlist.endpoint.splitter.ListsSplitter; @@ -44,12 +46,35 @@ public List> splitUserListMessage(Message long id = msgIn.getTaskId(); Task task = taskService.findById(id); task = taskService.start(task,countedEntities); - List fetchedUserList = twitterApiService.getLists(); - int loopId = 0; - int loopAll = fetchedUserList.size(); - for (UserList userList: fetchedUserList) { - loopId++; - Message mqMessageOut = userListMessageBuilder.buildUserListMessage(incomingTaskMessage,userList,loopId,loopAll); + User2UserList fetchedUserList = twitterApiService.getLists(); + for (UserList userList: fetchedUserList.getOwnLists()) { + UserListType type = UserListType.USERS_OWN_LIST; + Message mqMessageOut = userListMessageBuilder.buildUserListMessageFromTask( + incomingTaskMessage, + userList, + fetchedUserList.getIdTwitterOfListOwningUser(), + type + ); + messageListOut.add(mqMessageOut); + } + for (UserList userList: fetchedUserList.getUserListSubcriptions()) { + UserListType type = UserListType.USER_IS_SUBSCRIBER; + Message mqMessageOut = userListMessageBuilder.buildUserListMessageFromTask( + incomingTaskMessage, + userList, + fetchedUserList.getIdTwitterOfListOwningUser(), + type + ); + messageListOut.add(mqMessageOut); + } + for (UserList userList: fetchedUserList.getUserListMemberships()) { + UserListType type = UserListType.USER_IS_MEMBER; + Message mqMessageOut = userListMessageBuilder.buildUserListMessageFromTask( + incomingTaskMessage, + userList, + fetchedUserList.getIdTwitterOfListOwningUser(), + type + ); messageListOut.add(mqMessageOut); } return messageListOut; diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/msg/UserListMessage.java b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/msg/UserListMessage.java index 36f3ae7b..e288c7a1 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/msg/UserListMessage.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/msg/UserListMessage.java @@ -2,6 +2,7 @@ import org.springframework.social.twitter.api.UserList; import org.woehlke.twitterwall.backend.mq.tasks.TaskMessage; +import org.woehlke.twitterwall.oodm.model.parts.UserListType; import java.io.Serializable; @@ -10,34 +11,36 @@ public class UserListMessage implements Serializable { private final TaskMessage taskMessage; private final org.springframework.social.twitter.api.UserList userListTwitter; private final org.woehlke.twitterwall.oodm.model.UserList userList; - private final long idTwitter; + private final long idTwitterOfThisUserList; + private final long idTwitterOfListOwningUser; + private final UserListType userListType; - public UserListMessage(TaskMessage taskMessage, UserList userListTwitter, long idTwitter) { + + public UserListMessage(TaskMessage taskMessage, UserList userListTwitter, long idTwitterOfThisUserList, long idTwitterOfListOwningUser, UserListType userListType) { this.taskMessage = taskMessage; this.userListTwitter = userListTwitter; - this.idTwitter = idTwitter; + this.idTwitterOfThisUserList = idTwitterOfThisUserList; this.userList = null; + this.idTwitterOfListOwningUser = idTwitterOfListOwningUser; + this.userListType = userListType; } - public UserListMessage(TaskMessage taskMessage, UserList userListTwitter, org.woehlke.twitterwall.oodm.model.UserList userList, long idTwitter) { + public UserListMessage(TaskMessage taskMessage, UserList userListTwitter, org.woehlke.twitterwall.oodm.model.UserList userList, long idTwitterOfThisUserList, long idTwitterOfListOwningUser, UserListType userListType) { this.taskMessage = taskMessage; this.userListTwitter = userListTwitter; this.userList = userList; - this.idTwitter = idTwitter; + this.idTwitterOfThisUserList = idTwitterOfThisUserList; + this.idTwitterOfListOwningUser = idTwitterOfListOwningUser; + this.userListType = userListType; } - public UserListMessage(TaskMessage taskMessage, UserList userListTwitter) { + public UserListMessage(TaskMessage taskMessage, UserList userListTwitter, long idTwitterOfListOwningUser, UserListType userListType) { this.taskMessage = taskMessage; this.userListTwitter = userListTwitter; this.userList = null; - this.idTwitter = userListTwitter.getId(); - } - - public UserListMessage(TaskMessage taskMessage, UserList userListTwitter, org.woehlke.twitterwall.oodm.model.UserList userListOut) { - this.taskMessage = taskMessage; - this.userListTwitter = userListTwitter; - this.userList = userListOut; - this.idTwitter = userListTwitter.getId(); + this.idTwitterOfThisUserList = userListTwitter.getId(); + this.idTwitterOfListOwningUser = idTwitterOfListOwningUser; + this.userListType = userListType; } public TaskMessage getTaskMessage() { @@ -52,8 +55,16 @@ public org.woehlke.twitterwall.oodm.model.UserList getUserList() { return userList; } - public long getIdTwitter() { - return idTwitter; + public long getIdTwitterOfThisUserList() { + return idTwitterOfThisUserList; + } + + public long getIdTwitterOfListOwningUser() { + return idTwitterOfListOwningUser; + } + + public UserListType getUserListType() { + return userListType; } @Override @@ -63,30 +74,35 @@ public boolean equals(Object o) { UserListMessage that = (UserListMessage) o; - if (getIdTwitter() != that.getIdTwitter()) return false; - if (getTaskMessage() != null ? !getTaskMessage().equals(that.getTaskMessage()) : that.getTaskMessage() != null) - return false; - if (getUserListTwitter() != null ? !getUserListTwitter().equals(that.getUserListTwitter()) : that.getUserListTwitter() != null) + if (idTwitterOfThisUserList != that.idTwitterOfThisUserList) return false; + if (idTwitterOfListOwningUser != that.idTwitterOfListOwningUser) return false; + if (taskMessage != null ? !taskMessage.equals(that.taskMessage) : that.taskMessage != null) return false; + if (userListTwitter != null ? !userListTwitter.equals(that.userListTwitter) : that.userListTwitter != null) return false; - return getUserList() != null ? getUserList().equals(that.getUserList()) : that.getUserList() == null; + if (userList != null ? !userList.equals(that.userList) : that.userList != null) return false; + return userListType == that.userListType; } @Override public int hashCode() { - int result = getTaskMessage() != null ? getTaskMessage().hashCode() : 0; - result = 31 * result + (getUserListTwitter() != null ? getUserListTwitter().hashCode() : 0); - result = 31 * result + (getUserList() != null ? getUserList().hashCode() : 0); - result = 31 * result + (int) (getIdTwitter() ^ (getIdTwitter() >>> 32)); + int result = taskMessage != null ? taskMessage.hashCode() : 0; + result = 31 * result + (userListTwitter != null ? userListTwitter.hashCode() : 0); + result = 31 * result + (userList != null ? userList.hashCode() : 0); + result = 31 * result + (int) (idTwitterOfThisUserList ^ (idTwitterOfThisUserList >>> 32)); + result = 31 * result + (int) (idTwitterOfListOwningUser ^ (idTwitterOfListOwningUser >>> 32)); + result = 31 * result + (userListType != null ? userListType.hashCode() : 0); return result; } @Override public String toString() { return "UserListMessage{" + - "taskMessage=" + taskMessage + - ", userListTwitter=" + userListTwitter + - ", userList=" + userList + - ", idTwitter=" + idTwitter + - '}'; + "taskMessage=" + taskMessage + + ", userListTwitter=" + userListTwitter + + ", userList=" + userList + + ", idTwitterOfThisUserList=" + idTwitterOfThisUserList + + ", idTwitterOfListOwningUser=" + idTwitterOfListOwningUser + + ", userListType=" + userListType + + '}'; } } diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/msg/UserListMessageBuilder.java b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/msg/UserListMessageBuilder.java index f463babd..864bb965 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/msg/UserListMessageBuilder.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/msg/UserListMessageBuilder.java @@ -3,9 +3,14 @@ import org.springframework.messaging.Message; import org.springframework.social.twitter.api.UserList; import org.woehlke.twitterwall.backend.mq.tasks.TaskMessage; +import org.woehlke.twitterwall.backend.mq.users.msg.UserMessage; +import org.woehlke.twitterwall.oodm.model.parts.UserListType; public interface UserListMessageBuilder { - Message buildUserListMessage(Message incomingTaskMessage, UserList userList, int loopId, int loopAll); + Message buildUserListMessageFromUser(Message incomingUserMessage, UserList userList, long userIdTwitter,UserListType type); + Message buildUserListMessageFromTask(Message incomingUserMessage, UserList userList, long userIdTwitter, UserListType type); + + Message buildUserListMessageForTransformedUser(Message incomingMessage, org.woehlke.twitterwall.oodm.model.UserList userListOut,UserListType type); } diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/msg/impl/UserListMessageBuilderImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/msg/impl/UserListMessageBuilderImpl.java index 1dbc6454..21f2c9ff 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/msg/impl/UserListMessageBuilderImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/userlist/msg/impl/UserListMessageBuilderImpl.java @@ -7,20 +7,44 @@ import org.woehlke.twitterwall.backend.mq.tasks.TaskMessage; import org.woehlke.twitterwall.backend.mq.userlist.msg.UserListMessage; import org.woehlke.twitterwall.backend.mq.userlist.msg.UserListMessageBuilder; +import org.woehlke.twitterwall.backend.mq.users.msg.UserMessage; +import org.woehlke.twitterwall.oodm.model.parts.UserListType; @Component public class UserListMessageBuilderImpl implements UserListMessageBuilder { @Override - public Message buildUserListMessage(Message incomingTaskMessage, UserList userList, int loopId, int loopAll) { - UserListMessage outputPayload = new UserListMessage(incomingTaskMessage.getPayload(),userList); + public Message buildUserListMessageFromUser(Message incomingUserMessage, UserList userList, long idTwitterOfListOwningUser,UserListType type) { + UserListMessage outputPayload = new UserListMessage(incomingUserMessage.getPayload().getTaskMessage(), userList, idTwitterOfListOwningUser, type); Message mqMessageOut = MessageBuilder.withPayload(outputPayload) - .copyHeaders(incomingTaskMessage.getHeaders()) - .setHeader("loop_id",loopId) - .setHeader("loop_all",loopAll) + .copyHeaders(incomingUserMessage.getHeaders()) + .setHeader("idTwitterOfListOwningUser",idTwitterOfListOwningUser) .build(); return mqMessageOut; } + @Override + public Message buildUserListMessageFromTask(Message incomingUserMessage, UserList userList, long idTwitterOfListOwningUser, UserListType type) { + UserListMessage outputPayload = new UserListMessage(incomingUserMessage.getPayload(), userList, idTwitterOfListOwningUser, type); + Message mqMessageOut = + MessageBuilder.withPayload(outputPayload) + .copyHeaders(incomingUserMessage.getHeaders()) + .setHeader("idTwitterOfListOwningUser",idTwitterOfListOwningUser) + .build(); + return mqMessageOut; + } + + @Override + public Message buildUserListMessageForTransformedUser(Message incomingMessage, org.woehlke.twitterwall.oodm.model.UserList userListOut,UserListType type) { + long idTwitterOfThisUserList = incomingMessage.getPayload().getIdTwitterOfThisUserList(); + long idTwitterOfListOwningUser = incomingMessage.getPayload().getIdTwitterOfListOwningUser(); + UserListMessage retVal = new UserListMessage(incomingMessage.getPayload().getTaskMessage(),incomingMessage.getPayload().getUserListTwitter(),userListOut,idTwitterOfThisUserList, idTwitterOfListOwningUser, type); + Message mqMessageOut = MessageBuilder.withPayload(retVal) + .copyHeaders(incomingMessage.getHeaders()) + .setHeader("transformed",Boolean.TRUE) + .build(); + return mqMessageOut; + } + } diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/users/endpoint/serviceactivator/impl/UserFinisherImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/users/endpoint/serviceactivator/impl/UserFinisherImpl.java index 0f078e16..e94297e3 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/users/endpoint/serviceactivator/impl/UserFinisherImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/users/endpoint/serviceactivator/impl/UserFinisherImpl.java @@ -51,7 +51,7 @@ public void finishAsnyc(Message> incomingMessageList) { Task task = taskService.findById(taskId); String msgDone = "Sucessfully finished task "+task.getTaskType()+" via MQ by FIRE_AND_FORGET_SENDER"; taskService.done(msgDone,task,countedEntities); - log.info(msgDone); + log.debug(msgDone); } @Override @@ -61,7 +61,7 @@ public void finishOneUserAsnyc(Message incomingMessage) { Task task = taskService.findById(taskId); String msgDone = "Sucessfully finished task "+task.getTaskType()+" via MQ by FIRE_AND_FORGET_SENDER"; taskService.done(msgDone,task,countedEntities); - log.info(msgDone); + log.debug(msgDone); } @Autowired diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/users/endpoint/splitter/impl/FetchListsForUsersImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/users/endpoint/splitter/impl/FetchListsForUsersImpl.java index f2b21f3b..d3e29519 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/users/endpoint/splitter/impl/FetchListsForUsersImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/users/endpoint/splitter/impl/FetchListsForUsersImpl.java @@ -4,13 +4,16 @@ import org.springframework.messaging.Message; import org.springframework.stereotype.Component; import org.woehlke.twitterwall.backend.mq.tasks.TaskMessage; -import org.woehlke.twitterwall.backend.mq.userlist.msg.UserListMessageBuilder; import org.woehlke.twitterwall.backend.mq.users.endpoint.splitter.FetchListsForUsers; import org.woehlke.twitterwall.backend.mq.users.msg.UserMessage; +import org.woehlke.twitterwall.backend.mq.users.msg.UserMessageBuilder; +import org.woehlke.twitterwall.oodm.model.Task; +import org.woehlke.twitterwall.oodm.model.parts.CountedEntities; import org.woehlke.twitterwall.oodm.service.CountedEntitiesService; import org.woehlke.twitterwall.oodm.service.TaskService; import org.woehlke.twitterwall.oodm.service.UserService; +import java.util.ArrayList; import java.util.List; @Component("mqFetchListsForUsers") @@ -19,7 +22,20 @@ public class FetchListsForUsersImpl implements FetchListsForUsers { @Override public List> splitUserMessage(Message incomingTaskMessage) { - return null; + TaskMessage in = incomingTaskMessage.getPayload(); + Task task = taskService.findById(in.getTaskId()); + CountedEntities counted = countedEntitiesService.countAll(); + task = taskService.start(task,counted); + List> result = new ArrayList<>(); + List idTwitterOfAllUsers = userService.getIdTwitterOfAllUsers(); + int loopId = 0; + int loopAll = idTwitterOfAllUsers.size(); + for(long userIdTwitter:idTwitterOfAllUsers){ + loopId++; + Message out = userMessageBuilder.buildUserMessageForUser(incomingTaskMessage,userIdTwitter,loopId,loopAll); + result.add(out); + } + return result; } private final TaskService taskService; @@ -28,14 +44,14 @@ public List> splitUserMessage(Message incoming private final CountedEntitiesService countedEntitiesService; - private final UserListMessageBuilder userListMessageBuilder; + private final UserMessageBuilder userMessageBuilder; @Autowired - public FetchListsForUsersImpl(TaskService taskService, UserService userService, CountedEntitiesService countedEntitiesService, UserListMessageBuilder userListMessageBuilder) { + public FetchListsForUsersImpl(TaskService taskService, UserService userService, CountedEntitiesService countedEntitiesService, UserMessageBuilder userMessageBuilder) { this.taskService = taskService; this.userService = userService; this.countedEntitiesService = countedEntitiesService; - this.userListMessageBuilder = userListMessageBuilder; + this.userMessageBuilder = userMessageBuilder; } } diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/users/msg/UserMessageBuilder.java b/src/main/java/org/woehlke/twitterwall/backend/mq/users/msg/UserMessageBuilder.java index d1a9b568..42393902 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/users/msg/UserMessageBuilder.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/users/msg/UserMessageBuilder.java @@ -21,4 +21,5 @@ public interface UserMessageBuilder { Message buildUserMessage(Message mqMessageIn, User imprintUser); + Message buildUserMessageForUser(Message incomingTaskMessage, long userIdTwitter, int loopId, int loopAll); } diff --git a/src/main/java/org/woehlke/twitterwall/backend/mq/users/msg/impl/UserMessageBuilderImpl.java b/src/main/java/org/woehlke/twitterwall/backend/mq/users/msg/impl/UserMessageBuilderImpl.java index 86c8814e..b9e87996 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/mq/users/msg/impl/UserMessageBuilderImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/mq/users/msg/impl/UserMessageBuilderImpl.java @@ -18,8 +18,7 @@ public Message buildUserMessage(Message incomingTaskMe Message mqMessageOut = MessageBuilder.withPayload(outputPayload) .copyHeaders(incomingTaskMessage.getHeaders()) - .setHeader("loop_id",loopId) - .setHeader("loop_all",loopAll) + .setHeader("taskId",incomingTaskMessage.getPayload().getTaskId()) .build(); return mqMessageOut; } @@ -30,8 +29,7 @@ public Message buildUserMessage(Message incomingTaskMe Message mqMessageOut = MessageBuilder.withPayload(outputPayload) .copyHeaders(incomingTaskMessage.getHeaders()) - .setHeader("loop_id",loopId) - .setHeader("loop_all",loopAll) + .setHeader("taskId",incomingTaskMessage.getPayload().getTaskId()) .build(); return mqMessageOut; } @@ -42,8 +40,7 @@ public Message buildUserMessage(Message incomingTaskMe Message mqMessageOut = MessageBuilder.withPayload(outputPayload) .copyHeaders(incomingTaskMessage.getHeaders()) - .setHeader("loop_id",loopId) - .setHeader("loop_all",loopAll) + .setHeader("taskId",incomingTaskMessage.getPayload().getTaskId()) .build(); return mqMessageOut; } @@ -76,6 +73,7 @@ public Message buildUserMessage(Message incomingMessag Message mqMessageOut = MessageBuilder.withPayload(outputPayload) .copyHeaders(incomingMessage.getHeaders()) + .setHeader("taskId",incomingMessage.getPayload().getTaskId()) .setHeader("twitter_profile_id", twitterProfile.getId()) .build(); return mqMessageOut; @@ -87,10 +85,23 @@ public Message buildUserMessage(Message incomingMessag Message mqMessageOut = MessageBuilder.withPayload(outputPayload) .copyHeaders(incomingMessage.getHeaders()) + .setHeader("taskId",incomingMessage.getPayload().getTaskId()) .setHeader("twitter_profile_id", imprintUser.getIdTwitter()) .build(); return mqMessageOut; } + @Override + public Message buildUserMessageForUser(Message incomingTaskMessage, long userIdTwitter, int loopId, int loopAll) { + UserMessage outputPayload = new UserMessage(incomingTaskMessage.getPayload(),userIdTwitter); + Message mqMessageOut = + MessageBuilder.withPayload(outputPayload) + .copyHeaders(incomingTaskMessage.getHeaders()) + .setHeader("taskId",incomingTaskMessage.getPayload().getTaskId()) + .setHeader("userIdTwitter",userIdTwitter) + .build(); + return mqMessageOut; + } + } diff --git a/src/main/java/org/woehlke/twitterwall/backend/service/persist/impl/StoreEntitiesProcessImpl.java b/src/main/java/org/woehlke/twitterwall/backend/service/persist/impl/StoreEntitiesProcessImpl.java index 3e6dde5d..d3cfa6ef 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/service/persist/impl/StoreEntitiesProcessImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/service/persist/impl/StoreEntitiesProcessImpl.java @@ -23,28 +23,33 @@ public class StoreEntitiesProcessImpl implements StoreEntitiesProcess { @Override public Entities storeEntitiesProcessForTweet(Tweet tweet, Task task) { Entities entities = tweet.getEntities(); - entities = storeEntitiesProcess(entities,task); + entities = storeEntitiesProcess(entities, task); return entities; } @Override public Entities storeEntitiesProcessForUser(User user, Task task) { - Entities entities = user.getEntities(); - entities = storeEntitiesProcess(entities,task); + Entities entities = user.getEntities(); + entities = storeEntitiesProcess(entities, task); return entities; } @Override public Entities updateEntitiesForUserProcess(User user, Task task) { + String msg = "updateEntitiesForUserProcess " + user.getUniqueId() + " : "+task.getUniqueId() + " : "; long userId = user.getId(); long userIdTwitter = user.getIdTwitter(); Set newMentions = new HashSet<>(); Set mentions = user.getEntities().getMentions(); - for(Mention mention:mentions){ + for (Mention mention : mentions) { mention.setIdTwitterOfUser(userIdTwitter); mention.setIdOfUser(userId); - mention = mentionService.store(mention,task); - newMentions.add(mention); + try { + mention = mentionService.store(mention, task); + newMentions.add(mention); + } catch (Exception e) { + log.debug(msg + e.getMessage()); + } } user.getEntities().removeAllMentions(); user.getEntities().addAllMentions(newMentions); @@ -53,7 +58,7 @@ public Entities updateEntitiesForUserProcess(User user, Task task) { @Override public Entities storeEntitiesProcess(Entities entities, Task task) { - String msg = "storeEntitiesProcess "+task.getUniqueId()+" : "; + String msg = "storeEntitiesProcess " + task.getUniqueId() + " : "; try { Set urls = new LinkedHashSet<>(); Set hashTags = new LinkedHashSet(); @@ -62,41 +67,61 @@ public Entities storeEntitiesProcess(Entities entities, Task task) { Set tickerSymbols = new LinkedHashSet(); for (Url myUrl : entities.getUrls()) { if (myUrl.isValid()) { - Url urlPers = urlService.store(myUrl,task); - if(urlPers != null) { - urls.add(urlPers); + try { + Url urlPers = urlService.store(myUrl, task); + if (urlPers != null) { + urls.add(urlPers); + } + } catch (Exception e) { + log.debug(msg + e.getMessage()); } } } for (HashTag hashTag : entities.getHashTags()) { if (hashTag.isValid()) { - HashTag hashTagPers = hashTagService.store(hashTag, task); - if (hashTagPers != null) { - hashTags.add(hashTagPers); + try { + HashTag hashTagPers = hashTagService.store(hashTag, task); + if (hashTagPers != null) { + hashTags.add(hashTagPers); + } + } catch (Exception e) { + log.debug(msg + e.getMessage()); } } } for (Mention mention : entities.getMentions()) { if (mention.isValid()) { - Mention mentionPers = mentionService.store(mention, task); - if(mentionPers!= null){ - mentions.add(mentionPers); + try { + Mention mentionPers = mentionService.store(mention, task); + if (mentionPers != null) { + mentions.add(mentionPers); + } + } catch (Exception e) { + log.debug(msg + e.getMessage()); } } } for (Media medium : entities.getMedia()) { if (medium.isValid()) { - Media mediumPers = mediaService.store(medium, task); - if (mediumPers != null) { - media.add(mediumPers); + try { + Media mediumPers = mediaService.store(medium, task); + if (mediumPers != null) { + media.add(mediumPers); + } + } catch (Exception e) { + log.debug(msg + e.getMessage()); } } } for (TickerSymbol tickerSymbol : entities.getTickerSymbols()) { if (tickerSymbol.isValid()) { - TickerSymbol tickerSymbolPers = tickerSymbolService.store(tickerSymbol, task); - if(tickerSymbolPers != null){ - tickerSymbols.add(tickerSymbolPers); + try { + TickerSymbol tickerSymbolPers = tickerSymbolService.store(tickerSymbol, task); + if (tickerSymbolPers != null) { + tickerSymbols.add(tickerSymbolPers); + } + } catch (Exception e) { + log.debug(msg + e.getMessage()); } } } @@ -105,8 +130,8 @@ public Entities storeEntitiesProcess(Entities entities, Task task) { entities.setMentions(mentions); entities.setMedia(media); entities.setTickerSymbols(tickerSymbols); - } catch (Exception e){ - log.error(msg+e.getMessage()); + } catch (Exception e) { + log.warn(msg + e.getMessage()); } return entities; } diff --git a/src/main/java/org/woehlke/twitterwall/backend/service/persist/impl/StoreOneTweetPerformImpl.java b/src/main/java/org/woehlke/twitterwall/backend/service/persist/impl/StoreOneTweetPerformImpl.java index 06a0878d..b3d92563 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/service/persist/impl/StoreOneTweetPerformImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/service/persist/impl/StoreOneTweetPerformImpl.java @@ -40,7 +40,7 @@ public Tweet storeOneTweetPerform(Tweet tweet, Task task){ tweet = tweetService.store(tweet, task); log.debug(msg + "tweetService.store: " + tweet.getUniqueId()); } catch (Exception e){ - log.error(msg+e.getMessage()); + log.info(msg+e.getMessage()); } return tweet; } diff --git a/src/main/java/org/woehlke/twitterwall/backend/service/remote/TwitterApiService.java b/src/main/java/org/woehlke/twitterwall/backend/service/remote/TwitterApiService.java index 84a91c52..87fff6ba 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/service/remote/TwitterApiService.java +++ b/src/main/java/org/woehlke/twitterwall/backend/service/remote/TwitterApiService.java @@ -3,7 +3,7 @@ import org.springframework.social.twitter.api.CursoredList; import org.springframework.social.twitter.api.Tweet; import org.springframework.social.twitter.api.TwitterProfile; -import org.springframework.social.twitter.api.UserList; +import org.woehlke.twitterwall.oodm.model.parts.User2UserList; import java.util.List; @@ -36,5 +36,7 @@ public interface TwitterApiService { CursoredList getFriendIds(); - List getLists(); + User2UserList getLists(); + + User2UserList getUserListForUser(long idTwitterOfListOwningUser); } diff --git a/src/main/java/org/woehlke/twitterwall/backend/service/remote/impl/TwitterApiServiceImpl.java b/src/main/java/org/woehlke/twitterwall/backend/service/remote/impl/TwitterApiServiceImpl.java index dce578ed..2c698866 100644 --- a/src/main/java/org/woehlke/twitterwall/backend/service/remote/impl/TwitterApiServiceImpl.java +++ b/src/main/java/org/woehlke/twitterwall/backend/service/remote/impl/TwitterApiServiceImpl.java @@ -4,17 +4,22 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; +import org.springframework.social.ApiException; import org.springframework.social.RateLimitExceededException; import org.springframework.social.ResourceNotFoundException; import org.springframework.social.twitter.api.*; import org.springframework.social.twitter.api.impl.TwitterTemplate; import org.springframework.stereotype.Component; +import org.woehlke.twitterwall.configuration.properties.FrontendProperties; import org.woehlke.twitterwall.configuration.properties.TwitterProperties; import org.woehlke.twitterwall.backend.service.remote.TwitterApiService; +import org.woehlke.twitterwall.oodm.model.parts.User2UserList; import javax.inject.Inject; import java.util.ArrayList; +import java.util.HashSet; import java.util.List; +import java.util.Set; /** * Created by tw on 19.06.17. @@ -32,7 +37,7 @@ public List findTweetsForSearchQuery() { fetchedTweets = getTwitterProxy().searchOperations().search(twitterProperties.getSearchQuery(), twitterProperties.getPageSize()).getTweets(); msg += " result: "; if (fetchedTweets.size() == 0) { - log.error(msg + " result.size: 0"); + log.warn(msg + " result.size: 0"); return new ArrayList<>(); } else { log.debug(msg + " result.size: " + fetchedTweets.size()); @@ -41,6 +46,8 @@ public List findTweetsForSearchQuery() { } catch (RateLimitExceededException e) { log.warn(msg + " Rate Limit Exceeded : "); waitLongerForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); } catch (Exception e) { log.error(msg + e.getMessage()); return new ArrayList<>(); @@ -64,6 +71,11 @@ public Tweet findOneTweetById(long tweetTwitterId) { } catch (RateLimitExceededException e) { log.warn(msg + " Rate Limit Exceeded "); waitLongerForApi(); + } catch (ResourceNotFoundException ex){ + log.warn(msg + ex.getMessage()); + waitForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); } catch (Exception e) { log.error(msg + e.getMessage()); e.printStackTrace(); @@ -79,10 +91,10 @@ public List getHomeTimeline() { List fetchedTweets; while(true) { try { - fetchedTweets = getTwitterProxy().timelineOperations().getHomeTimeline(); + fetchedTweets = getTwitterProxy().timelineOperations().getHomeTimeline(twitterProperties.getPageSize()); msg += " result: "; if (fetchedTweets.size() == 0) { - log.error(msg + " result.size: 0"); + log.warn(msg + " result.size: 0"); return new ArrayList<>(); } else { log.debug(msg + " result.size: " + fetchedTweets.size()); @@ -91,6 +103,8 @@ public List getHomeTimeline() { } catch (RateLimitExceededException e) { log.warn(msg + " Rate Limit Exceeded : "); waitLongerForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); } catch (Exception e) { log.error(msg + e.getMessage()); return new ArrayList<>(); @@ -105,10 +119,10 @@ public List getUserTimeline() { List fetchedTweets; while(true) { try { - fetchedTweets = getTwitterProxy().timelineOperations().getUserTimeline(); + fetchedTweets = getTwitterProxy().timelineOperations().getUserTimeline(twitterProperties.getPageSize()); msg += " result: "; if (fetchedTweets.size() == 0) { - log.error(msg + " result.size: 0"); + log.warn(msg + " result.size: 0"); //TODO: Why? return new ArrayList<>(); } else { @@ -118,6 +132,8 @@ public List getUserTimeline() { } catch (RateLimitExceededException e) { log.warn(msg + " Rate Limit Exceeded : "); waitLongerForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); } catch (Exception e) { log.error(msg + e.getMessage()); return new ArrayList<>(); @@ -132,10 +148,10 @@ public List getMentions() { List fetchedTweets; while(true) { try { - fetchedTweets = getTwitterProxy().timelineOperations().getMentions(); + fetchedTweets = getTwitterProxy().timelineOperations().getMentions(twitterProperties.getPageSize()); msg += " result: "; if (fetchedTweets.size() == 0) { - log.error(msg + " result.size: 0"); + log.warn(msg + " result.size: 0"); return new ArrayList<>(); } else { log.debug(msg + " result.size: " + fetchedTweets.size()); @@ -144,6 +160,9 @@ public List getMentions() { } catch (RateLimitExceededException e) { log.warn(msg + " Rate Limit Exceeded : "); waitLongerForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); + waitLongerForApi(); } catch (Exception e) { log.error(msg + e.getMessage()); return new ArrayList<>(); @@ -158,10 +177,10 @@ public List getFavorites() { List fetchedTweets; while(true) { try { - fetchedTweets = getTwitterProxy().timelineOperations().getFavorites(); + fetchedTweets = getTwitterProxy().timelineOperations().getFavorites(twitterProperties.getPageSize()); msg += " result: "; if (fetchedTweets.size() == 0) { - log.error(msg + " result.size: 0"); + log.warn(msg + " result.size: 0"); return new ArrayList<>(); } else { log.debug(msg + " result.size: " + fetchedTweets.size()); @@ -170,6 +189,9 @@ public List getFavorites() { } catch (RateLimitExceededException e) { log.warn(msg + " Rate Limit Exceeded : "); waitLongerForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); + waitLongerForApi(); } catch (Exception e) { log.error(msg + e.getMessage()); return new ArrayList<>(); @@ -196,6 +218,9 @@ public List getRetweetsOfMe(){ } catch (RateLimitExceededException e) { log.warn(msg + " Rate Limit Exceeded : "); waitLongerForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); + waitLongerForApi(); } catch (Exception e) { log.error(msg + e.getMessage()); return new ArrayList<>(); @@ -204,29 +229,113 @@ public List getRetweetsOfMe(){ } @Override - public List getLists(){ + public User2UserList getLists(){ String msg = MSG+"getMentions: "; log.debug(msg); - List fetchedUserLists; - while(true) { + long idTwitterOfListOwningUser = getTwitterProxy().userOperations().getProfileId(); + String exceptionMsg1 = "getTwitterProxy().listOperations().getLists("+idTwitterOfListOwningUser+") "; + boolean doTheJob = true; + while(doTheJob) { + try { + User2UserList result = getUserListForUser(idTwitterOfListOwningUser); + doTheJob = false; + return result; + } catch (RateLimitExceededException e) { + log.warn(msg + " Rate Limit Exceeded : " + exceptionMsg1); + waitLongerForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); + waitLongerForApi(); + } catch (Exception e) { + log.error(msg + "Exception at: " + exceptionMsg1 + e.getMessage()); + } + } + return null; + } + + + @Override + public User2UserList getUserListForUser(long idTwitterOfListOwningUser){ + String msg = MSG+"getMentions: "; + String exceptionMsg1 = "getTwitterProxy().listOperations().getLists("+idTwitterOfListOwningUser+") "; + String exceptionMsg2 = "getTwitterProxy().listOperations().getSubscriptions("+idTwitterOfListOwningUser+") "; + String exceptionMsg3 = "getTwitterProxy().listOperations().getMemberships("+idTwitterOfListOwningUser+") "; + log.debug(msg); + Set ownLists = new HashSet<>(); + Set userListSubcriptions = new HashSet<>(); + Set userListMemberships = new HashSet<>(); + boolean doTheJob = true; + while(doTheJob) { try { - fetchedUserLists = getTwitterProxy().listOperations().getLists(); + List fetchedLists= getTwitterProxy().listOperations().getLists(idTwitterOfListOwningUser); msg += " result: "; - if (fetchedUserLists.size() == 0) { - log.error(msg + " result.size: 0"); - return new ArrayList<>(); - } else { - log.debug(msg + " result.size: " + fetchedUserLists.size()); - return fetchedUserLists; - } + ownLists.addAll(fetchedLists); + log.debug(msg + " result.size: " + fetchedLists.size()); + waitForApi(); + doTheJob = false; } catch (RateLimitExceededException e) { - log.warn(msg + " Rate Limit Exceeded : "); + log.warn(msg + " Rate Limit Exceeded : "+exceptionMsg1); + waitLongerForApi(); + } catch (ResourceNotFoundException ex){ + log.warn(msg + ex.getMessage()); + waitForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); waitLongerForApi(); } catch (Exception e) { - log.error(msg + e.getMessage()); - return new ArrayList<>(); + log.error(msg + "Exception at: "+exceptionMsg1+ e.getMessage()); + } + } + doTheJob = true; + while(doTheJob) { + try { + List fetchedLists= getTwitterProxy().listOperations().getSubscriptions(idTwitterOfListOwningUser); + msg += " result: "; + userListSubcriptions.addAll(fetchedLists); + log.debug(msg + " result.size: " + fetchedLists.size()); + waitForApi(); + doTheJob = false; + } catch (RateLimitExceededException e) { + log.warn(msg + " Rate Limit Exceeded : "+exceptionMsg2); + waitLongerForApi(); + } catch (ResourceNotFoundException ex){ + log.warn(msg + ex.getMessage()); + waitForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); + waitLongerForApi(); + } catch (Exception e) { + log.error(msg + "Exception at: "+exceptionMsg2+ e.getMessage()); + } + } + doTheJob = true; + while(doTheJob) { + try { + List fetchedOwnLists = getTwitterProxy().listOperations().getMemberships(idTwitterOfListOwningUser); + msg += " result: "; + userListMemberships.addAll(fetchedOwnLists); + log.debug(msg + " result.size: " + fetchedOwnLists.size()); + waitForApi(); + doTheJob = false; + } catch (RateLimitExceededException e) { + log.warn(msg + " Rate Limit Exceeded : "+exceptionMsg3); + waitLongerForApi(); + } catch (ResourceNotFoundException ex){ + log.warn(msg + ex.getMessage()); + waitForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); + waitLongerForApi(); + } catch (Exception e) { + log.error(msg + "Exception at: "+exceptionMsg3+ e.getMessage()); } } + User2UserList result = new User2UserList(); + result.setIdTwitterOfListOwningUser(idTwitterOfListOwningUser); + result.setOwnLists(ownLists); + result.setUserListMemberships(userListSubcriptions); + result.setUserListMemberships(userListMemberships); + return result; } @Override @@ -249,6 +358,9 @@ public TwitterProfile getUserProfileForTwitterId(long userProfileTwitterId) { } catch (ResourceNotFoundException e) { log.warn(msg + " User not found : " + userProfileTwitterId); return null; + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); + waitLongerForApi(); } catch (Exception e) { log.error(msg + e.getMessage()); return null; @@ -275,6 +387,9 @@ public TwitterProfile getUserProfileForScreenName(String screenName) { } catch (ResourceNotFoundException e) { log.warn(msg + " User not found : " + screenName); return null; + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); + waitLongerForApi(); } catch (Exception e) { log.error(msg + e.getMessage()); return null; @@ -295,6 +410,12 @@ public List findUsersFromDefinedList(String screenNameOfTheListO } catch (RateLimitExceededException e) { log.warn(msg + " Rate Limit Exceeded : "); waitLongerForApi(); + } catch (ResourceNotFoundException ex){ + log.warn(msg + ex.getMessage()); + waitForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); + waitLongerForApi(); } catch (Exception e) { log.error(msg + e.getMessage()); return new ArrayList<>(); @@ -315,6 +436,9 @@ public CursoredList getFollowerIds() { } catch (RateLimitExceededException e) { log.warn(msg + " Rate Limit Exceeded : "); waitLongerForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); + waitLongerForApi(); } catch (Exception e) { log.error(msg + e.getMessage()); return new CursoredList<>(new ArrayList<>(), 0L, 0L); @@ -335,6 +459,9 @@ public CursoredList getFriendIds() { } catch (RateLimitExceededException e) { log.warn(msg + " Rate Limit Exceeded : "); waitLongerForApi(); + } catch (ApiException apiEx){ + log.warn(msg + " Api Exception : " + apiEx.getMessage()); + waitLongerForApi(); } catch (Exception e) { log.error(msg + e.getMessage()); return new CursoredList<>(new ArrayList<>(), 0L, 0L); @@ -353,7 +480,7 @@ private void waitForApi(){ private void waitLongerForApi(){ int millisToWaitBetweenTwoApiCalls = twitterProperties.getMillisToWaitBetweenTwoApiCalls(); - millisToWaitBetweenTwoApiCalls *= 10; + millisToWaitBetweenTwoApiCalls *= 100; log.debug("### waiting now for (ms): "+millisToWaitBetweenTwoApiCalls); try { Thread.sleep(millisToWaitBetweenTwoApiCalls); @@ -368,6 +495,8 @@ private void waitLongerForApi(){ private final TwitterProperties twitterProperties; + private final FrontendProperties frontendProperties; + private Twitter getTwitterProxy() { String consumerKey = environment.getProperty("TWITTER_CONSUMER_KEY"); String consumerSecret = environment.getProperty("TWITTER_CONSUMER_SECRET"); @@ -380,7 +509,8 @@ private Twitter getTwitterProxy() { private String MSG = "Remote API Call "; @Autowired - public TwitterApiServiceImpl(TwitterProperties twitterProperties) { + public TwitterApiServiceImpl(TwitterProperties twitterProperties, FrontendProperties frontendProperties) { this.twitterProperties = twitterProperties; + this.frontendProperties = frontendProperties; } } diff --git a/src/main/java/org/woehlke/twitterwall/frontend/controller/ImprintController.java b/src/main/java/org/woehlke/twitterwall/frontend/controller/ImprintController.java index c751b796..c088b242 100644 --- a/src/main/java/org/woehlke/twitterwall/frontend/controller/ImprintController.java +++ b/src/main/java/org/woehlke/twitterwall/frontend/controller/ImprintController.java @@ -21,14 +21,14 @@ public class ImprintController { @RequestMapping("/imprint") public String imprint(Model model) { - log.info("-----------------------------------------"); + log.debug("-----------------------------------------"); String symbol = Symbols.IMPRINT.toString(); String title = "Imprint"; String subtitle = frontendProperties.getImprintSubtitle(); model = contentFactory.setupPage(model, title, subtitle, symbol); User user = taskStart.createImprintUser(); model.addAttribute("user", user); - log.info("-----------------------------------------"); + log.debug("-----------------------------------------"); return "imprint/imprint"; } diff --git a/src/main/java/org/woehlke/twitterwall/frontend/controller/LoginController.java b/src/main/java/org/woehlke/twitterwall/frontend/controller/LoginController.java index 951a5c81..18c5d09a 100644 --- a/src/main/java/org/woehlke/twitterwall/frontend/controller/LoginController.java +++ b/src/main/java/org/woehlke/twitterwall/frontend/controller/LoginController.java @@ -14,12 +14,12 @@ public class LoginController { @RequestMapping("/login") public String login(Model model) { - log.info("-----------------------------------------"); + log.debug("-----------------------------------------"); String symbol = Symbols.LOGIN.toString(); String title = "Login"; String subtitle = "Enter your Credentials"; model = contentFactory.setupPage(model, title, subtitle, symbol); - log.info("-----------------------------------------"); + log.debug("-----------------------------------------"); return "login/login"; } diff --git a/src/main/java/org/woehlke/twitterwall/frontend/controller/TaskController.java b/src/main/java/org/woehlke/twitterwall/frontend/controller/TaskController.java index fe08ff99..116016d2 100644 --- a/src/main/java/org/woehlke/twitterwall/frontend/controller/TaskController.java +++ b/src/main/java/org/woehlke/twitterwall/frontend/controller/TaskController.java @@ -102,13 +102,13 @@ public String getOnListRenew( ) { Pageable pageRequest = new PageRequest(page, frontendProperties.getPageSize()); String msg = "getOnListRenew: "; - log.info(msg+"START startTask.fetchUsersFromList"); + log.debug(msg+"START startTask.fetchUsersFromList"); Task task = mqTaskStartFireAndForget.fetchUsersFromList(); model.addAttribute("task",task); - log.info(msg+"DONE startTask.fetchUsersFromList: "); - log.info(msg+"START userService.findOnList(): "); + log.debug(msg+"DONE startTask.fetchUsersFromList: "); + log.debug(msg+"START userService.findOnList(): "); Page usersOnList = userService.getOnList(pageRequest); - log.info(msg+"DONE userService.findOnList(): "); + log.debug(msg+"DONE userService.findOnList(): "); model.addAttribute("users", usersOnList); String symbol = Symbols.LEAF.toString(); String title = "Renew List of Users On List"; @@ -268,7 +268,9 @@ public String getLists(Model model) { String symbol = Symbols.TASK.toString(); model = contentFactory.setupPage(model,title,subtitle,symbol); List listOfTasks = new ArrayList<>(); - Task task1 = mqTaskStartFireAndForget.getLists(); + //Task task1 = mqTaskStartFireAndForget.getLists(); + //listOfTasks.add(task1); + Task task1 = mqTaskStartFireAndForget.startFetchListsForUsers(); listOfTasks.add(task1); Task task2 = mqTaskStartFireAndForget.fetchUserlistOwners(); listOfTasks.add(task2); diff --git a/src/main/java/org/woehlke/twitterwall/oodm/model/Tweet.java b/src/main/java/org/woehlke/twitterwall/oodm/model/Tweet.java index 8fcd4000..8e38ad3e 100644 --- a/src/main/java/org/woehlke/twitterwall/oodm/model/Tweet.java +++ b/src/main/java/org/woehlke/twitterwall/oodm/model/Tweet.java @@ -12,9 +12,7 @@ import javax.validation.constraints.NotNull; import java.util.Date; -import static javax.persistence.CascadeType.DETACH; -import static javax.persistence.CascadeType.REFRESH; -import static javax.persistence.CascadeType.REMOVE; +import static javax.persistence.CascadeType.*; import static javax.persistence.FetchType.EAGER; /** @@ -170,7 +168,7 @@ public class Tweet extends AbstractDomainObject implements DomainObjectWi private Boolean retweeted; @JoinColumn(name="fk_tweet_retweeted") - @ManyToOne(cascade = {DETACH, REFRESH, REMOVE}, fetch = EAGER, optional = true) + @ManyToOne(cascade = {DETACH, REFRESH, REMOVE, MERGE}, fetch = EAGER, optional = true) private Tweet retweetedStatus; @Column(name="favorited") @@ -217,7 +215,7 @@ public class Tweet extends AbstractDomainObject implements DomainObjectWi @NotNull @JoinColumn(name="fk_user") - @ManyToOne(cascade = {DETACH, REFRESH, REMOVE}, fetch = EAGER, optional = false) + @ManyToOne(cascade = {DETACH, REFRESH, REMOVE, MERGE}, fetch = EAGER, optional = false) private User user; public Tweet(Task createdBy, Task updatedBy, long idTwitter, String idStr, String text, Date createdAt) { diff --git a/src/main/java/org/woehlke/twitterwall/oodm/model/User.java b/src/main/java/org/woehlke/twitterwall/oodm/model/User.java index 7efaeac4..55d73bde 100644 --- a/src/main/java/org/woehlke/twitterwall/oodm/model/User.java +++ b/src/main/java/org/woehlke/twitterwall/oodm/model/User.java @@ -8,14 +8,17 @@ import org.woehlke.twitterwall.oodm.model.common.DomainObjectWithTask; import org.woehlke.twitterwall.oodm.model.entities.Entities; import org.woehlke.twitterwall.oodm.model.listener.UserListener; +import org.woehlke.twitterwall.oodm.model.parts.User2UserList; import javax.persistence.*; import javax.validation.constraints.NotNull; -import java.util.Date; -import java.util.Set; +import java.util.*; import java.util.regex.Matcher; import java.util.regex.Pattern; +import static javax.persistence.FetchType.EAGER; +import static javax.persistence.FetchType.LAZY; + /** * Created by tw on 10.06.17. */ @@ -106,6 +109,10 @@ @NamedQuery( name="User.getUsersForTickerSymbol", query="select t from User t join t.entities.tickerSymbols tickerSymbol where tickerSymbol=:tickerSymbol" + ), + @NamedQuery( + name="User.getIdTwitterOfAllUsers", + query = "select t.idTwitter from User t " ) }) @NamedNativeQueries({ @@ -291,6 +298,35 @@ public class User extends AbstractDomainObject implements DomainObjectWith }) private Entities entities = new Entities(); + @NotNull + @OneToMany( + orphanRemoval = true, + mappedBy ="listOwner", + fetch = FetchType.EAGER, + cascade = CascadeType.ALL + ) + private Set ownLists = new HashSet<>(); + + @NotNull + @JoinTable( + name = "userlist_subcriber" + ) + @ManyToMany( + fetch = FetchType.EAGER, + cascade = CascadeType.ALL + ) + private Set userListSubcriptions = new HashSet<>(); + + @NotNull + @JoinTable( + name = "userlist_members" + ) + @ManyToMany( + fetch = FetchType.EAGER, + cascade= CascadeType.ALL + ) + private Set userListMemberships = new HashSet<>(); + public User(Task createdBy, Task updatedBy, long idTwitter, String screenName, String name, String url, String profileImageUrl, String description, String location, Date createdDate) { super(createdBy,updatedBy); this.idTwitter = idTwitter; @@ -773,6 +809,30 @@ public void setEntities(Entities entities) { this.entities = entities; } + public Set getOwnLists() { + return ownLists; + } + + public void setOwnLists(Set ownLists) { + this.ownLists = ownLists; + } + + public Set getUserListSubcriptions() { + return userListSubcriptions; + } + + public void setUserListSubcriptions(Set userListSubcriptions) { + this.userListSubcriptions = userListSubcriptions; + } + + public Set getUserListMemberships() { + return userListMemberships; + } + + public void setUserListMemberships(Set userListMemberships) { + this.userListMemberships = userListMemberships; + } + @Override public String toString() { return "User{" + diff --git a/src/main/java/org/woehlke/twitterwall/oodm/model/UserList.java b/src/main/java/org/woehlke/twitterwall/oodm/model/UserList.java index 8de3c496..e246e685 100644 --- a/src/main/java/org/woehlke/twitterwall/oodm/model/UserList.java +++ b/src/main/java/org/woehlke/twitterwall/oodm/model/UserList.java @@ -8,12 +8,12 @@ import javax.persistence.*; import javax.validation.constraints.NotNull; +import java.util.HashSet; import java.util.LinkedHashSet; import java.util.Set; -import static javax.persistence.CascadeType.DETACH; -import static javax.persistence.CascadeType.REFRESH; -import static javax.persistence.CascadeType.REMOVE; +import static javax.persistence.CascadeType.*; +import static javax.persistence.FetchType.EAGER; import static javax.persistence.FetchType.LAZY; @Entity @@ -101,30 +101,32 @@ public String getListOwnersScreenName(){ return myuriPath.split("/")[1]; } - @NotNull - @ManyToOne(fetch = FetchType.EAGER) - @JoinColumn(name="fk_user") + @ManyToOne( + fetch = FetchType.EAGER, + cascade = { ALL } + ) + @JoinColumn( + name="fk_user_owner" + ) private User listOwner; - @NotNull @JoinTable( name="userlist_members" ) @ManyToMany( - cascade = { DETACH, REFRESH, REMOVE }, - fetch = LAZY + cascade = { ALL }, + fetch = EAGER ) private Set members = new LinkedHashSet(); - @NotNull @JoinTable( name="userlist_subcriber" ) @ManyToMany( - cascade = { DETACH, REFRESH, REMOVE }, - fetch = LAZY + cascade = { ALL }, + fetch = EAGER ) private Set subscriber = new LinkedHashSet(); diff --git a/src/main/java/org/woehlke/twitterwall/oodm/model/parts/AbstractDomainObject.java b/src/main/java/org/woehlke/twitterwall/oodm/model/parts/AbstractDomainObject.java index cc10a9e5..90d4a9e4 100644 --- a/src/main/java/org/woehlke/twitterwall/oodm/model/parts/AbstractDomainObject.java +++ b/src/main/java/org/woehlke/twitterwall/oodm/model/parts/AbstractDomainObject.java @@ -16,6 +16,7 @@ import java.util.Map; import static javax.persistence.CascadeType.DETACH; +import static javax.persistence.CascadeType.MERGE; import static javax.persistence.CascadeType.REFRESH; import static javax.persistence.FetchType.EAGER; diff --git a/src/main/java/org/woehlke/twitterwall/oodm/model/parts/User2UserList.java b/src/main/java/org/woehlke/twitterwall/oodm/model/parts/User2UserList.java new file mode 100644 index 00000000..272a2624 --- /dev/null +++ b/src/main/java/org/woehlke/twitterwall/oodm/model/parts/User2UserList.java @@ -0,0 +1,77 @@ +package org.woehlke.twitterwall.oodm.model.parts; + + +import org.springframework.social.twitter.api.UserList; + +import java.io.Serializable; +import java.util.HashSet; +import java.util.Set; + + +public class User2UserList implements Serializable { + + private long idTwitterOfListOwningUser; + + private Set ownLists = new HashSet<>(); + + private Set userListSubcriptions = new HashSet<>(); + + private Set userListMemberships = new HashSet<>(); + + + + public long getIdTwitterOfListOwningUser() { + return idTwitterOfListOwningUser; + } + + public void setIdTwitterOfListOwningUser(long idTwitterOfListOwningUser) { + this.idTwitterOfListOwningUser = idTwitterOfListOwningUser; + } + + public Set getOwnLists() { + return ownLists; + } + + public void setOwnLists(Set ownLists) { + this.ownLists = ownLists; + } + + public Set getUserListSubcriptions() { + return userListSubcriptions; + } + + public void setUserListSubcriptions(Set userListSubcriptions) { + this.userListSubcriptions = userListSubcriptions; + } + + public Set getUserListMemberships() { + return userListMemberships; + } + + public void setUserListMemberships(Set userListMemberships) { + this.userListMemberships = userListMemberships; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (!(o instanceof User2UserList)) return false; + + User2UserList that = (User2UserList) o; + + if (idTwitterOfListOwningUser != that.idTwitterOfListOwningUser) return false; + if (ownLists != null ? !ownLists.equals(that.ownLists) : that.ownLists != null) return false; + if (userListSubcriptions != null ? !userListSubcriptions.equals(that.userListSubcriptions) : that.userListSubcriptions != null) + return false; + return userListMemberships != null ? userListMemberships.equals(that.userListMemberships) : that.userListMemberships == null; + } + + @Override + public int hashCode() { + int result = (int) (idTwitterOfListOwningUser ^ (idTwitterOfListOwningUser >>> 32)); + result = 31 * result + (ownLists != null ? ownLists.hashCode() : 0); + result = 31 * result + (userListSubcriptions != null ? userListSubcriptions.hashCode() : 0); + result = 31 * result + (userListMemberships != null ? userListMemberships.hashCode() : 0); + return result; + } +} diff --git a/src/main/java/org/woehlke/twitterwall/oodm/model/parts/UserListType.java b/src/main/java/org/woehlke/twitterwall/oodm/model/parts/UserListType.java new file mode 100644 index 00000000..13a0c512 --- /dev/null +++ b/src/main/java/org/woehlke/twitterwall/oodm/model/parts/UserListType.java @@ -0,0 +1,8 @@ +package org.woehlke.twitterwall.oodm.model.parts; + +public enum UserListType { + + USERS_OWN_LIST, + USER_IS_MEMBER, + USER_IS_SUBSCRIBER +} diff --git a/src/main/java/org/woehlke/twitterwall/oodm/repositories/UserListRepository.java b/src/main/java/org/woehlke/twitterwall/oodm/repositories/UserListRepository.java index 52ae16a3..b6e00e6d 100644 --- a/src/main/java/org/woehlke/twitterwall/oodm/repositories/UserListRepository.java +++ b/src/main/java/org/woehlke/twitterwall/oodm/repositories/UserListRepository.java @@ -6,6 +6,8 @@ import org.woehlke.twitterwall.oodm.repositories.common.DomainRepository; import org.woehlke.twitterwall.oodm.repositories.custom.UserListRepositoryCustom; +import java.util.List; + public interface UserListRepository extends DomainRepository,UserListRepositoryCustom { UserList findByIdTwitter(long idTwitter); diff --git a/src/main/java/org/woehlke/twitterwall/oodm/repositories/UserRepository.java b/src/main/java/org/woehlke/twitterwall/oodm/repositories/UserRepository.java index a53e8478..a8321f0f 100644 --- a/src/main/java/org/woehlke/twitterwall/oodm/repositories/UserRepository.java +++ b/src/main/java/org/woehlke/twitterwall/oodm/repositories/UserRepository.java @@ -9,6 +9,8 @@ import org.woehlke.twitterwall.oodm.repositories.common.DomainRepository; import org.woehlke.twitterwall.oodm.repositories.custom.UserRepositoryCustom; +import java.util.List; + /** * Created by tw on 15.07.17. */ @@ -86,4 +88,7 @@ public interface UserRepository extends DomainRepository,UserRepositoryCus @Query(name="User.countAllUser2Url",nativeQuery=true) long countAllUser2Url(); + + @Query(name="User.getIdTwitterOfAllUsers") + List getIdTwitterOfAllUsers(); } diff --git a/src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/impl/HashTagRepositoryImpl.java b/src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/impl/HashTagRepositoryImpl.java index 225eb037..03b29528 100644 --- a/src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/impl/HashTagRepositoryImpl.java +++ b/src/main/java/org/woehlke/twitterwall/oodm/repositories/custom/impl/HashTagRepositoryImpl.java @@ -15,6 +15,7 @@ import javax.persistence.EntityManager; import javax.persistence.TypedQuery; +import javax.sql.DataSource; import java.util.List; import static org.woehlke.twitterwall.oodm.model.transients.mapper.CountAllTweets2HashTagsRowMapper.SQL_COUNT_ALL_TWEET_2_HASHTAG; @@ -28,9 +29,9 @@ public class HashTagRepositoryImpl implements HashTagRepositoryCustom { private final JdbcTemplate jdbcTemplate; @Autowired - public HashTagRepositoryImpl(EntityManager entityManager, JdbcTemplate jdbcTemplate) { + public HashTagRepositoryImpl(EntityManager entityManager, DataSource dataSource) { this.entityManager = entityManager; - this.jdbcTemplate = jdbcTemplate; + this.jdbcTemplate = new JdbcTemplate(dataSource); } @Override diff --git a/src/main/java/org/woehlke/twitterwall/oodm/service/UserService.java b/src/main/java/org/woehlke/twitterwall/oodm/service/UserService.java index 6379c071..e0d843b2 100644 --- a/src/main/java/org/woehlke/twitterwall/oodm/service/UserService.java +++ b/src/main/java/org/woehlke/twitterwall/oodm/service/UserService.java @@ -7,6 +7,8 @@ import org.woehlke.twitterwall.oodm.service.common.DomainObjectWithEntitiesService; import org.woehlke.twitterwall.oodm.service.common.DomainServiceWithScreenName; +import java.util.List; + /** * Created by tw on 11.06.17. @@ -60,4 +62,6 @@ public interface UserService extends DomainObjectWithEntitiesService,Domai boolean isByIdTwitter(long userIdTwitter); Page findUsersForUserList(UserList userList, Pageable pageRequest); + + List getIdTwitterOfAllUsers(); } diff --git a/src/main/java/org/woehlke/twitterwall/oodm/service/impl/UserServiceImpl.java b/src/main/java/org/woehlke/twitterwall/oodm/service/impl/UserServiceImpl.java index 824f478c..e674a011 100644 --- a/src/main/java/org/woehlke/twitterwall/oodm/service/impl/UserServiceImpl.java +++ b/src/main/java/org/woehlke/twitterwall/oodm/service/impl/UserServiceImpl.java @@ -176,4 +176,8 @@ public Page findUsersForUserList(UserList userList, Pageable pageRequest) public User findByUniqueId(User domainExampleObject) { return userRepository.findByUniqueId(domainExampleObject); } + + public List getIdTwitterOfAllUsers(){ + return userRepository.getIdTwitterOfAllUsers(); + } } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 26b50577..ea60e8cd 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -33,7 +33,7 @@ spring: #initialSize: 5 max-total: 20 maxActive: 20 - #maxIdle: 5 + maxIdle: 20 #minIdle: 2 platform: POSTGRESQL #removeAbandoned: true @@ -348,15 +348,8 @@ spring: spring: profiles: travis datasource: - driverClassName: org.h2.Driver - platform: H2 - url: jdbc:h2:mem:test + url: 'jdbc:postgresql://localhost:5432/twitterwall2test?user=twitterwall2test&password=twitterwall2testpwd' jpa: hibernate: ddl-auto: update - properties: - hibernate: - dialect: org.hibernate.dialect.H2Dialect - show-sql: true -hibernate: - dialect: org.hibernate.dialect.H2Dialect + show-sql: false diff --git a/src/main/resources/mq/FetchLists.xml b/src/main/resources/mq/FetchLists.xml index 79be618d..16e04492 100644 --- a/src/main/resources/mq/FetchLists.xml +++ b/src/main/resources/mq/FetchLists.xml @@ -24,9 +24,13 @@ + + + + + + diff --git a/src/main/resources/mq/FetchListsForUsers.xml b/src/main/resources/mq/FetchListsForUsers.xml index 8041cc48..9e409537 100644 --- a/src/main/resources/mq/FetchListsForUsers.xml +++ b/src/main/resources/mq/FetchListsForUsers.xml @@ -30,23 +30,27 @@ ref="mqFetchUserListsForUsers" method="splitUserListMessage" /> + @@ -61,23 +65,23 @@ ref="mqFetchUserListsForUsers" method="splitUserListMessage" /> diff --git a/src/test/java/org/woehlke/twitterwall/AlphaTopLevelSuiteIT.java b/src/test/java/org/woehlke/twitterwall/AlphaTopLevelSuiteIT.java new file mode 100644 index 00000000..5160eb69 --- /dev/null +++ b/src/test/java/org/woehlke/twitterwall/AlphaTopLevelSuiteIT.java @@ -0,0 +1,62 @@ +package org.woehlke.twitterwall; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.woehlke.twitterwall.backend.mq.tasks.TaskStartFireAndForgetTestImpl; +import org.woehlke.twitterwall.backend.mq.tasks.TaskStartTestImpl; +import org.woehlke.twitterwall.backend.service.remote.TwitterUrlServiceTest; +import org.woehlke.twitterwall.frontend.controller.*; +import org.woehlke.twitterwall.oodm.model.*; +import org.woehlke.twitterwall.oodm.service.*; + +@Suite.SuiteClasses({ + + + HashTagTest.class, + MediaTest.class, + MentionTest.class, + TaskHistoryTest.class, + TaskTest.class, + TickerSymbolTest.class, + TweetTest.class, + UrlTest.class, + UserDescriptionTest.class, + UserListTest.class, + UserTest.class, + + HashTagServiceTest.class, + MediaServiceTest.class, + MentionServiceTest.class, + TaskHistoryServiceTest.class, + TaskServiceTest.class, + TickerSymbolServiceTest.class, + TweetServiceTest.class, + UrlServiceTest.class, + UserListServiceTest.class, + UserServiceTest.class, + + ApplicationControllerTest.class, + CountedEntitiesControllerTest.class, + HashTagControllerTest.class, + ImprintControllerTest.class, + LoginControllerTest.class, + MediaControllerTest.class, + MentionControllerTest.class, + TaskControllerTest.class, + TaskHistoryControllerTest.class, + TickerSymbolControllerTest.class, + TweetControllerTest.class, + UrlControllerTest.class, + UserControllerTest.class, + UserListControllerTest.class, + + //TwitterUrlServiceTest.class, + + //TaskStartFireAndForgetTestImpl.class, + //TaskStartTestImpl.class, + + CronJobsTest.class +}) +@RunWith(Suite.class) +public class AlphaTopLevelSuiteIT { +} diff --git a/src/test/java/org/woehlke/twitterwall/CronJobsTest.java b/src/test/java/org/woehlke/twitterwall/CronJobsTest.java index 6c068a3e..cccf2e45 100644 --- a/src/test/java/org/woehlke/twitterwall/CronJobsTest.java +++ b/src/test/java/org/woehlke/twitterwall/CronJobsTest.java @@ -1,85 +1,88 @@ package org.woehlke.twitterwall; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class}) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class CronJobsTest { @Autowired private CronJobs cronJobs; @Test - public void createImprintUserAsync() throws Exception { + public void test001createImprintUserAsync() throws Exception { cronJobs.createImprintUserAsync(); } @Test - public void fetchTweetsFromTwitterSearch() throws Exception { + public void test002fetchTweetsFromTwitterSearch() throws Exception { cronJobs.fetchTweetsFromTwitterSearch(); } @Test - public void updateTweets() throws Exception { + public void test003updateTweets() throws Exception { cronJobs.updateTweets(); } @Test - public void updateUserProfiles() throws Exception { + public void test004updateUserProfiles() throws Exception { cronJobs.updateUserProfiles(); } @Test - public void updateUserProfilesFromMentions() throws Exception { + public void test005updateUserProfilesFromMentions() throws Exception { cronJobs.updateUserProfilesFromMentions(); } @Test - public void fetchUsersFromDefinedUserList() throws Exception { + public void test006fetchUsersFromDefinedUserList() throws Exception { cronJobs.fetchUsersFromDefinedUserList(); } @Test - public void removeOldDataFromStorage() throws Exception { + public void test007removeOldDataFromStorage() throws Exception { cronJobs.removeOldDataFromStorage(); } @Test - public void fetchFollower() throws Exception { + public void test008fetchFollower() throws Exception { cronJobs.fetchFollower(); } @Test - public void getHomeTimeline() throws Exception { + public void test009getHomeTimeline() throws Exception { cronJobs.getHomeTimeline(); } @Test - public void getUserTimeline() throws Exception { + public void test010getUserTimeline() throws Exception { cronJobs.getUserTimeline(); } @Test - public void getMentions() throws Exception { + public void test011getMentions() throws Exception { cronJobs.getMentions(); } @Test - public void getFavorites() throws Exception { + public void test012getFavorites() throws Exception { cronJobs.getFavorites(); } @Test - public void getRetweetsOfMe() throws Exception { + public void test013getRetweetsOfMe() throws Exception { cronJobs.getRetweetsOfMe(); } @Test - public void getLists() throws Exception { + public void test014getLists() throws Exception { cronJobs.getLists(); } } diff --git a/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartFireAndForgetTest.java b/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartFireAndForgetTest.java index 2f2a11f1..90c04065 100644 --- a/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartFireAndForgetTest.java +++ b/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartFireAndForgetTest.java @@ -2,35 +2,35 @@ /** - * @see StartTaskAsynchron + * @see TaskStartFireAndForget */ public interface TaskStartFireAndForgetTest { - void updateTweetsTest() throws Exception; + void test010updateTweetsTest() throws Exception; - void updateUsersTest() throws Exception; + void test011updateUsersTest() throws Exception; - void updateUsersFromMentionsTest() throws Exception; + void test012updateUsersFromMentionsTest() throws Exception; - void fetchTweetsFromSearchTest() throws Exception; + void test013fetchTweetsFromSearchTest() throws Exception; - void fetchUsersFromListTest() throws Exception; + void test014fetchUsersFromListTest() throws Exception; - void fetchFollowerTest() throws Exception; + void test015fetchFollowerTest() throws Exception; - void fetchFriendsTest() throws Exception; + void test016fetchFriendsTest() throws Exception; - void removeOldDataFromStorageTest() throws Exception; + void test017removeOldDataFromStorageTest() throws Exception; - void getHomeTimeline() throws Exception; + void test018getHomeTimeline() throws Exception; - void getUserTimeline() throws Exception; + void test019getUserTimeline() throws Exception; - void getMentions() throws Exception; + void test020getMentions() throws Exception; - void getFavorites() throws Exception; + void test021getFavorites() throws Exception; - void getRetweetsOfMe() throws Exception; + void test022getRetweetsOfMe() throws Exception; - void getLists() throws Exception; + void test023getLists() throws Exception; } diff --git a/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartFireAndForgetTestImpl.java b/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartFireAndForgetTestImpl.java index 1f4c5a9a..36cf3b0e 100644 --- a/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartFireAndForgetTestImpl.java +++ b/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartFireAndForgetTestImpl.java @@ -1,9 +1,11 @@ package org.woehlke.twitterwall.backend.mq.tasks; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -17,8 +19,11 @@ import org.woehlke.twitterwall.oodm.model.tasks.TaskType; import org.woehlke.twitterwall.oodm.service.CountedEntitiesService; +import static org.assertj.core.api.Java6Assertions.assertThat; + @RunWith(SpringRunner.class) -@SpringBootTest(classes={Application.class}) +@SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TaskStartFireAndForgetTestImpl extends AbstractMqEndpointTest implements TaskStartFireAndForgetTest { private static final Logger log = LoggerFactory.getLogger(TaskStartFireAndForgetTestImpl.class); @@ -30,12 +35,21 @@ public class TaskStartFireAndForgetTestImpl extends AbstractMqEndpointTest imple private TaskStartFireAndForget mqTaskStartFireAndForget; @Test - public void updateTweetsTest() throws Exception { + public void test001checkDependentComponents(){ + String msg = "updateTweetsTest: "; + log.debug(msg+"START TEST"); + assertThat(countedEntitiesService).isNotNull(); + assertThat(mqTaskStartFireAndForget).isNotNull(); + log.debug(msg+"FINISHED TEST"); + } + + @Test + public void test010updateTweetsTest() throws Exception { String msg = "updateTweetsTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.updateTweets(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -43,16 +57,16 @@ public void updateTweetsTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntities(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test - public void updateUsersTest() throws Exception { + public void test011updateUsersTest() throws Exception { String msg = "updateUsersTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.updateUsers(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -60,16 +74,16 @@ public void updateUsersTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntities(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test - public void updateUsersFromMentionsTest() throws Exception { + public void test012updateUsersFromMentionsTest() throws Exception { String msg = "updateUsersFromMentionsTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.updateUsersFromMentions(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -77,16 +91,16 @@ public void updateUsersFromMentionsTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntities(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test - public void fetchTweetsFromSearchTest() throws Exception { + public void test013fetchTweetsFromSearchTest() throws Exception { String msg = "fetchTweetsFromSearchTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.fetchTweetsFromSearch(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -94,16 +108,16 @@ public void fetchTweetsFromSearchTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntities(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test - public void fetchUsersFromListTest() throws Exception { + public void test014fetchUsersFromListTest() throws Exception { String msg = "fetchTweetsFromSearchTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.fetchUsersFromList(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -111,17 +125,17 @@ public void fetchUsersFromListTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntities(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void fetchFollowerTest() throws Exception { + public void test015fetchFollowerTest() throws Exception { String msg = "fetchFollowerTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.fetchFollower(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -129,17 +143,17 @@ public void fetchFollowerTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void fetchFriendsTest() throws Exception { + public void test016fetchFriendsTest() throws Exception { String msg = "fetchFriendsTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.fetchFriends(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -147,19 +161,19 @@ public void fetchFriendsTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } //TODO: #229 https://github.com/phasenraum2010/twitterwall2/issues/229 @Ignore @Test @Override - public void removeOldDataFromStorageTest() throws Exception { + public void test017removeOldDataFromStorageTest() throws Exception { String msg = "removeOldDataFromStorageTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.removeOldDataFromStorage(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -167,17 +181,17 @@ public void removeOldDataFromStorageTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void getHomeTimeline() throws Exception { + public void test018getHomeTimeline() throws Exception { String msg = "getHomeTimeline: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.getHomeTimeline(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -185,17 +199,17 @@ public void getHomeTimeline() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void getUserTimeline() throws Exception { + public void test019getUserTimeline() throws Exception { String msg = "getUserTimeline: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.getUserTimeline(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -203,17 +217,17 @@ public void getUserTimeline() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void getMentions() throws Exception { + public void test020getMentions() throws Exception { String msg = "getUserTimeline: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.getMentions(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -221,17 +235,17 @@ public void getMentions() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void getFavorites() throws Exception { + public void test021getFavorites() throws Exception { String msg = "getFavorites: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.getFavorites(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -239,17 +253,17 @@ public void getFavorites() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void getRetweetsOfMe() throws Exception { + public void test022getRetweetsOfMe() throws Exception { String msg = "getRetweetsOfMe: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.getRetweetsOfMe(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -257,17 +271,17 @@ public void getRetweetsOfMe() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void getLists() throws Exception { + public void test023getLists() throws Exception { String msg = "getLists: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStartFireAndForget.getLists(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.FIRE_AND_FORGET,task.getTaskSendType()); @@ -275,6 +289,6 @@ public void getLists() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } } diff --git a/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartTest.java b/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartTest.java index 52e0fcec..799e4a04 100644 --- a/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartTest.java +++ b/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartTest.java @@ -2,14 +2,14 @@ /** * @see TaskStart - * @see StartTaskAsynchron + * @see TaskStartFireAndForget */ public interface TaskStartTest extends TaskStartFireAndForgetTest { - void createImprintUserTest() throws Exception; + void test100createImprintUserTest() throws Exception; - void createTestDataUsersTest() throws Exception; + void test110createTestDataUsersTest() throws Exception; - void createTestDataTweetsTest() throws Exception; + void test120createTestDataTweetsTest() throws Exception; } diff --git a/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartTestImpl.java b/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartTestImpl.java index 39b488f9..574c19e6 100644 --- a/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartTestImpl.java +++ b/src/test/java/org/woehlke/twitterwall/backend/mq/tasks/TaskStartTestImpl.java @@ -2,9 +2,11 @@ import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -21,7 +23,8 @@ import org.woehlke.twitterwall.oodm.service.CountedEntitiesService; @RunWith(SpringRunner.class) -@SpringBootTest(classes={Application.class}) +@SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TaskStartTestImpl extends AbstractMqEndpointTest implements TaskStartTest { private static final Logger log = LoggerFactory.getLogger(TaskStartTestImpl.class); @@ -36,12 +39,12 @@ public class TaskStartTestImpl extends AbstractMqEndpointTest implements TaskSta private FrontendProperties frontendProperties; @Test - public void updateTweetsTest() throws Exception { + public void test010updateTweetsTest() throws Exception { String msg = "updateTweetsTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.updateTweets(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -49,16 +52,16 @@ public void updateTweetsTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntities(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test - public void updateUsersTest() throws Exception { + public void test011updateUsersTest() throws Exception { String msg = "updateUsersTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.updateUsers(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -66,16 +69,16 @@ public void updateUsersTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntities(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test - public void updateUsersFromMentionsTest() throws Exception { + public void test012updateUsersFromMentionsTest() throws Exception { String msg = "updateUsersFromMentionsTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.updateUsersFromMentions(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -83,16 +86,16 @@ public void updateUsersFromMentionsTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntities(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test - public void fetchTweetsFromSearchTest() throws Exception { + public void test013fetchTweetsFromSearchTest() throws Exception { String msg = "fetchTweetsFromSearchTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.fetchTweetsFromSearch(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -100,16 +103,16 @@ public void fetchTweetsFromSearchTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntities(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test - public void fetchUsersFromListTest() throws Exception { + public void test014fetchUsersFromListTest() throws Exception { String msg = "fetchUsersFromListTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.fetchUsersFromList(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -117,18 +120,18 @@ public void fetchUsersFromListTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntities(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void fetchFollowerTest() throws Exception { + public void test015fetchFollowerTest() throws Exception { String msg = "fetchFollowerTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.fetchFollower(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -136,17 +139,17 @@ public void fetchFollowerTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void fetchFriendsTest() throws Exception { + public void test016fetchFriendsTest() throws Exception { String msg = "fetchFollowerTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.fetchFriends(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -154,7 +157,7 @@ public void fetchFriendsTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @@ -162,12 +165,12 @@ public void fetchFriendsTest() throws Exception { @Ignore @Test @Override - public void removeOldDataFromStorageTest() throws Exception { + public void test017removeOldDataFromStorageTest() throws Exception { String msg = "removeOldDataFromStorageTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.removeOldDataFromStorage(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -175,17 +178,17 @@ public void removeOldDataFromStorageTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void getHomeTimeline() throws Exception { + public void test018getHomeTimeline() throws Exception { String msg = "getHomeTimeline: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.getHomeTimeline(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -193,17 +196,17 @@ public void getHomeTimeline() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void getUserTimeline() throws Exception { + public void test019getUserTimeline() throws Exception { String msg = "getUserTimeline: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.getUserTimeline(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -211,17 +214,17 @@ public void getUserTimeline() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void getMentions() throws Exception { + public void test020getMentions() throws Exception { String msg = "getMentions: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.getMentions(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -229,17 +232,17 @@ public void getMentions() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void getFavorites() throws Exception { + public void test021getFavorites() throws Exception { String msg = "getFavorites: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.getFavorites(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -247,17 +250,17 @@ public void getFavorites() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void getRetweetsOfMe() throws Exception { + public void test022getRetweetsOfMe() throws Exception { String msg = "getRetweetsOfMe: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.getRetweetsOfMe(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -265,17 +268,17 @@ public void getRetweetsOfMe() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test @Override - public void getLists() throws Exception { + public void test023getLists() throws Exception { String msg = "getLists: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.getLists(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -283,29 +286,29 @@ public void getLists() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntitiesReduced(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test - public void createImprintUserTest() throws Exception { + public void test100createImprintUserTest() throws Exception { String msg = "createImprintUserTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); User user = this.mqTaskStart.createImprintUser(); Assert.assertNotNull(user); Assert.assertNotNull(user.getUniqueId()); - log.info(msg+"created User = "+user.getUniqueId()); + log.debug(msg+"created User = "+user.getUniqueId()); String screenName = frontendProperties.getImprintScreenName(); Assert.assertEquals(user.getScreenName(),screenName); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test - public void createTestDataUsersTest() throws Exception { + public void test110createTestDataUsersTest() throws Exception { String msg = "createTestDataUsersTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.createTestDataForUser(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -313,16 +316,16 @@ public void createTestDataUsersTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntities(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Test - public void createTestDataTweetsTest() throws Exception { + public void test120createTestDataTweetsTest() throws Exception { String msg = "createTestDataTweetsTest: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); CountedEntities beforeTest = countedEntitiesService.countAll(); Task task = this.mqTaskStart.createTestDataForTweets(); - log.info(msg+"created Task = "+task.getUniqueId()); + log.debug(msg+"created Task = "+task.getUniqueId()); Assert.assertNotNull(task); Assert.assertNotNull(task.getUniqueId()); Assert.assertEquals(TaskSendType.SEND_AND_WAIT_FOR_RESULT,task.getTaskSendType()); @@ -330,6 +333,6 @@ public void createTestDataTweetsTest() throws Exception { CountedEntities afterTest = countedEntitiesService.countAll(); boolean ok = assertCountedEntities(beforeTest,afterTest); Assert.assertTrue(ok); - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } } diff --git a/src/test/java/org/woehlke/twitterwall/backend/service/remote/TwitterUrlServiceTest.java b/src/test/java/org/woehlke/twitterwall/backend/service/remote/TwitterUrlServiceTest.java index 36b0da66..e43ac630 100644 --- a/src/test/java/org/woehlke/twitterwall/backend/service/remote/TwitterUrlServiceTest.java +++ b/src/test/java/org/woehlke/twitterwall/backend/service/remote/TwitterUrlServiceTest.java @@ -8,13 +8,16 @@ import org.apache.http.impl.client.CloseableHttpClient; import org.apache.http.impl.client.HttpClients; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.context.SpringBootTest; import org.springframework.test.context.junit4.SpringRunner; +import org.woehlke.twitterwall.Application; import org.woehlke.twitterwall.configuration.properties.TestdataProperties; import org.woehlke.twitterwall.oodm.model.Task; import org.woehlke.twitterwall.oodm.model.Url; @@ -34,7 +37,8 @@ * Created by tw on 21.06.17. */ @RunWith(SpringRunner.class) -@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@SpringBootTest(classes={Application.class},webEnvironment = SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TwitterUrlServiceTest { private static final Logger log = LoggerFactory.getLogger(TwitterUrlServiceTest.class); @@ -46,10 +50,9 @@ public class TwitterUrlServiceTest { private TwitterUrlService twitterUrlService; @Test - public void fetchUrlTest(){ + public void test001fetchUrlTest(){ String msg = "fetchUrlTest "; - log.info("------------------------------------"); - log.info(msg); + log.debug(msg+"------------------------------------"); String descriptionTask = "Make it so, Scotty"; TaskType taskType = TaskType.FETCH_TWEETS_FROM_SEARCH; @@ -65,21 +68,23 @@ public void fetchUrlTest(){ List exprectedUrls = testdataProperties.getOodm().getEntities().getUrl().getUrl(); for(String exprectedUrl:exprectedUrls){ - log.info(msg+"expected: " + exprectedUrl); + log.debug(msg+"expected: " + exprectedUrl); Url foundUrl = twitterUrlService.fetchTransientUrl(exprectedUrl,task); Assert.assertNotNull(foundUrl); - log.info(msg+"found: " + foundUrl.toString()); + log.debug(msg+"found: " + foundUrl.toString()); Assert.assertEquals(exprectedUrl, foundUrl.getUrl()); } - log.info("------------------------------------"); + log.debug(msg+"------------------------------------"); } @Test - public void fetchTransientUrlsTest(){ + public void test002fetchTransientUrlsTest(){ + String msg = "fetchTransientUrlsTest: "; + log.debug(msg+"------------------------------------"); Map urls = new HashMap<>(); Map hosts = new HashMap<>(); for(String urlSrc : testdataProperties.getOodm().getEntities().getUrl().getUrl()){ - log.info(urlSrc); + log.debug(msg+urlSrc); CloseableHttpClient httpclient = HttpClients.createDefault(); HttpGet httpGet = new HttpGet(urlSrc); try { @@ -88,7 +93,7 @@ public void fetchTransientUrlsTest(){ HttpHost target = context.getTargetHost(); List redirectLocations = context.getRedirectLocations(); URI location = URIUtils.resolve(httpGet.getURI(), target, redirectLocations); - log.info("Final HTTP location: " + location.toASCIIString()); + log.debug(msg+"Final HTTP location: " + location.toASCIIString()); urls.put(urlSrc,location.toURL().toExternalForm()); hosts.put(urlSrc,location.toURL().getHost()); response1.close(); @@ -98,14 +103,15 @@ public void fetchTransientUrlsTest(){ log.error(e.getMessage()); } } - log.info("FETCHED HOST: Map hosts = new HashMap<>()"); - log.info("FETCHED URL: Map URLS = new HashMap<>();"); + log.debug(msg+"FETCHED HOST: Map hosts = new HashMap<>()"); + log.debug(msg+"FETCHED URL: Map URLS = new HashMap<>();"); for(Map.Entry host:hosts.entrySet()){ - log.info("FETCHED HOST: hosts.put(\""+host.getKey()+"\",\""+host.getValue()+"\");"); + log.debug(msg+"FETCHED HOST: hosts.put(\""+host.getKey()+"\",\""+host.getValue()+"\");"); } for(Map.Entry url:urls.entrySet()){ - log.info("FETCHED URL: URLS.put(\""+url.getKey()+"\",\""+url.getValue()+"\");"); + log.debug(msg+"FETCHED URL: URLS.put(\""+url.getKey()+"\",\""+url.getValue()+"\");"); } + log.debug(msg+"------------------------------------"); } } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/ApplicationControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/ApplicationControllerTest.java index 9ea9dda0..acb00475 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/ApplicationControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/ApplicationControllerTest.java @@ -2,8 +2,10 @@ import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -26,6 +28,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ApplicationControllerTest { private static final Logger log = LoggerFactory.getLogger(ApplicationControllerTest.class); @@ -41,27 +44,36 @@ public class ApplicationControllerTest { @Commit @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + String msg = "test001controllerIsPresentTest: "; + log.debug(msg+"------------------------------------"); + log.debug("controllerIsPresentTest"); assertThat(controller).isNotNull(); + assertThat(mockMvc).isNotNull(); + assertThat(prepareDataTest).isNotNull(); + log.debug(msg+"------------------------------------"); } @Commit @Test - public void setupTestData() throws Exception { - String msg = "setupTestData: "; + public void test002setupTestData() throws Exception { + String msg = "test002setupTestData: "; + log.debug(msg+"------------------------------------"); prepareDataTest.getTestDataTweets(msg); prepareDataTest.getTestDataUser(msg); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @WithMockUser @Commit @Test - public void managementPageTest() throws Exception { - String msg ="managementPageTest: "; - - MvcResult result = this.mockMvc.perform(get("/application/management")) + public void test003managementPageTest() throws Exception { + String msg ="test003managementPageTest: "; + log.debug(msg+"------------------------------------"); + String url = "/application/management"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "application/management")) .andExpect(model().attributeExists("page")) @@ -69,11 +81,12 @@ public void managementPageTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/CountedEntitiesControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/CountedEntitiesControllerTest.java index 97fc9caf..84224fea 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/CountedEntitiesControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/CountedEntitiesControllerTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.frontend.controller; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -25,6 +27,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class CountedEntitiesControllerTest { private static final Logger log = LoggerFactory.getLogger(CountedEntitiesControllerTest.class); @@ -40,18 +43,24 @@ public class CountedEntitiesControllerTest { @Commit @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + String msg = "test001controllerIsPresentTest: "; + log.debug(msg+"------------------------------------"); assertThat(controller).isNotNull(); + assertThat(prepareDataTest).isNotNull(); + assertThat(mockMvc).isNotNull(); + log.debug(msg+"------------------------------------"); } @Commit @Test - public void setupTestData() throws Exception { - String msg = "setupTestData: "; + public void test002setupTestData() throws Exception { + String msg = "test002setupTestData: "; + log.debug(msg+"------------------------------------"); prepareDataTest.getTestDataTweets(msg); prepareDataTest.getTestDataUser(msg); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } private final static String URL_PATH = "/application/countedEntities"; @@ -60,10 +69,12 @@ public void setupTestData() throws Exception { @WithMockUser @Commit @Test - public void domainCountTest() throws Exception { - String msg ="domainCountTest: "; - - MvcResult result = this.mockMvc.perform(get("/application/countedEntities/domain/count")) + public void test003domainCountTest() throws Exception { + String msg ="test003domainCountTest: "; + log.debug(msg+"------------------------------------"); + String url = "/application/countedEntities/domain/count"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "application/domain/count")) .andExpect(model().attributeExists("countedEntities")) @@ -72,21 +83,24 @@ public void domainCountTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @WithMockUser @Commit @Test - public void domainCountTweet2hashtag() throws Exception { - String msg ="domainCountTweet2hashtag: "; - - MvcResult result = this.mockMvc.perform(get(URL_PATH+"/tweet/hashtag")) + public void test004domainCountTweet2hashtag() throws Exception { + String msg ="test004domainCountTweet2hashtag: "; + log.debug(msg+"------------------------------------"); + String url =URL_PATH+"/tweet/hashtag"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( TEMPLATE_PATH )) .andExpect(model().attributeExists("page")) @@ -98,21 +112,24 @@ public void domainCountTweet2hashtag() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @WithMockUser @Commit @Test - public void domainCountTweet2media() throws Exception { - String msg ="domainCountTweet2media: "; - - MvcResult result = this.mockMvc.perform(get(URL_PATH+"/tweet/media")) + public void test005domainCountTweet2media() throws Exception { + String msg ="test005domainCountTweet2media: "; + log.debug(msg+"------------------------------------"); + String url = URL_PATH+"/tweet/media"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( TEMPLATE_PATH )) .andExpect(model().attributeExists("page")) @@ -124,21 +141,24 @@ public void domainCountTweet2media() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @WithMockUser @Commit @Test - public void domainCountTweet2mention() throws Exception { - String msg ="domainCountTweet2mention: "; - - MvcResult result = this.mockMvc.perform(get(URL_PATH+"/tweet/mention")) + public void test006domainCountTweet2mention() throws Exception { + String msg ="test006domainCountTweet2mention: "; + log.debug(msg+"------------------------------------"); + String url =URL_PATH+"/tweet/mention"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( TEMPLATE_PATH )) .andExpect(model().attributeExists("page")) @@ -150,21 +170,24 @@ public void domainCountTweet2mention() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @WithMockUser @Commit @Test - public void domainCountTweet2tickersymbol() throws Exception { - String msg ="domainCountTweet2tickersymbol: "; - - MvcResult result = this.mockMvc.perform(get(URL_PATH+"/tweet/tickersymbol")) + public void test007domainCountTweet2tickersymbol() throws Exception { + String msg ="test007domainCountTweet2tickersymbol: "; + log.debug(msg+"------------------------------------"); + String url =URL_PATH+"/tweet/tickersymbol"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( TEMPLATE_PATH )) .andExpect(model().attributeExists("page")) @@ -176,21 +199,25 @@ public void domainCountTweet2tickersymbol() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @WithMockUser @Commit @Test - public void domainCountTweet2url() throws Exception { - String msg ="domainCountTweet2url: "; + public void test008domainCountTweet2url() throws Exception { + String msg ="test008domainCountTweet2url: "; + log.debug(msg+"------------------------------------"); + String url =URL_PATH+"/tweet/url"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get(URL_PATH+"/tweet/url")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( TEMPLATE_PATH )) .andExpect(model().attributeExists("page")) @@ -202,21 +229,25 @@ public void domainCountTweet2url() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @WithMockUser @Commit @Test - public void domainCountUserprofile2hashtag() throws Exception { - String msg ="domainCountUserprofile2hashtag: "; + public void test009domainCountUserprofile2hashtag() throws Exception { + String msg ="test009domainCountUserprofile2hashtag: "; + log.debug(msg+"------------------------------------"); + String url =URL_PATH+"/user/hashtag"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get(URL_PATH+"/user/hashtag")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( TEMPLATE_PATH )) .andExpect(model().attributeExists("page")) @@ -228,21 +259,25 @@ public void domainCountUserprofile2hashtag() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @WithMockUser @Commit @Test - public void domainCountUserprofile2media() throws Exception { - String msg ="domainCountUserprofile2media: "; + public void test010domainCountUserprofile2media() throws Exception { + String msg ="test010domainCountUserprofile2media: "; + log.debug(msg+"------------------------------------"); + String url =URL_PATH+"/user/media"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get(URL_PATH+"/user/media")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( TEMPLATE_PATH )) .andExpect(model().attributeExists("page")) @@ -254,21 +289,25 @@ public void domainCountUserprofile2media() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @WithMockUser @Commit @Test - public void domainCountUserprofile2mention() throws Exception { - String msg ="domainCountUserprofile2mention: "; + public void test011domainCountUserprofile2mention() throws Exception { + String msg ="test011domainCountUserprofile2mention: "; + log.debug(msg+"------------------------------------"); + String url =URL_PATH+"/user/mention"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get(URL_PATH+"/user/mention")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( TEMPLATE_PATH )) .andExpect(model().attributeExists("page")) @@ -280,21 +319,25 @@ public void domainCountUserprofile2mention() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @WithMockUser @Commit @Test - public void domainCountUserprofile2Tickersymbol() throws Exception { - String msg ="domainCountUserprofile2Tickersymbol: "; + public void test012domainCountUserprofile2Tickersymbol() throws Exception { + String msg ="test012domainCountUserprofile2Tickersymbol: "; + log.debug(msg+"------------------------------------"); + String url =URL_PATH+"/user/tickersymbol"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get(URL_PATH+"/user/tickersymbol")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( TEMPLATE_PATH )) .andExpect(model().attributeExists("page")) @@ -306,21 +349,25 @@ public void domainCountUserprofile2Tickersymbol() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @WithMockUser @Commit @Test - public void domainCountUserprofile2Url() throws Exception { - String msg ="domainCountUserprofile2Url: "; + public void test013domainCountUserprofile2Url() throws Exception { + String msg ="test013domainCountUserprofile2Url: "; + log.debug(msg+"------------------------------------"); + String url =URL_PATH+"/user/url"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get(URL_PATH+"/user/url")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( TEMPLATE_PATH )) .andExpect(model().attributeExists("page")) @@ -332,12 +379,13 @@ public void domainCountUserprofile2Url() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/HashTagControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/HashTagControllerTest.java index 1909aa8b..08020ef3 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/HashTagControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/HashTagControllerTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.frontend.controller; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -35,6 +37,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class HashTagControllerTest { private static final Logger log = LoggerFactory.getLogger(HashTagControllerTest.class); @@ -52,26 +55,36 @@ public class HashTagControllerTest { private PrepareDataTest prepareDataTest; @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + String msg = "test001controllerIsPresentTest "; + log.debug(msg+"------------------------------------"); assertThat(controller).isNotNull(); + assertThat(mockMvc).isNotNull(); + assertThat(hashTagService).isNotNull(); + assertThat(prepareDataTest).isNotNull(); + log.debug(msg+"------------------------------------"); } @Commit @Test - public void setupTestData(){ - String msg = "setupTestData: "; + public void test002setupTestData(){ + String msg = "test002setupTestData: "; + log.debug(msg+"------------------------------------"); prepareDataTest.getTestDataTweets(msg); prepareDataTest.getTestDataUser(msg); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @Commit @WithMockUser @Test - public void getAllTest() throws Exception { - String msg ="getAllTest: "; - MvcResult result = this.mockMvc.perform(get("/hashtag/all")) + public void test003getAllTest() throws Exception { + String msg ="test003getAllTest: "; + log.debug(msg+"------------------------------------"); + String url ="/hashtag/all"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("hashtag/all")) .andExpect(model().attributeExists("myPageContent")) @@ -80,15 +93,16 @@ public void getAllTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } - private HashTag findOneHashTag(){ + private HashTag test004findOneHashTag(){ Pageable pageRequest = new PageRequest(FIRST_PAGE_NUMBER, 1); Page hashTagPage = hashTagService.getAll(pageRequest); if(hashTagPage.getContent().size()>0){ @@ -101,11 +115,14 @@ private HashTag findOneHashTag(){ @Commit @WithAnonymousUser @Test - public void findHashTagById() throws Exception { - String msg ="findHashTagById: "; - HashTag hashTag = findOneHashTag(); + public void test005findHashTagById() throws Exception { + String msg ="test005findHashTagById: "; + log.debug(msg+"------------------------------------"); + HashTag hashTag = test004findOneHashTag(); long id = hashTag.getId(); - MvcResult result = this.mockMvc.perform(get("/hashtag/"+id)) + String url ="/hashtag/"+id; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("hashtag/id")) .andExpect(model().attributeExists("users")) @@ -116,22 +133,26 @@ public void findHashTagById() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @Commit @WithAnonymousUser @Test - public void hashTagFromTweetsAndUsersTest() throws Exception { - String msg ="hashTagFromTweetsAndUsersTest: "; - HashTag hashTag = findOneHashTag(); + public void test006hashTagFromTweetsAndUsersTest() throws Exception { + String msg ="test006hashTagFromTweetsAndUsersTest: "; + log.debug(msg+"------------------------------------"); + HashTag hashTag = test004findOneHashTag(); String hashtagText = hashTag.getText(); - MvcResult result = this.mockMvc.perform(get("/hashtag/text/"+hashtagText)) + String url ="/hashtag/text/"+hashtagText; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("hashtag/id")) .andExpect(model().attributeExists("users")) @@ -142,20 +163,24 @@ public void hashTagFromTweetsAndUsersTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } @Commit @WithAnonymousUser @Test - public void hashTagsOverview() throws Exception { - String msg ="hashTagsOverview: "; - MvcResult result = this.mockMvc.perform(get("/hashtag/overview")) + public void test007hashTagsOverview() throws Exception { + String msg ="test007hashTagsOverview: "; + log.debug(msg+"------------------------------------"); + String url ="/hashtag/overview"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("hashtag/overview")) .andExpect(model().attributeExists("hashTagsTweets")) @@ -165,12 +190,13 @@ public void hashTagsOverview() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/ImprintControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/ImprintControllerTest.java index 239582a9..e9426c9c 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/ImprintControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/ImprintControllerTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.frontend.controller; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -31,6 +33,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class ImprintControllerTest { private static final Logger log = LoggerFactory.getLogger(ImprintControllerTest.class); @@ -48,36 +51,55 @@ public class ImprintControllerTest { private PrepareDataTest prepareDataTest; @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + log.debug("controllerIsPresentTest"); assertThat(controller).isNotNull(); } @Commit @Test - public void prepareDataTest() throws Exception { - log.info("------------------------------------"); - log.info("fetchTweetsFromSearchTest: START userServiceTest.createUser("+ frontendProperties.getImprintScreenName()+")"); + public void test002prepareDataTest() throws Exception { + log.debug("------------------------------------"); + log.debug("fetchTweetsFromSearchTest: START userServiceTest.createUser("+ frontendProperties.getImprintScreenName()+")"); prepareDataTest.createUser(frontendProperties.getImprintScreenName()); - log.info("fetchTweetsFromSearchTest: DONE userServiceTest.createUser("+ frontendProperties.getImprintScreenName()+")"); - log.info("------------------------------------"); + log.debug("fetchTweetsFromSearchTest: DONE userServiceTest.createUser("+ frontendProperties.getImprintScreenName()+")"); + log.debug("------------------------------------"); Assert.assertTrue(true); } @Commit @WithAnonymousUser @Test - public void imprintTest1() throws Exception { - this.mockMvc.perform(get("/imprint")).andDo(print()).andExpect(status().isOk()) - .andExpect(content().string(containsString("port80guru"))); + public void test003imprintTest1() throws Exception { + String msg ="test003imprintTest1: "; + log.debug(msg+"------------------------------------"); + String url = "/imprint"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) + .andExpect(status().isOk()) + .andExpect(content().string(containsString("port80guru"))).andReturn(); + + String content = result.getResponse().getContentAsString(); + + log.debug("#######################################"); + log.debug("#######################################"); + log.debug(content); + log.debug("#######################################"); + log.debug("#######################################"); Assert.assertTrue(true); + + log.debug(msg+"------------------------------------"); } @Commit @WithAnonymousUser @Test - public void imprintTest2() throws Exception { - MvcResult result = this.mockMvc.perform(get("/imprint")) + public void test004imprintTest2() throws Exception { + String msg ="test004imprintTest2: "; + log.debug(msg+"------------------------------------"); + String url = "/imprint"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "imprint/imprint")) .andExpect(model().attributeExists("user")) @@ -85,11 +107,12 @@ public void imprintTest2() throws Exception { String content = result.getResponse().getContentAsString(); - log.info("#######################################"); - log.info("#######################################"); - log.info(content); - log.info("#######################################"); - log.info("#######################################"); + log.debug("#######################################"); + log.debug("#######################################"); + log.debug(content); + log.debug("#######################################"); + log.debug("#######################################"); Assert.assertTrue(true); + log.debug(msg+"------------------------------------"); } } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/LoginControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/LoginControllerTest.java index 788e080a..77ffb115 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/LoginControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/LoginControllerTest.java @@ -1,14 +1,17 @@ package org.woehlke.twitterwall.frontend.controller; +import org.junit.FixMethodOrder; import org.junit.Ignore; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.boot.test.autoconfigure.web.servlet.AutoConfigureMockMvc; import org.springframework.boot.test.context.SpringBootTest; +import org.springframework.security.test.context.support.WithAnonymousUser; import org.springframework.test.annotation.Commit; import org.springframework.test.context.junit4.SpringRunner; import org.springframework.test.web.servlet.MockMvc; @@ -19,6 +22,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class LoginControllerTest { private static final Logger log = LoggerFactory.getLogger(LoginControllerTest.class); @@ -30,8 +34,8 @@ public class LoginControllerTest { private MockMvc mockMvc; @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + log.debug("controllerIsPresentTest"); assertThat(controller).isNotNull(); } @@ -39,8 +43,13 @@ public void controllerIsPresentTest(){ //TODO: #218 https://github.com/phasenraum2010/twitterwall2/issues/218 @Commit @Ignore + @WithAnonymousUser @Test - public void login() throws Exception { + public void test002login() throws Exception { + String msg ="test002login: "; + log.debug(msg+"------------------------------------"); + String url = "/login"; + log.info(msg+url); boolean ok = true; assertThat(ok).isTrue(); } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/MediaControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/MediaControllerTest.java index 4b1b88aa..18c831d7 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/MediaControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/MediaControllerTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.frontend.controller; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -31,6 +33,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class MediaControllerTest { private static final Logger log = LoggerFactory.getLogger(MediaControllerTest.class); @@ -49,14 +52,14 @@ public class MediaControllerTest { @Commit @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + log.debug("controllerIsPresentTest"); assertThat(controller).isNotNull(); } @Commit @Test - public void setupTestData() throws Exception { + public void test002setupTestData() throws Exception { String msg = "setupTestData: "; prepareDataTest.getTestDataTweets(msg); prepareDataTest.getTestDataUser(msg); @@ -66,9 +69,12 @@ public void setupTestData() throws Exception { @WithMockUser @Commit @Test - public void getAllTest() throws Exception { - String msg ="getAllTest: "; - MvcResult result = this.mockMvc.perform(get("/media/all")) + public void test003getAllTest() throws Exception { + String msg ="test003getAllTest: "; + log.debug(msg+"------------------------------------"); + String url = "/media/all"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("media/all")) .andExpect(model().attributeExists("myPageContent")) @@ -77,23 +83,26 @@ public void getAllTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @Commit @WithMockUser @Test - public void getMediaById() throws Exception { - String msg ="getMediaById: "; + public void test004getMediaById() throws Exception { + String msg ="test004getMediaById: "; + log.debug(msg+"------------------------------------"); Media oneMedia = findOneMedia(); if(oneMedia != null) { long id = oneMedia.getId(); - MvcResult result = this.mockMvc.perform(get("/media/" + id)) + String url = "/media/" + id; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("media/id")) .andExpect(model().attributeExists("users")) @@ -104,11 +113,11 @@ public void getMediaById() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg + "#######################################"); - log.info(msg + "#######################################"); - log.info(msg + content); - log.info(msg + "#######################################"); - log.info(msg + "#######################################"); + log.debug(msg + "#######################################"); + log.debug(msg + "#######################################"); + log.debug(msg + content); + log.debug(msg + "#######################################"); + log.debug(msg + "#######################################"); Assert.assertTrue(true); } } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/MentionControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/MentionControllerTest.java index 748ff547..d8d1d10b 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/MentionControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/MentionControllerTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.frontend.controller; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -31,6 +33,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class MentionControllerTest { private static final Logger log = LoggerFactory.getLogger(MentionControllerTest.class); @@ -49,14 +52,14 @@ public class MentionControllerTest { @Commit @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + log.debug("controllerIsPresentTest"); assertThat(controller).isNotNull(); } @Commit @Test - public void setupTestData() throws Exception { + public void test002setupTestData() throws Exception { String msg = "setupTestData: "; prepareDataTest.getTestDataTweets(msg); prepareDataTest.getTestDataUser(msg); @@ -66,34 +69,40 @@ public void setupTestData() throws Exception { @WithMockUser @Commit @Test - public void getAllTest() throws Exception { - String msg ="getAllTest: "; - MvcResult result = this.mockMvc.perform(get("/media/all")) + public void test003getAllTest() throws Exception { + String msg ="test003getAllTest: "; + log.debug(msg+"------------------------------------"); + String url = "/mention/all"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) - .andExpect(view().name("media/all")) + .andExpect(view().name("mention/all")) .andExpect(model().attributeExists("myPageContent")) .andExpect(model().attributeExists("page")) .andReturn(); String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @Commit @WithMockUser @Test - public void getMentionById() throws Exception { - String msg ="getMentionById: "; + public void test004getMentionById() throws Exception { + String msg ="test004getMentionById: "; + log.debug(msg+"------------------------------------"); Mention oneMention = findOneMention(); if(oneMention != null) { long id = oneMention.getId(); - MvcResult result = this.mockMvc.perform(get("/mention/" + id)) + String url = "/mention/" + id; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("mention/id")) .andExpect(model().attributeExists("users")) @@ -104,11 +113,11 @@ public void getMentionById() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg + "#######################################"); - log.info(msg + "#######################################"); - log.info(msg + content); - log.info(msg + "#######################################"); - log.info(msg + "#######################################"); + log.debug(msg + "#######################################"); + log.debug(msg + "#######################################"); + log.debug(msg + content); + log.debug(msg + "#######################################"); + log.debug(msg + "#######################################"); Assert.assertTrue(true); } } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/TaskControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/TaskControllerTest.java index aea995b7..0a931f9f 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/TaskControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/TaskControllerTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.frontend.controller; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -34,6 +36,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TaskControllerTest { private static final Logger log = LoggerFactory.getLogger(TaskControllerTest.class); @@ -54,14 +57,14 @@ public class TaskControllerTest { private CountedEntitiesService countedEntitiesService; @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + log.debug("controllerIsPresentTest"); assertThat(controller).isNotNull(); } @Commit @Test - public void setupTestData() throws Exception { + public void test002setupTestData() throws Exception { String msg = "setupTestData: "; prepareDataTest.getTestDataTweets(msg); prepareDataTest.getTestDataUser(msg); @@ -71,8 +74,12 @@ public void setupTestData() throws Exception { @Commit @WithMockUser @Test - public void getAllTest()throws Exception { - MvcResult result = this.mockMvc.perform(get("/task/all")) + public void test003getAllTest()throws Exception { + String msg ="test003getAllTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/all"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "task/all")) .andExpect(model().attributeExists("tasks")) @@ -81,25 +88,28 @@ public void getAllTest()throws Exception { String content = result.getResponse().getContentAsString(); - log.info("#######################################"); - log.info("#######################################"); - log.info(content); - log.info("#######################################"); - log.info("#######################################"); + log.debug("#######################################"); + log.debug("#######################################"); + log.debug(content); + log.debug("#######################################"); + log.debug("#######################################"); Assert.assertTrue(true); } @Commit @WithMockUser @Test - public void getTaskByIdTest() throws Exception { + public void test004getTaskByIdTest() throws Exception { + String msg ="test004getTaskByIdTest: "; + log.debug(msg+"------------------------------------"); CountedEntities countedEntities = countedEntitiesService.countAll(); - String msg ="getTaskByIdTest: "; TaskType taskType = TaskType.FETCH_TWEETS_FROM_SEARCH; TaskSendType taskSendType = TaskSendType.NO_MQ; Task task = taskService.create(msg,taskType, taskSendType,countedEntities); long id = task.getId(); - MvcResult result = this.mockMvc.perform(get("/task/"+id)) + String url = "/task/"+id; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "task/id")) .andExpect(model().attributeExists("task")) @@ -109,19 +119,23 @@ public void getTaskByIdTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info("#######################################"); - log.info("#######################################"); - log.info(content); - log.info("#######################################"); - log.info("#######################################"); + log.debug("#######################################"); + log.debug("#######################################"); + log.debug(content); + log.debug("#######################################"); + log.debug("#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void createTestDataTest() throws Exception { - MvcResult result = this.mockMvc.perform(get("/task/start/createTestData")) + public void test005createTestDataTest() throws Exception { + String msg ="test005createTestDataTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/createTestData"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "task/start/createTestData")) .andExpect(model().attributeExists("taskTweets")) @@ -131,20 +145,23 @@ public void createTestDataTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info("#######################################"); - log.info("#######################################"); - log.info(content); - log.info("#######################################"); - log.info("#######################################"); + log.debug("#######################################"); + log.debug("#######################################"); + log.debug(content); + log.debug("#######################################"); + log.debug("#######################################"); Assert.assertTrue(true); } @Commit @WithMockUser @Test - public void getOnListRenewTest() throws Exception { - String msg = "getOnListRenewTest: "; - MvcResult result = this.mockMvc.perform(get("/task/start/user/onlist/renew")) + public void test006getOnListRenewTest() throws Exception { + String msg ="test006getOnListRenewTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/user/onlist/renew"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "task/start/renew")) .andExpect(model().attributeExists("users")) @@ -153,11 +170,11 @@ public void getOnListRenewTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @@ -166,9 +183,12 @@ public void getOnListRenewTest() throws Exception { @WithMockUser @Commit @Test - public void fetchTweetsFromTwitterSearchStartTaskTest() throws Exception { - String msg = "fetchTweetsFromTwitterSearchStartTaskTest: "; - MvcResult result = this.mockMvc.perform(get("/task/start/tweets/search")) + public void test007fetchTweetsFromTwitterSearchStartTaskTest() throws Exception { + String msg ="test007fetchTweetsFromTwitterSearchStartTaskTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/tweets/search"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( PATH+"/start/taskStarted")) .andExpect(model().attributeExists("task")) @@ -177,20 +197,23 @@ public void fetchTweetsFromTwitterSearchStartTaskTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void fetchFollowerStartTaskTest() throws Exception { - String msg = "fetchFollowerStartTaskTest: "; - MvcResult result = this.mockMvc.perform(get("/task/start/users/follower/fetch")) + public void test008fetchFollowerStartTaskTest() throws Exception { + String msg ="test008fetchFollowerStartTaskTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/users/follower/fetch"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( PATH+"/start/taskStarted")) .andExpect(model().attributeExists("task")) @@ -199,20 +222,23 @@ public void fetchFollowerStartTaskTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void fetchFriendsStartTask() throws Exception { - String msg = "fetchFriendsStartTask: "; - MvcResult result = this.mockMvc.perform(get("/task/start/users/friends/fetch")) + public void test009fetchFriendsStartTask() throws Exception { + String msg ="test009fetchFriendsStartTask: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/users/friends/fetch"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( PATH+"/start/taskStarted")) .andExpect(model().attributeExists("task")) @@ -221,20 +247,23 @@ public void fetchFriendsStartTask() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void updateTweetsStartTaskTest() throws Exception { - String msg = "updateTweetsStartTaskTest: "; - MvcResult result = this.mockMvc.perform(get("/task/start/user/onlist/renew")) + public void test010updateTweetsStartTaskTest() throws Exception { + String msg ="test010updateTweetsStartTaskTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/user/onlist/renew"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "task/start/renew")) .andExpect(model().attributeExists("task")) @@ -243,20 +272,23 @@ public void updateTweetsStartTaskTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void fetchUsersFromDefinedUserListStartTaskTest() throws Exception { - String msg = "fetchUsersFromDefinedUserListStartTaskTest: "; - MvcResult result = this.mockMvc.perform(get("/task/start/users/list/fetch")) + public void test011fetchUsersFromDefinedUserListStartTaskTest() throws Exception { + String msg ="test011fetchUsersFromDefinedUserListStartTaskTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/users/list/fetch"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( PATH+"/start/taskStarted")) .andExpect(model().attributeExists("task")) @@ -265,20 +297,23 @@ public void fetchUsersFromDefinedUserListStartTaskTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void updateUserProfilesFromMentionsStartTaskTest() throws Exception { - String msg = "updateUserProfilesFromMentionsStartTaskTest: "; - MvcResult result = this.mockMvc.perform(get("/task/start/users/list/fetch")) + public void test012updateUserProfilesFromMentionsStartTaskTest() throws Exception { + String msg ="test012updateUserProfilesFromMentionsStartTaskTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/users/list/fetch"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( PATH+"/start/taskStarted")) .andExpect(model().attributeExists("task")) @@ -287,20 +322,23 @@ public void updateUserProfilesFromMentionsStartTaskTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void updateUserProfilesStartTaskTest() throws Exception { - String msg = "updateUserProfilesStartTaskTest: "; - MvcResult result = this.mockMvc.perform(get("/task/start/users/mentions/update")) + public void test013updateUserProfilesStartTaskTest() throws Exception { + String msg ="test013updateUserProfilesStartTaskTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/users/mentions/update"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( PATH+"/start/taskStarted")) .andExpect(model().attributeExists("task")) @@ -309,20 +347,23 @@ public void updateUserProfilesStartTaskTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getHomeTimelineTest() throws Exception { - String msg = "updateUserProfilesStartTaskTest: "; - MvcResult result = this.mockMvc.perform(get("/task/start/tweets/timeline/home")) + public void test014getHomeTimelineTest() throws Exception { + String msg ="test014getHomeTimelineTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/tweets/timeline/home"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( PATH+"/start/taskStarted")) .andExpect(model().attributeExists("task")) @@ -331,20 +372,23 @@ public void getHomeTimelineTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getUserTimelineTest() throws Exception { - String msg = "updateUserProfilesStartTaskTest: "; - MvcResult result = this.mockMvc.perform(get("/task/start/tweets/timeline/user")) + public void test015getUserTimelineTest() throws Exception { + String msg ="test015getUserTimelineTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/tweets/timeline/user"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( PATH+"/start/taskStarted")) .andExpect(model().attributeExists("task")) @@ -353,20 +397,23 @@ public void getUserTimelineTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getMentionsTest() throws Exception { - String msg = "updateUserProfilesStartTaskTest: "; - MvcResult result = this.mockMvc.perform(get("/task/start/tweets/mentions")) + public void test016getMentionsTest() throws Exception { + String msg ="test016getMentionsTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/tweets/mentions"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( PATH+"/start/taskStarted")) .andExpect(model().attributeExists("task")) @@ -375,20 +422,23 @@ public void getMentionsTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getFavoritesTest() throws Exception { - String msg = "updateUserProfilesStartTaskTest: "; - MvcResult result = this.mockMvc.perform(get("/task/start/tweets/favorites")) + public void test017getFavoritesTest() throws Exception { + String msg ="test017getFavoritesTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/tweets/favorites"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( PATH+"/start/taskStarted")) .andExpect(model().attributeExists("task")) @@ -397,20 +447,23 @@ public void getFavoritesTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getRetweetsOfMeTest() throws Exception { - String msg = "updateUserProfilesStartTaskTest: "; - MvcResult result = this.mockMvc.perform(get("/task/start/tweets/myretweets")) + public void test018getRetweetsOfMeTest() throws Exception { + String msg ="test018getRetweetsOfMeTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/tweets/myretweets"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( PATH+"/start/taskStarted")) .andExpect(model().attributeExists("task")) @@ -419,20 +472,23 @@ public void getRetweetsOfMeTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getListsTest() throws Exception { - String msg = "updateUserProfilesStartTaskTest: "; - MvcResult result = this.mockMvc.perform(get("/task/start/userlists")) + public void test019getListsTest() throws Exception { + String msg ="test019getListsTest: "; + log.debug(msg+"------------------------------------"); + String url = "/task/start/userlists"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( PATH+"/start/tasksStarted")) .andExpect(model().attributeExists("listOfTasks")) @@ -441,11 +497,11 @@ public void getListsTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/TaskHistoryControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/TaskHistoryControllerTest.java index 6260241b..25657469 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/TaskHistoryControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/TaskHistoryControllerTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.frontend.controller; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -25,6 +27,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TaskHistoryControllerTest { private static final Logger log = LoggerFactory.getLogger(TaskHistoryControllerTest.class); @@ -40,14 +43,14 @@ public class TaskHistoryControllerTest { @Commit @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + log.debug("controllerIsPresentTest"); assertThat(controller).isNotNull(); } @Commit @Test - public void setupTestData() throws Exception { + public void test002setupTestData() throws Exception { String msg = "setupTestData: "; prepareDataTest.getTestDataTweets(msg); prepareDataTest.getTestDataUser(msg); @@ -57,10 +60,13 @@ public void setupTestData() throws Exception { @WithMockUser @Commit @Test - public void getAllTest() throws Exception { - String msg = "getAllTest: "; + public void test003getAllTest() throws Exception { + String msg ="test003getAllTest: "; + log.debug(msg+"------------------------------------"); + String url = "/taskhistory/all"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get("/taskhistory/all")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "taskhistory/all")) .andExpect(model().attributeExists("myPageContent")) @@ -69,11 +75,11 @@ public void getAllTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/TickerSymbolControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/TickerSymbolControllerTest.java index 465fb194..44051cc2 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/TickerSymbolControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/TickerSymbolControllerTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.frontend.controller; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -31,6 +33,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TickerSymbolControllerTest { private static final Logger log = LoggerFactory.getLogger(TickerSymbolControllerTest.class); @@ -48,13 +51,14 @@ public class TickerSymbolControllerTest { private MockMvc mockMvc; @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + log.debug("controllerIsPresentTest"); assertThat(controller).isNotNull(); } + @Commit @Test - public void setupTestData() throws Exception { + public void test002setupTestData() throws Exception { String msg = "setupTestData: "; prepareDataTest.getTestDataTweets(msg); prepareDataTest.getTestDataUser(msg); @@ -64,10 +68,13 @@ public void setupTestData() throws Exception { @Commit @WithMockUser @Test - public void getAllTest() throws Exception { - String msg = "getAllTest: "; + public void test003getAllTest() throws Exception { + String msg ="test003getAllTest: "; + log.debug(msg+"------------------------------------"); + String url = "/tickersymbol/all"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get("/tickersymbol/all")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "tickersymbol/all")) .andExpect(model().attributeExists("myPageContent")) @@ -76,23 +83,26 @@ public void getAllTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @Commit @WithMockUser @Test - public void getTickerSymbolById() throws Exception { - String msg ="getTickerSymbolById: "; + public void test004getTickerSymbolById() throws Exception { + String msg ="test004getTickerSymbolById: "; + log.debug(msg+"------------------------------------"); TickerSymbol oneTickerSymbol = findOneTickerSymbol(); if(oneTickerSymbol != null) { long id = oneTickerSymbol.getId(); - MvcResult result = this.mockMvc.perform(get("/tickersymbol/" + id)) + String url = "/tickersymbol/" + id; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("tickersymbol/id")) .andExpect(model().attributeExists("users")) @@ -103,11 +113,11 @@ public void getTickerSymbolById() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg + "#######################################"); - log.info(msg + "#######################################"); - log.info(msg + content); - log.info(msg + "#######################################"); - log.info(msg + "#######################################"); + log.debug(msg + "#######################################"); + log.debug(msg + "#######################################"); + log.debug(msg + content); + log.debug(msg + "#######################################"); + log.debug(msg + "#######################################"); Assert.assertTrue(true); } } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/TweetControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/TweetControllerTest.java index 983c7e02..b34d031b 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/TweetControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/TweetControllerTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.frontend.controller; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -35,6 +37,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TweetControllerTest { private static final Logger log = LoggerFactory.getLogger(TweetControllerTest.class); @@ -54,14 +57,14 @@ public class TweetControllerTest { @Commit @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + log.debug("controllerIsPresentTest"); assertThat(controller).isNotNull(); } @Commit @Test - public void setupTestData() throws Exception { + public void test002setupTestData() throws Exception { String msg = "setupTestData: "; prepareDataTest.getTestDataTweets(msg); prepareDataTest.getTestDataUser(msg); @@ -71,10 +74,13 @@ public void setupTestData() throws Exception { @WithAnonymousUser @Commit @Test - public void getLatestTweetsTest() throws Exception { - String msg ="getLatestTweetsTest: "; + public void test003getLatestTweetsTest() throws Exception { + String msg ="test003getLatestTweetsTest: "; + log.debug(msg+"------------------------------------"); + String url = "/tweet/all"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get("/tweet/all")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "tweet/all")) .andExpect(model().attributeExists("latestTweets")) @@ -83,11 +89,11 @@ public void getLatestTweetsTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @@ -104,11 +110,13 @@ private Tweet findOneTweet(){ @WithMockUser @Commit @Test - public void getTweetById() throws Exception { - String msg ="getLatestTweetsById: "; + public void test004getTweetById() throws Exception { + String msg ="test003getLatestTweetsTest: "; + log.debug(msg+"------------------------------------"); Tweet tweet = findOneTweet(); - - MvcResult result = this.mockMvc.perform(get("/tweet/"+tweet.getId())) + String url = "/tweet/"+tweet.getId(); + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "tweet/id")) .andExpect(model().attributeExists("tweet")) @@ -117,21 +125,24 @@ public void getTweetById() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getHomeTimeline() throws Exception { - String msg ="getHomeTimeline: "; + public void test005getHomeTimeline() throws Exception { + String msg ="test005getHomeTimeline: "; + log.debug(msg+"------------------------------------"); + String url = "/tweet/timeline/home"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get("/tweet/timeline/home")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "tweet/all")) .andExpect(model().attributeExists("latestTweets")) @@ -140,21 +151,24 @@ public void getHomeTimeline() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getUserTimeline() throws Exception { - String msg ="getUserTimeline: "; + public void test006getUserTimeline() throws Exception { + String msg ="test006getUserTimeline: "; + log.debug(msg+"------------------------------------"); + String url = "/tweet/timeline/user"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get("/tweet/timeline/user")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "tweet/all")) .andExpect(model().attributeExists("latestTweets")) @@ -163,21 +177,24 @@ public void getUserTimeline() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getMentions() throws Exception { - String msg ="getMentions: "; + public void test007getMentions() throws Exception { + String msg ="test007getMentions: "; + log.debug(msg+"------------------------------------"); + String url = "/tweet/mentions"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get("/tweet/mentions")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "tweet/all")) .andExpect(model().attributeExists("latestTweets")) @@ -186,21 +203,24 @@ public void getMentions() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getFavorites() throws Exception { - String msg ="getFavorites: "; + public void test008getFavorites() throws Exception { + String msg ="test008getFavorites: "; + log.debug(msg+"------------------------------------"); + String url = "/tweet/favorites"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get("/tweet/favorites")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "tweet/all")) .andExpect(model().attributeExists("latestTweets")) @@ -209,21 +229,24 @@ public void getFavorites() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getRetweetsOfMe() throws Exception { - String msg ="getRetweetsOfMe: "; + public void test009getRetweetsOfMe() throws Exception { + String msg ="test009getRetweetsOfMe: "; + log.debug(msg+"------------------------------------"); + String url = "/tweet/retweets"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get("/tweet/retweets")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name( "tweet/all")) .andExpect(model().attributeExists("latestTweets")) @@ -232,11 +255,11 @@ public void getRetweetsOfMe() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/UrlControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/UrlControllerTest.java index a291046e..8b2e17a5 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/UrlControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/UrlControllerTest.java @@ -2,8 +2,10 @@ import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -32,6 +34,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UrlControllerTest { private static final Logger log = LoggerFactory.getLogger(UrlControllerTest.class); @@ -50,14 +53,14 @@ public class UrlControllerTest { @Commit @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + log.debug("controllerIsPresentTest"); assertThat(controller).isNotNull(); } @Commit @Test - public void setupTestData() throws Exception { + public void test002setupTestData() throws Exception { String msg = "setupTestData: "; prepareDataTest.getTestDataTweets(msg); prepareDataTest.getTestDataUser(msg); @@ -67,9 +70,12 @@ public void setupTestData() throws Exception { @WithMockUser @Commit @Test - public void getAllTest() throws Exception { - String msg ="getAllTest: "; - MvcResult result = this.mockMvc.perform(get("/url/all")) + public void test003getAllTest() throws Exception { + String msg ="test003getAllTest: "; + log.debug(msg+"------------------------------------"); + String url = "/url/all"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("url/all")) .andExpect(model().attributeExists("myPageContent")) @@ -78,23 +84,26 @@ public void getAllTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @Commit @WithMockUser @Test - public void getUrlById() throws Exception { - String msg ="getUrlById: "; + public void test004getUrlById() throws Exception { + String msg ="test004getUrlById: "; + log.debug(msg+"------------------------------------"); Url oneUrl = findOneUrl(); if(oneUrl != null) { long id = oneUrl.getId(); - MvcResult result = this.mockMvc.perform(get("/url/" + id)) + String url = "/url/" + id; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("url/id")) .andExpect(model().attributeExists("users")) @@ -105,11 +114,11 @@ public void getUrlById() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg + "#######################################"); - log.info(msg + "#######################################"); - log.info(msg + content); - log.info(msg + "#######################################"); - log.info(msg + "#######################################"); + log.debug(msg + "#######################################"); + log.debug(msg + "#######################################"); + log.debug(msg + content); + log.debug(msg + "#######################################"); + log.debug(msg + "#######################################"); Assert.assertTrue(true); } } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/UserControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/UserControllerTest.java index b359351b..d13637c8 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/UserControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/UserControllerTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.frontend.controller; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -38,6 +40,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UserControllerTest { private static final Logger log = LoggerFactory.getLogger(UserControllerTest.class); @@ -65,14 +68,14 @@ public class UserControllerTest { @Commit @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + log.debug("controllerIsPresentTest"); assertThat(controller).isNotNull(); } @Commit @Test - public void setupTestData() throws Exception { + public void test002setupTestData() throws Exception { String msg = "setupTestData: "; prepareDataTest.getTestDataTweets(msg); prepareDataTest.getTestDataUser(msg); @@ -82,9 +85,12 @@ public void setupTestData() throws Exception { @WithMockUser @Commit @Test - public void getAllTest() throws Exception { - String msg = "getAllTest: "; - MvcResult result = this.mockMvc.perform(get("/user/all")) + public void test003getAllTest() throws Exception { + String msg ="test003getAllTest: "; + log.debug(msg+"------------------------------------"); + String url = "/user/all"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("user/all")) .andExpect(model().attributeExists("users")) @@ -93,11 +99,11 @@ public void getAllTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @@ -114,10 +120,13 @@ private User findOneUser(){ @WithMockUser @Commit @Test - public void getUserForIdTest() throws Exception { - String msg = "getUserForIdTest: "; + public void test004getUserForIdTest() throws Exception { + String msg ="test004getUserForIdTest: "; + log.debug(msg+"------------------------------------"); User user = findOneUser(); - MvcResult result = this.mockMvc.perform(get("/user/"+user.getId())) + String url = "/user/"+user.getId(); + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("user/id")) .andExpect(model().attributeExists("user")) @@ -127,11 +136,11 @@ public void getUserForIdTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @@ -139,10 +148,13 @@ public void getUserForIdTest() throws Exception { @WithAnonymousUser @Commit @Test - public void getUserForScreeNameTest() throws Exception { - String msg = "getUserForScreeNameTest: "; + public void test005getUserForScreeNameTest() throws Exception { + String msg ="test005getUserForScreeNameTest: "; + log.debug(msg+"------------------------------------"); User user = findOneUser(); - MvcResult result = this.mockMvc.perform(get("/user/screenName/"+ user.getScreenName())) + String url = "/user/screenName/"+ user.getScreenName(); + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("user/id")) .andExpect(model().attributeExists("user")) @@ -152,20 +164,23 @@ public void getUserForScreeNameTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithAnonymousUser @Commit @Test - public void getTweetingUsersTest() throws Exception { - String msg = "getTweetingUsersTest: "; - MvcResult result = this.mockMvc.perform(get("/user/list/tweets")) + public void test006getTweetingUsersTest() throws Exception { + String msg ="test006getTweetingUsersTest: "; + log.debug(msg+"------------------------------------"); + String url = "/user/list/tweets"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("user/list/allWithTweets")) .andExpect(model().attributeExists("users")) @@ -174,20 +189,23 @@ public void getTweetingUsersTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getNotYetFriendUsersTest() throws Exception { - String msg = "getNotYetFriendUsersTest: "; - MvcResult result = this.mockMvc.perform(get("/user/list/notyetfriends")) + public void test007getNotYetFriendUsersTest() throws Exception { + String msg ="test007getNotYetFriendUsersTest: "; + log.debug(msg+"------------------------------------"); + String url = "/user/list/notyetfriends"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("user/list/friendsNotYet")) .andExpect(model().attributeExists("users")) @@ -196,21 +214,24 @@ public void getNotYetFriendUsersTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getFriendUsersTest() throws Exception { - String msg = "getFriendUsersTest: "; + public void test008getFriendUsersTest() throws Exception { + String msg ="test008getFriendUsersTest: "; + log.debug(msg+"------------------------------------"); + String url = "/user/list/friends"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get("/user/list/friends")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("user/list/friends")) .andExpect(model().attributeExists("users")) @@ -219,11 +240,11 @@ public void getFriendUsersTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @@ -231,10 +252,13 @@ public void getFriendUsersTest() throws Exception { @WithMockUser @Commit @Test - public void getFollowerTest() throws Exception { - String msg = "getFollowerTest: "; + public void test009getFollowerTest() throws Exception { + String msg ="test009getFollowerTest: "; + log.debug(msg+"------------------------------------"); + String url = "/user/list/follower"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get("/user/list/follower")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("user/list/follower")) .andExpect(model().attributeExists("users")) @@ -243,11 +267,11 @@ public void getFollowerTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @@ -255,10 +279,13 @@ public void getFollowerTest() throws Exception { @WithMockUser @Commit @Test - public void getNotYetFollowerTest() throws Exception { - String msg = "getNotYetFollowerTest: "; + public void test010getNotYetFollowerTest() throws Exception { + String msg ="test010getNotYetFollowerTest: "; + log.debug(msg+"------------------------------------"); + String url = "/user/list/notyetfollower"; + log.info(msg+url); - MvcResult result = this.mockMvc.perform(get("/user/list/notyetfollower")) + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("user/list/followerNotYet")) .andExpect(model().attributeExists("users")) @@ -267,20 +294,23 @@ public void getNotYetFollowerTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getOnListTest() throws Exception { - String msg = "getOnListTest: "; - MvcResult result = this.mockMvc.perform(get("/user/list/onlist")) + public void test011getOnListTest() throws Exception { + String msg ="test011getOnListTest: "; + log.debug(msg+"------------------------------------"); + String url = "/user/list/onlist"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("user/list/onlist")) .andExpect(model().attributeExists("users")) @@ -289,20 +319,23 @@ public void getOnListTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @WithMockUser @Commit @Test - public void getNotYetOnListTest() throws Exception { - String msg = "getNotYetOnListTest: "; - MvcResult result = this.mockMvc.perform(get("/user/list/notyetonlist")) + public void test012getNotYetOnListTest() throws Exception { + String msg ="test012getNotYetOnListTest: "; + log.debug(msg+"------------------------------------"); + String url = "/user/list/notyetonlist"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("user/list/onlistNotYet")) .andExpect(model().attributeExists("users")) @@ -311,11 +344,11 @@ public void getNotYetOnListTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/UserListControllerTest.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/UserListControllerTest.java index d49c21fd..cacb9a93 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/UserListControllerTest.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/UserListControllerTest.java @@ -2,8 +2,10 @@ import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -26,6 +28,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(classes={Application.class},webEnvironment=SpringBootTest.WebEnvironment.RANDOM_PORT) @AutoConfigureMockMvc +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UserListControllerTest { private static final Logger log = LoggerFactory.getLogger(UserListControllerTest.class); @@ -42,17 +45,20 @@ public class UserListControllerTest { @Commit @Test - public void controllerIsPresentTest(){ - log.info("controllerIsPresentTest"); + public void test001controllerIsPresentTest(){ + log.debug("controllerIsPresentTest"); assertThat(controller).isNotNull(); } @WithMockUser @Commit @Test - public void getAllTest() throws Exception { - String msg = "getAllTest: "; - MvcResult result = this.mockMvc.perform(get("/userlist/all")) + public void test002getAllTest() throws Exception { + String msg ="test002getAllTest: "; + log.debug(msg+"------------------------------------"); + String url = "/userlist/all"; + log.info(msg+url); + MvcResult result = this.mockMvc.perform(get(url)) .andExpect(status().isOk()) .andExpect(view().name("userlist/all")) .andExpect(model().attributeExists("myPageContent")) @@ -61,11 +67,11 @@ public void getAllTest() throws Exception { String content = result.getResponse().getContentAsString(); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); - log.info(msg+content); - log.info(msg+"#######################################"); - log.info(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); + log.debug(msg+content); + log.debug(msg+"#######################################"); + log.debug(msg+"#######################################"); Assert.assertTrue(true); } @@ -73,7 +79,11 @@ public void getAllTest() throws Exception { @WithMockUser @Commit @Test - public void getUserListForIdTest() throws Exception { + public void test003getUserListForIdTest() throws Exception { + String msg ="test003getUserListForIdTest: "; + log.debug(msg+"------------------------------------"); + //String url = "/userlist/all"; + //log.info(msg+url); Assert.assertTrue(true); } diff --git a/src/test/java/org/woehlke/twitterwall/frontend/controller/common/impl/PrepareDataTestImpl.java b/src/test/java/org/woehlke/twitterwall/frontend/controller/common/impl/PrepareDataTestImpl.java index 1e67b057..120307d0 100644 --- a/src/test/java/org/woehlke/twitterwall/frontend/controller/common/impl/PrepareDataTestImpl.java +++ b/src/test/java/org/woehlke/twitterwall/frontend/controller/common/impl/PrepareDataTestImpl.java @@ -60,7 +60,7 @@ public void getTestDataTweets(String msg){ Task task = taskService.create(msg, taskType, taskSendType, countedEntities); List latest = new ArrayList<>(); try { - log.info(msg + "--------------------------------------------------------------------"); + log.debug(msg + "--------------------------------------------------------------------"); int loopId = 0; List idTwitterListTweets = testdataProperties.getOodm().getEntities().getTweet().getIdTwitter(); for (long idTwitter : idTwitterListTweets) { @@ -68,9 +68,9 @@ public void getTestDataTweets(String msg){ org.woehlke.twitterwall.oodm.model.Tweet persTweet = tweetService.findByIdTwitter(idTwitter); if(persTweet != null){ loopId++; - log.info(msg + "--------------------------------------------------------------------"); - log.info(msg + loopId + " " + persTweet.getUniqueId()); - log.info(msg + "--------------------------------------------------------------------"); + log.debug(msg + "--------------------------------------------------------------------"); + log.debug(msg + loopId + " " + persTweet.getUniqueId()); + log.debug(msg + "--------------------------------------------------------------------"); latest.add(persTweet); } else { org.springframework.social.twitter.api.Tweet tweet = twitterApiService.findOneTweetById(idTwitter); @@ -78,9 +78,9 @@ public void getTestDataTweets(String msg){ persTweet = this.storeOneTweet.storeOneTweet(tweet, task); if (persTweet != null) { loopId++; - log.info(msg + "--------------------------------------------------------------------"); - log.info(msg + loopId + " " + persTweet.getUniqueId()); - log.info(msg + "--------------------------------------------------------------------"); + log.debug(msg + "--------------------------------------------------------------------"); + log.debug(msg + loopId + " " + persTweet.getUniqueId()); + log.debug(msg + "--------------------------------------------------------------------"); latest.add(persTweet); } } @@ -92,11 +92,11 @@ public void getTestDataTweets(String msg){ } } } catch (RateLimitExceededException e) { - log.info(msg + e.getMessage()); + log.debug(msg + e.getMessage()); } catch (Exception e) { log.warn(msg + e.getMessage()); } finally { - log.info(msg + "--------------------------------------------------------------------"); + log.debug(msg + "--------------------------------------------------------------------"); } for(Tweet tweet:latest){ log.debug(msg + tweet.toString()); @@ -165,7 +165,7 @@ public void getTestDataUser(String msg){ log.warn(msg + e.getMessage()); } } catch (RateLimitExceededException e) { - log.info(msg + e.getMessage()); + log.debug(msg + e.getMessage()); } catch (Exception e) { log.warn(msg + e.getMessage()); } @@ -183,39 +183,39 @@ public User createUser(String screenName) { CountedEntities countedEntities = countedEntitiesService.countAll(); String msg = "createUser for screenName="+screenName; Task task = taskService.create(msg, taskType, taskSendType, countedEntities); - log.info("-----------------------------------------"); + log.debug("-----------------------------------------"); try { - log.info("screenName = "+ screenName); + log.debug("screenName = "+ screenName); User user = userService.findByScreenName(screenName); - log.info("userService.findByScreenName: found User = "+user.toString()); - log.info("model.addAttribute user = "+user.toString()); + log.debug("userService.findByScreenName: found User = "+user.toString()); + log.debug("model.addAttribute user = "+user.toString()); return user; } catch (EmptyResultDataAccessException e){ - log.info("EmptyResultDataAccessException at userService.findByScreenName for screenName="+screenName); + log.debug("EmptyResultDataAccessException at userService.findByScreenName for screenName="+screenName); TwitterProfile twitterProfile = twitterApiService.getUserProfileForScreenName(screenName); - log.info("twitterApiService.getUserProfileForScreenName: found TwitterProfile = "+twitterProfile.toString()); + log.debug("twitterApiService.getUserProfileForScreenName: found TwitterProfile = "+twitterProfile.toString()); try { - log.info("try: persistDataFromTwitter.storeUserProfile for twitterProfile = "+twitterProfile.toString()); + log.debug("try: persistDataFromTwitter.storeUserProfile for twitterProfile = "+twitterProfile.toString()); User user = storeUserProfile.storeUserProfile(twitterProfile,task); - log.info("persistDataFromTwitter.storeUserProfile: stored User = "+user.toString()); - log.info("model.addAttribute user = "+user.toString()); + log.debug("persistDataFromTwitter.storeUserProfile: stored User = "+user.toString()); + log.debug("model.addAttribute user = "+user.toString()); return user; } catch (EmptyResultDataAccessException ex){ log.warn("persistDataFromTwitter.storeUserProfile raised EmptyResultDataAccessException: "+ex.getMessage()); User user = getDummyUser(task); - log.info("model.addAttribute user = "+user.toString()); + log.debug("model.addAttribute user = "+user.toString()); return user; } catch (NoResultException exe) { log.warn("persistDataFromTwitter.storeUserProfile raised NoResultException: "+exe.getMessage()); User user = getDummyUser(task); - log.info("model.addAttribute user = "+user.toString()); + log.debug("model.addAttribute user = "+user.toString()); return user; } } finally { countedEntities = countedEntitiesService.countAll(); taskService.done(task,countedEntities); - log.info("... finally done ..."); - log.info("-----------------------------------------"); + log.debug("... finally done ..."); + log.debug("-----------------------------------------"); } } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/model/DomainObjectMinimalTest.java b/src/test/java/org/woehlke/twitterwall/oodm/model/DomainObjectMinimalTest.java index 1a9aff59..882069fa 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/model/DomainObjectMinimalTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/model/DomainObjectMinimalTest.java @@ -2,7 +2,7 @@ public interface DomainObjectMinimalTest { - void getUniqueIdTest() throws Exception; + void test001getUniqueIdTest() throws Exception; - void isValidTest() throws Exception; + void test002isValidTest() throws Exception; } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/model/HashTagTest.java b/src/test/java/org/woehlke/twitterwall/oodm/model/HashTagTest.java index 6e14e8f7..cbcf4997 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/model/HashTagTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/model/HashTagTest.java @@ -1,13 +1,16 @@ package org.woehlke.twitterwall.oodm.model; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.runners.MethodSorters; +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class HashTagTest implements DomainObjectMinimalTest { @Test @Override - public void getUniqueIdTest() throws Exception { + public void test001getUniqueIdTest() throws Exception { String msg = "getUniqueIdTest: "; Task createdBy = null; @@ -21,7 +24,7 @@ public void getUniqueIdTest() throws Exception { @Test @Override - public void isValidTest() throws Exception { + public void test002isValidTest() throws Exception { String msg = "isValidTest: "; Task createdBy = null; diff --git a/src/test/java/org/woehlke/twitterwall/oodm/model/MediaTest.java b/src/test/java/org/woehlke/twitterwall/oodm/model/MediaTest.java index 3c0cd99d..d761e0c2 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/model/MediaTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/model/MediaTest.java @@ -1,13 +1,16 @@ package org.woehlke.twitterwall.oodm.model; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.runners.MethodSorters; +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class MediaTest implements DomainObjectMinimalTest { @Test @Override - public void getUniqueIdTest() throws Exception { + public void test001getUniqueIdTest() throws Exception { String msg = "getUniqueIdTest: "; Task createdBy=null; @@ -32,7 +35,7 @@ public void getUniqueIdTest() throws Exception { @Test @Override - public void isValidTest() throws Exception { + public void test002isValidTest() throws Exception { String msg = "isValidTest: "; Task createdBy=null; diff --git a/src/test/java/org/woehlke/twitterwall/oodm/model/MentionTest.java b/src/test/java/org/woehlke/twitterwall/oodm/model/MentionTest.java index 7b6ddd65..26ecc341 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/model/MentionTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/model/MentionTest.java @@ -1,17 +1,20 @@ package org.woehlke.twitterwall.oodm.model; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class MentionTest implements DomainObjectMinimalTest { private static final Logger log = LoggerFactory.getLogger(MentionTest.class); @Test @Override - public void getUniqueIdTest() throws Exception { + public void test001getUniqueIdTest() throws Exception { String msg = "getUniqueIdTest: "; final long ID_TWITTER_UNDEFINED = -1L; @@ -45,7 +48,7 @@ public void getUniqueIdTest() throws Exception { } @Test - public void isValidTest() throws Exception { + public void test002isValidTest() throws Exception { String msg = "isValidTest: "; final long ID_TWITTER_UNDEFINED = -1L; @@ -84,13 +87,13 @@ public void isValidTest() throws Exception { Mention mention2 = new Mention(createdBy,updatedBy,screenName2); Mention mention3 = new Mention(createdBy,updatedBy,idTwitter3,screenName3,name3); - log.info(msg+" mention1 "+mention1.toString()+" "+mention1.getUniqueId()+" "+mention1.isValid()); + log.debug(msg+" mention1 "+mention1.toString()+" "+mention1.getUniqueId()+" "+mention1.isValid()); Assert.assertTrue(msg,mention1.isValid()); - log.info(msg+" mention2 "+mention2.toString()+" "+mention2.getUniqueId()+" "+mention2.isValid()); + log.debug(msg+" mention2 "+mention2.toString()+" "+mention2.getUniqueId()+" "+mention2.isValid()); Assert.assertTrue(msg,mention2.isValid()); - log.info(msg+" mention3 "+mention3.toString()+" "+mention3.getUniqueId()+" "+mention3.isValid()); + log.debug(msg+" mention3 "+mention3.toString()+" "+mention3.getUniqueId()+" "+mention3.isValid()); Assert.assertTrue(msg,mention3.isValid()); mention1.setScreenName(null); @@ -103,19 +106,19 @@ public void isValidTest() throws Exception { mention4.setIdTwitter(idTwitter4); mention5.setIdTwitter(idTwitter4); - log.info(msg+" mention1 "+mention1.toString()+" "+mention1.getUniqueId()+" "+mention1.isValid()); + log.debug(msg+" mention1 "+mention1.toString()+" "+mention1.getUniqueId()+" "+mention1.isValid()); Assert.assertFalse(msg,mention1.isValid()); - log.info(msg+" mention2 "+mention2.toString()+" "+mention2.getUniqueId()+" "+mention2.isValid()); + log.debug(msg+" mention2 "+mention2.toString()+" "+mention2.getUniqueId()+" "+mention2.isValid()); Assert.assertFalse(msg,mention2.isValid()); - log.info(msg+" mention3 "+mention3.toString()+" "+mention3.getUniqueId()+" "+mention3.isValid()); + log.debug(msg+" mention3 "+mention3.toString()+" "+mention3.getUniqueId()+" "+mention3.isValid()); Assert.assertFalse(msg,mention3.isValid()); - log.info(msg+" mention4 "+mention4.toString()+" "+mention4.getUniqueId()+" "+mention4.isValid()); + log.debug(msg+" mention4 "+mention4.toString()+" "+mention4.getUniqueId()+" "+mention4.isValid()); Assert.assertFalse(msg,mention4.isValid()); - log.info(msg+" mention5 "+mention5.toString()+" "+mention5.getUniqueId()+" "+mention5.isValid()); + log.debug(msg+" mention5 "+mention5.toString()+" "+mention5.getUniqueId()+" "+mention5.isValid()); Assert.assertFalse(msg,mention5.isValid()); } } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/model/TaskHistoryTest.java b/src/test/java/org/woehlke/twitterwall/oodm/model/TaskHistoryTest.java index 51524338..75da699d 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/model/TaskHistoryTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/model/TaskHistoryTest.java @@ -1,7 +1,9 @@ package org.woehlke.twitterwall.oodm.model; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.woehlke.twitterwall.oodm.model.parts.CountedEntities; @@ -11,13 +13,15 @@ import java.util.Date; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TaskHistoryTest implements DomainObjectMinimalTest { private static final Logger log = LoggerFactory.getLogger(TaskHistoryTest.class); @Test @Override - public void getUniqueIdTest() throws Exception { + public void test001getUniqueIdTest() throws Exception { String msg = "getUniqueIdTest: "; String descriptionTask = "Make it so, Scotty"; @@ -42,14 +46,14 @@ public void getUniqueIdTest() throws Exception { String myUniqueId = "" + task.getId().toString() +"_"+ timeEvent.getTime(); - log.info(msg+" Expected: "+myUniqueId+" == Found: "+taskHistory.getUniqueId()); + log.debug(msg+" Expected: "+myUniqueId+" == Found: "+taskHistory.getUniqueId()); Assert.assertEquals(msg,myUniqueId,taskHistory.getUniqueId()); } @Test @Override - public void isValidTest() throws Exception { + public void test002isValidTest() throws Exception { String msg = "isValidTest: "; String descriptionTask = "Make it so, Scotty"; diff --git a/src/test/java/org/woehlke/twitterwall/oodm/model/TaskTest.java b/src/test/java/org/woehlke/twitterwall/oodm/model/TaskTest.java index 9cb4b381..34160516 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/model/TaskTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/model/TaskTest.java @@ -1,7 +1,9 @@ package org.woehlke.twitterwall.oodm.model; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.woehlke.twitterwall.oodm.model.tasks.TaskSendType; @@ -10,13 +12,15 @@ import java.util.Date; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TaskTest implements DomainObjectMinimalTest { private static final Logger log = LoggerFactory.getLogger(TweetTest.class); @Test @Override - public void getUniqueIdTest() throws Exception { + public void test001getUniqueIdTest() throws Exception { String msg = "getUniqueIdTest: "; String descriptionTask = "Make it so, Scotty"; @@ -34,14 +38,14 @@ public void getUniqueIdTest() throws Exception { String myUniqueId = "" + taskType.name() +"_"+ timeStarted.getTime(); - log.info(msg+" Expected: "+myUniqueId+" == Found: "+task.getUniqueId()); + log.debug(msg+" Expected: "+myUniqueId+" == Found: "+task.getUniqueId()); Assert.assertEquals(msg,myUniqueId,task.getUniqueId()); } @Test @Override - public void isValidTest() throws Exception { + public void test002isValidTest() throws Exception { String msg = "isValidTest: "; String descriptionTask = "Make it so, Scotty"; diff --git a/src/test/java/org/woehlke/twitterwall/oodm/model/TickerSymbolTest.java b/src/test/java/org/woehlke/twitterwall/oodm/model/TickerSymbolTest.java index 0c503814..9e5d7733 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/model/TickerSymbolTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/model/TickerSymbolTest.java @@ -1,17 +1,20 @@ package org.woehlke.twitterwall.oodm.model; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TickerSymbolTest implements DomainObjectMinimalTest { private static final Logger log = LoggerFactory.getLogger(TickerSymbolTest.class); @Test @Override - public void getUniqueIdTest() throws Exception { + public void test001getUniqueIdTest() throws Exception { String msg = "getUniqueIdTest: "; Task createdBy = null; @@ -28,8 +31,8 @@ public void getUniqueIdTest() throws Exception { TickerSymbol tickerSymbol2 = new TickerSymbol(createdBy,updatedBy, url2); - log.info(msg+" Expected: "+myUniqueId1+" == Found: "+tickerSymbol1.getUniqueId()); - log.info(msg+" Expected: "+myUniqueId2+" == Found: "+tickerSymbol2.getUniqueId()); + log.debug(msg+" Expected: "+myUniqueId1+" == Found: "+tickerSymbol1.getUniqueId()); + log.debug(msg+" Expected: "+myUniqueId2+" == Found: "+tickerSymbol2.getUniqueId()); Assert.assertEquals(msg,myUniqueId1,tickerSymbol1.getUniqueId()); Assert.assertEquals(msg,myUniqueId2,tickerSymbol2.getUniqueId()); @@ -37,7 +40,7 @@ public void getUniqueIdTest() throws Exception { @Test @Override - public void isValidTest() throws Exception { + public void test002isValidTest() throws Exception { String msg = "isValidTest: "; Assert.assertTrue(msg,true); } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/model/TweetTest.java b/src/test/java/org/woehlke/twitterwall/oodm/model/TweetTest.java index dac07fde..4c8baa7d 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/model/TweetTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/model/TweetTest.java @@ -1,7 +1,9 @@ package org.woehlke.twitterwall.oodm.model; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.woehlke.twitterwall.oodm.model.tasks.TaskSendType; @@ -10,13 +12,14 @@ import java.util.Date; +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TweetTest implements DomainObjectMinimalTest { private static final Logger log = LoggerFactory.getLogger(TweetTest.class); @Test @Override - public void getUniqueIdTest() throws Exception { + public void test001getUniqueIdTest() throws Exception { String descriptionTask = "start: "; TaskType type = TaskType.FETCH_TWEETS_FROM_SEARCH; TaskSendType taskSendType = TaskSendType.NO_MQ; @@ -39,7 +42,7 @@ public void getUniqueIdTest() throws Exception { @Test @Override - public void isValidTest() throws Exception { + public void test002isValidTest() throws Exception { String msg = "isValidTest: "; String descriptionTask = "start: "; diff --git a/src/test/java/org/woehlke/twitterwall/oodm/model/UrlTest.java b/src/test/java/org/woehlke/twitterwall/oodm/model/UrlTest.java index 5c18cd1e..de3ecd65 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/model/UrlTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/model/UrlTest.java @@ -1,18 +1,21 @@ package org.woehlke.twitterwall.oodm.model; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.runners.MethodSorters; import org.woehlke.twitterwall.oodm.model.tasks.TaskSendType; import org.woehlke.twitterwall.oodm.model.tasks.TaskStatus; import org.woehlke.twitterwall.oodm.model.tasks.TaskType; import java.util.Date; +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UrlTest implements DomainObjectMinimalTest { @Test @Override - public void getUniqueIdTest() throws Exception { + public void test001getUniqueIdTest() throws Exception { String msg = "getUniqueIdTest: "; String descriptionTask = "start: "; @@ -37,7 +40,7 @@ public void getUniqueIdTest() throws Exception { @Test @Override - public void isValidTest() throws Exception { + public void test002isValidTest() throws Exception { String msg = "isValidTest: "; String descriptionTask = "start: "; diff --git a/src/test/java/org/woehlke/twitterwall/oodm/model/UserDescriptionTest.java b/src/test/java/org/woehlke/twitterwall/oodm/model/UserDescriptionTest.java index a4831ff1..5c06fa0b 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/model/UserDescriptionTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/model/UserDescriptionTest.java @@ -1,7 +1,9 @@ package org.woehlke.twitterwall.oodm.model; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -24,6 +26,7 @@ */ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UserDescriptionTest { @Autowired @@ -32,7 +35,7 @@ public class UserDescriptionTest { private static final Logger log = LoggerFactory.getLogger(UserDescriptionTest.class); @Test - public void printDescriptionsTest(){ + public void test001printDescriptionsTest(){ String descriptionTask = "Just another Task"; TaskSendType taskSendType = TaskSendType.NO_MQ; @@ -47,24 +50,24 @@ public void printDescriptionsTest(){ List descriptions = testdataProperties.getOodm().getEntities().getUser().getDescriptions(); - log.info("printDescriptionsTest"); - log.info("++++++++++++++++++++"); - log.info("found "+descriptions.size()+" descriptions"); + log.debug("printDescriptionsTest"); + log.debug("++++++++++++++++++++"); + log.debug("found "+descriptions.size()+" descriptions"); for(String description:descriptions){ - log.info("--------------------"); + log.debug("--------------------"); lfdNr++; - log.info("description "+lfdNr+": "+description); + log.debug("description "+lfdNr+": "+description); for(HashTag hashTag:this.getHashTags(description,task)){ - log.info("found hashTag: "+hashTag.getUniqueId()); + log.debug("found hashTag: "+hashTag.getUniqueId()); } for(Url url:this.getUrls(description,task)){ - log.info("found url: "+ url.getUniqueId()); + log.debug("found url: "+ url.getUniqueId()); } for(Mention mention:this.getMentions(description,task)){ - log.info("found mention: "+mention.getUniqueId()); + log.debug("found mention: "+mention.getUniqueId()); } } - log.info("++++++++++++++++++++"); + log.debug("++++++++++++++++++++"); } private List getHashTags(String description,Task task){ diff --git a/src/test/java/org/woehlke/twitterwall/oodm/model/UserListTest.java b/src/test/java/org/woehlke/twitterwall/oodm/model/UserListTest.java index fbd310f0..f7852512 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/model/UserListTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/model/UserListTest.java @@ -1,22 +1,25 @@ package org.woehlke.twitterwall.oodm.model; +import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UserListTest implements DomainObjectMinimalTest { private static final Logger log = LoggerFactory.getLogger(UserTest.class); @Test @Override - public void getUniqueIdTest() throws Exception { + public void test001getUniqueIdTest() throws Exception { } @Test @Override - public void isValidTest() throws Exception { + public void test002isValidTest() throws Exception { } } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/model/UserTest.java b/src/test/java/org/woehlke/twitterwall/oodm/model/UserTest.java index 73bbc292..48d0eb48 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/model/UserTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/model/UserTest.java @@ -1,7 +1,9 @@ package org.woehlke.twitterwall.oodm.model; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.woehlke.twitterwall.oodm.model.tasks.TaskStatus; @@ -14,15 +16,16 @@ /** * Created by tw on 22.06.17. */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UserTest implements DomainObjectMinimalTest { private static final Logger log = LoggerFactory.getLogger(UserTest.class); @Test @Override - public void getUniqueIdTest() throws Exception { + public void test001getUniqueIdTest() throws Exception { String msg = "getUniqueIdTest: "; - log.info(msg+"------------------------------------------------"); + log.debug(msg+"------------------------------------------------"); String screenName = "port80guru"; @@ -39,7 +42,7 @@ public void getUniqueIdTest() throws Exception { String mygUniqueId1 = user1.getIdTwitter().toString()+"_"+user1.getScreenNameUnique(); - log.info(msg+" Expected: "+mygUniqueId1+" == Found: "+user1.getUniqueId()); + log.debug(msg+" Expected: "+mygUniqueId1+" == Found: "+user1.getUniqueId()); Assert.assertEquals(msg,mygUniqueId1,user1.getUniqueId()); @@ -54,18 +57,18 @@ public void getUniqueIdTest() throws Exception { String mygUniqueId2 = Long.toString(idTwitter)+"_"+user2.getScreenNameUnique(); - log.info(msg+" Expected: "+mygUniqueId2+" == Found: "+user2.getUniqueId()); + log.debug(msg+" Expected: "+mygUniqueId2+" == Found: "+user2.getUniqueId()); Assert.assertEquals(msg,mygUniqueId2,user2.getUniqueId()); - log.info(msg+"------------------------------------------------"); + log.debug(msg+"------------------------------------------------"); } @Test @Override - public void isValidTest() throws Exception { + public void test002isValidTest() throws Exception { String msg = "isValidTest: "; - log.info(msg+"------------------------------------------------"); + log.debug(msg+"------------------------------------------------"); String invalidScreenName = "3765726öäöäß%$dsffsdf"; Long idTwitter1 = null; @@ -96,6 +99,6 @@ public void isValidTest() throws Exception { user.setScreenName(invalidScreenName); Assert.assertFalse(msg,user.isValid()); - log.info(msg+"------------------------------------------------"); + log.debug(msg+"------------------------------------------------"); } } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/DomainObjectMinimalServiceTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/DomainObjectMinimalServiceTest.java index 76cfdaa3..a40496ff 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/DomainObjectMinimalServiceTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/DomainObjectMinimalServiceTest.java @@ -2,15 +2,16 @@ public interface DomainObjectMinimalServiceTest { - void findById() throws Exception; + void test000areDependenciesLoaded() throws Exception; - void getAll() throws Exception; + void test001fetchTestData() throws Exception; - void count() throws Exception; + void test050findById() throws Exception; - void findByUniqueId() throws Exception; + void test051getAll() throws Exception; - void areDependenciesLoaded() throws Exception; + void test052count() throws Exception; + + void test053findByUniqueId() throws Exception; - void fetchTestData() throws Exception; } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithIdTwitterTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithIdTwitterTest.java index 705eb1d6..402b7680 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithIdTwitterTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithIdTwitterTest.java @@ -2,5 +2,5 @@ public interface DomainServiceWithIdTwitterTest { - void findByIdTwitter() throws Exception; + void test020findByIdTwitter() throws Exception; } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithScreenNameTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithScreenNameTest.java index b01610eb..a1370dd1 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithScreenNameTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithScreenNameTest.java @@ -2,5 +2,5 @@ public interface DomainServiceWithScreenNameTest { - void findByScreenName() throws Exception; + void test030findByScreenName() throws Exception; } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithTaskTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithTaskTest.java index e6a9ec27..21e7e6ae 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithTaskTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithTaskTest.java @@ -3,10 +3,10 @@ public interface DomainServiceWithTaskTest { - void store() throws Exception; + void test100store() throws Exception; - void create() throws Exception; + void test101create() throws Exception; - void update() throws Exception; + void test102update() throws Exception; } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithUrlTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithUrlTest.java index 7e41c577..360002bf 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithUrlTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/DomainServiceWithUrlTest.java @@ -2,5 +2,5 @@ public interface DomainServiceWithUrlTest { - void findByUrl() throws Exception; + void test025findByUrl() throws Exception; } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/HashTagServiceTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/HashTagServiceTest.java index 51731a69..195c38f7 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/HashTagServiceTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/HashTagServiceTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.oodm.service; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -19,6 +21,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class HashTagServiceTest implements DomainObjectMinimalServiceTest,DomainServiceWithTaskTest { private static final Logger log = LoggerFactory.getLogger(HashTagServiceTest.class); @@ -30,14 +33,14 @@ public class HashTagServiceTest implements DomainObjectMinimalServiceTest,Domain private TestdataProperties testdataProperties; @Test - public void areDependenciesLoaded() throws Exception { + public void test000areDependenciesLoaded() throws Exception { Assert.assertNotNull(hashTagService); Assert.assertNotNull(testdataProperties); } @Commit @Test - public void fetchTestData() throws Exception { + public void test001fetchTestData() throws Exception { String msg = "fetchTestData: "; int page=1; int size=1; @@ -55,7 +58,7 @@ public void fetchTestData() throws Exception { @Commit @Test - public void findByText() throws Exception { + public void test002findByText() throws Exception { String msg = "findByText: "; int page=1; int size=1; @@ -81,14 +84,14 @@ public void findByText() throws Exception { */ @Commit @Test - public void getHashTagsTweets() throws Exception { + public void test003getHashTagsTweets() throws Exception { String msg = "getHashTagsTweets: "; int page=1; int size=30; Pageable pageRequestTweets = new PageRequest(page,size); Page hashTagsTweets = hashTagService.getHashTagsTweets(pageRequestTweets); for(HashTagCounted counted:hashTagsTweets){ - log.info(msg+" hashTagsTweets: "+counted.getText()); + log.debug(msg+" hashTagsTweets: "+counted.getText()); } } @@ -103,63 +106,63 @@ public void getHashTagsTweets() throws Exception { */ @Commit @Test - public void getHashTagsUsers() throws Exception { + public void test004getHashTagsUsers() throws Exception { String msg = "getHashTagsUsers: "; int page=1; int size=30; Pageable pageRequestUsers = new PageRequest(page,size); Page hashTagsUsers = hashTagService.getHashTagsUsers(pageRequestUsers); for(HashTagCounted counted:hashTagsUsers){ - log.info(msg+" hashTagsUsers: "+counted.getText()); + log.debug(msg+" hashTagsUsers: "+counted.getText()); } } @Commit @Test @Override - public void findById() throws Exception { + public void test050findById() throws Exception { } @Commit @Test @Override - public void getAll() throws Exception { + public void test051getAll() throws Exception { } @Commit @Test @Override - public void count() throws Exception { + public void test052count() throws Exception { } @Commit @Test @Override - public void findByUniqueId() throws Exception { + public void test053findByUniqueId() throws Exception { } @Commit @Test @Override - public void store() throws Exception { + public void test100store() throws Exception { } @Commit @Test @Override - public void create() throws Exception { + public void test101create() throws Exception { } @Commit @Test @Override - public void update() throws Exception { + public void test102update() throws Exception { } } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/MediaServiceTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/MediaServiceTest.java index cbc3f529..9bdbbc83 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/MediaServiceTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/MediaServiceTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.oodm.service; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +19,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class MediaServiceTest implements DomainObjectMinimalServiceTest,DomainServiceWithTaskTest,DomainServiceWithIdTwitterTest,DomainServiceWithUrlTest { private static final Logger log = LoggerFactory.getLogger(MediaServiceTest.class); @@ -28,14 +31,14 @@ public class MediaServiceTest implements DomainObjectMinimalServiceTest,DomainSe private TestdataProperties testdataProperties; @Test - public void areDependenciesLoaded() throws Exception { + public void test000areDependenciesLoaded() throws Exception { Assert.assertNotNull(mediaService); Assert.assertNotNull(testdataProperties); } @Commit @Test - public void fetchTestData() throws Exception { + public void test001fetchTestData() throws Exception { String msg = "fetchTestData: "; int page=1; int size=1; @@ -53,7 +56,7 @@ public void fetchTestData() throws Exception { @Commit @Test - public void findByIdTwitter() throws Exception { + public void test020findByIdTwitter() throws Exception { String msg = "findByIdTwitter: "; int page=1; int size=1; @@ -73,7 +76,7 @@ public void findByIdTwitter() throws Exception { @Commit @Test - public void findByUrl() throws Exception { + public void test025findByUrl() throws Exception { String msg = "findByUrl: "; int page=1; int size=1; @@ -94,49 +97,49 @@ public void findByUrl() throws Exception { @Commit @Test @Override - public void findById() throws Exception { + public void test050findById() throws Exception { } @Commit @Test @Override - public void getAll() throws Exception { + public void test051getAll() throws Exception { } @Commit @Test @Override - public void count() throws Exception { + public void test052count() throws Exception { } @Commit @Test @Override - public void findByUniqueId() throws Exception { + public void test053findByUniqueId() throws Exception { } @Commit @Test @Override - public void store() throws Exception { + public void test100store() throws Exception { } @Commit @Test @Override - public void create() throws Exception { + public void test101create() throws Exception { } @Commit @Test @Override - public void update() throws Exception { + public void test102update() throws Exception { } } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/MentionServiceTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/MentionServiceTest.java index 369fff64..9715c120 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/MentionServiceTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/MentionServiceTest.java @@ -2,8 +2,10 @@ import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -24,6 +26,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class MentionServiceTest implements DomainObjectMinimalServiceTest,DomainServiceWithTaskTest,DomainServiceWithScreenNameTest,DomainServiceWithIdTwitterTest { private static final Logger log = LoggerFactory.getLogger(MentionServiceTest.class); @@ -42,7 +45,7 @@ public class MentionServiceTest implements DomainObjectMinimalServiceTest,Domain @Commit @Test - public void areDependenciesLoaded() throws Exception { + public void test000areDependenciesLoaded() throws Exception { Assert.assertNotNull(mentionService); Assert.assertNotNull(testdataProperties); Assert.assertNotNull(countedEntitiesService); @@ -50,7 +53,7 @@ public void areDependenciesLoaded() throws Exception { @Commit @Test - public void createTestData() throws Exception { + public void test000createTestData() throws Exception { String msg = "createTestData: "; CountedEntities countedEntities = countedEntitiesService.countAll(); Task createdBy= taskService.create(msg, TaskType.NULL, TaskSendType.NO_MQ,countedEntities); @@ -91,7 +94,7 @@ public void createTestData() throws Exception { @Commit @Test - public void fetchTestData() throws Exception { + public void test001fetchTestData() throws Exception { String msg = "fetchTestData: "; int page=1; int size=1; @@ -110,7 +113,7 @@ public void fetchTestData() throws Exception { @Commit @Test - public void createProxyMention() throws Exception { + public void test010createProxyMention() throws Exception { String msg = "createProxyMention: "; CountedEntities countedEntities = countedEntitiesService.countAll(); TaskType type = TaskType.FETCH_TWEETS_FROM_SEARCH; @@ -125,7 +128,7 @@ public void createProxyMention() throws Exception { @Commit @Test - public void getAllWithoutPersistentUser() throws Exception { + public void test011getAllWithoutPersistentUser() throws Exception { String msg = "getAllWithoutUser: "; int page=1; int size=100; @@ -140,9 +143,9 @@ public void getAllWithoutPersistentUser() throws Exception { @Commit @Test - public void findByIdTwitter() throws Exception { + public void test020findByIdTwitter() throws Exception { String msg = "findByIdTwitter: "; - createTestData(); + test000createTestData(); int page=1; int size=20; Pageable pageRequest = new PageRequest(page,size); @@ -161,9 +164,9 @@ public void findByIdTwitter() throws Exception { @Commit @Test @Override - public void findByScreenName() throws Exception { + public void test030findByScreenName() throws Exception { String msg = "findByScreenName: "; - createTestData(); + test000createTestData(); int page=1; int size=1; Pageable pageRequest = new PageRequest(page,size); @@ -183,55 +186,49 @@ public void findByScreenName() throws Exception { @Commit @Test @Override - public void findById() throws Exception { + public void test050findById() throws Exception { } @Commit @Test @Override - public void getAll() throws Exception { + public void test051getAll() throws Exception { } @Commit @Test @Override - public void count() throws Exception { + public void test052count() throws Exception { } @Commit @Test @Override - public void findByUniqueId() throws Exception { + public void test053findByUniqueId() throws Exception { } @Commit @Test @Override - public void store() throws Exception { + public void test100store() throws Exception { } @Commit @Test @Override - public void create() throws Exception { + public void test101create() throws Exception { } @Commit @Test @Override - public void update() throws Exception { - - } - - @Commit - @Test - public void findByUserId() throws Exception { + public void test102update() throws Exception { } @@ -255,4 +252,5 @@ private void waitFor500ms(){ } catch (InterruptedException e) { } } + } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/TaskHistoryServiceTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/TaskHistoryServiceTest.java index 74867da5..ddab471a 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/TaskHistoryServiceTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/TaskHistoryServiceTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.oodm.service; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -17,6 +19,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TaskHistoryServiceTest implements DomainObjectMinimalServiceTest { private static final Logger log = LoggerFactory.getLogger(TaskHistoryServiceTest.class); @@ -28,14 +31,14 @@ public class TaskHistoryServiceTest implements DomainObjectMinimalServiceTest { private TestdataProperties testdataProperties; @Test - public void areDependenciesLoaded() throws Exception { + public void test000areDependenciesLoaded() throws Exception { Assert.assertNotNull(taskHistoryService); Assert.assertNotNull(testdataProperties); } @Commit @Test - public void fetchTestData() throws Exception { + public void test001fetchTestData() throws Exception { String msg = "fetchTestData: "; int page=1; int size=1; @@ -53,34 +56,34 @@ public void fetchTestData() throws Exception { @Commit @Test - public void store() throws Exception {} + public void test100store() throws Exception {} @Commit @Test @Override - public void findById() throws Exception { + public void test050findById() throws Exception { } @Commit @Test @Override - public void getAll() throws Exception { + public void test051getAll() throws Exception { } @Commit @Test @Override - public void count() throws Exception { + public void test052count() throws Exception { } @Commit @Test @Override - public void findByUniqueId() throws Exception { + public void test053findByUniqueId() throws Exception { } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/TaskServiceTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/TaskServiceTest.java index 7dcbeb16..c346735c 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/TaskServiceTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/TaskServiceTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.oodm.service; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -21,6 +23,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TaskServiceTest implements DomainObjectMinimalServiceTest { @@ -36,14 +39,14 @@ public class TaskServiceTest implements DomainObjectMinimalServiceTest { private CountedEntitiesService countedEntitiesService; @Test - public void areDependenciesLoaded() throws Exception { + public void test000areDependenciesLoaded() throws Exception { Assert.assertNotNull(taskService); Assert.assertNotNull(testdataProperties); } @Commit @Test - public void fetchTestData() throws Exception { + public void test001fetchTestData() throws Exception { String msg = "fetchTestData: "; int page=1; int size=1; @@ -61,7 +64,7 @@ public void fetchTestData() throws Exception { @Commit @Test - public void create() throws Exception { + public void test101create() throws Exception { String msg = "TaskServiceTest.create"; TaskType type = TaskType.FETCH_TWEETS_FROM_SEARCH; TaskSendType taskSendType = TaskSendType.NO_MQ; @@ -72,7 +75,7 @@ public void create() throws Exception { @Commit @Test - public void done() throws Exception { + public void test200done() throws Exception { String msg = "TaskServiceTest.done"; TaskType type = TaskType.FETCH_TWEETS_FROM_SEARCH; TaskSendType taskSendType = TaskSendType.NO_MQ; @@ -87,7 +90,7 @@ public void done() throws Exception { @Commit @Test - public void error() throws Exception { + public void test201error() throws Exception { String msg = "TaskServiceTest.error"; TaskType type = TaskType.FETCH_TWEETS_FROM_SEARCH; TaskSendType taskSendType = TaskSendType.NO_MQ; @@ -102,7 +105,7 @@ public void error() throws Exception { @Commit @Test - public void warn() throws Exception { + public void test202warn() throws Exception { String msg = "TaskServiceTest.error"; TaskType type = TaskType.FETCH_TWEETS_FROM_SEARCH; TaskSendType taskSendType = TaskSendType.NO_MQ; @@ -117,7 +120,7 @@ public void warn() throws Exception { @Commit @Test - public void event() throws Exception { + public void test203event() throws Exception { String msg = "TaskServiceTest.error"; TaskType type = TaskType.FETCH_TWEETS_FROM_SEARCH; TaskSendType taskSendType = TaskSendType.NO_MQ; @@ -133,7 +136,7 @@ public void event() throws Exception { @Commit @Test - public void start() throws Exception { + public void test204start() throws Exception { String msg = "TaskServiceTest.error"; TaskType type = TaskType.FETCH_TWEETS_FROM_SEARCH; TaskSendType taskSendType = TaskSendType.NO_MQ; @@ -148,7 +151,7 @@ public void start() throws Exception { @Commit @Test - public void finalError() throws Exception { + public void test205finalError() throws Exception { String msg = "TaskServiceTest.error"; TaskType type = TaskType.FETCH_TWEETS_FROM_SEARCH; TaskSendType taskSendType = TaskSendType.NO_MQ; @@ -165,28 +168,28 @@ public void finalError() throws Exception { @Commit @Test @Override - public void findById() throws Exception { + public void test050findById() throws Exception { } @Commit @Test @Override - public void getAll() throws Exception { + public void test051getAll() throws Exception { } @Commit @Test @Override - public void count() throws Exception { + public void test052count() throws Exception { } @Commit @Test @Override - public void findByUniqueId() throws Exception { + public void test053findByUniqueId() throws Exception { } } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/TickerSymbolServiceTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/TickerSymbolServiceTest.java index ac28692a..9812bf9c 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/TickerSymbolServiceTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/TickerSymbolServiceTest.java @@ -2,8 +2,10 @@ import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -18,6 +20,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TickerSymbolServiceTest implements DomainObjectMinimalServiceTest,DomainServiceWithTaskTest,DomainServiceWithUrlTest { private static final Logger log = LoggerFactory.getLogger(TaskServiceTest.class); @@ -29,14 +32,14 @@ public class TickerSymbolServiceTest implements DomainObjectMinimalServiceTest,D private TestdataProperties testdataProperties; @Test - public void areDependenciesLoaded() throws Exception { + public void test000areDependenciesLoaded() throws Exception { Assert.assertNotNull(tickerSymbolService); Assert.assertNotNull(testdataProperties); } @Commit @Test - public void fetchTestData() throws Exception { + public void test001fetchTestData() throws Exception { String msg = "fetchTestData: "; int page=1; int size=20; @@ -55,7 +58,7 @@ public void fetchTestData() throws Exception { @Commit @Test - public void findByUrl() throws Exception { + public void test025findByUrl() throws Exception { String msg = "findByUrl: "; int page=1; int size=1; @@ -77,49 +80,49 @@ public void findByUrl() throws Exception { @Commit @Test @Override - public void findById() throws Exception { + public void test050findById() throws Exception { } @Commit @Test @Override - public void getAll() throws Exception { + public void test051getAll() throws Exception { } @Commit @Test @Override - public void count() throws Exception { + public void test052count() throws Exception { } @Commit @Test @Override - public void findByUniqueId() throws Exception { + public void test053findByUniqueId() throws Exception { } @Commit @Test @Override - public void store() throws Exception { + public void test100store() throws Exception { } @Commit @Test @Override - public void create() throws Exception { + public void test101create() throws Exception { } @Commit @Test @Override - public void update() throws Exception { + public void test102update() throws Exception { } } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/TweetServiceTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/TweetServiceTest.java index 7803a58d..3a205e47 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/TweetServiceTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/TweetServiceTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.oodm.service; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -20,6 +22,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class TweetServiceTest implements DomainObjectMinimalServiceTest,DomainServiceWithTaskTest ,DomainServiceWithIdTwitterTest{ private static final Logger log = LoggerFactory.getLogger(TweetServiceTest.class); @@ -49,16 +52,16 @@ public class TweetServiceTest implements DomainObjectMinimalServiceTest,DomainSe private TestdataProperties testdataProperties; @Test - public void areDependenciesLoaded() throws Exception { + public void test000areDependenciesLoaded() throws Exception { Assert.assertNotNull(tweetService); Assert.assertNotNull(testdataProperties); } @Commit @Test - public void fetchTestData() throws Exception { + public void test001fetchTestData() throws Exception { String msg = "fetchTestData: "; - log.info(msg+"START TEST"); + log.debug(msg+"START TEST"); int page=1; int size=20; Pageable pageRequest = new PageRequest(page,size); @@ -67,17 +70,17 @@ public void fetchTestData() throws Exception { for(Tweet myTweet :myPage.getContent()){ Assert.assertNotNull(msg,myTweet); Assert.assertNotNull(msg,myTweet.getUniqueId()); - log.info(msg+" found: "+myTweet.getUniqueId()); + log.debug(msg+" found: "+myTweet.getUniqueId()); } } else { - log.info(msg+" found: myPage.getTotalElements() == 0"); + log.debug(msg+" found: myPage.getTotalElements() == 0"); } - log.info(msg+"FINISHED TEST"); + log.debug(msg+"FINISHED TEST"); } @Commit @Test - public void findByIdTwitter() throws Exception { + public void test020findByIdTwitter() throws Exception { String msg = "findByIdTwitter: "; int page=1; int size=20; @@ -90,7 +93,7 @@ public void findByIdTwitter() throws Exception { if(myFoundTweet != null) { long foundIdTwitter = myFoundTweet.getIdTwitter(); Assert.assertEquals(msg, expectedIdTwitter, foundIdTwitter); - log.info(msg + " found: " + myFoundTweet.getUniqueId()); + log.debug(msg + " found: " + myFoundTweet.getUniqueId()); } } } else { @@ -100,7 +103,7 @@ public void findByIdTwitter() throws Exception { @Commit @Test - public void findTweetsForHashTag() throws Exception { + public void test030findTweetsForHashTag() throws Exception { String msg = "findTweetsForHashTag: "; int page=1; int size=10; @@ -114,12 +117,12 @@ public void findTweetsForHashTag() throws Exception { log.debug(msg+" found Tweet: "+tweet.getUniqueId()+" found HashTag: "+hashTag.getUniqueId()); } } - log.info(msg); + log.debug(msg); } @Commit @Test - public void findTweetsForMedia() throws Exception { + public void test031findTweetsForMedia() throws Exception { String msg = "findTweetsForMedia: "; int page=1; int size=10; @@ -133,12 +136,12 @@ public void findTweetsForMedia() throws Exception { log.debug(msg+" found Tweet: "+tweet.getUniqueId()+" found Media: "+media.getUniqueId()); } } - log.info(msg); + log.debug(msg); } @Commit @Test - public void findTweetsForMention() throws Exception { + public void test032findTweetsForMention() throws Exception { String msg = "findTweetsForMention: "; int page=1; int size=10; @@ -152,12 +155,12 @@ public void findTweetsForMention() throws Exception { log.debug(msg+" found Tweet: "+tweet.getUniqueId()+" found Mention: "+mention.getUniqueId()); } } - log.info(msg); + log.debug(msg); } @Commit @Test - public void findTweetsForUrl() throws Exception { + public void test033findTweetsForUrl() throws Exception { String msg = "findTweetsForUrl: "; int page=1; int size=10; @@ -171,12 +174,12 @@ public void findTweetsForUrl() throws Exception { log.debug(msg+" found Tweet: "+tweet.getUniqueId()+" found Url: "+url.getUniqueId()); } } - log.info(msg); + log.debug(msg); } @Commit @Test - public void findTweetsForTickerSymbol() throws Exception { + public void test034findTweetsForTickerSymbol() throws Exception { String msg = "findTweetsForTickerSymbol: "; int page=1; int size=10; @@ -190,17 +193,17 @@ public void findTweetsForTickerSymbol() throws Exception { log.debug(msg+" found Tweet: "+tweet.getUniqueId()+" found TickerSymbol: "+tickerSymbol.getUniqueId()); } } - log.info(msg); + log.debug(msg); } @Commit @Test - public void findTweetsForUser() throws Exception { + public void test035findTweetsForUser() throws Exception { String msg = "findTweetsForUser: "; int page=1; int size=100; Pageable pageRequest = new PageRequest(page,size); - log.info(msg + "STARTED TEST"); + log.debug(msg + "STARTED TEST"); Page foundTweetingUsers = userService.getTweetingUsers(pageRequest); long loopUser = 0L; long loopTweet = 0L; @@ -213,16 +216,16 @@ public void findTweetsForUser() throws Exception { loopTweet++; Assert.assertNotNull(msg,tweet.getUser()); Assert.assertEquals(msg,tweet.getUser().getUniqueId(), user.getUniqueId()); - log.info(msg+" tweet: "+tweet.getUniqueId()+" user: "+tweet.getUser().getUniqueId()); + log.debug(msg+" tweet: "+tweet.getUniqueId()+" user: "+tweet.getUser().getUniqueId()); } - log.info(msg+" RUNNING TEST. Tested Users "+loopUser+" and Tweets "+loopTweet); + log.debug(msg+" RUNNING TEST. Tested Users "+loopUser+" and Tweets "+loopTweet); } - log.info(msg+" FINISHED TEST. Tested Users "+loopUser+" and Tweets "+loopTweet); + log.debug(msg+" FINISHED TEST. Tested Users "+loopUser+" and Tweets "+loopTweet); } @Commit @Test - public void findAllTweet2HashTag() throws Exception { + public void test036findAllTweet2HashTag() throws Exception { String msg = "findAllTweet2HashTag: "; int page=1; int size=10; @@ -241,14 +244,14 @@ public void findAllTweet2HashTag() throws Exception { Assert.assertNull(objectInfo); Assert.assertNull(entityInfo); Assert.assertTrue(msg,foundObject.getEntities().getHashTags().contains(foundEntity)); - log.info(msg+" tweet: "+foundObject.getUniqueId()+" HashTag: "+foundEntity.getUniqueId()); + log.debug(msg+" tweet: "+foundObject.getUniqueId()+" HashTag: "+foundEntity.getUniqueId()); } } } @Commit @Test - public void findAllTweet2Media() throws Exception { + public void test037findAllTweet2Media() throws Exception { String msg = "findAllTweet2Media: "; int page=1; int size=10; @@ -268,13 +271,13 @@ public void findAllTweet2Media() throws Exception { Set media = foundObject.getEntities().getMedia(); Assert.assertTrue(msg,media.size()>0); Assert.assertTrue(msg,media.contains(foundEntity)); - log.info(msg+" tweet: "+foundObject.getUniqueId()+" Media: "+foundEntity.getUniqueId()); + log.debug(msg+" tweet: "+foundObject.getUniqueId()+" Media: "+foundEntity.getUniqueId()); } } @Commit @Test - public void findAllTweet2Mention() throws Exception { + public void test038findAllTweet2Mention() throws Exception { String msg = "findAllTweet2Mention: "; int page=1; int size=20; @@ -295,14 +298,14 @@ public void findAllTweet2Mention() throws Exception { Set mentions = foundObject.getEntities().getMentions(); Assert.assertTrue(msg,mentions.size() >0); Assert.assertTrue(msg,mentions.contains(foundEntity)); - log.info(msg+" tweet: "+foundObject.getUniqueId()+" Mention: "+foundEntity.getUniqueId()); + log.debug(msg+" tweet: "+foundObject.getUniqueId()+" Mention: "+foundEntity.getUniqueId()); } } } @Commit @Test - public void findAllTweet2Url() throws Exception { + public void test039findAllTweet2Url() throws Exception { String msg = "findAllTweet2Url: "; int page=1; int size=20; @@ -322,13 +325,13 @@ public void findAllTweet2Url() throws Exception { Set urls = foundObject.getEntities().getUrls(); Assert.assertTrue(msg,urls.size()>0); Assert.assertTrue(msg,urls.contains(foundEntity)); - log.info(msg+" tweet: "+foundObject.getUniqueId()+" Url: "+foundEntity.getUniqueId()); + log.debug(msg+" tweet: "+foundObject.getUniqueId()+" Url: "+foundEntity.getUniqueId()); } } @Commit @Test - public void findAllTweet2TickerSymbol() throws Exception { + public void test040findAllTweet2TickerSymbol() throws Exception { String msg = "findAllTweet2TickerSymbol: "; int page=1; int size=10; @@ -347,7 +350,7 @@ public void findAllTweet2TickerSymbol() throws Exception { Assert.assertNull(objectInfo); Assert.assertNull(entityInfo); Assert.assertTrue(msg,foundObject.getEntities().getTickerSymbols().contains(foundEntity)); - log.info(msg+" tweet: "+foundObject.getUniqueId()+" TickerSymbol: "+foundEntity.getUniqueId()); + log.debug(msg+" tweet: "+foundObject.getUniqueId()+" TickerSymbol: "+foundEntity.getUniqueId()); } } } @@ -355,49 +358,49 @@ public void findAllTweet2TickerSymbol() throws Exception { @Commit @Test @Override - public void findById() throws Exception { + public void test050findById() throws Exception { } @Commit @Test @Override - public void getAll() throws Exception { + public void test051getAll() throws Exception { } @Commit @Test @Override - public void count() throws Exception { + public void test052count() throws Exception { } @Commit @Test @Override - public void findByUniqueId() throws Exception { + public void test053findByUniqueId() throws Exception { } @Commit @Test @Override - public void store() throws Exception { + public void test100store() throws Exception { } @Commit @Test @Override - public void create() throws Exception { + public void test101create() throws Exception { } @Commit @Test @Override - public void update() throws Exception { + public void test102update() throws Exception { } } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/UrlServiceTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/UrlServiceTest.java index 0393ed3c..d1fd199f 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/UrlServiceTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/UrlServiceTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.oodm.service; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -23,6 +25,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UrlServiceTest implements DomainObjectMinimalServiceTest,DomainServiceWithTaskTest,DomainServiceWithUrlTest { private static final Logger log = LoggerFactory.getLogger(UrlServiceTest.class); @@ -40,14 +43,14 @@ public class UrlServiceTest implements DomainObjectMinimalServiceTest,DomainServ private TestdataProperties testdataProperties; @Test - public void areDependenciesLoaded() throws Exception { + public void test000areDependenciesLoaded() throws Exception { Assert.assertNotNull(urlService); Assert.assertNotNull(testdataProperties); } @Commit @Test - public void fetchTestData() throws Exception { + public void test001fetchTestData() throws Exception { String msg = "fetchTestData: "; int page=1; int size=1; @@ -65,7 +68,7 @@ public void fetchTestData() throws Exception { @Commit @Test - public void findByUrl() throws Exception { + public void test025findByUrl() throws Exception { String msg = "findByUrl: "; int page=1; int size=1; @@ -108,18 +111,18 @@ public void findRawUrlsFromDescription() throws Exception { urlService.store(urlTest4,createdBy); List urlList = urlService.findRawUrlsFromDescription(); - log.info(msg+"+++++++++++++++++++++++++++++++++++++++++"); - log.info(msg+" size: "+urlList.size()); - log.info(msg+"+++++++++++++++++++++++++++++++++++++++++"); + log.debug(msg+"+++++++++++++++++++++++++++++++++++++++++"); + log.debug(msg+" size: "+urlList.size()); + log.debug(msg+"+++++++++++++++++++++++++++++++++++++++++"); Assert.assertTrue(urlList.size()>0); for(Url url:urlList){ Assert.assertTrue(url.isValid()); Assert.assertTrue(url.isRawUrlsFromDescription()); Assert.assertTrue(url.getExpanded().compareTo(Url.UNDEFINED)==0); Assert.assertTrue(url.getDisplay().compareTo(Url.UNDEFINED)==0); - log.info(msg+"-----------------------------------------"); - log.info(msg+url.getUniqueId()); - log.info(msg+"-----------------------------------------"); + log.debug(msg+"-----------------------------------------"); + log.debug(msg+url.getUniqueId()); + log.debug(msg+"-----------------------------------------"); log.trace(msg+url.toString()); } } @@ -150,17 +153,17 @@ public void findUrlAndExpandedTheSame() throws Exception { urlService.store(urlTest4,createdBy); List urlList = urlService.findUrlAndExpandedTheSame(); - log.info(msg+"+++++++++++++++++++++++++++++++++++++++++"); - log.info(msg+" size: "+urlList.size()); - log.info(msg+"+++++++++++++++++++++++++++++++++++++++++"); + log.debug(msg+"+++++++++++++++++++++++++++++++++++++++++"); + log.debug(msg+" size: "+urlList.size()); + log.debug(msg+"+++++++++++++++++++++++++++++++++++++++++"); Assert.assertTrue(urlList.size()>0); for(Url url:urlList){ Assert.assertTrue(url.isValid()); Assert.assertTrue(url.isUrlAndExpandedTheSame()); Assert.assertTrue(url.getUrl().compareTo(url.getExpanded())==0); - log.info(msg+"-----------------------------------------"); - log.info(msg+url.getUniqueId()); - log.info(msg+"-----------------------------------------"); + log.debug(msg+"-----------------------------------------"); + log.debug(msg+url.getUniqueId()); + log.debug(msg+"-----------------------------------------"); log.trace(msg+url.toString()); } } @@ -168,49 +171,49 @@ public void findUrlAndExpandedTheSame() throws Exception { @Commit @Test @Override - public void findById() throws Exception { + public void test050findById() throws Exception { } @Commit @Test @Override - public void getAll() throws Exception { + public void test051getAll() throws Exception { } @Commit @Test @Override - public void count() throws Exception { + public void test052count() throws Exception { } @Commit @Test @Override - public void findByUniqueId() throws Exception { + public void test053findByUniqueId() throws Exception { } @Commit @Test @Override - public void store() throws Exception { + public void test100store() throws Exception { } @Commit @Test @Override - public void create() throws Exception { + public void test101create() throws Exception { } @Commit @Test @Override - public void update() throws Exception { + public void test102update() throws Exception { } } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/UserListServiceTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/UserListServiceTest.java index 71278cc8..4a365a1d 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/UserListServiceTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/UserListServiceTest.java @@ -1,8 +1,10 @@ package org.woehlke.twitterwall.oodm.service; import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -12,6 +14,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UserListServiceTest implements DomainObjectMinimalServiceTest,DomainServiceWithTaskTest { private static final Logger log = LoggerFactory.getLogger(UserListServiceTest.class); @@ -20,7 +23,7 @@ public class UserListServiceTest implements DomainObjectMinimalServiceTest,Domai private UserListService userListService; @Test - public void areDependenciesLoaded() throws Exception { + public void test000areDependenciesLoaded() throws Exception { String msg = "areDependenciesLoaded: "; Assert.assertNotNull(userListService); log.debug(msg+" YES "); @@ -29,56 +32,56 @@ public void areDependenciesLoaded() throws Exception { @Commit @Test @Override - public void fetchTestData() throws Exception { + public void test001fetchTestData() throws Exception { } @Commit @Test @Override - public void findById() throws Exception { + public void test050findById() throws Exception { } @Commit @Test @Override - public void getAll() throws Exception { + public void test051getAll() throws Exception { } @Commit @Test @Override - public void count() throws Exception { + public void test052count() throws Exception { } @Commit @Test @Override - public void findByUniqueId() throws Exception { + public void test053findByUniqueId() throws Exception { } @Commit @Test @Override - public void store() throws Exception { + public void test100store() throws Exception { } @Commit @Test @Override - public void create() throws Exception { + public void test101create() throws Exception { } @Commit @Test @Override - public void update() throws Exception { + public void test102update() throws Exception { } } diff --git a/src/test/java/org/woehlke/twitterwall/oodm/service/UserServiceTest.java b/src/test/java/org/woehlke/twitterwall/oodm/service/UserServiceTest.java index 42cbdb97..35b3885d 100644 --- a/src/test/java/org/woehlke/twitterwall/oodm/service/UserServiceTest.java +++ b/src/test/java/org/woehlke/twitterwall/oodm/service/UserServiceTest.java @@ -2,8 +2,10 @@ import org.junit.Assert; +import org.junit.FixMethodOrder; import org.junit.Test; import org.junit.runner.RunWith; +import org.junit.runners.MethodSorters; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -24,6 +26,7 @@ @RunWith(SpringRunner.class) @SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.NONE) +@FixMethodOrder(MethodSorters.NAME_ASCENDING) public class UserServiceTest implements DomainObjectMinimalServiceTest,DomainServiceWithTaskTest { private static final Logger log = LoggerFactory.getLogger(UserServiceTest.class); @@ -53,7 +56,7 @@ public class UserServiceTest implements DomainObjectMinimalServiceTest,DomainSer private TestdataProperties testdataProperties; @Test - public void areDependenciesLoaded() throws Exception { + public void test000areDependenciesLoaded() throws Exception { String msg = "areDependenciesLoaded: "; Assert.assertNotNull(userService); Assert.assertNotNull(testdataProperties); @@ -63,7 +66,7 @@ public void areDependenciesLoaded() throws Exception { @Commit @Test - public void fetchTestData() throws Exception { + public void test001fetchTestData() throws Exception { String msg = "fetchTestData: "; int page=1; int size=1; @@ -83,7 +86,7 @@ public void fetchTestData() throws Exception { @Test public void getAllDescriptionsTest() { String msg = "getAllDescriptionsTest"; - log.info(msg+"------------------------------------------------"); + log.debug(msg+"------------------------------------------------"); boolean hasNext; Pageable pageRequest = new PageRequest(FIRST_PAGE_NUMBER, twitterProperties.getPageSize()); do { @@ -91,15 +94,15 @@ public void getAllDescriptionsTest() { hasNext = descriptions.hasNext(); long totalNumber = descriptions.getTotalElements(); int number = descriptions.getNumber(); - log.info(msg+"found "+number+" descriptions (total: "+totalNumber+")"); + log.debug(msg+"found "+number+" descriptions (total: "+totalNumber+")"); for(String description:descriptions){ - log.info(msg+"description: "+description); + log.debug(msg+"description: "+description); } pageRequest = pageRequest.next(); } while (hasNext); String message = "userService.findAllDescriptions(); "; Assert.assertTrue(message,true); - log.info(msg+"------------------------------------------------"); + log.debug(msg+"------------------------------------------------"); } @Commit @@ -375,17 +378,17 @@ public void findAllUser2Mentiong() throws Exception { Page foundPage = userService.findAllUser2Mentiong(pageRequest); for(Object2Entity object2Entity:foundPage.getContent()){ long objectId = object2Entity.getObjectId(); - log.info(msg+" objectId: "+objectId); + log.debug(msg+" objectId: "+objectId); String objectInfo = object2Entity.getObjectInfo(); - log.info(msg+" objectInfo: "+objectInfo); + log.debug(msg+" objectInfo: "+objectInfo); long entityId = object2Entity.getEntityId(); - log.info(msg+" entityId: "+entityId); + log.debug(msg+" entityId: "+entityId); String entityInfo = object2Entity.getObjectInfo(); - log.info(msg+" entityInfo: "+entityInfo); + log.debug(msg+" entityInfo: "+entityInfo); User userPers = userService.findById(objectId); - log.info(msg+" userPers: "+userPers); + log.debug(msg+" userPers: "+userPers); Mention mentionPers = mentionService.findById(entityId); - log.info(msg+" mentionPers: "+mentionPers); + log.debug(msg+" mentionPers: "+mentionPers); Assert.assertNotNull(msg+" userPers: ",userPers); Assert.assertNotNull(msg+" mentionPers: ",mentionPers); Assert.assertNull(msg+" objectInfo: " ,objectInfo); @@ -472,49 +475,49 @@ public void findByidTwitterAndScreenNameUnique() throws Exception { @Commit @Test @Override - public void findById() throws Exception { + public void test050findById() throws Exception { } @Commit @Test @Override - public void getAll() throws Exception { + public void test051getAll() throws Exception { } @Commit @Test @Override - public void count() throws Exception { + public void test052count() throws Exception { } @Commit @Test @Override - public void findByUniqueId() throws Exception { + public void test053findByUniqueId() throws Exception { } @Commit @Test @Override - public void store() throws Exception { + public void test100store() throws Exception { } @Commit @Test @Override - public void create() throws Exception { + public void test101create() throws Exception { } @Commit @Test @Override - public void update() throws Exception { + public void test102update() throws Exception { } } diff --git a/src/test/resources/logback.xml b/src/test/resources/logback.xml index d28cf14d..1a9c22ce 100644 --- a/src/test/resources/logback.xml +++ b/src/test/resources/logback.xml @@ -1,25 +1,36 @@ - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test.txt b/test.txt new file mode 100644 index 00000000..c74b5c79 --- /dev/null +++ b/test.txt @@ -0,0 +1,44 @@ +- [ ] HashTagTest.class, +- [ ] MediaTest.class, +- [ ] MentionTest.class, +- [ ] TaskHistoryTest.class, +- [ ] TaskTest.class, +- [ ] TickerSymbolTest.class, +- [ ] TweetTest.class, +- [ ] UrlTest.class, +- [ ] UserDescriptionTest.class, +- [ ] UserListTest.class, +- [ ] UserTest.class, + +- [ ] HashTagServiceTest.class, +- [ ] MediaServiceTest.class, +- [ ] MentionServiceTest.class, +- [ ] TaskHistoryServiceTest.class, +- [ ] TaskServiceTest.class, +- [ ] TickerSymbolServiceTest.class, +- [ ] TweetServiceTest.class, +- [ ] UrlServiceTest.class, +- [ ] UserListServiceTest.class, +- [ ] UserServiceTest.class, + +- [ ] ApplicationControllerTest.class, +- [ ] CountedEntitiesControllerTest.class, +- [ ] HashTagControllerTest.class, +- [ ] ImprintControllerTest.class, +- [ ] LoginControllerTest.class, +- [ ] MediaControllerTest.class, +- [ ] MentionControllerTest.class, +- [ ] TaskControllerTest.class, +- [ ] TaskHistoryControllerTest.class, +- [ ] TickerSymbolControllerTest.class, +- [ ] TweetControllerTest.class, +- [ ] UrlControllerTest.class, +- [ ] UserControllerTest.class, +- [ ] UserListControllerTest.class, + +- [ ] TwitterUrlServiceTest.class, + +- [ ] TaskStartFireAndForgetTestImpl.class, +- [ ] TaskStartTestImpl.class, + +- [ ] CronJobsTest.class \ No newline at end of file diff --git a/travis.sh b/travis.sh new file mode 100755 index 00000000..bb5d0612 --- /dev/null +++ b/travis.sh @@ -0,0 +1,49 @@ +#!/opt/local/bin/bash + +export TWITTERWALL_FRONTEND_MAX_RESULTS=200 +export TWITTERWALL_SHOW_USERS_MENU=true +export TWITTERWALL_CONTEXT_TEST=true +export TWITTER_PAGE_SIZE=50 +export TWITTER_FETCH_TESTDATA=false +export TWITTERWALL_WAIT_FOR_TEST=120000 +export TWITTERWALL_URL_TEST_DATA_VERBOSE=false +export TWITTERWALL_SCHEDULER_ALLOW_UPDATE_TWEETS=false +export TWITTERWALL_SCHEDULER_ALLOW_UPDATE_USERS=false +export TWITTERWALL_SCHEDULER_ALLOW_UPDATE_USERS_FROM_MENTION=false +export TWITTERWALL_SCHEDULER_ALLOW_REMOVE_OLD_DATA_FROM_STORAGE=false +export TWITTERWALL_SCHEDULER_ALLOW_SEARCH=false +export TWITTER_SEARCH_TERM='#hibernate OR #java OR #TYPO3' +export TWITTERWALL_INFO_WEBPAGE=https://github.com/phasenraum2010/twitterwall2 +export TWITTERWALL_THEME=typo3 +export TWITTERWALL_APP_NAME=Twitterwall +export TWITTERWALL_INFO_IMPRINT_SCREEN_NAME=port80guru +export TWITTERWALL_GOOGLE_ANALYTICS_ID=TWITTERWALL_GOOGLE_ANALYTICS_ID +export TWITTERWALL_SCHEDULER_HEROKU_DB_LIMIT=false +export TWITTERWALL_SCHEDULER_USER_LIST_NAME=test-typo3-hibernate-java +export TWITTERWALL_SCHEDULER_USER_LIST_ALLOW=false +export TWITTERWALL_JPA_HIBERNATE_DDL_AUTO=update +#export TWITTERWALL_JPA_HIBERNATE_DDL_AUTO=create-drop +export TWITTERWALL_LOGIN_USERNAME=tw +export TWITTERWALL_LOGIN_PASSWORD=vbfvjdgar64r67tf7a46tf76rgtfgf7d6g + +#psql -U twitterwall2test < etc/drop-tables.sql + +#psql -c 'DROP DATABASE kandidatentest;' -U postgres +#psql -c 'DROP USER kandidatentest;' -U postgres +#psql -c 'DROP ROLE kandidatentest;' -U postgres +#psql -c "CREATE USER kandidatentest WITH PASSWORD 'kandidatentestpwd' LOGIN SUPERUSER INHERIT CREATEDB CREATEROLE NOREPLICATION;" -U postgres +#psql -c 'GRANT pg_signal_backend, postgres TO kandidatentest WITH ADMIN OPTION;' -U postgres +#psql -c "CREATE DATABASE kandidatentest WITH OWNER = kandidatentest TEMPLATE = template1 ENCODING = 'UTF8' LC_COLLATE = 'de_DE.UTF-8' LC_CTYPE = 'de_DE.UTF-8' CONNECTION LIMIT = -1;" -U postgres + +psql -c 'select * from version();' -U twitterwall2test +psql -c '\l' -U postgres +psql -c '\dg' -U postgres +psql -c '\dn' -U postgres + +./mvnw install -DskipTests=true -Dmaven.javadoc.skip=true -B -V +./mvnw clean site site:deploy -Ptravis -Dtest=AlphaTopLevelSuiteIT -B -V +#./mvnw clean site site:deploy -Ptravis -Dtest=CronJobsTest -B -V + + + +exit 0 \ No newline at end of file diff --git a/twitterwall2.iml b/twitterwall2.iml index 5aee46d4..995a09b8 100644 --- a/twitterwall2.iml +++ b/twitterwall2.iml @@ -2,7 +2,33 @@ - + + + file://$MODULE_DIR$/src/main/resources/mq/CreateImprintUser.xml + file://$MODULE_DIR$/src/main/resources/mq/CreateTestDataTweets.xml + file://$MODULE_DIR$/src/main/resources/mq/CreateTestDataUser.xml + file://$MODULE_DIR$/src/main/resources/mq/FetchFavorites.xml + file://$MODULE_DIR$/src/main/resources/mq/FetchFollower.xml + file://$MODULE_DIR$/src/main/resources/mq/FetchFriends.xml + file://$MODULE_DIR$/src/main/resources/mq/FetchHomeTimeline.xml + file://$MODULE_DIR$/src/main/resources/mq/FetchListOwner.xml + file://$MODULE_DIR$/src/main/resources/mq/FetchLists.xml + file://$MODULE_DIR$/src/main/resources/mq/FetchListsForUsers.xml + file://$MODULE_DIR$/src/main/resources/mq/FetchMentions.xml + file://$MODULE_DIR$/src/main/resources/mq/FetchRetweetsOfMe.xml + file://$MODULE_DIR$/src/main/resources/mq/FetchTweetsFromSearch.xml + file://$MODULE_DIR$/src/main/resources/mq/FetchUsersFromList.xml + file://$MODULE_DIR$/src/main/resources/mq/FetchUserTimeline.xml + file://$MODULE_DIR$/src/main/resources/mq/GarbageCollection.xml + file://$MODULE_DIR$/src/main/resources/integration.xml + file://$MODULE_DIR$/src/main/resources/mq/RemoveOldDataFromStorage.xml + file://$MODULE_DIR$/src/main/resources/mq/TaskStart.xml + file://$MODULE_DIR$/src/main/resources/mq/UpdateMentionsForUsers.xml + file://$MODULE_DIR$/src/main/resources/mq/UpdateTweets.xml + file://$MODULE_DIR$/src/main/resources/mq/UpdateUrls.xml + file://$MODULE_DIR$/src/main/resources/mq/UpdateUser.xml + +