Initial OpenECOMP APPC commit
[appc.git] / app-c / appc / appc-event-listener / appc-event-listener-bundle / src / test / java / org / openecomp / appc / listener / CL / impl / TestWorker.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * openECOMP : APP-C
4  * ================================================================================
5  * Copyright (C) 2017 AT&T Intellectual Property. All rights
6  *                                              reserved.
7  * ================================================================================
8  * Licensed under the Apache License, Version 2.0 (the "License");
9  * you may not use this file except in compliance with the License.
10  * You may obtain a copy of the License at
11  * 
12  *      http://www.apache.org/licenses/LICENSE-2.0
13  * 
14  * Unless required by applicable law or agreed to in writing, software
15  * distributed under the License is distributed on an "AS IS" BASIS,
16  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
17  * See the License for the specific language governing permissions and
18  * limitations under the License.
19  * ============LICENSE_END=========================================================
20  */
21
22 package org.openecomp.appc.listener.CL.impl;
23
24 import static org.junit.Assert.assertNotNull;
25
26 import java.util.Properties;
27
28 import org.junit.Before;
29 import org.junit.Test;
30 import org.openecomp.appc.configuration.ConfigurationFactory;
31 import org.openecomp.appc.listener.EventHandler;
32 import org.openecomp.appc.listener.ListenerProperties;
33 import org.openecomp.appc.listener.CL.impl.ProviderOperations;
34 import org.openecomp.appc.listener.CL.impl.WorkerImpl;
35 import org.openecomp.appc.listener.CL.model.IncomingMessage;
36 import org.openecomp.appc.listener.impl.EventHandlerImpl;
37 import org.slf4j.Logger;
38 import org.slf4j.LoggerFactory;
39
40 public class TestWorker {
41
42     private static final Logger LOG = LoggerFactory.getLogger(WorkerImpl.class);
43
44     private IncomingMessage msg;
45     private EventHandler dmaap;
46
47     @Before
48     public void setup() {
49         Properties props = ConfigurationFactory.getConfiguration().getProperties();
50         String activeEndpoint = props.getProperty("appc.ClosedLoop.provider.url");
51         assertNotNull(activeEndpoint);
52         ProviderOperations.setUrl(activeEndpoint);
53
54         String vmUrl = props.getProperty("test.vm_url");
55         assertNotNull(vmUrl);
56         msg = new IncomingMessage();
57         // Client and Time are for ID
58         msg.setRequestClient("APPC");
59         msg.setRequestTime("TEST");
60         msg.setRequest("Restart");
61         msg.setUrl(vmUrl);
62
63         dmaap = new EventHandlerImpl(new ListenerProperties("appc.ClosedLoop", props));
64     }
65
66     @Test
67     public void testWorker() {
68         WorkerImpl w = new WorkerImpl(msg, dmaap);
69         w.run();
70     }
71
72 }