### Question:
FrontendLoggerService { public FrontendLog findById(Long frontendLogId) { return frontendLoggerRepository.findByIdOrThrow(frontendLogId); } @Autowired  FrontendLoggerService(FrontendLoggerRepository frontendLoggerRepository); FrontendLog findById(Long frontendLogId); FrontendLog createFrontendLog(FrontendLog frontendLog);  }### Answer:
@Test public void test_findByIdShouldFindCorrectly() { FrontendLog expectedFrontendLog = new FrontendLog(1L, "ERROR", LocalDateTime.now(), "main.ts", "5", "Failed to build file"); when(frontendLoggerRepository.findByIdOrThrow(expectedFrontendLog.getId())) .thenReturn(expectedFrontendLog); FrontendLog frontendLog = frontendLoggerService.findById(expectedFrontendLog.getId()); Assert.assertEquals(expectedFrontendLog, frontendLog); }
@Test(expected = NullPointerException.class) public void test_findByIdShouldThrowNullPointerException() { FrontendLog expectedFrontendLog = new FrontendLog(1L, "ERROR", LocalDateTime.now(), "main.ts", "5", "Failed to build file"); when(frontendLoggerRepository.findByIdOrThrow(expectedFrontendLog.getId())) .thenThrow(NullPointerException.class); frontendLoggerService.findById(expectedFrontendLog.getId()); }