View Javadoc
1   package org.apache.maven.lifecycle.internal;
2   
3   /*
4    * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
5    * agreements. See the NOTICE file distributed with this work for additional information regarding
6    * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance with the License. You may obtain a
8    * copy of the License at
9    *
10   * http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing, software distributed under the License
13   * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
14   * or implied. See the License for the specific language governing permissions and limitations under
15   * the License.
16   */
17  
18  import junit.framework.TestCase;
19  import org.apache.maven.execution.MavenSession;
20  import org.apache.maven.lifecycle.internal.stub.LifecycleTaskSegmentCalculatorStub;
21  import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
22  
23  import java.util.List;
24  
25  public class BuildListCalculatorTest
26      extends TestCase
27  {
28  
29      public void testCalculateProjectBuilds()
30          throws Exception
31      {
32          LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator = getTaskSegmentCalculator();
33          BuildListCalculator buildListCalculator = new BuildListCalculator();
34          final MavenSession session = ProjectDependencyGraphStub.getMavenSession();
35          List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session );
36          final ProjectBuildList buildList = buildListCalculator.calculateProjectBuilds( session, taskSegments );
37          final ProjectBuildList segments = buildList.getByTaskSegment( taskSegments.get( 0 ) );
38          assertEquals( "Stub data contains 3 segments", 3, taskSegments.size() );
39          assertEquals( "Stub data contains 6 items", 6, segments.size() );
40          final ProjectSegment build = segments.get( 0 );
41          assertNotNull( build );
42      }
43  
44      private static LifecycleTaskSegmentCalculator getTaskSegmentCalculator()
45      {
46          return new LifecycleTaskSegmentCalculatorStub();
47      }
48  
49  }