2 * ============LICENSE_START=======================================================
3 * TestSOActorServiceProvider
4 * ================================================================================
5 * Copyright (C) 2018 Ericsson. 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
11 * http://www.apache.org/licenses/LICENSE-2.0
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=========================================================
21 package org.onap.policy.controlloop.actor.so;
23 import static org.junit.Assert.*;
25 import java.util.UUID;
27 import org.junit.AfterClass;
28 import org.junit.BeforeClass;
29 import org.junit.Test;
30 import org.onap.policy.controlloop.ControlLoopOperation;
31 import org.onap.policy.controlloop.VirtualControlLoopEvent;
32 import org.onap.policy.controlloop.policy.Policy;
33 import org.onap.policy.drools.http.server.HttpServletServer;
34 import org.onap.policy.drools.system.PolicyEngine;
35 import org.onap.policy.simulators.Util;
36 import org.onap.policy.so.SORequest;
38 public class TestSOActorServiceProvider {
40 public static void setUpSimulator() {
43 } catch (Exception e) {
49 public static void tearDownSimulator() {
50 HttpServletServer.factory.destroy();
54 public void testConstructRequest() {
55 VirtualControlLoopEvent onset = new VirtualControlLoopEvent();
56 ControlLoopOperation operation = new ControlLoopOperation();
58 UUID requestID = UUID.randomUUID();
59 onset.setRequestID(requestID);
61 PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
62 PolicyEngine.manager.setEnvironmentProperty("aai.username", "AAI");
63 PolicyEngine.manager.setEnvironmentProperty("aai.password", "AAI");
65 Policy policy = new Policy();
66 policy.setActor("Dorothy");
67 policy.setRecipe("GoToOz");
68 assertNull(new SOActorServiceProvider().constructRequest(onset, operation, policy));
70 policy.setActor("SO");
71 assertNull(new SOActorServiceProvider().constructRequest(onset, operation, policy));
73 policy.setRecipe("VF Module Create");
74 assertNotNull(new SOActorServiceProvider().constructRequest(onset, operation, policy));
76 PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:999999");
77 assertNull(new SOActorServiceProvider().constructRequest(onset, operation, policy));
79 PolicyEngine.manager.setEnvironmentProperty("aai.url", "http://localhost:6666");
80 assertNotNull(new SOActorServiceProvider().constructRequest(onset, operation, policy));
82 SORequest request = new SOActorServiceProvider().constructRequest(onset, operation, policy);
84 assertEquals(requestID, request.getRequestId());
85 assertEquals("policy", request.getRequestDetails().getRequestInfo().getRequestorId());
86 assertEquals("RegionOne", request.getRequestDetails().getCloudConfiguration().getLcpCloudRegionId());
90 public void testSendRequest() {
92 SOActorServiceProvider.sendRequest(UUID.randomUUID().toString(), null, null);
95 fail("Test should not throw an exception");
100 public void testMethods() {
101 SOActorServiceProvider sp = new SOActorServiceProvider();
103 assertEquals("SO", sp.actor());
104 assertEquals(1, sp.recipes().size());
105 assertEquals("VF Module Create", sp.recipes().get(0));
106 assertEquals(0, sp.recipePayloads("VF Module Create").size());