Downloading and Structure
The source code is available from OpenNTF Stash. Download the projects and import into Eclipse. The project structure is:
- wws.parent: parent pom, this is the one that should be built using Maven install. Building is best done via Eclipse so runtime parameters can be defined.
- wws-api: this project is the main code
- wws-api-integrationtests: this project contains all unit tests run during Maven build, connecting as your WWS application
- wws-api-assembly: this project assembles the output
The project is designed to compile against Java 1.6. However, Maven in Eclipse requires later JREs to run. We recommend Java 1.8.
Test and Run Configuration
The tests in wws-api use JUnit and do not connect to Watson Work Services and can be run without access to Watson Workspace. They can be run in Eclipse using Run As > JUnit Test. There are MockClient and MockGraphQLEndpoint classes in org.opencode4workspace.mocks in the test/java folder for loading a response into an endpoint and parsing the JSON from either the endpoint or the client.
The tests in wws-api-integrationtests use TestNg (to allow parameters to be passed from the run configurations) and do connect to Watson Work Services as an application. Before running the tests you will need to register an app and add it to at least one space. See the Watson Work Services developer site for this. When you register an app, note its app key and app secret. You will need those for the tests to run.
Create a Run Configuration in Eclipse, with the Base Directory set to wws.parent, with the goals clean install.
As will be seen from the screenshot, a number of parameters will need to be added. These are used by the various tests.
|appSecret||The secret for the app you have registered|
|appId||The id of the app you have registered|
|myDisplayName||The displayName property for your Person object. Use the GraphiQL browser IDE to find this out|
|profileId||The id for your Person object. Use the GraphiQL browser IDE to find this out|
|conversationId||An id for a Conversation in a Space your app has access to|
|myAppName||The displayName property for your app's Person object|
|messageId||An id for a Message from the Conversation corresponding to your conversationId property|
An id for a Space your app can post a Message to
|spaceName||The name for the space corresponding to your spaceId property|
|space2Id||An Id for a second space your app can post a Message to|
|space2Name||The name for the space corresponding to your space2Id|
|Long corresponding to a lower bound for the created date of a Message in the conversation corresponding to your conversationId property|
|mostRecentTimestamp||Long corresponding to a upper bound for the created date of a Message in the conversation corresponding to your conversationId property|
To find timestamps, check the "created" property in a Message's annotations
If these are set correctly, you will be able to build the project using the Run button.