Clover Coverage Report - FEST Swing 1.2
Coverage timestamp: Tue Jun 1 2010 15:19:25 PDT
../../../../img/srcFileCovDistChart10.png 0% of files have more coverage
14   128   11   1.56
4   37   0.79   9
9     1.22  
1    
 
  ColorFixture       Line # 31 14 0% 11 0 100% 1.0
 
No Tests
 
1    /*
2    * Created on May 2, 2008
3    *
4    * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5    * in compliance with the License. You may obtain a copy of the License at
6    *
7    * http://www.apache.org/licenses/LICENSE-2.0
8    *
9    * Unless required by applicable law or agreed to in writing, software distributed under the License
10    * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11    * or implied. See the License for the specific language governing permissions and limitations under
12    * the License.
13    *
14    * Copyright @2008-2010 the original author or authors.
15    */
16    package org.fest.swing.fixture;
17   
18    import static org.fest.assertions.Assertions.assertThat;
19    import static org.fest.swing.util.Colors.colorFromHexString;
20   
21    import java.awt.Color;
22   
23    import org.fest.assertions.BasicDescription;
24    import org.fest.assertions.Description;
25   
26    /**
27    * Understands state verification of <code>{@link Color}</code>s.
28    *
29    * @author Alex Ruiz
30    */
 
31    public class ColorFixture {
32   
33    private final Color target;
34    private final Description description;
35   
36    /**
37    * Creates a new </code>{@link ColorFixture}</code>.
38    * @param target the color to manage.
39    * @throws NullPointerException if <code>target</code> is <code>null</code>.
40    */
 
41  12 toggle public ColorFixture(Color target) {
42  12 this(target, (Description)null);
43    }
44   
45    /**
46    * Creates a new </code>{@link ColorFixture}</code>.
47    * @param target the color to manage.
48    * @param description this fixture's description.
49    * @throws NullPointerException if <code>target</code> is <code>null</code>.
50    */
 
51  5 toggle public ColorFixture(Color target, String description) {
52  5 this(target, new BasicDescription(description));
53    }
54   
55    /**
56    * Creates a new </code>{@link ColorFixture}</code>.
57    * @param target the color to manage.
58    * @param description this fixture's description.
59    * @throws NullPointerException if <code>target</code> is <code>null</code>.
60    */
 
61  22 toggle public ColorFixture(Color target, Description description) {
62  1 if (target == null) throw new NullPointerException("The given color should not be null");
63  21 this.target = target;
64  21 this.description = description;
65    }
66   
67    /**
68    * Verifies that this fixture's <code>Color</code> is equal to the given color represented by the given hexadecimal
69    * value (e.g. "82A9FF".)
70    * @param hexValue the value representing the color to compare to.
71    * @return this fixture.
72    * @throws NullPointerException if the hexadecimal code is <code>null</code>.
73    * @throws IllegalArgumentException if the hexadecimal code is empty.
74    * @throws NumberFormatException if the hexadecimal code is empty.
75    * @throws AssertionError if this fixture's <code>Color</code> is not equal to the given one.
76    */
 
77  3 toggle public ColorFixture requireEqualTo(String hexValue) {
78  3 return requireEqualTo(colorFromHexString(hexValue));
79    }
80   
81    /**
82    * Verifies that this fixture's <code>Color</code> is equal to the given one.
83    * @param color the given <code>Color</code> to compare to.
84    * @return this fixture.
85    * @throws AssertionError if this fixture's <code>Color</code> is not equal to the given one.
86    */
 
87  6 toggle public ColorFixture requireEqualTo(Color color) {
88  6 assertThat(target).as(description).isEqualTo(color);
89  2 return this;
90    }
91   
92    /**
93    * Verifies that this fixture's <code>Color</code> is not equal to the given color represented by the given
94    * hexadecimal value (e.g. "82A9FF".)
95    * @param hexValue the value representing the color to compare to.
96    * @return this fixture.
97    * @throws NullPointerException if the hexadecimal code is <code>null</code>.
98    * @throws IllegalArgumentException if the hexadecimal code is empty.
99    * @throws NumberFormatException if the hexadecimal code is empty.
100    * @throws AssertionError if this fixture's <code>Color</code> is equal to the given one.
101    */
 
102  3 toggle public ColorFixture requireNotEqualTo(String hexValue) {
103  3 return requireNotEqualTo(colorFromHexString(hexValue));
104    }
105   
106    /**
107    * Verifies that this fixture's <code>Color</code> is not equal to the given one.
108    * @param color the given <code>Color</code> to compare to.
109    * @return this fixture.
110    * @throws AssertionError if this fixture's <code>Color</code> is equal to the given one.
111    */
 
112  6 toggle public ColorFixture requireNotEqualTo(Color color) {
113  6 assertThat(target).as(description).isNotEqualTo(color);
114  2 return this;
115    }
116   
117    /**
118    * Returns this fixture's color.
119    * @return this fixture's color.
120    */
 
121  4 toggle public Color target() { return target; }
122   
123    /**
124    * Returns this fixture's description.
125    * @return this fixture's description.
126    */
 
127  6 toggle public final String description() { return description != null ? description.value() : null; }
128    }