7696cbe7360b99fea3f747cd9245a21e49e7d1b7
[policy/drools-applications.git] /
1 /*-
2  * ============LICENSE_START=======================================================
3  * demo
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.onap.policy.template.demo;
22
23 import static org.junit.Assert.*;
24
25 import java.util.HashMap;
26
27 import org.junit.AfterClass;
28 import org.junit.BeforeClass;
29 import org.junit.Test;
30 import org.onap.policy.drools.http.server.HttpServletServer;
31 import org.onap.policy.mso.SOResponse;
32 import org.onap.policy.mso.util.Serialization;
33 import org.onap.policy.rest.RESTManager;
34 import org.onap.policy.rest.RESTManager.Pair;
35
36 public class MsoSimulatorTest {
37         
38         @BeforeClass
39         public static void setUpSimulator() {
40                 try {
41                         Util.buildMsoSim();
42                 } catch (InterruptedException e) {
43                         fail(e.getMessage());
44                 }
45         }
46         
47         @AfterClass
48         public static void tearDownSimulator() {
49                 HttpServletServer.factory.destroy();
50         }
51         
52         @Test
53         public void testResponse(){
54                 Pair<Integer, String> httpDetails = RESTManager.post("http://localhost:6667/serviceInstances/v2/12345/vnfs/12345/vfModulesHTTPS/1.1", "username", "password", new HashMap<String, String>(), "application/json", "Some Request Here");
55                 assertNotNull(httpDetails);
56                 SOResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, SOResponse.class);
57                 assertNotNull(response);
58         }
59 }