340404136bb2dd2c7476d14edf175e5cc054b03b
[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.Ignore;
30 import org.junit.Test;
31 import org.onap.policy.drools.http.server.HttpServletServer;
32 import org.onap.policy.vfc.VFCResponse;
33 import org.onap.policy.vfc.util.Serialization;
34 import org.onap.policy.rest.RESTManager;
35 import org.onap.policy.rest.RESTManager.Pair;
36
37 public class VfcSimulatorTest {
38         
39         @BeforeClass
40         public static void setUpSimulator() {
41                 try {
42                         Util.buildVfcSim();
43                 } catch (InterruptedException e) {
44                         fail(e.getMessage());
45                 }
46         }
47         
48         @AfterClass
49         public static void tearDownSimulator() {
50                 HttpServletServer.factory.destroy();
51         }
52         
53         @Test
54         public void testPost(){
55                 Pair<Integer, String> httpDetails = RESTManager.post("http://localhost:6668/api/nslcm/v1/ns/1234567890/heal", "username", "password", new HashMap<String, String>(), "application/json", "Some Request Here");
56                 assertNotNull(httpDetails);
57                 VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
58                 assertNotNull(response);
59         }
60         
61         //This test case fails because the model code does not match the response I was given, I do not know which is wrong
62         @Ignore
63         @Test
64         public void testGet(){
65                 Pair<Integer, String> httpDetails = RESTManager.get("http://localhost:6668/api/nslcm/v1/jobs/1234&responseId=5678", "username", "password", new HashMap<String, String>());
66                 assertNotNull(httpDetails);
67                 VFCResponse response = Serialization.gsonPretty.fromJson(httpDetails.b, VFCResponse.class);
68                 assertNotNull(response);
69         }
70 }