### Question:
BuildServiceImpl extends ServiceSupport implements BuildService { public AbstractBuild<?, ?> findBuild(final String projectName, final int buildNumber) { checkProjectName(projectName); checkBuildNumber(buildNumber); AbstractProject<?, ?> project = projects.findProject(projectName); return project != null ? findBuild(project, buildNumber) : null; } @Inject  BuildServiceImpl(final ProjectService projects, SecurityService security); void deleteBuild(final AbstractProject<?, ?> project, final int buildNumber); void keepBuild(final AbstractProject<?, ?> project, final int buildNumber, final boolean release); AbstractBuild<?, ?> getBuild(final String projectName, final int buildNumber); AbstractBuild<?, ?> getBuild(final AbstractProject<?,?> project, final int buildNumber); AbstractBuild<?, ?> findBuild(final String projectName, final int buildNumber); AbstractBuild<?,?> findBuild(final AbstractProject<?, ?> project, final int buildNumber); void stopBuild(final AbstractProject<?, ?> project, final int buildNumber);  }### Answer:
@Test(expected = NullPointerException.class) public void findBuildByProjectNullProject() { getInst().findBuild((AbstractProject<?, ?>) null, 1); }
@Test(expected = IllegalArgumentException.class) public void findBuildByProjectBuildNumber() { getInst().findBuild(project, -1); }
@Test(expected = IllegalArgumentException.class) public void findBuildByProjectZeroBuildNumber() { getInst().findBuild(project, 0); }
@Test public void findBuildByProjectSecurity() throws IOException { BuildService buildService = spy(getInst()); doReturn(build).when(project).getBuildByNumber(1); buildService.findBuild(project, 1); verify(securityService).checkPermission(build, Item.READ); }
@Test public void findBuildByProjectReturnNull() { assertNull(getInst().findBuild(project, 1)); }
@Test(expected = NullPointerException.class) public void findBuildProjectNameNullName() { getInst().findBuild((String) null, 1); }
@Test(expected = IllegalArgumentException.class) public void findBuildProjectNameNegativeBuildNumber() { getInst().findBuild("projectName", -1); }
@Test(expected = IllegalArgumentException.class) public void findBuildProjectNameZeroBuildNumber() { getInst().findBuild("projectName", 0); }
@Test public void findBuildByProjectNameSecurity() throws IOException { BuildService buildService = spy(getInst()); doReturn(project).when(projectService).findProject("projectName"); doReturn(build).when(project).getBuildByNumber(1); buildService.findBuild("projectName", 1); verify(securityService).checkPermission(build, Item.READ); }
@Test public void findBuildByProjectNameReturnNull() { assertNull(getInst().findBuild("projectName", 1)); }