View Javadoc

1   /*
2    PlantUMLDependencyProgramTaskTest.java
3    Creation date : 3/07/2011
4    Copyright © Benjamin Croizet (graffity2199@yahoo.fr)
5   
6    This program is free software; you can redistribute it and/or
7    modify it under the terms of the GNU General Public License
8    or GNU Lesser General Public License as published by the
9    Free Software Foundation; either version 3 of the License,
10   or (at your option) any later version.
11  
12   This program is distributed in the hope that it will be useful,
13   but WITHOUT ANY WARRANTY; without even the implied warranty of
14   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15   GNU General Public License for more details.
16  
17   You should have received copies of the GNU General Public License
18   and GNU Lesser General Public License along with this program;
19   if not, write to the Free Software Foundation, Inc.,
20   51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
21   http://www.fsf.org/licensing/licenses/gpl.html
22   http://www.gnu.org/licenses/lgpl.html
23   */
24  
25  package net.sourceforge.plantumldependency.cli.main.ant;
26  
27  import static java.util.logging.Level.INFO;
28  import static net.sourceforge.plantumldependency.cli.constants.PlantUMLDependencyConstants.DEFAULT_DISPLAY_NAME_OPTIONS_STRING;
29  import static net.sourceforge.plantumldependency.cli.constants.PlantUMLDependencyConstants.DEFAULT_DISPLAY_PACKAGE_NAME_OPTIONS_STRING;
30  import static net.sourceforge.plantumldependency.cli.constants.PlantUMLDependencyConstants.DEFAULT_DISPLAY_TYPES_OPTIONS_STRING;
31  import static net.sourceforge.plantumldependency.cli.constants.PlantUMLDependencyConstants.DEFAULT_EXCLUDE_OPTIONS;
32  import static net.sourceforge.plantumldependency.cli.constants.PlantUMLDependencyConstants.DEFAULT_INCLUDE_OPTIONS;
33  import static net.sourceforge.plantumldependency.cli.main.option.programminglanguage.PlantUMLDependencyProgrammingLanguageOption.DEFAULT_PROGRAMMING_LANGUAGE;
34  import static net.sourceforge.plantumldependency.common.constants.CharacterConstants.DOT_CHAR;
35  import static net.sourceforge.plantumldependency.common.constants.CommonFileConstants.TXT_EXTENSION;
36  import static org.junit.Assert.assertEquals;
37  
38  import org.junit.Test;
39  
40  /**
41   * JUnit test classes for {@link PlantUMLDependencyProgramTask}.
42   *
43   * @author Benjamin Croizet (<a href="mailto:graffity2199@yahoo.fr>graffity2199@yahoo.fr</a>)
44   * @since 1.1.0
45   * @version 1.4.0
46   */
47  public class PlantUMLDependencyProgramTaskTest {
48  
49      /** PlantUML Dependency test 1 instance. */
50      public static final PlantUMLDependencyProgramTask PLANTUML_DEPENDENCY_TASK1 = new PlantUMLDependencyProgramTask();
51  
52      /** PlantUML Dependency test 1 instance. */
53      public static final PlantUMLDependencyProgramTask PLANTUML_DEPENDENCY_TASK2 = createPlantUMLDependencyTask1();
54  
55      /**
56       * Creates a {@link PlantUMLDependencyProgramTask} test instance.
57       *
58       * @return a {@link PlantUMLDependencyProgramTask} test instance.
59       * @since 1.1.0
60       */
61      private static PlantUMLDependencyProgramTask createPlantUMLDependencyTask1() {
62          final PlantUMLDependencyProgramTask task = new PlantUMLDependencyProgramTask();
63          task.setBaseDir(DOT_CHAR);
64          task.setDisplayType(DEFAULT_DISPLAY_TYPES_OPTIONS_STRING);
65          task.setDisplayName(DEFAULT_DISPLAY_NAME_OPTIONS_STRING);
66          task.setDisplayPackageName(DEFAULT_DISPLAY_PACKAGE_NAME_OPTIONS_STRING);
67          task.setExcludes(DEFAULT_EXCLUDE_OPTIONS);
68          task.setIncludes(DEFAULT_INCLUDE_OPTIONS + DEFAULT_PROGRAMMING_LANGUAGE.getName());
69          task.setOutput("plantuml" + TXT_EXTENSION);
70          task.setProgrammingLanguage(DEFAULT_PROGRAMMING_LANGUAGE.getName());
71          task.setVerboseLevel(INFO.getName());
72          return task;
73      }
74  
75      /**
76       * Test method for
77       * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#execute()}
78       * .
79       */
80      @Test
81      public void testExecute() {
82          // TODO finish with all options and compare generated files such as the Program
83      }
84  
85      /**
86       * Test method for
87       * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#getBaseDir()}
88       * .
89       */
90      @Test
91      public void testGetBaseDir() {
92          assertEquals(DOT_CHAR, PLANTUML_DEPENDENCY_TASK2.getBaseDir());
93      }
94  
95      /**
96       * Test method for
97       * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#getDisplayName()}
98       * .
99       */
100     @Test
101     public void testGetDisplayName() {
102         assertEquals(".*", PLANTUML_DEPENDENCY_TASK2.getDisplayName());
103     }
104 
105     /**
106      * Test method for
107      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#getDisplayPackageName()}
108      * .
109      */
110     @Test
111     public void testGetDisplayPackageName() {
112         assertEquals(".*", PLANTUML_DEPENDENCY_TASK2.getDisplayPackageName());
113     }
114 
115     /**
116      * Test method for
117      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#getDisplayType()}
118      * .
119      */
120     @Test
121     public void testGetDisplayType() {
122         assertEquals(DEFAULT_DISPLAY_TYPES_OPTIONS_STRING, PLANTUML_DEPENDENCY_TASK2.getDisplayType());
123     }
124 
125     /**
126      * Test method for
127      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#getExcludes()}
128      * .
129      */
130     @Test
131     public void testGetExcludes() {
132         assertEquals(DEFAULT_EXCLUDE_OPTIONS, PLANTUML_DEPENDENCY_TASK2.getExcludes());
133     }
134 
135     /**
136      * Test method for
137      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#getIncludes()}
138      * .
139      */
140     @Test
141     public void testGetIncludes() {
142         assertEquals(DEFAULT_INCLUDE_OPTIONS + DEFAULT_PROGRAMMING_LANGUAGE.getName(),
143                 PLANTUML_DEPENDENCY_TASK2.getIncludes());
144     }
145 
146     /**
147      * Test method for
148      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#getOutput()}
149      * .
150      */
151     @Test
152     public void testGetOutput() {
153         assertEquals("plantuml" + TXT_EXTENSION, PLANTUML_DEPENDENCY_TASK2.getOutput());
154     }
155 
156     /**
157      * Test method for
158      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#getProgrammingLanguage()}
159      * .
160      */
161     @Test
162     public void testGetProgrammingLanguage() {
163         assertEquals(DEFAULT_PROGRAMMING_LANGUAGE.getName(), PLANTUML_DEPENDENCY_TASK2.getProgrammingLanguage());
164     }
165 
166     /**
167      * Test method for
168      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#getVerboseLevel()}
169      * .
170      */
171     @Test
172     public void testGetVerboseLevel() {
173         assertEquals(INFO.getName(), PLANTUML_DEPENDENCY_TASK2.getVerboseLevel());
174     }
175 
176     /**
177      * Test method for
178      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#setBaseDir(java.lang.String)}
179      * .
180      */
181     @Test
182     public void testSetBaseDir() {
183         final PlantUMLDependencyProgramTask testTask = new PlantUMLDependencyProgramTask();
184         testTask.setBaseDir(DOT_CHAR);
185         assertEquals(DOT_CHAR, testTask.getBaseDir());
186     }
187 
188     /**
189      * Test method for
190      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#setDisplayName(java.lang.String)}
191      * .
192      */
193     @Test
194     public void testSetDisplayName() {
195         final PlantUMLDependencyProgramTask testTask = new PlantUMLDependencyProgramTask();
196         testTask.setDisplayName(DEFAULT_DISPLAY_NAME_OPTIONS_STRING);
197         assertEquals(DEFAULT_DISPLAY_NAME_OPTIONS_STRING, testTask.getDisplayName());
198     }
199 
200     /**
201      * Test method for
202      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#setDisplayPackageName(java.lang.String)}
203      * .
204      */
205     @Test
206     public void testSetDisplayPackageName() {
207         final PlantUMLDependencyProgramTask testTask = new PlantUMLDependencyProgramTask();
208         testTask.setDisplayPackageName(DEFAULT_DISPLAY_PACKAGE_NAME_OPTIONS_STRING);
209         assertEquals(DEFAULT_DISPLAY_PACKAGE_NAME_OPTIONS_STRING, testTask.getDisplayPackageName());
210     }
211 
212     /**
213      * Test method for
214      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#setDisplayType(java.lang.String)}
215      * .
216      */
217     @Test
218     public void testSetDisplayType() {
219         final PlantUMLDependencyProgramTask testTask = new PlantUMLDependencyProgramTask();
220         testTask.setDisplayType(DEFAULT_DISPLAY_TYPES_OPTIONS_STRING);
221         assertEquals(DEFAULT_DISPLAY_TYPES_OPTIONS_STRING, testTask.getDisplayType());
222     }
223 
224     /**
225      * Test method for
226      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#setExcludes(java.lang.String)}
227      * .
228      */
229     @Test
230     public void testSetExcludes() {
231         final PlantUMLDependencyProgramTask testTask = new PlantUMLDependencyProgramTask();
232         testTask.setExcludes(DEFAULT_EXCLUDE_OPTIONS);
233         assertEquals(DEFAULT_EXCLUDE_OPTIONS, testTask.getExcludes());
234     }
235 
236     /**
237      * Test method for
238      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#setIncludes(java.lang.String)}
239      * .
240      */
241     @Test
242     public void testSetIncludes() {
243         final PlantUMLDependencyProgramTask testTask = new PlantUMLDependencyProgramTask();
244         testTask.setIncludes(DEFAULT_INCLUDE_OPTIONS + DEFAULT_PROGRAMMING_LANGUAGE.getName());
245         assertEquals(DEFAULT_INCLUDE_OPTIONS + DEFAULT_PROGRAMMING_LANGUAGE.getName(), testTask.getIncludes());
246     }
247 
248     /**
249      * Test method for
250      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#setOutput(java.lang.String)}
251      * .
252      */
253     @Test
254     public void testSetOutput() {
255         final PlantUMLDependencyProgramTask testTask = new PlantUMLDependencyProgramTask();
256         testTask.setOutput("plantuml" + TXT_EXTENSION);
257         assertEquals("plantuml" + TXT_EXTENSION, testTask.getOutput());
258     }
259 
260     /**
261      * Test method for
262      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#setProgrammingLanguage(java.lang.String)}
263      * .
264      */
265     @Test
266     public void testSetProgrammingLanguage() {
267         final PlantUMLDependencyProgramTask testTask = new PlantUMLDependencyProgramTask();
268         testTask.setProgrammingLanguage(DEFAULT_PROGRAMMING_LANGUAGE.getName());
269         assertEquals(DEFAULT_PROGRAMMING_LANGUAGE.getName(), testTask.getProgrammingLanguage());
270     }
271 
272     /**
273      * Test method for
274      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#setVerboseLevel(java.lang.String)}
275      * .
276      */
277     @Test
278     public void testSetVerboseLevel() {
279         final PlantUMLDependencyProgramTask testTask = new PlantUMLDependencyProgramTask();
280         testTask.setVerboseLevel(INFO.getName());
281         assertEquals(INFO.getName(), testTask.getVerboseLevel());
282     }
283 
284     /**
285      * Test method for
286      * {@link net.sourceforge.plantumldependency.cli.main.ant.PlantUMLDependencyProgramTask#toString()}
287      * .
288      */
289     @Test
290     public void testToString() {
291         assertEquals(
292                 "PlantUMLDependencyProgramTask [output=plantuml.txt, verboseLevel=INFO, programmingLanguage=java, includes=**/*.java, excludes=**/package-info.java, displayType=abstract_classes,annotations,classes,enums,extensions,implementations,imports,interfaces,native_methods,static_imports, baseDir=., displayName=.*, displayPackageName=.*]",
293                 PLANTUML_DEPENDENCY_TASK2.toString());
294     }
295 }