-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Nicolas Arkkila
committed
Dec 9, 2013
1 parent
a6fe4d3
commit b659816
Showing
25 changed files
with
438 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
The class structure is as follows: | ||
|
||
# FotmServlet (in Servlet) | ||
FotmServlet is the user-facing class. It handles all requests. | ||
It also contains the TwitterEvaluator service and the TwitterHistory repository, to which it communicates. It passes data to TwitterHistory for caching. | ||
|
||
# TwitterHistory (in Repo) | ||
Simply a list repository of cached tweets. It gives results based on the repository status, such as latest result, this month's favourite, and can return a list for other classes to use. Uses TwitterCache objects to store into the cache. | ||
|
||
# TwitterEvaluator implements EvaluatorService (in Service) | ||
This class is responsible for communicating with the Twitter API. It sends requests, gets responses and sends the responses for evaluation to TwitterCrunch. It passes data as a String object further to the servlet. | ||
|
||
#TwitterCrunch (in Logic) | ||
This class is a helper class for TwitterEvaluator, to determine which hashtag is the top trending #1 of a list of hashtags, based on their latest 100 tweets. Only TwitterEvaluator has access to this class. | ||
|
||
#TwitterCache (in Data) | ||
A simple datatype to store a hashtag and a Date when the cache was set. Used in TwitterHistory. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Flavour of the Now (jlab) was a University of Helsinki Java assignment for "Javalabra 2013". | ||
|
||
Need to use a database for your program? This app will tell you which one to choose. | ||
Flavour of the Now (FOTN) parses Twitter feeds to determine what is your database of choice. The base functionality of the app is built upon the Twitter API 1.1, and it uses the twitter4j library. | ||
|
||
FOTN gets a list of hashtags with a list of their tweets, and calculates which one is the top #1 trending of the bunch, which is then returned to the user. These results are then cached for later requests, and a new Twitter API request is not made until the cache times out. | ||
|
||
Users consists of anyone making a request. In this version, users only make requests and receive a view based on the result. | ||
|
||
Of course, while the results are accurate, you should not take the descriptions of the features seriously, they are meant to be satire :). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
# Instructions | ||
If you do not have Maven, download it. You can also use a bundled Maven if you use some IDE like NetBeans. You can run the app through the IDE as well, if you have a server like Tomcat installed. | ||
|
||
If you already have Maven, to run the app, you need simply clone the source and run the following in jlab/: | ||
$ mvn clean package | ||
$ java -jar target/dependency/jetty-runner.jar <--port {number}> target/<war package>.war | ||
|
||
After jetty-runner is launched (you see SelectChannelConnector@0.0.0.0:8080 STARTING), open your browser at localhost:8080. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
Test Documentation | ||
==== | ||
|
||
There were some challenges regarding testing. At first, while I was building the servlet, I didn't have a lot of tests, because there was no real core logic. After familiarising myself with the Twitter API, I had to quickly jump into the testing section, which helped me greatly in the end. | ||
|
||
Lots of things in Spring had to be tested by hand. | ||
|
||
# CrunchTest | ||
Testing saved lots of time in this class. I did have another Java program just to test the number crunching coming from the Twitter API, but with unit tests I was able to build reliable methods to determine the trending hashtag. I also had to create a TestStatus class to be able to test this class, since the base Status class from twitter4j did not have a mutable Status class. | ||
|
||
The final test (when scores collide up until timescores) is based on randomness, so I left that untested and did it by hand. I did get variable (that is, random) results on it nevertheless. | ||
|
||
# HistoryTest | ||
I was having some odd in this class before fixing it with unit tests. The core logic of this class is a lot simpler, so there is not that much to test. | ||
|
||
# ServletTest | ||
As there is not much going on on the view side, just testing if the servlet launches properly was the only thing of use I could really think of, since otherwise there would be a system issue the admin would have to review. | ||
|
||
# CacheTest | ||
Once again, a very simple class with just actually a string and a Date object. Mostly to just test whether they are set correctly. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.