View Javadoc

1   /*
2    * Copyright 2012 smartics, Kronseder & Reiner GmbH
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License");
5    * you may not use this file except in compliance with the License.
6    * You may obtain a copy of the License at
7    *
8    *     http://www.apache.org/licenses/LICENSE-2.0
9    *
10   * Unless required by applicable law or agreed to in writing, software
11   * distributed under the License is distributed on an "AS IS" BASIS,
12   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13   * See the License for the specific language governing permissions and
14   * limitations under the License.
15   */
16  package test.de.smartics.ci.config.load;
17  
18  import static org.hamcrest.MatcherAssert.assertThat;
19  import static org.hamcrest.Matchers.equalTo;
20  import static org.hamcrest.Matchers.hasItem;
21  import static org.hamcrest.Matchers.is;
22  
23  import java.util.List;
24  
25  import org.apache.commons.collections.IteratorUtils;
26  import org.junit.Before;
27  import org.junit.Test;
28  
29  import de.smartics.ci.config.load.LoaderPlan;
30  import de.smartics.ci.config.maven.MavenConfig;
31  import de.smartics.ci.config.test.MavenConfigBuilder;
32  import de.smartics.testdoc.annotations.Uut;
33  
34  /**
35   * Tests {@link LoaderPlan}.
36   */
37  public class LoaderPlanTest
38  {
39    // ********************************* Fields *********************************
40  
41    // --- constants ------------------------------------------------------------
42  
43    // --- members --------------------------------------------------------------
44  
45    @Uut
46    private LoaderPlan uut;
47  
48    // ****************************** Inner Classes *****************************
49  
50    // ********************************* Methods ********************************
51  
52    // --- prepare --------------------------------------------------------------
53  
54    @Before
55    public void setUp()
56    {
57      final MavenConfig mavenConfig = MavenConfigBuilder.a().build();
58  
59      uut = new LoaderPlan("test", mavenConfig);
60    }
61  
62    // --- helper ---------------------------------------------------------------
63  
64    // --- tests ----------------------------------------------------------------
65  
66    @Test
67    @SuppressWarnings("unchecked")
68    public void allowsToAddConfigurationNames()
69    {
70      final String configurationName = "testName";
71  
72      assertThat(uut.isEmpty(), is(true));
73  
74      uut.addConfigurationName(configurationName);
75  
76      assertThat(uut.isEmpty(), is(false));
77  
78      final List<String> nameList = IteratorUtils.toList(uut.iterator());
79      assertThat(nameList.size(), is(equalTo(1)));
80      assertThat(nameList, hasItem(configurationName));
81    }
82  }