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 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.is;
21  
22  import org.junit.Test;
23  import org.junit.experimental.categories.Category;
24  
25  import de.smartics.testdoc.annotations.Uut;
26  import de.smartics.testdoc.categories.type.Construction;
27  import de.smartics.util.lang.BlankArgumentException;
28  
29  /**
30   * Tests {@link HudsonJobConfig}.
31   */
32  @Uut(type = HudsonJobConfig.class)
33  @Category(Construction.class)
34  public class HudsonJobConfigTest
35  {
36    // ********************************* Fields *********************************
37  
38    // --- constants ------------------------------------------------------------
39  
40    private static final String TEST_ID = "id";
41  
42    private static final String TEST_CONFIG_XML = "<xml></xml>";
43  
44    // --- members --------------------------------------------------------------
45  
46    // ****************************** Inner Classes *****************************
47  
48    // ********************************* Methods ********************************
49  
50    // --- prepare --------------------------------------------------------------
51  
52    // --- helper ---------------------------------------------------------------
53  
54    // --- tests ----------------------------------------------------------------
55  
56    @Test(expected = BlankArgumentException.class)
57    public void requiresAnIdOnConstruction()
58    {
59      new HudsonJobConfig(null, TEST_CONFIG_XML);
60    }
61  
62    @Test(expected = BlankArgumentException.class)
63    public void requiresTheXmlRepresentation()
64    {
65      new HudsonJobConfig(TEST_ID, "");
66    }
67  
68    @Test
69    public void allowsToAccessAllProperties()
70    {
71      final HudsonJobConfig uut = new HudsonJobConfig(TEST_ID, TEST_CONFIG_XML);
72  
73      assertThat(uut.getId(), is(equalTo(TEST_ID)));
74      assertThat(uut.getConfigXml(), is(equalTo(TEST_CONFIG_XML)));
75    }
76  
77  }