Initial OpenECOMP MSO commit
[so.git] / asdc-controller / src / test / java / org / openecomp / mso / asdc / util / YamlEditorESTest.java
1 /*
2  * This file was automatically generated by EvoSuite
3  * Fri Nov 25 13:17:51 GMT 2016
4  */
5
6 package org.openecomp.mso.asdc.util;
7
8 import org.junit.Test;
9 import static org.junit.Assert.*;
10 import static org.evosuite.shaded.org.mockito.Mockito.*;
11 import static org.evosuite.runtime.MockitoExtension.*;
12 import static org.evosuite.runtime.EvoAssertions.*;
13
14 import org.openecomp.mso.db.catalog.beans.HeatTemplateParam;
15 import java.util.HashMap;
16 import java.util.Iterator;
17 import java.util.LinkedHashSet;
18 import java.util.List;
19 import java.util.Map;
20 import java.util.Set;
21 import org.evosuite.runtime.EvoRunner;
22 import org.evosuite.runtime.EvoRunnerParameters;
23 import org.evosuite.runtime.PrivateAccess;
24 import org.evosuite.runtime.ViolatedAssumptionAnswer;
25 import org.junit.runner.RunWith;
26 import org.yaml.snakeyaml.Yaml;
27
28 @RunWith(EvoRunner.class) @EvoRunnerParameters(mockJVMNonDeterminism = true, useVFS = true, useVNET = true, resetStaticState = true, useJEE = true) 
29 public class YamlEditorESTest extends YamlEditorESTestscaffolding {
30
31   @Test(timeout = 4000)
32   public void test00()  throws Throwable  {
33       YamlEditor yamlEditor0 = new YamlEditor();
34       boolean boolean0 = yamlEditor0.isParentTemplate("file:///");
35       assertTrue(boolean0);
36   }
37
38   @Test(timeout = 4000)
39   public void test01()  throws Throwable  {
40       YamlEditor yamlEditor0 = new YamlEditor();
41       HashMap<String, Object> hashMap0 = new HashMap<String, Object>();
42       Yaml yaml0 = mock(Yaml.class, new ViolatedAssumptionAnswer());
43       doReturn((String) null, (String) null).when(yaml0).dump(any());
44       PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yaml", (Object) yaml0);
45       yamlEditor0.encode((Map<String, Object>) hashMap0);
46       Map<String, Object> map0 = (Map<String, Object>) mock(Map.class, new ViolatedAssumptionAnswer());
47       doReturn((Object) null).when(map0).get(any());
48       PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0);
49       yamlEditor0.toString();
50       // Undeclared exception!
51       try { 
52         yamlEditor0.getYamlResourceTypeList();
53         fail("Expecting exception: NullPointerException");
54       
55       } catch(NullPointerException e) {
56          //
57          // no message in exception (getMessage() returned null)
58          //
59          verifyException("org.openecomp.mso.asdc.util.YamlEditor", e);
60       }
61   }
62
63   @Test(timeout = 4000)
64   public void test02()  throws Throwable  {
65       YamlEditor yamlEditor0 = new YamlEditor();
66       HashMap<Object, String> hashMap0 = new HashMap<Object, String>();
67       Yaml yaml0 = mock(Yaml.class, new ViolatedAssumptionAnswer());
68       PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yaml", (Object) yaml0);
69       Object object0 = new Object();
70       Map<Integer, Object> map0 = (Map<Integer, Object>) mock(Map.class, new ViolatedAssumptionAnswer());
71       doReturn(hashMap0, object0).when(map0).get(any());
72       PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0);
73       yamlEditor0.getParameterList();
74       // Undeclared exception!
75       try { 
76         yamlEditor0.getYamlResourceTypeList();
77         fail("Expecting exception: ClassCastException");
78       
79       } catch(ClassCastException e) {
80          //
81          // java.lang.Object cannot be cast to java.util.Map
82          //
83          verifyException("org.openecomp.mso.asdc.util.YamlEditor", e);
84       }
85   }
86
87   @Test(timeout = 4000)
88   public void test03()  throws Throwable  {
89       YamlEditor yamlEditor0 = new YamlEditor();
90       // Undeclared exception!
91       try { 
92         yamlEditor0.getYamlNestedFileResourceTypeList();
93         fail("Expecting exception: NullPointerException");
94       
95       } catch(NullPointerException e) {
96          //
97          // no message in exception (getMessage() returned null)
98          //
99          verifyException("org.openecomp.mso.asdc.util.YamlEditor", e);
100       }
101   }
102
103   @Test(timeout = 4000)
104   public void test04()  throws Throwable  {
105       YamlEditor yamlEditor0 = new YamlEditor();
106       HashMap<Object, String> hashMap0 = new HashMap<Object, String>();
107       Yaml yaml0 = mock(Yaml.class, new ViolatedAssumptionAnswer());
108       PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yaml", (Object) yaml0);
109       Map<Integer, Object> map0 = (Map<Integer, Object>) mock(Map.class, new ViolatedAssumptionAnswer());
110       doReturn(hashMap0, (Object) null).when(map0).get(any());
111       PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0);
112       yamlEditor0.getYamlNestedFileResourceTypeList();
113       // Undeclared exception!
114       try { 
115         yamlEditor0.getParameterList();
116         fail("Expecting exception: NullPointerException");
117       
118       } catch(NullPointerException e) {
119          //
120          // no message in exception (getMessage() returned null)
121          //
122          verifyException("org.openecomp.mso.asdc.util.YamlEditor", e);
123       }
124   }
125
126   @Test(timeout = 4000)
127   public void test05()  throws Throwable  {
128       YamlEditor yamlEditor0 = new YamlEditor();
129       HashMap<String, Object> hashMap0 = new HashMap<String, Object>();
130       Set<Map.Entry<String, Object>> set0 = (Set<Map.Entry<String, Object>>)hashMap0.entrySet();
131       hashMap0.put("null\n", set0);
132       // Undeclared exception!
133       try { 
134         yamlEditor0.encode((Map<String, Object>) hashMap0);
135         fail("Expecting exception: StackOverflowError");
136       
137       } catch(StackOverflowError e) {
138          //
139          // no message in exception (getMessage() returned null)
140          //
141       }
142   }
143
144   @Test(timeout = 4000)
145   public void test06()  throws Throwable  {
146       YamlEditor yamlEditor0 = new YamlEditor();
147       Set<Map.Entry<String, Object>> set0 = (Set<Map.Entry<String, Object>>) mock(Set.class, new ViolatedAssumptionAnswer());
148       doReturn((Iterator) null).when(set0).iterator();
149       Map<String, Object> map0 = (Map<String, Object>) mock(Map.class, new ViolatedAssumptionAnswer());
150       doReturn(set0).when(map0).entrySet();
151       doReturn(2655).when(map0).size();
152       // Undeclared exception!
153       try { 
154         yamlEditor0.encode(map0);
155         fail("Expecting exception: NullPointerException");
156       
157       } catch(NullPointerException e) {
158          //
159          // no message in exception (getMessage() returned null)
160          //
161          verifyException("org.yaml.snakeyaml.representer.BaseRepresenter", e);
162       }
163   }
164
165   @Test(timeout = 4000)
166   public void test07()  throws Throwable  {
167       YamlEditor yamlEditor0 = new YamlEditor();
168       Map<String, Object> map0 = (Map<String, Object>) mock(Map.class, new ViolatedAssumptionAnswer());
169       doReturn((-300)).when(map0).size();
170       // Undeclared exception!
171       try { 
172         yamlEditor0.encode(map0);
173         fail("Expecting exception: IllegalArgumentException");
174       
175       } catch(IllegalArgumentException e) {
176          //
177          // Illegal Capacity: -300
178          //
179          verifyException("java.util.ArrayList", e);
180       }
181   }
182
183   @Test(timeout = 4000)
184   public void test08()  throws Throwable  {
185       byte[] byteArray0 = new byte[0];
186       YamlEditor yamlEditor0 = new YamlEditor(byteArray0);
187       Map<HeatTemplateParam, String> map0 = (Map<HeatTemplateParam, String>) mock(Map.class, new ViolatedAssumptionAnswer());
188       doReturn("").when(map0).get(any());
189       PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0);
190       LinkedHashSet<HeatTemplateParam> linkedHashSet0 = new LinkedHashSet<HeatTemplateParam>();
191       // Undeclared exception!
192       try { 
193         yamlEditor0.addParameterList(linkedHashSet0);
194         fail("Expecting exception: ClassCastException");
195       
196       } catch(ClassCastException e) {
197          //
198          // java.lang.String cannot be cast to java.util.Map
199          //
200          verifyException("org.openecomp.mso.asdc.util.YamlEditor", e);
201       }
202   }
203
204   @Test(timeout = 4000)
205   public void test09()  throws Throwable  {
206       byte[] byteArray0 = new byte[1];
207       YamlEditor yamlEditor0 = null;
208       try {
209         yamlEditor0 = new YamlEditor(byteArray0);
210         fail("Expecting exception: RuntimeException");
211       
212       } catch(RuntimeException e) {
213          //
214          // special characters are not allowed
215          //
216          verifyException("org.yaml.snakeyaml.reader.StreamReader", e);
217       }
218   }
219
220   @Test(timeout = 4000)
221   public void test10()  throws Throwable  {
222       byte[] byteArray0 = new byte[1];
223       byteArray0[0] = (byte)37;
224       YamlEditor yamlEditor0 = null;
225       try {
226         yamlEditor0 = new YamlEditor(byteArray0);
227         fail("Expecting exception: RuntimeException");
228       
229       } catch(RuntimeException e) {
230          //
231          // while scanning a directive
232          //  in 'reader', line 1, column 1:
233          //     %
234          //     ^
235          // expected alphabetic or numeric character, but found \u0000(0)
236          //  in 'reader', line 1, column 2:
237          //     %
238          //      ^
239          //
240          verifyException("org.yaml.snakeyaml.scanner.ScannerImpl", e);
241       }
242   }
243
244   @Test(timeout = 4000)
245   public void test11()  throws Throwable  {
246       byte[] byteArray0 = new byte[2];
247       byteArray0[1] = (byte) (-80);
248       YamlEditor yamlEditor0 = null;
249       try {
250         yamlEditor0 = new YamlEditor(byteArray0);
251         fail("Expecting exception: RuntimeException");
252       
253       } catch(RuntimeException e) {
254          //
255          // java.nio.charset.MalformedInputException: Input length = 1
256          //
257          verifyException("org.yaml.snakeyaml.reader.StreamReader", e);
258       }
259   }
260
261   @Test(timeout = 4000)
262   public void test13()  throws Throwable  {
263       byte[] byteArray0 = new byte[1];
264       byteArray0[0] = (byte)110;
265       YamlEditor yamlEditor0 = null;
266       try {
267         yamlEditor0 = new YamlEditor(byteArray0);
268         fail("Expecting exception: ClassCastException");
269       
270       } catch(ClassCastException e) {
271          //
272          // java.lang.String cannot be cast to java.util.Map
273          //
274          verifyException("org.openecomp.mso.asdc.util.YamlEditor", e);
275       }
276   }
277
278   @Test(timeout = 4000)
279   public void test14()  throws Throwable  {
280       YamlEditor yamlEditor0 = new YamlEditor();
281       String string0 = yamlEditor0.encode();
282       assertEquals("null\n", string0);
283   }
284
285   @Test(timeout = 4000)
286   public void test15()  throws Throwable  {
287       YamlEditor yamlEditor0 = new YamlEditor();
288       HashMap<Object, String> hashMap0 = new HashMap<Object, String>();
289       Map<Integer, Object> map0 = (Map<Integer, Object>) mock(Map.class, new ViolatedAssumptionAnswer());
290       doReturn(hashMap0).when(map0).get(any());
291       PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0);
292       Set<HeatTemplateParam> set0 = (Set<HeatTemplateParam>) mock(Set.class, new ViolatedAssumptionAnswer());
293       doReturn((Iterator) null).when(set0).iterator();
294       // Undeclared exception!
295       try { 
296         yamlEditor0.addParameterList(set0);
297         fail("Expecting exception: NullPointerException");
298       
299       } catch(NullPointerException e) {
300          //
301          // no message in exception (getMessage() returned null)
302          //
303          verifyException("org.openecomp.mso.asdc.util.YamlEditor", e);
304       }
305   }
306
307   @Test(timeout = 4000)
308   public void test16()  throws Throwable  {
309       byte[] byteArray0 = new byte[0];
310       YamlEditor yamlEditor0 = new YamlEditor(byteArray0);
311       HashMap<HeatTemplateParam, String> hashMap0 = new HashMap<HeatTemplateParam, String>();
312       PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) hashMap0);
313       LinkedHashSet<HeatTemplateParam> linkedHashSet0 = new LinkedHashSet<HeatTemplateParam>();
314       HeatTemplateParam heatTemplateParam0 = mock(HeatTemplateParam.class, new ViolatedAssumptionAnswer());
315       doReturn(">!=_`7`2d(").when(heatTemplateParam0).getParamName();
316       doReturn(">!=_`7`2d(").when(heatTemplateParam0).getParamType();
317       linkedHashSet0.add(heatTemplateParam0);
318       yamlEditor0.addParameterList(linkedHashSet0);
319       Set<HeatTemplateParam> set0 = yamlEditor0.getParameterList();
320       assertFalse(set0.isEmpty());
321   }
322
323   @Test(timeout = 4000)
324   public void test17()  throws Throwable  {
325       YamlEditor yamlEditor0 = new YamlEditor();
326       HashMap<Object, String> hashMap0 = new HashMap<Object, String>();
327       Map<Integer, Object> map0 = (Map<Integer, Object>) mock(Map.class, new ViolatedAssumptionAnswer());
328       doReturn(hashMap0).when(map0).get(any());
329       hashMap0.put(yamlEditor0, "V28");
330       PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0);
331       // Undeclared exception!
332       try { 
333         yamlEditor0.getParameterList();
334         fail("Expecting exception: ClassCastException");
335       
336       } catch(ClassCastException e) {
337          //
338          // java.lang.String cannot be cast to java.util.Map
339          //
340          verifyException("org.openecomp.mso.asdc.util.YamlEditor", e);
341       }
342   }
343
344   @Test(timeout = 4000)
345   public void test18()  throws Throwable  {
346       YamlEditor yamlEditor0 = new YamlEditor();
347       HashMap<Object, String> hashMap0 = new HashMap<Object, String>();
348       Map<Integer, Object> map0 = (Map<Integer, Object>) mock(Map.class, new ViolatedAssumptionAnswer());
349       doReturn(hashMap0).when(map0).get(any());
350       PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0);
351       List<String> list0 = yamlEditor0.getYamlResourceTypeList();
352       assertEquals(0, list0.size());
353   }
354
355   @Test(timeout = 4000)
356   public void test19()  throws Throwable  {
357       YamlEditor yamlEditor0 = new YamlEditor();
358       // Undeclared exception!
359       try { 
360         yamlEditor0.isParentTemplate((String) null);
361         fail("Expecting exception: NullPointerException");
362       
363       } catch(NullPointerException e) {
364          //
365          // no message in exception (getMessage() returned null)
366          //
367          verifyException("org.openecomp.mso.asdc.util.YamlEditor", e);
368       }
369   }
370
371   @Test(timeout = 4000)
372   public void test20()  throws Throwable  {
373       YamlEditor yamlEditor0 = new YamlEditor();
374       yamlEditor0.verifyTemplate();
375       yamlEditor0.isParentTemplate("\"");
376       Map<String, Object> map0 = (Map<String, Object>) mock(Map.class, new ViolatedAssumptionAnswer());
377       doReturn(yamlEditor0).when(map0).get(any());
378       PrivateAccess.setVariable((Class<YamlEditor>) YamlEditor.class, yamlEditor0, "yml", (Object) map0);
379       // Undeclared exception!
380       try { 
381         yamlEditor0.getYamlNestedFileResourceTypeList();
382         fail("Expecting exception: ClassCastException");
383       
384       } catch(ClassCastException e) {
385          //
386          // org.openecomp.mso.asdc.util.YamlEditor cannot be cast to java.util.Map
387          //
388          verifyException("org.openecomp.mso.asdc.util.YamlEditor", e);
389       }
390   }
391
392   @Test(timeout = 4000)
393   public void test21()  throws Throwable  {
394       YamlEditor yamlEditor0 = new YamlEditor();
395       HashMap<String, Object> hashMap0 = new HashMap<String, Object>();
396       String string0 = yamlEditor0.encode((Map<String, Object>) hashMap0);
397       assertEquals("{}\n", string0);
398   }
399
400   @Test(timeout = 4000)
401   public void test22()  throws Throwable  {
402       YamlEditor yamlEditor0 = null;
403       try {
404         yamlEditor0 = new YamlEditor((byte[]) null);
405         fail("Expecting exception: NullPointerException");
406       
407       } catch(NullPointerException e) {
408          //
409          // no message in exception (getMessage() returned null)
410          //
411       }
412   }
413
414   @Test(timeout = 4000)
415   public void test23()  throws Throwable  {
416       YamlEditor yamlEditor0 = new YamlEditor();
417       String string0 = yamlEditor0.toString();
418       assertEquals("null\n", string0);
419   }
420 }