re base code
[sdc.git] / openecomp-be / tools / zusammen-tools / src / test / java / org / openecomp / core / tools / commands / exportinfo / serialize / VLMExtractTest.java
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.*;
7 public class VLMExtractTest {
8
9
10
11     @Test
12     public void extractVLM(){
13         String vlmId = "979a56c7b2fa41e6a5742137f53a5c1b";
14         String elemenet_info_string = "{\n" +
15                 "  \"name\": \"VendorSoftwareProduct\",\n" +
16                 "  \"properties\": {\n" +
17                 "    \"subCategory\": \"resourceNewCategory.dcae component.collector\",\n" +
18                 "    \"name\": \"vsp1\",\n" +
19                 "    \"icon\": \"icon\",\n" +
20                 "    \"onboardingMethod\": \"NetworkPackage\",\n" +
21                 "    \"description\": \"d\",\n" +
22                 "    \"vendorId\": \""+vlmId+"\",\n" +
23                 "    \"category\": \"resourceNewCategory.dcae component\",\n" +
24                 "    \"vendorName\": \"vlm1\",\n" +
25                 "    \"elementType\": \"VendorSoftwareProduct\"\n" +
26                 "  }\n" +
27                 "}\n"    ;
28         String extractedVlmId = new CustomExportSerializer().extractVlm(elemenet_info_string);
29         assertNotNull(extractedVlmId);
30         assertEquals(extractedVlmId,vlmId);
31
32     }
33
34     @Test(expectedExceptions = IllegalStateException.class)
35     public void failToExtractVLMBecauseJsonIsCorrupted(){
36         String elemenet_info_string = "gfhhhghgh";
37         assertNull(new CustomExportSerializer().extractVlm(elemenet_info_string));
38     }
39
40     private static final class CustomExportSerializer extends ExportSerializer{
41         public String extractVlm(String inJson) {
42             return super.extractVlm(inJson);
43         }
44     }
45 }