Added oparent to sdc main
[sdc.git] / openecomp-be / tools / zusammen-tools / src / test / java / org / openecomp / core / tools / commands / exportinfo / serialize / VLMExtractTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * SDC
4  * ================================================================================
5  * Copyright (C) 2017 - 2019 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.core.tools.commands.exportinfo.serialize;
22
23 import org.openecomp.core.tools.exportinfo.ExportSerializer;
24 import org.testng.annotations.Test;
25
26 import static org.testng.Assert.*;
27 public class VLMExtractTest {
28
29
30
31     @Test
32     public void extractVLM(){
33         String vlmId = "979a56c7b2fa41e6a5742137f53a5c1b";
34         String elemenet_info_string = "{\n" +
35                 "  \"name\": \"VendorSoftwareProduct\",\n" +
36                 "  \"properties\": {\n" +
37                 "    \"subCategory\": \"resourceNewCategory.dcae component.collector\",\n" +
38                 "    \"name\": \"vsp1\",\n" +
39                 "    \"icon\": \"icon\",\n" +
40                 "    \"onboardingMethod\": \"NetworkPackage\",\n" +
41                 "    \"description\": \"d\",\n" +
42                 "    \"vendorId\": \""+vlmId+"\",\n" +
43                 "    \"category\": \"resourceNewCategory.dcae component\",\n" +
44                 "    \"vendorName\": \"vlm1\",\n" +
45                 "    \"elementType\": \"VendorSoftwareProduct\"\n" +
46                 "  }\n" +
47                 "}\n"    ;
48         String extractedVlmId = new CustomExportSerializer().extractVlm(elemenet_info_string);
49         assertNotNull(extractedVlmId);
50         assertEquals(extractedVlmId,vlmId);
51
52     }
53
54     @Test(expectedExceptions = IllegalStateException.class)
55     public void failToExtractVLMBecauseJsonIsCorrupted(){
56         String elemenet_info_string = "gfhhhghgh";
57         assertNull(new CustomExportSerializer().extractVlm(elemenet_info_string));
58     }
59
60     private static final class CustomExportSerializer extends ExportSerializer{
61         public String extractVlm(String inJson) {
62             return super.extractVlm(inJson);
63         }
64     }
65 }