### Question:
AppReleaseServiceImpl implements AppReleaseService { @Override public Optional<AppRelease> findLatestReleaseApp(Integer appId) { return appReleaseDao.findFirstByAppIdOrderByIdDesc(appId); }  @Override Optional<AppRelease> findById(int releaseId); @Override Optional<AppRelease> findLatestReleaseApp(Integer appId); @Override Optional<AppRelease> findByAppIdAndVersion(Integer appId, String version); @Override List<AppRelease> findAllByAppName(String appName); @Override Optional<AppRelease> findLatestReleaseAppByAppName(String appName);  }### Answer:
@Test public void find_latest_release_app_no_data() { int appId = 9999; Optional<AppRelease> appReleaseOption = appReleaseService.findLatestReleaseApp(appId); assertThat(appReleaseOption.isEmpty()).isTrue(); }
@Test public void find_latest_release_app_one_row_success() { int appId = 1; AppRelease appRelease = new AppRelease(); appRelease.setAppId(appId); appRelease.setVersion("0.0.1"); appRelease.setTitle("title"); appRelease.setDescription("description"); appRelease.setReleaseTime(LocalDateTime.now()); appRelease.setReleaseMethod(ReleaseMethod.AUTO); appRelease.setCreateUserId(1); appRelease.setCreateTime(LocalDateTime.now()); appReleaseDao.save(appRelease); Optional<AppRelease> appReleaseOption = appReleaseService.findLatestReleaseApp(appId); assertThat(appReleaseOption.get().getVersion()).isEqualTo("0.0.1"); }
@Test public void find_latest_release_app_two_row_success() { int appId = 1; AppRelease appRelease = new AppRelease(); appRelease.setAppId(appId); appRelease.setVersion("0.0.1"); appRelease.setTitle("title"); appRelease.setDescription("description"); appRelease.setReleaseTime(LocalDateTime.now()); appRelease.setReleaseMethod(ReleaseMethod.AUTO); appRelease.setCreateUserId(1); appRelease.setCreateTime(LocalDateTime.now()); appReleaseDao.save(appRelease); appRelease = new AppRelease(); appRelease.setAppId(appId); appRelease.setVersion("0.0.2"); appRelease.setTitle("title"); appRelease.setDescription("description"); appRelease.setReleaseTime(LocalDateTime.now()); appRelease.setReleaseMethod(ReleaseMethod.AUTO); appRelease.setCreateUserId(1); appRelease.setCreateTime(LocalDateTime.now()); appReleaseDao.save(appRelease); Optional<AppRelease> appReleaseOption = appReleaseService.findLatestReleaseApp(appId); assertThat(appReleaseOption.get().getVersion()).isEqualTo("0.0.2"); }