Skip to content
This repository has been archived by the owner on Sep 16, 2020. It is now read-only.

Initialising services via SymphonyClientConfigBuilder and SymphonyClientConfig #117

Open
dayoaws opened this issue Apr 20, 2018 · 1 comment

Comments

@dayoaws
Copy link

dayoaws commented Apr 20, 2018

Various services follow the pattern below which makes them hard to unit test.
public MessageService(SymphonyClient symClient) {
this.symClient = symClient;
//Lets startup the worker thread to listen for raw datafeed messages
dataFeedWorker = new DataFeedWorker(symClient, this);
new Thread(dataFeedWorker, "DataFeedWorker: "+ symClient.getName()).start();
}

To simplify and reduce the components that need to be initialised in unit testing, i suggest we extract the initialisation of the runnables out of the constructors into a private init method and perform the initialisation based on a new lazyInit attribute added to the ClientConfig and built using the ClientConfigBuilder

@dayoaws
Copy link
Author

dayoaws commented Apr 20, 2018

See the following gist for an example of what the MessageService would look like after the change described above https://gist.github.com/dayoaws/3e3e4898bfc4c9a552558c19ae224efa

this of course assumes that the config was built using the builder and the lazy init flag is a mandatory BuildStep after the withServices buildstep

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant