assertEquals( 1, projects.size() );
assertEquals( Project.class, projects.get( 0 ).getClass() );
Project project = projects.get( 0 );
// reattach
project = continuum.getProject( project.getId() );
ProjectGroup projectGroup = getProjectGroupDao().getProjectGroupByProjectId( project.getId() );
projectGroup = getProjectGroupDao().getProjectGroupWithBuildDetailsByProjectGroupId( projectGroup.getId() );
List<BuildDefinition> buildDefs = projectGroup.getBuildDefinitions();
assertTrue( "missing project group build definition", !buildDefs.isEmpty() );
assertTrue( "more then one project group build definition on add project", buildDefs.size() == 1 );
BuildDefinition pgbd = buildDefs.get( 0 );
pgbd.setGoals( "foo" );
continuum.updateBuildDefinitionForProjectGroup( projectGroup.getId(), pgbd );
pgbd = continuum.getBuildDefinition( pgbd.getId() );
assertTrue( "update failed for project group build definition", "foo".equals( pgbd.getGoals() ) );
assertTrue( "project group build definition is not default", pgbd.isDefaultForProject() );
assertTrue( "project group build definition not default for project",
continuum.getDefaultBuildDefinition( project.getId() ).getId() == pgbd.getId() );
BuildDefinition nbd = new BuildDefinition();
nbd.setGoals( "clean" );
nbd.setArguments( "" );
nbd.setDefaultForProject( true );
nbd.setSchedule( getScheduleDao().getScheduleByName( ConfigurationService.DEFAULT_SCHEDULE_NAME ) );
continuum.addBuildDefinitionToProject( project.getId(), nbd );
assertTrue( "project lvl build definition not default for project",
continuum.getDefaultBuildDefinition( project.getId() ).getId() == nbd.getId() );
continuum.removeBuildDefinitionFromProject( project.getId(), nbd.getId() );
assertTrue( "default build definition didn't toggle back to project group level",
continuum.getDefaultBuildDefinition( project.getId() ).getId() == pgbd.getId() );
try
{
continuum.removeBuildDefinitionFromProjectGroup( projectGroup.getId(), pgbd.getId() );
fail( "we were able to remove the default build definition, and that is bad" );