### Question:
ProjectBuildList implements Iterable<ProjectSegment> { public ProjectBuildList getByTaskSegment( TaskSegment taskSegment ) { List<ProjectSegment> currentSegment = new ArrayList<>(); for ( ProjectSegment projectBuild : items ) { if ( taskSegment == projectBuild.getTaskSegment() ) { currentSegment.add( projectBuild ); } } return new ProjectBuildList( currentSegment ); } ProjectBuildList( List<ProjectSegment> items ); ProjectBuildList getByTaskSegment( TaskSegment taskSegment ); Map<MavenProject, ProjectSegment> selectSegment( TaskSegment taskSegment ); ProjectSegment findByMavenProject( MavenProject mavenProject ); Iterator<ProjectSegment> iterator(); void closeAll(); int size(); ProjectSegment get( int index ); Set<String> getReactorProjectKeys(); boolean isEmpty(); Set<MavenProject> getProjects();  }### Answer:
@Test public void testGetByTaskSegment() throws Exception { final MavenSession session = ProjectDependencyGraphStub.getMavenSession(); ProjectBuildList projectBuildList = ProjectDependencyGraphStub.getProjectBuildList( session ); TaskSegment taskSegment = projectBuildList.get( 0 ).getTaskSegment(); assertThat( "This test assumes there are at least 6 elements in projectBuilds", projectBuildList.size(), is( greaterThanOrEqualTo( 6 ) ) ); final ProjectBuildList byTaskSegment = projectBuildList.getByTaskSegment( taskSegment ); assertEquals( projectBuildList.size(), byTaskSegment.size() ); }