Sobes.tech

Tell about a complex bug or a difficult enhancement in your last project.

178

How did you optimize slow SQL queries? How did you solve the N+1 problem in Hibernate?

164

What ORMs have you used? When Hibernate, when JDBC? Were Liquibase/Flyway used?

160

Why did you choose Cassandra? What alternatives did you consider? How did you test?

159

What monitoring, logging, and metrics tools did you use? What approach in microservices?

144

How have you worked with Kafka? Have you tuned partitions or configurations? What happens if consumers are fewer than partitions?

138

What were you able to influence in the architectural decisions on your last project?

124

Was there access to monitoring on different circuits? How was the release process conducted?

121

Description of the task: It is required to implement a REST endpoint to retrieve a list of insurance policies that belong to a specified client and are paid. Since there are a very large number of policies in the system, a parameter for limiting the result should be provided. @RestController public class ClientController { @Value("policy.limit") private int policyLimit; @Autowired private PolicyService policyService; @RequestMapping(path = "client/{clientId}/policies", method = RequestMethod.POST) public Response getClientPolicies(@PathVariable("clientId") String clientId) { List<PolicyDTO> policies = getPolicies().stream() .limit(policyLimit) .filter(p -> p.getClientIds().contains(clientId)) .filter(p -> p.isPaid()) .toList(); return new Response(policies); } @Transactional private List<PolicyDTO> getPolicies() { return policyService.getPolicies(); } @Data @AllArgsConstructor public class Response { private List<PolicyDTO> policies; } @Data public class PolicyDTO { private String id; private String name; private List<String> clientId; private Boolean isPaid; } @RequiredArgsConstructor @Component public class PolicyService { private PolicyDbRepository repository; List<PolicyDTO> getPolicies() { return repository.getPolicies(); } } public interface PolicyDbRepository { List<PolicyDTO> getPolicies(); }

106