### Question:
ProjectDeployServiceImpl implements ProjectDeployService { @Override public Optional<ProjectDeploy> findOrCreate(Integer projectId, Integer userId) { return projectDeployDao.findByProjectIdAndUserId(projectId, userId).or(() ->{ ProjectDeploy deploy = new ProjectDeploy(); deploy.setUserId(userId); deploy.setProjectId(projectId); deploy.setRegistrationToken(IdGenerator.shortUuid()); deploy.setDeployState(DeployState.UNDEPLOY); deploy.setCreateTime(LocalDateTime.now()); deploy.setCreateUserId(userId); return Optional.of(projectDeployDao.save(deploy)); }); }  @Override Optional<ProjectDeploy> findOrCreate(Integer projectId, Integer userId); @Override Optional<ProjectDeploy> findByRegistrationToken(String registrationToken);  }### Answer:
@Test public void find_or_create_is_not_exist_then_create_it() { assertThat(projectDeployService.findOrCreate(1, 1)).isPresent(); }
@Test public void find_or_create_success() { ProjectDeploy deploy = new ProjectDeploy(); deploy.setUserId(1); deploy.setProjectId(1); deploy.setRegistrationToken("token"); deploy.setDeployState(DeployState.UNDEPLOY); deploy.setCreateTime(LocalDateTime.now()); deploy.setCreateUserId(1); projectDeployDao.save(deploy); assertThat(projectDeployService.findOrCreate(1, 1)).isPresent(); }