1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
|
/*-
* ============LICENSE_START=======================================================
* simulators
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
* ============LICENSE_END=========================================================
*/
package org.onap.policy.simulators;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.fail;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
import org.onap.policy.aai.AAIGETVnfResponse;
import org.onap.policy.aai.AAIManager;
import org.onap.policy.aai.AAINQInstanceFilters;
import org.onap.policy.aai.AAINQNamedQuery;
import org.onap.policy.aai.AAINQQueryParameters;
import org.onap.policy.aai.AAINQRequest;
import org.onap.policy.aai.AAINQResponse;
import org.onap.policy.drools.http.server.HttpServletServer;
import org.onap.policy.drools.utils.LoggerUtil;
import org.onap.policy.rest.RESTManager;
public class AaiSimulatorTest {
@BeforeClass
public static void setUpSimulator() {
LoggerUtil.setLevel("ROOT", "INFO");
LoggerUtil.setLevel("org.eclipse.jetty", "WARN");
try {
Util.buildAaiSim();
} catch (final Exception e) {
fail(e.getMessage());
}
}
@AfterClass
public static void tearDownSimulator() {
HttpServletServer.factory.destroy();
}
@Test
public void testGet() {
final AAIGETVnfResponse response = new AAIManager(new RESTManager()).getQueryByVnfID(
"http://localhost:6666/aai/v11/network/generic-vnfs/generic-vnf/", "testUser", "testPass",
UUID.randomUUID(), "5e49ca06-2972-4532-9ed4-6d071588d792");
assertNotNull(response);
assertNotNull(response.getRelationshipList());
}
@Test
public void testPost() {
final AAINQRequest request = new AAINQRequest();
final AAINQQueryParameters tempQueryParameters = new AAINQQueryParameters();
final AAINQNamedQuery tempNamedQuery = new AAINQNamedQuery();
tempNamedQuery.setNamedQueryUUID(UUID.fromString("4ff56a54-9e3f-46b7-a337-07a1d3c6b469"));
tempQueryParameters.setNamedQuery(tempNamedQuery);
request.setQueryParameters(tempQueryParameters);
Map<String, String> tempInnerMap = new HashMap<>();
tempInnerMap.put("vserver-name", "vserver-name-16102016-aai3255-data-11-1");
Map<String, Map<String, String>> tempOuterMap = new HashMap<>();
tempOuterMap.put("vserver", tempInnerMap);
List<Map<String, Map<String, String>>> tempInstanceFilter = new LinkedList<>();
tempInstanceFilter.add(tempOuterMap);
AAINQInstanceFilters tempInstanceFilters = new AAINQInstanceFilters();
tempInstanceFilters.setInstanceFilter(tempInstanceFilter);
request.setInstanceFilters(tempInstanceFilters);
AAINQResponse response = new AAIManager(new RESTManager()).postQuery("http://localhost:6666", "testUser", "testPass",
request, UUID.randomUUID());
assertNotNull(response);
assertNotNull(response.getInventoryResponseItems());
tempNamedQuery.setNamedQueryUUID(UUID.fromString("a93ac487-409c-4e8c-9e5f-334ae8f99087"));
tempQueryParameters.setNamedQuery(tempNamedQuery);
request.setQueryParameters(tempQueryParameters);
tempInnerMap = new HashMap<>();
tempInnerMap.put("vnf-id", "de7cc3ab-0212-47df-9e64-da1c79234deb");
tempOuterMap = new HashMap<>();
tempOuterMap.put("generic-vnf", tempInnerMap);
tempInstanceFilter = new LinkedList<>();
tempInstanceFilter.add(tempOuterMap);
tempInstanceFilters = new AAINQInstanceFilters();
tempInstanceFilters.setInstanceFilter(tempInstanceFilter);
request.setInstanceFilters(tempInstanceFilters);
response = new AAIManager(new RESTManager()).postQuery("http://localhost:6666", "testUser", "testPass", request,
UUID.randomUUID());
assertNotNull(response);
assertNotNull(response.getInventoryResponseItems());
}
}
|