Advertisement
IronJoo

Untitled

Aug 27th, 2024
1,349
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.28 KB | None | 0 0
  1. The system you work with on a daily basis runs multiple microservices. You have been asked to prepare an aggregation that represents the number o user visits to all microservices, for use by data analysts. The architect you're working with has already designed the API, which consists of a single class: VisitCounter. VisitCounter has a single method, count. It returns Map<Long, Long> - this map should contain the number of visits by the user with a given ID. This method accepts an array of Map<String, UserStats>. 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<Long>. A getter for this field is also implemented. This field will never be null; however it might be empty. You must skip any sch 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. Assumptions: The UserStats class is already implemented. You do not have to write the implementation of this class as part of your solution.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement