Simple tool for generating and hosting fake and/or cached Sense API data. A Java port of the original nonsense project.
The nonsense-java project requires a copy of the JDK8 to run. Grab it from oracle.com.
Download the latest jar from the releases page.
Run the jar downloaded from the releases page through the java command, like so:
$ java -jar nonsense-release.jar
The web server run by nonsense currently responds to the following Sense API calls:
POST /v1/oauth/token: authenticates the user, accepts any input and returns a random token.GET /v1/account: returns fake user info consistent with the POST /v1/oauth/token route.GET /v2/trends/:time-scale: returns a trends object matching the spec.
:time-scale: either last_week, last_month, or last_3_months.GET /v1/timeline/:date: returns an array of timelines.
:date: A date of the format yyyy-MM-ddGET /v2/timeline/:date: returns a single timeline object matching the spec.
:date: A date of the format yyyy-MM-ddGET /v1/insights: returns an array of insights.GET /v2/insights: returns an array of insights.The data routes included in nonsense support several non-spec query parameters that control
parameters of randomized data.
GET /v2/trends/:time-scale
ns_time_zone: the time-zone the trends should be generated in, uses the format +/-hh:mm.ns_locale: specifies the locale to use when generating textual data.ns_account_age: specifies the age of the fake nonsense account, affects the last_week :time-scale.GET /:version/timeline/:date
ns_time_zone: the time-zone the timeline should be generated in, uses the format +/-hh:mm.ns_locale: specifies the locale to use when generating textual data.GET /v1/insights
ns_limit: the number of insights to include in the payload, defaults to 5.GET /v2/insights
ns_limit: the number of insights to include in the payload, defaults to 5.If you’d like to use a data dump of real timelines, use the --timeline-cache option:
$ java -jar nonsense-release.jar --timeline-cache ./assets/timeline-cache/timeline_1.txt
Requests to the timeline endpoints will return random timelines from the dump.
The assets/timeline-caches directory in this repository includes example timeline
responses in the expected format, one timeline JSON object per line.
Building the project requires maven, and a copy of IntelliJ.
To import the nonsense-java project into IntelliJ, follow these steps:
Import Project from Welcome to IntelliJ windownonsense-java directoryMaven in the Import Project windowis.hello:nonsense artifact is selected on the Maven projects to import screenMaven Projects tab, select nonsense -> Lifecycle -> packageTo set up the project to run nonsense, follow these steps:
+ buttonApplicationRun and check Single instance onlynonsense.Nonsense for the main classTo set up the project to run the nonsense tests, follow these steps:
+ buttonJUnitTestsAll in package under Test kindnonsense for the packageAcross module dependencies for Search for testsOr, you can run the tests from the command line through maven like so:
$ mvn test
Maven Projects tab, select nonsense -> Plugins -> assembly -> assemblytarget/nonsense-*-jar-with-dependencies.jar file wherever you need it