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