View Javadoc
1   /*
2    * This file is part of dependency-check-core.
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   * Copyright (c) 2015 The OWASP Foundatio. All Rights Reserved.
17   */
18  package org.owasp.dependencycheck.xml.pom;
19  
20  import java.util.ArrayList;
21  import java.util.List;
22  import java.util.Properties;
23  
24  import org.junit.Test;
25  import static org.junit.Assert.*;
26  import org.owasp.dependencycheck.BaseTest;
27  
28  /**
29   *
30   * @author jeremy
31   */
32  public class ModelTest extends BaseTest {
33  
34      /**
35       * Test of getName method, of class Model.
36       */
37      @Test
38      public void testGetName() {
39          Model instance = new Model();
40          instance.setName("");
41          String expResult = "";
42          String result = instance.getName();
43          assertEquals(expResult, result);
44      }
45  
46      /**
47       * Test of setName method, of class Model.
48       */
49      @Test
50      public void testSetName() {
51          String name = "";
52          Model instance = new Model();
53          instance.setName(name);
54      }
55  
56      /**
57       * Test of getOrganization method, of class Model.
58       */
59      @Test
60      public void testGetOrganization() {
61          Model instance = new Model();
62          instance.setOrganization("");
63          String expResult = "";
64          String result = instance.getOrganization();
65          assertEquals(expResult, result);
66      }
67  
68      /**
69       * Test of setOrganization method, of class Model.
70       */
71      @Test
72      public void testSetOrganization() {
73          String organization = "";
74          Model instance = new Model();
75          instance.setOrganization(organization);
76      }
77  
78      /**
79       * Test of getDescription method, of class Model.
80       */
81      @Test
82      public void testGetDescription() {
83          Model instance = new Model();
84          instance.setDescription("");
85          String expResult = "";
86          String result = instance.getDescription();
87          assertEquals(expResult, result);
88      }
89  
90      /**
91       * Test of setDescription method, of class Model.
92       */
93      @Test
94      public void testSetDescription() {
95          String description = "";
96          Model instance = new Model();
97          instance.setDescription(description);
98      }
99  
100     /**
101      * Test of getGroupId method, of class Model.
102      */
103     @Test
104     public void testGetGroupId() {
105         Model instance = new Model();
106         instance.setGroupId("");
107         String expResult = "";
108         String result = instance.getGroupId();
109         assertEquals(expResult, result);
110     }
111 
112     /**
113      * Test of setGroupId method, of class Model.
114      */
115     @Test
116     public void testSetGroupId() {
117         String groupId = "";
118         Model instance = new Model();
119         instance.setGroupId(groupId);
120     }
121 
122     /**
123      * Test of getArtifactId method, of class Model.
124      */
125     @Test
126     public void testGetArtifactId() {
127         Model instance = new Model();
128         instance.setArtifactId("");
129         String expResult = "";
130         String result = instance.getArtifactId();
131         assertEquals(expResult, result);
132     }
133 
134     /**
135      * Test of setArtifactId method, of class Model.
136      */
137     @Test
138     public void testSetArtifactId() {
139         String artifactId = "";
140         Model instance = new Model();
141         instance.setArtifactId(artifactId);
142     }
143 
144     /**
145      * Test of getVersion method, of class Model.
146      */
147     @Test
148     public void testGetVersion() {
149         Model instance = new Model();
150         instance.setVersion("");
151         String expResult = "";
152         String result = instance.getVersion();
153         assertEquals(expResult, result);
154     }
155 
156     /**
157      * Test of setVersion method, of class Model.
158      */
159     @Test
160     public void testSetVersion() {
161         String version = "";
162         Model instance = new Model();
163         instance.setVersion(version);
164     }
165 
166     /**
167      * Test of getParentGroupId method, of class Model.
168      */
169     @Test
170     public void testGetParentGroupId() {
171         Model instance = new Model();
172         instance.setParentGroupId("");
173         String expResult = "";
174         String result = instance.getParentGroupId();
175         assertEquals(expResult, result);
176     }
177 
178     /**
179      * Test of setParentGroupId method, of class Model.
180      */
181     @Test
182     public void testSetParentGroupId() {
183         String parentGroupId = "";
184         Model instance = new Model();
185         instance.setParentGroupId(parentGroupId);
186     }
187 
188     /**
189      * Test of getParentArtifactId method, of class Model.
190      */
191     @Test
192     public void testGetParentArtifactId() {
193         Model instance = new Model();
194         instance.setParentArtifactId("");
195         String expResult = "";
196         String result = instance.getParentArtifactId();
197         assertEquals(expResult, result);
198     }
199 
200     /**
201      * Test of setParentArtifactId method, of class Model.
202      */
203     @Test
204     public void testSetParentArtifactId() {
205         String parentArtifactId = "";
206         Model instance = new Model();
207         instance.setParentArtifactId(parentArtifactId);
208     }
209 
210     /**
211      * Test of getParentVersion method, of class Model.
212      */
213     @Test
214     public void testGetParentVersion() {
215         Model instance = new Model();
216         instance.setParentVersion("");
217         String expResult = "";
218         String result = instance.getParentVersion();
219         assertEquals(expResult, result);
220     }
221 
222     /**
223      * Test of setParentVersion method, of class Model.
224      */
225     @Test
226     public void testSetParentVersion() {
227         String parentVersion = "";
228         Model instance = new Model();
229         instance.setParentVersion(parentVersion);
230     }
231 
232     /**
233      * Test of getLicenses method, of class Model.
234      */
235     @Test
236     public void testGetLicenses() {
237         Model instance = new Model();
238         instance.addLicense(new License("name", "url"));
239         List<License> expResult = new ArrayList<License>();
240         expResult.add(new License("name", "url"));
241         List<License> result = instance.getLicenses();
242         assertEquals(expResult, result);
243     }
244 
245     /**
246      * Test of addLicense method, of class Model.
247      */
248     @Test
249     public void testAddLicense() {
250         License license = new License("name", "url");
251         Model instance = new Model();
252         instance.addLicense(license);
253     }
254 
255     /**
256      * Test of processProperties method, of class Model.
257      */
258     @Test
259     public void testProcessProperties() {
260         Properties prop = new Properties();
261         prop.setProperty("key", "value");
262         prop.setProperty("nested", "nested ${key}");
263         String text = "This is a test of '${key}' '${nested}'";
264 
265         Model instance = new Model();
266         instance.setName(text);
267         instance.processProperties(prop);
268         String expResults = "This is a test of 'value' 'nested value'";
269         assertEquals(expResults, instance.getName());
270     }
271 
272     /**
273      * Test of interpolateString method, of class Model.
274      */
275     @Test
276     public void testInterpolateString() {
277         Properties prop = new Properties();
278         prop.setProperty("key", "value");
279         prop.setProperty("nested", "nested ${key}");
280         String text = "This is a test of '${key}' '${nested}'";
281         String expResults = "This is a test of 'value' 'nested value'";
282         String results = Model.interpolateString(text, prop);
283         assertEquals(expResults, results);
284     }
285 
286 }