001package org.apache.maven.lifecycle.internal;
002
003/*
004 * Licensed to the Apache Software Foundation (ASF) under one or more contributor license
005 * agreements. See the NOTICE file distributed with this work for additional information regarding
006 * copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the
007 * "License"); you may not use this file except in compliance with the License. You may obtain a
008 * copy of the License at
009 *
010 * http://www.apache.org/licenses/LICENSE-2.0
011 *
012 * Unless required by applicable law or agreed to in writing, software distributed under the License
013 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
014 * or implied. See the License for the specific language governing permissions and limitations under
015 * the License.
016 */
017
018import junit.framework.TestCase;
019import org.apache.maven.execution.MavenSession;
020import org.apache.maven.lifecycle.internal.stub.LifecycleTaskSegmentCalculatorStub;
021import org.apache.maven.lifecycle.internal.stub.ProjectDependencyGraphStub;
022
023import java.util.List;
024
025public class BuildListCalculatorTest
026    extends TestCase
027{
028
029    public void testCalculateProjectBuilds()
030        throws Exception
031    {
032        LifecycleTaskSegmentCalculator lifecycleTaskSegmentCalculator = getTaskSegmentCalculator();
033        BuildListCalculator buildListCalculator = new BuildListCalculator();
034        final MavenSession session = ProjectDependencyGraphStub.getMavenSession();
035        List<TaskSegment> taskSegments = lifecycleTaskSegmentCalculator.calculateTaskSegments( session );
036        final ProjectBuildList buildList = buildListCalculator.calculateProjectBuilds( session, taskSegments );
037        final ProjectBuildList segments = buildList.getByTaskSegment( taskSegments.get( 0 ) );
038        assertEquals( "Stub data contains 3 segments", 3, taskSegments.size() );
039        assertEquals( "Stub data contains 6 items", 6, segments.size() );
040        final ProjectSegment build = segments.get( 0 );
041        assertNotNull( build );
042    }
043
044    private static LifecycleTaskSegmentCalculator getTaskSegmentCalculator()
045    {
046        return new LifecycleTaskSegmentCalculatorStub();
047    }
048
049}