Welcome to the interview screening.
Please read the instructions carefully before proceeding. Excluding the bonus task, all other tasks are independent and can be tackled in any sequence.
Good Luck!
- Java Development Kit (JDK) 17
Please ensure you have the above pre-requisites installed and configured before starting the tasks.
Your primary objective is to improve the performance of the API in the FirstProblemController class. There are two main requirements:
- The API should be able to save a list of 5 words in under 500ms.
- If any word in the list contains the letter "a", the service should throw an
UnsupportedOperationException.
There are already two unit tests provided:
- One checks the performance requirement.
- The other checks the validation requirement.
Your goal is to make changes to the code such that both unit tests pass successfully.
- You MUST NOT modify the
saveWordToExternalApimethod. - The API in the
FirstProblemControllershould return a 201 status as soon as possible, but it should still throw an exception if the request is invalid.
- Run the tests in the
FirstProblemServiceTestclass instead of trying to use another tool (like Postman). We already implemented some request there.
Your primary objective is to debug and fix the issues present in the BookService class. There are a series of bugs related to the creation and handling of the Book entity:
- The
BookServiceis responsible for adding a book, which includes generating an SEO name and product code. - The product code is generated based on the SEO name, with specific conversion rules for characters.
- There are multiple unit tests provided in the
BookServiceTestclass that validate the functionality. Some of these tests are currently failing due to bugs in the logic.
Your goal is to identify and fix the issues in the BookService and the Book entity such that all the unit tests in the BookServiceTest class pass successfully.
- You MUST NOT modify the structure of the tests in the
BookServiceTestclass. Only the service and entity logic should be adjusted. - Utilize a debugger to help identify the issues in the logic.
- Run the tests in the
BookServiceTestclass to identify the failing tests and the related bugs. - Pay close attention to the logic for generating the product code based on the SEO name.
Your primary objective is to create a new API that manages customizable greeting messages based on the time of day and locale.
-
Greeting Configuration: The application should support configurable greeting messages based on the time of day (morning, afternoon, evening) and locale (e.g., English, Spanish). The greetings should be stored in the
application.yamlfile. -
REST Endpoint: Expose a single REST endpoint:
GET /greet/{name}?locale=en- which returns a greeting message based on the time of day and provided locale.
-
Configurable Greetings: The greetings in
application.yamlshould support multiple formats based on time of day and locale. The application should select the appropriate greeting based on the current time and the provided locale.
greeting:
morning:
en: "Good morning, {name}!"
es: "¡Buenos días, {name}!"
afternoon:
en: "Good afternoon, {name}!"
es: "¡Buenas tardes, {name}!"
evening:
en: "Good evening, {name}!"
es: "¡Buenas noches, {name}!"- A request to
GET /greet/John?locale=enat 9 AM should return: "Good morning, John!" - A request to
GET /greet/John?locale=esat 2 PM should return: "¡Buenas tardes, John!"
Your objective for this bonus task is to implement a security layer for the /greet API using Spring Security.
- Spring Security Configuration: Set up Spring Security in the application to protect the
/greetendpoint. - Header-Based Authentication: Ensure that every request to the
/greetendpoint must have a headerX-Auth-Tokenwith the valuesuch-secure-much-wow.
- A request to
GET /greet/John?locale=enwithout the correctX-Auth-Tokenheader should return a403 Forbiddenresponse. - A request to
GET /greet/John?locale=enwith the headerX-Auth-Token: such-secure-much-wowshould proceed and return the appropriate greeting.
- Integrate Spring Security into the application.
- Configure the security settings to require the specific header and value for the
/greetendpoint. - Ensure other endpoints are not affected by this security configuration.