The system you work with on a daily basis runs multiple microservices. You have been asked to
Fantastic news! We've Found the answer you've been seeking!
Question:
The system you work with on a daily basis runs multiple microservices. You have been asked to prepare an aggregation that represents number of user visits to all microservices, for use by data analysis.
The architect you are working with has already designed the API, which consists of a single class:VisitCounter.VisitCounter has a single method,count.
It returns Map this map should contain the number of visits by the user with a given ID
This method accepts an array of Map. Every Map represents the total number of visits per user to a given microservice. There are some problems, however:
The Map key, which is a string, should be parseable to Long but it may not be You must skip any such faulty entries.
for some keys, UserStats may be null. You must skip any such faulty entries.
UserStats has a single field, visitCount, of type Optional. A getter for this field is also implemented. This field will never be null; however it might be empty. You must skip any such faulty entries.
Remember that you may receive some invalid input: null,empty maps, and so on Handle it all appropriately and return an empty map.
You may use Java Streams API to implement your solution.
Final solution should also contains Java Unit tests especially for edge cases
Related Book For
Financial Management for Public Health and Not for Profit Organizations
ISBN: 978-0132805667
4th edition
Authors: Steven A. Finkler, Thad Calabrese
Posted Date: