Support Outputs during Import Service
[sdc.git] / catalog-be / src / test / java / org / openecomp / sdc / be / components / impl / ImportUtilsTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
6  * ================================================================================
7  * Licensed under the Apache License, Version 2.0 (the "License");
8  * you may not use this file except in compliance with the License.
9  * You may obtain a copy of the License at
10  *
11  *      http://www.apache.org/licenses/LICENSE-2.0
12  *
13  * Unless required by applicable law or agreed to in writing, software
14  * distributed under the License is distributed on an "AS IS" BASIS,
15  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16  * See the License for the specific language governing permissions and
17  * limitations under the License.
18  * ============LICENSE_END=========================================================
19  */
20
21 package org.openecomp.sdc.be.components.impl;
22
23 import static org.junit.jupiter.api.Assertions.assertEquals;
24 import static org.junit.jupiter.api.Assertions.assertFalse;
25 import static org.junit.jupiter.api.Assertions.assertNotNull;
26 import static org.junit.jupiter.api.Assertions.assertTrue;
27
28 import com.google.common.collect.Lists;
29 import fj.data.Either;
30 import java.io.IOException;
31 import java.nio.file.FileSystems;
32 import java.nio.file.Files;
33 import java.util.ArrayList;
34 import java.util.HashMap;
35 import java.util.Iterator;
36 import java.util.List;
37 import java.util.Map;
38 import java.util.Map.Entry;
39 import org.junit.jupiter.api.Test;
40 import org.mockito.Mockito;
41 import org.openecomp.sdc.be.components.impl.ImportUtils.ResultStatusEnum;
42 import org.openecomp.sdc.be.components.impl.ImportUtils.ToscaElementTypeEnum;
43 import org.openecomp.sdc.be.datatypes.elements.AttributeDataDefinition;
44 import org.openecomp.sdc.be.datatypes.elements.PropertyDataDefinition;
45 import org.openecomp.sdc.be.datatypes.elements.SchemaDefinition;
46 import org.openecomp.sdc.be.model.AttributeDefinition;
47 import org.openecomp.sdc.be.model.HeatParameterDefinition;
48 import org.openecomp.sdc.be.model.InputDefinition;
49 import org.openecomp.sdc.be.model.OutputDefinition;
50 import org.openecomp.sdc.be.model.PropertyConstraint;
51 import org.openecomp.sdc.be.model.PropertyDefinition;
52 import org.openecomp.sdc.be.model.operations.impl.AnnotationTypeOperations;
53 import org.openecomp.sdc.be.model.tosca.constraints.ValidValuesConstraint;
54 import org.openecomp.sdc.be.utils.TypeUtils;
55 import org.openecomp.sdc.common.api.ArtifactTypeEnum;
56 import org.yaml.snakeyaml.Yaml;
57
58 public class ImportUtilsTest {
59
60     public static String loadFileNameToJsonString(String fileName) throws IOException {
61         String sourceDir = "src/test/resources/normativeTypes";
62         return loadFileNameToJsonString(sourceDir, fileName);
63     }
64
65     public static String loadCustomTypeFileNameToJsonString(String fileName) throws IOException {
66         String sourceDir = "src/test/resources/customTypes";
67         return loadFileNameToJsonString(sourceDir, fileName);
68     }
69
70     private static String loadFileNameToJsonString(String sourceDir, String fileName) throws IOException {
71         java.nio.file.Path filePath = FileSystems.getDefault().getPath(sourceDir, fileName);
72         byte[] fileContent = Files.readAllBytes(filePath);
73         return new String(fileContent);
74     }
75
76     private static Object loadJsonFromFile(String fileName) throws IOException {
77         String content = loadFileNameToJsonString(fileName);
78         return new Yaml().load(content);
79     }
80
81     @Test
82     void testStringTypeFindToscaElements() throws IOException {
83         Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements(
84             (Map<String, Object>) loadJsonFromFile("normative-types-string-list-test.yml"), "stringTestTag", ToscaElementTypeEnum.STRING,
85             new ArrayList<>());
86         assertTrue(toscaElements.isLeft());
87         List<Object> list = toscaElements.left().value();
88         assertEquals(4, list.size());
89         int count = 1;
90         for (Object element : list) {
91             assertTrue(element instanceof String);
92             String value = (String) element;
93             assertEquals(value, "stringVal" + count);
94             count++;
95         }
96     }
97
98     @Test
99     void testBooleanTypeFindToscaElements() throws IOException {
100         Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements(
101             (Map<String, Object>) loadJsonFromFile("normative-types-all-map-test.yml"), "required", ToscaElementTypeEnum.BOOLEAN, new ArrayList<>());
102         assertTrue(toscaElements.isLeft());
103         List<Object> list = toscaElements.left().value();
104         assertEquals(3, list.size());
105         int count = 1;
106         for (Object element : list) {
107             assertTrue(element instanceof Boolean);
108             Boolean value = (Boolean) element;
109             if (count == 1 || count == 3) {
110                 assertFalse(value);
111             } else if (count == 2) {
112                 assertTrue(value);
113             }
114
115             count++;
116         }
117     }
118
119     @Test
120     void testListTypeFindToscaElements() throws IOException {
121         Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements(
122             (Map<String, Object>) loadJsonFromFile("normative-types-string-list-test.yml"), "listTestTag", ToscaElementTypeEnum.LIST,
123             new ArrayList<>());
124         assertTrue(toscaElements.isLeft());
125         List<Object> list = toscaElements.left().value();
126         assertEquals(3, list.size());
127         int count = 1;
128         for (Object element : list) {
129             assertTrue(element instanceof List);
130
131             if (count == 1) {
132                 verifyListElement1(element);
133             } else if (count == 2) {
134                 verifyListElement2(element);
135             } else if (count == 3) {
136                 verifyListElement3(element);
137             }
138             count++;
139         }
140     }
141
142     @Test
143     void testAllTypeFindToscaElements() throws IOException {
144         Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements(
145             (Map<String, Object>) loadJsonFromFile("normative-types-all-map-test.yml"), "allTestTag", ToscaElementTypeEnum.ALL, new ArrayList<>());
146         assertTrue(toscaElements.isLeft());
147         List<Object> list = toscaElements.left().value();
148         assertEquals(5, list.size());
149         int count = 1;
150         for (Object element : list) {
151             if (count == 1) {
152                 assertTrue(element instanceof String);
153                 assertEquals("tosca.nodes.Root", element);
154             } else if (count == 2) {
155                 assertTrue(element instanceof Map);
156                 Map<String, Object> mapElement = (Map<String, Object>) element;
157                 assertEquals(2, mapElement.size());
158                 Iterator<Entry<String, Object>> elementEntries = mapElement.entrySet().iterator();
159                 Entry<String, Object> elementEntry = elementEntries.next();
160                 assertEquals("mapTestTag", elementEntry.getKey());
161                 assertEquals("string", elementEntry.getValue());
162
163                 elementEntry = elementEntries.next();
164                 assertEquals("required", elementEntry.getKey());
165                 assertTrue(elementEntry.getValue() instanceof Boolean);
166                 assertTrue((Boolean) elementEntry.getValue());
167             } else if (count == 3) {
168                 assertTrue(element instanceof String);
169                 assertEquals("1 MB", element);
170             } else if (count == 4) {
171                 assertTrue(element instanceof List);
172                 List<Object> listElement = (List<Object>) element;
173                 assertEquals(2, listElement.size());
174
175                 assertTrue(listElement.get(0) instanceof Map);
176                 Map<String, Object> innerElement = (Map<String, Object>) listElement.get(0);
177                 assertEquals(1, innerElement.size());
178                 Entry<String, Object> innerEntry = innerElement.entrySet().iterator().next();
179                 assertEquals("greater_or_equal", innerEntry.getKey());
180                 assertEquals("1 MB", innerEntry.getValue());
181
182                 assertTrue(listElement.get(1) instanceof Map);
183                 innerElement = (Map<String, Object>) listElement.get(1);
184                 assertEquals(1, innerElement.size());
185                 innerEntry = innerElement.entrySet().iterator().next();
186                 assertEquals("stringTestTag", innerEntry.getKey());
187                 assertEquals("stringVal3", innerEntry.getValue());
188             } else if (count == 5) {
189                 assertTrue(element instanceof Boolean);
190                 assertFalse((Boolean) element);
191             }
192             count++;
193         }
194     }
195
196     @Test
197     void testMapTypeFindToscaElements() throws IOException {
198         Either<List<Object>, ResultStatusEnum> toscaElements = ImportUtils.findToscaElements(
199             (Map<String, Object>) loadJsonFromFile("normative-types-all-map-test.yml"), "mapTestTag", ToscaElementTypeEnum.MAP, new ArrayList<>());
200         assertTrue(toscaElements.isLeft());
201         List<Object> list = toscaElements.left().value();
202         assertEquals(2, list.size());
203         int count = 1;
204         for (Object element : list) {
205             assertTrue(element instanceof Map);
206
207             if (count == 1) {
208                 Map<String, Object> mapElement = (Map<String, Object>) element;
209                 assertEquals(2, mapElement.size());
210                 Iterator<Entry<String, Object>> iterator = mapElement.entrySet().iterator();
211                 Entry<String, Object> inerElementEntry = iterator.next();
212                 assertEquals("stringTestTag", inerElementEntry.getKey());
213                 assertEquals("stringVal1", inerElementEntry.getValue());
214
215                 inerElementEntry = iterator.next();
216                 assertEquals("listTestTag", inerElementEntry.getKey());
217                 assertTrue(inerElementEntry.getValue() instanceof List);
218                 List<Object> innerValue = (List<Object>) inerElementEntry.getValue();
219
220                 assertEquals(3, innerValue.size());
221
222             } else if (count == 2) {
223                 Map<String, Object> mapElement = (Map<String, Object>) element;
224                 assertEquals(2, mapElement.size());
225                 Iterator<Entry<String, Object>> entryItr = mapElement.entrySet().iterator();
226                 Entry<String, Object> inerElementEntry = entryItr.next();
227                 assertEquals("type", inerElementEntry.getKey());
228                 assertEquals("tosca.capabilities.Attachment", inerElementEntry.getValue());
229                 inerElementEntry = entryItr.next();
230                 assertEquals("allTestTag", inerElementEntry.getKey());
231                 assertTrue(inerElementEntry.getValue() instanceof Boolean);
232             }
233
234             count++;
235         }
236     }
237
238     @Test
239     void testCreateFullHeatParameterModuleWithString() {
240
241         testCreateFullHeatParameterModule("string", "default value");
242
243     }
244
245     @Test
246     void testCreateFullHeatParameterModuleWithNumber() {
247
248         testCreateFullHeatParameterModule("number", "777");
249         testCreateFullHeatParameterModule("number", "777.23");
250
251     }
252
253     @Test
254     void testCreateFullHeatParameterModuleWithBoolean() {
255
256         testCreateFullHeatParameterModule("boolean", "true");
257         testCreateFullHeatParameterModule("boolean", "on");
258         testCreateFullHeatParameterModule("boolean", "n");
259
260     }
261
262     @Test
263     void testCreateFullHeatParameterModuleWithList() {
264
265         testCreateFullHeatParameterModule("comma_delimited_list", "[one, two]");
266
267     }
268
269     @Test
270     void testCreateFullHeatParameterModuleWithMissingType() {
271
272         String name = "fullParameter";
273         String description = "description_text";
274
275         Map<String, Object> parametersMap = new HashMap<>();
276         Map<String, Object> firstParam = createParameterMap(null, "aaa", name, description);
277         parametersMap.put(TypeUtils.ToscaTagNamesEnum.PARAMETERS.getElementName(), firstParam);
278
279         Either<List<HeatParameterDefinition>, ResultStatusEnum> heatParameters = ImportUtils.getHeatParameters(parametersMap,
280             ArtifactTypeEnum.HEAT.getType());
281         assertTrue(heatParameters.isRight());
282         assertEquals(ResultStatusEnum.INVALID_PROPERTY_TYPE, heatParameters.right().value());
283
284     }
285
286     @Test
287     void testCreateFullHeatParameterModuleWithMissingFields() {
288
289         String name = "fullParameter";
290
291         Map<String, Object> parametersMap = new HashMap<>();
292         String type = "number";
293         String defValue = "defvalue";
294         // default value cannot be empty in heat in case tag exists
295         Map<String, Object> firstParam = createParameterMap(type, defValue, name, null);
296         parametersMap.put(TypeUtils.ToscaTagNamesEnum.PARAMETERS.getElementName(), firstParam);
297
298         Either<List<HeatParameterDefinition>, ResultStatusEnum> heatParameters = ImportUtils.getHeatParameters(parametersMap,
299             ArtifactTypeEnum.HEAT.getType());
300         assertTrue(heatParameters.isLeft());
301         List<HeatParameterDefinition> parameterDefList = heatParameters.left().value();
302         assertFalse(parameterDefList.isEmpty());
303         HeatParameterDefinition parameterDefinition = parameterDefList.get(0);
304
305         assertParameter(parameterDefinition, name, type, null, defValue);
306
307     }
308
309     @Test
310     void testGetPropertiesFromYml() throws IOException {
311
312         Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("importToscaProperties.yml");
313         Either<Map<String, PropertyDefinition>, ResultStatusEnum> actualProperties = ImportUtils.getProperties(toscaJson);
314         assertTrue(actualProperties.isLeft());
315         Map<String, Map<String, Object>> expectedProperties = getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.PROPERTIES);
316         compareProperties(expectedProperties, actualProperties.left().value());
317
318     }
319
320     @Test
321     void testGetPropertiesWithConstraintsFromYml() throws IOException {
322
323         Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("propertyConstraintsTest.yml");
324         Either<Map<String, PropertyDefinition>, ResultStatusEnum> actualProperties = ImportUtils.getProperties(toscaJson);
325         assertTrue(actualProperties.isLeft());
326         Map<String, PropertyDefinition> properties = actualProperties.left().value();
327         assertTrue(properties.containsKey("service_type"));
328         PropertyDefinition property = properties.get("service_type");
329         assertTrue(property.getConstraints() != null && property.getConstraints().size() == 1);
330         assertTrue(property.getConstraints().get(0) instanceof ValidValuesConstraint);
331         assertNotNull(((ValidValuesConstraint) property.getConstraints().get(0)).getValidValues());
332         List<String> validValues = ((ValidValuesConstraint) property.getConstraints().get(0)).getValidValues();
333         assertTrue(validValues.containsAll(Lists.newArrayList("firewall", "analyzer", "source-nat", "loadbalancer")));
334
335         assertTrue(properties.containsKey("service_interface_type_list"));
336         property = properties.get("service_interface_type_list");
337         assertTrue(property.getSchema() != null && property.getSchema().getProperty() != null);
338         PropertyDefinition innerProperty = new PropertyDefinition(property.getSchema().getProperty());
339         List<PropertyConstraint> innerConstraints = innerProperty.getConstraints();
340         assertTrue(innerConstraints.get(0) instanceof ValidValuesConstraint);
341         assertNotNull(((ValidValuesConstraint) innerConstraints.get(0)).getValidValues());
342         validValues = ((ValidValuesConstraint) innerConstraints.get(0)).getValidValues();
343         assertTrue(validValues.containsAll(Lists.newArrayList("management", "left", "right", "other")));
344     }
345
346     @Test
347     void testGetInputsFromYml() throws IOException {
348
349         Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("importToscaInputsOutputs.yml");
350
351         AnnotationTypeOperations annotationTypeOperations = Mockito.mock(AnnotationTypeOperations.class);
352         Mockito.when(annotationTypeOperations.getLatestType(Mockito.anyString())).thenReturn(null);
353
354         Either<Map<String, InputDefinition>, ResultStatusEnum> actualInputs = ImportUtils.getInputs(toscaJson, annotationTypeOperations);
355         assertTrue(actualInputs.isLeft());
356         Map<String, Map<String, Object>> expectedProperties = getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.INPUTS);
357         compareProperties(expectedProperties, actualInputs.left().value());
358
359         actualInputs = ImportUtils.getInputs(toscaJson);
360         assertTrue(actualInputs.isLeft());
361         expectedProperties = getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.INPUTS);
362         compareProperties(expectedProperties, actualInputs.left().value());
363     }
364
365     @Test
366     void testGetOutputsFromYml() throws IOException {
367
368         Map<String, Object> toscaJson = (Map<String, Object>) loadJsonFromFile("importToscaInputsOutputs.yml");
369
370         Either<Map<String, OutputDefinition>, ResultStatusEnum> actualOutputs = ImportUtils.getOutputs(toscaJson);
371         assertTrue(actualOutputs.isLeft());
372         Map<String, Map<String, Object>> expectedProperties = getElements(toscaJson, TypeUtils.ToscaTagNamesEnum.OUTPUTS);
373         compareAttributes(expectedProperties, actualOutputs.left().value());
374     }
375
376     private void compareAttributes(Map<String, Map<String, Object>> expected, Map<String, OutputDefinition> actual) {
377
378         Map<String, Object> singleExpectedAttribute;
379         AttributeDataDefinition actualAttribute, expectedAttributeModel;
380         // attributes of resource
381         for (Map.Entry<String, Map<String, Object>> expectedAttribute : expected.entrySet()) {
382
383             singleExpectedAttribute = expectedAttribute.getValue();
384             assertNotNull(singleExpectedAttribute);
385             actualAttribute = actual.get(expectedAttribute.getKey());
386             assertNotNull(actualAttribute);
387             actualAttribute.setName(expectedAttribute.getKey().toString());
388             expectedAttributeModel = ImportUtils.createModuleAttribute(singleExpectedAttribute);
389             expectedAttributeModel.setName(expectedAttribute.getKey().toString());
390
391             assertEquals(((AttributeDefinition) expectedAttributeModel).getDefaultValue(), ((AttributeDefinition) actualAttribute).getDefaultValue());
392             assertEquals(((AttributeDefinition) expectedAttributeModel).getDescription(), ((AttributeDefinition) actualAttribute).getDescription());
393             assertEquals(((AttributeDefinition) expectedAttributeModel).getName(), ((AttributeDefinition) actualAttribute).getName());
394             assertEquals(((AttributeDefinition) expectedAttributeModel).getStatus(), ((AttributeDefinition) actualAttribute).getStatus());
395             assertEquals(((AttributeDefinition) expectedAttributeModel).getType(), ((AttributeDefinition) actualAttribute).getType());
396
397             compareSchemas(expectedAttributeModel.getSchema(), actualAttribute.getSchema());
398
399         }
400
401     }
402
403     private void compareProperties(Map<String, Map<String, Object>> expected, Map<String, ? extends PropertyDefinition> actual) {
404
405         Map<String, Object> singleExpectedProperty;
406         PropertyDefinition actualProperty, expectedPropertyModel;
407
408         for (Map.Entry<String, Map<String, Object>> expectedProperty : expected.entrySet()) {
409
410             singleExpectedProperty = expectedProperty.getValue();
411             assertNotNull(singleExpectedProperty);
412             actualProperty = actual.get(expectedProperty.getKey());
413             assertNotNull(actualProperty);
414             actualProperty.setName(expectedProperty.getKey().toString());
415             expectedPropertyModel = ImportUtils.createModuleProperty(singleExpectedProperty);
416             expectedPropertyModel.setName(expectedProperty.getKey().toString());
417
418             assertEquals(expectedPropertyModel.getDefaultValue(), actualProperty.getDefaultValue());
419             assertEquals(expectedPropertyModel.getDescription(), actualProperty.getDescription());
420             assertEquals(expectedPropertyModel.getName(), actualProperty.getName());
421             assertEquals(expectedPropertyModel.getStatus(), actualProperty.getStatus());
422             assertEquals(expectedPropertyModel.getType(), actualProperty.getType());
423
424             compareSchemas(expectedPropertyModel.getSchema(), actualProperty.getSchema());
425
426         }
427
428     }
429
430     private void compareSchemas(SchemaDefinition expected, SchemaDefinition actual) {
431
432         if (expected == null && actual == null) {
433             return;
434         }
435         PropertyDataDefinition actualPropertySchema = actual.getProperty();
436         PropertyDataDefinition expectedPropertySchema = expected.getProperty();
437         assertNotNull(actualPropertySchema);
438         assertNotNull(expectedPropertySchema);
439         assertEquals(expectedPropertySchema.getDescription(), actualPropertySchema.getDescription());
440         assertEquals(expectedPropertySchema.getType(), actualPropertySchema.getType());
441
442     }
443
444     private <T> Map<String, T> getElements(Map<String, Object> toscaJson, TypeUtils.ToscaTagNamesEnum elementType) {
445
446         Either<Map<String, T>, ResultStatusEnum> toscaExpectedElements = ImportUtils.findFirstToscaMapElement(toscaJson, elementType);
447         assertTrue(toscaExpectedElements.isLeft());
448
449         return toscaExpectedElements.left().value();
450
451     }
452
453     private void testCreateFullHeatParameterModule(String type, Object defaultVal) {
454
455         String name = "fullParameter";
456         String description = "description_text";
457
458         Map<String, Object> parametersMap = new HashMap<>();
459         Map<String, Object> firstParam = createParameterMap(type, defaultVal, name, description);
460         parametersMap.put(TypeUtils.ToscaTagNamesEnum.PARAMETERS.getElementName(), firstParam);
461
462         Either<List<HeatParameterDefinition>, ResultStatusEnum> heatParameters = ImportUtils.getHeatParameters(parametersMap,
463             ArtifactTypeEnum.HEAT.getType());
464         assertTrue(heatParameters.isLeft());
465         List<HeatParameterDefinition> parameterDefList = heatParameters.left().value();
466         assertFalse(parameterDefList.isEmpty());
467         HeatParameterDefinition parameterDefinition = parameterDefList.get(0);
468
469         assertParameter(parameterDefinition, name, type, description, defaultVal);
470
471     }
472
473     private Map<String, Object> createParameterMap(String type, Object defaultVal, String name, String description) {
474         Map<String, Object> firstParam = new HashMap<>();
475         Map<String, Object> valuesMap = new HashMap<>();
476
477         valuesMap.put(TypeUtils.ToscaTagNamesEnum.TYPE.getElementName(), type);
478         valuesMap.put(TypeUtils.ToscaTagNamesEnum.DESCRIPTION.getElementName(), description);
479         valuesMap.put(TypeUtils.ToscaTagNamesEnum.DEFAULT_VALUE.getElementName(), defaultVal);
480
481         firstParam.put(name, valuesMap);
482         return firstParam;
483     }
484
485     private void assertParameter(HeatParameterDefinition parameterDefinition, String name, String type, String description, Object defaultVal) {
486         assertEquals(name, parameterDefinition.getName());
487         assertEquals(description, parameterDefinition.getDescription());
488         assertEquals(type, parameterDefinition.getType());
489         assertEquals(String.valueOf(defaultVal), parameterDefinition.getDefaultValue());
490         assertEquals(String.valueOf(defaultVal), parameterDefinition.getCurrentValue());
491     }
492
493     private void verifyListElement3(Object element) {
494         List<Object> listElement = (List<Object>) element;
495         assertEquals(2, listElement.size());
496
497         Map<String, String> innerElement = (Map<String, String>) listElement.get(0);
498         assertEquals(1, innerElement.size());
499         Entry<String, String> innerEntry = innerElement.entrySet().iterator().next();
500         assertEquals("testTag1", innerEntry.getKey());
501         assertEquals("1 MB", innerEntry.getValue());
502
503         innerElement = (Map<String, String>) listElement.get(1);
504         assertEquals(1, innerElement.size());
505         innerEntry = innerElement.entrySet().iterator().next();
506         assertEquals("type", innerEntry.getKey());
507         assertEquals("stringVal2", innerEntry.getValue());
508     }
509
510     private void verifyListElement2(Object element) {
511         List<Object> listElement = (List<Object>) element;
512         assertEquals(2, listElement.size());
513
514         Map<String, Object> innerElement = (Map<String, Object>) listElement.get(0);
515         assertEquals(1, innerElement.size());
516         Entry<String, Object> innerEntry = innerElement.entrySet().iterator().next();
517         assertEquals("testTag1", innerEntry.getKey());
518         assertEquals("1 MB", innerEntry.getValue());
519
520         assertTrue(listElement.get(1) instanceof Map);
521         innerElement = (Map<String, Object>) listElement.get(1);
522         assertEquals(1, innerElement.size());
523         innerEntry = innerElement.entrySet().iterator().next();
524         assertEquals("listTestTag", innerEntry.getKey());
525         assertTrue(innerEntry.getValue() instanceof List);
526     }
527
528     private void verifyListElement1(Object element) {
529         List<Object> listElement = (List<Object>) element;
530         assertEquals(3, listElement.size());
531
532         Map<String, String> innerElement = (Map<String, String>) listElement.get(0);
533         assertEquals(1, innerElement.size());
534         Entry<String, String> innerEntry = innerElement.entrySet().iterator().next();
535         assertEquals("listTestTag", innerEntry.getKey());
536         assertEquals("1 MB", innerEntry.getValue());
537
538         innerElement = (Map<String, String>) listElement.get(1);
539         assertEquals(1, innerElement.size());
540         innerEntry = innerElement.entrySet().iterator().next();
541         assertEquals("listTestTag", innerEntry.getKey());
542         assertEquals("2 MB", innerEntry.getValue());
543
544         innerElement = (Map<String, String>) listElement.get(2);
545         assertEquals(1, innerElement.size());
546         innerEntry = innerElement.entrySet().iterator().next();
547         assertEquals("stringTestTag", innerEntry.getKey());
548         assertEquals("stringVal2", innerEntry.getValue());
549     }
550
551 }