### Question:
DefaultBuildDefinitionService implements BuildDefinitionService, Initializable { public boolean isBuildDefinitionInUse( BuildDefinition buildDefinition ) throws BuildDefinitionServiceException { boolean inUse = false; List<BuildDefinitionTemplate> buildDefinitionTemplates = getAllBuildDefinitionTemplate(); for ( BuildDefinitionTemplate template : buildDefinitionTemplates ) { for ( BuildDefinition definition : (List<BuildDefinition>) template.getBuildDefinitions() ) { if ( buildDefinition.getId() == definition.getId() ) { inUse = true; break; } } if ( inUse ) { break; } } return inUse; }  void initialize(); BuildDefinition getBuildDefinition( int buildDefinitionId ); BuildDefinition addBuildDefinition( BuildDefinition buildDefinition ); void removeBuildDefinition( BuildDefinition buildDefinition ); void updateBuildDefinition( BuildDefinition buildDefinition ); List<BuildDefinition> getAllBuildDefinitions(); List<BuildDefinition> getAllTemplates(); BuildDefinition cloneBuildDefinition( BuildDefinition buildDefinition ); boolean isBuildDefinitionInUse( BuildDefinition buildDefinition ); BuildDefinitionTemplate getContinuumDefaultWithType( String type ); BuildDefinitionTemplate getDefaultAntBuildDefinitionTemplate(); BuildDefinitionTemplate getDefaultMavenOneBuildDefinitionTemplate(); BuildDefinitionTemplate getDefaultMavenTwoBuildDefinitionTemplate(); BuildDefinitionTemplate getDefaultShellBuildDefinitionTemplate(); List<BuildDefinitionTemplate> getAllBuildDefinitionTemplate(); BuildDefinitionTemplate getBuildDefinitionTemplate( int id ); void removeBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate ); BuildDefinitionTemplate updateBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate ); BuildDefinitionTemplate addBuildDefinitionTemplate( BuildDefinitionTemplate buildDefinitionTemplate ); BuildDefinitionTemplate addBuildDefinitionInTemplate( BuildDefinitionTemplate buildDefinitionTemplate,
                                                                 BuildDefinition buildDefinition, boolean template ); BuildDefinitionTemplate removeBuildDefinitionFromTemplate( BuildDefinitionTemplate buildDefinitionTemplate,
                                                                      BuildDefinition buildDefinition ); void addTemplateInProject( int buildDefinitionTemplateId, Project project ); ProjectGroup addBuildDefinitionTemplateToProjectGroup( int projectGroupId, BuildDefinitionTemplate template ); List<BuildDefinitionTemplate> getBuildDefinitionTemplatesWithType( String type ); List<BuildDefinitionTemplate> getContinuumBuildDefinitionTemplates();  }### Answer:
@Test public void testUnusedBuildDefinition() throws Exception { BuildDefinition unused = new BuildDefinition(); unused.setTemplate( true ); unused.setArguments( "-N" ); unused.setGoals( "clean test-compile" ); unused.setBuildFile( "pom.xml" ); unused.setDescription( "desc template" ); assertFalse( getBuildDefinitionService().isBuildDefinitionInUse( unused ) ); }