001package org.apache.maven.lifecycle.mapping; 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 static org.junit.Assert.assertEquals; 019import static org.junit.Assert.assertNotNull; 020import static org.junit.Assert.assertNull; 021import java.util.Arrays; 022import java.util.List; 023 024import org.junit.Test; 025 026/** 027 * @author atanasenko 028 */ 029public class LifecyclePhaseTest 030{ 031 @Test 032 public void testToString() 033 { 034 LifecyclePhase phase = new LifecyclePhase(); 035 assertEquals( "", phase.toString() ); 036 037 LifecycleMojo mojo1 = new LifecycleMojo(); 038 mojo1.setGoal( "jar:jar" ); 039 phase.setMojos( Arrays.asList( mojo1 ) ); 040 assertEquals( "jar:jar", phase.toString() ); 041 042 LifecycleMojo mojo2 = new LifecycleMojo(); 043 mojo2.setGoal( "war:war" ); 044 phase.setMojos( Arrays.asList( mojo1, mojo2 ) ); 045 assertEquals( "jar:jar,war:war", phase.toString() ); 046 } 047 048 @Test 049 public void testSet() 050 { 051 LifecyclePhase phase = new LifecyclePhase(); 052 assertNull( phase.getMojos() ); 053 054 phase.set( "" ); 055 assertNotNull( phase.getMojos() ); 056 assertEquals( 0, phase.getMojos().size() ); 057 058 phase.set( "jar:jar, war:war" ); 059 060 List<LifecycleMojo> mojos = phase.getMojos(); 061 assertNotNull( mojos ); 062 assertEquals( 2, mojos.size() ); 063 064 LifecycleMojo mojo1 = mojos.get(0); 065 assertNotNull( mojo1 ); 066 assertEquals( "jar:jar", mojo1.getGoal() ); 067 068 LifecycleMojo mojo2 = mojos.get(1); 069 assertNotNull( mojo2 ); 070 assertEquals( "war:war", mojo2.getGoal() ); 071 } 072} 073