### Question:
DefaultDistributedReleaseManager implements DistributedReleaseManager { public String getDefaultBuildagent( int projectId ) { BuildResult buildResult = buildResultDao.getLatestBuildResultForProject( projectId ); return buildResult != null ? buildResult.getBuildUrl() : null; }  Map getReleasePluginParameters( int projectId, String pomFilename ); List<Map<String, String>> processProject( int projectId, String pomFilename, boolean autoVersionSubmodules ); String releasePrepare( Project project, Properties releaseProperties, Map<String, String> releaseVersion,
                                  Map<String, String> developmentVersion, Map<String, String> environments,
                                  String username ); ReleaseResult getReleaseResult( String releaseId ); Map<String, Object> getListener( String releaseId ); void removeListener( String releaseId ); String getPreparedReleaseName( String releaseId ); Map<String, String> getPreparedReleases( String groupId, String artifactId ); void releasePerform( int projectId, String releaseId, String goals, String arguments,
                                boolean useReleaseProfile, LocalRepository repository, String username ); String releasePerformFromScm( int projectId, String goals, String arguments, boolean useReleaseProfile,
                                         LocalRepository repository, String scmUrl, String scmUsername,
                                         String scmPassword, String scmTag, String scmTagBase, Map environments,
                                         String username ); void releaseRollback( String releaseId, int projectId ); String releaseCleanup( String releaseId ); List<Map<String, Object>> getAllReleasesInProgress(); String getDefaultBuildagent( int projectId ); PreparedRelease getPreparedRelease( String releaseId, String releaseType ); SlaveBuildAgentTransportService createSlaveBuildAgentTransportClientConnection( String buildAgentUrl ); void setBuildResultDao( BuildResultDao buildResultDao ); final String PREPARED_RELEASES_FILENAME; }### Answer:
@Test public void testGetDefaultBuildagent() throws Exception { String defaultBuildagentUrl = "http: BuildResult buildResult = new BuildResult(); buildResult.setBuildUrl( defaultBuildagentUrl ); when( buildResultDao.getLatestBuildResultForProject( 0 ) ).thenReturn( buildResult ); String returnedBuildagent = distributedReleaseManager.getDefaultBuildagent( 0 ); assertNotNull( returnedBuildagent ); assertEquals( returnedBuildagent, defaultBuildagentUrl ); }
@Test public void testGetDefaultBuildagentNullBuildResult() throws Exception { BuildResult buildResult = null; when( buildResultDao.getLatestBuildResultForProject( 0 ) ).thenReturn( buildResult ); String returnedBuildagent = distributedReleaseManager.getDefaultBuildagent( 0 ); assertNull( returnedBuildagent ); }