a5a1ff2cbcc7d8d8d9ae08d73d3f7864f3a11df9
[sdc.git] /
1 package org.openecomp.core.tools.Commands.exportinfo.serialize;
2
3 import org.openecomp.core.tools.exportinfo.ExportSerializer;
4 import org.testng.annotations.Test;
5
6 import static org.testng.Assert.assertEquals;
7 import static org.testng.Assert.assertNotNull;
8 import static org.testng.Assert.assertNull;
9 public class VLMExtractTest {
10
11
12
13     @Test
14     public void extractVLM(){
15         String vlmId = "979a56c7b2fa41e6a5742137f53a5c1b";
16         String elemenet_info_string = "{\n" +
17                 "  \"name\": \"VendorSoftwareProduct\",\n" +
18                 "  \"properties\": {\n" +
19                 "    \"subCategory\": \"resourceNewCategory.dcae component.collector\",\n" +
20                 "    \"name\": \"vsp1\",\n" +
21                 "    \"icon\": \"icon\",\n" +
22                 "    \"onboardingMethod\": \"NetworkPackage\",\n" +
23                 "    \"description\": \"d\",\n" +
24                 "    \"vendorId\": \""+vlmId+"\",\n" +
25                 "    \"category\": \"resourceNewCategory.dcae component\",\n" +
26                 "    \"vendorName\": \"vlm1\",\n" +
27                 "    \"elementType\": \"VendorSoftwareProduct\"\n" +
28                 "  }\n" +
29                 "}\n"    ;
30         String extractedVlmId = new CustomExportSerializer().extractVlm(elemenet_info_string);
31         assertNotNull(extractedVlmId);
32         assertEquals(extractedVlmId,vlmId);
33
34     }
35
36     @Test(expectedExceptions = IllegalStateException.class)
37     public void failToExtractVLMBecauseJsonIsCorrupted(){
38         String elemenet_info_string = "gfhhhghgh";
39         new CustomExportSerializer().extractVlm(elemenet_info_string);
40     }
41
42     private static final class CustomExportSerializer extends ExportSerializer{
43         public String extractVlm(String injson) {
44             return super.extractVlm(injson);
45         }
46     }
47 }