Merge "Reorder modifiers"
[so.git] / adapters / mso-sdnc-adapter / src / test / java / org / openecomp / mso / adapters / sdnc / impl / RequestTunablesTest.java
1 /*-
2  * ============LICENSE_START=======================================================
3  * ONAP - SO
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.openecomp.mso.adapters.sdnc.impl;
22
23 import static org.junit.Assert.*;
24
25 import org.junit.AfterClass;
26 import org.junit.Before;
27 import org.junit.Test;
28
29 import org.openecomp.mso.properties.MsoJavaProperties;
30 import org.openecomp.mso.properties.MsoPropertiesException;
31 import org.openecomp.mso.properties.MsoPropertiesFactory;
32
33 public class RequestTunablesTest {
34
35         private static MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
36         
37         public static final String SDNC_PROP = MsoJavaProperties.class.getClassLoader().getResource("mso.sdnc.properties").toString().substring(5);
38         
39         @Before
40         public final void initBeforeEachTest() throws MsoPropertiesException {
41                         msoPropertiesFactory.removeAllMsoProperties();
42                         msoPropertiesFactory.initializeMsoProperties("MSO_PROP_SDNC_ADAPTER", SDNC_PROP);
43         }
44
45         @AfterClass
46         public static final void kill () throws MsoPropertiesException {
47
48                     msoPropertiesFactory.removeMsoProperties("MSO_PROP_SDNC_ADAPTER");
49         }
50         
51     /**
52      * Test method for
53      * {@link org.openecomp.mso.adapters.sdnc.impl.RequestTunables#RequestTunables(java.lang.String, java.lang.String, java.lang.String, java.lang.String)}
54      * .
55      */
56     @Test
57     public final void testRequestTunables () {
58         RequestTunables rt = new RequestTunables (null, null, "op", null,msoPropertiesFactory);
59         assertEquals(0, rt.getReqId ().length ());
60         rt = new RequestTunables ("reqId", "msoAction", null, "query",msoPropertiesFactory);
61         rt.setTunables ();
62         System.out.println(rt.toString ());
63       //  assert (rt.getReqMethod ().equals ("toto"));
64         assertNotNull(rt.getTimeout ());
65         assertEquals("query", rt.getAction ());
66         assertEquals("msoAction", rt.getMsoAction ());
67         assertEquals("sdnc-request-header", rt.getHeaderName ());
68         assertEquals(0, rt.getOperation ().length ());
69         assertEquals("N", rt.getAsyncInd ());
70         assertEquals("reqId", rt.getReqId ());
71     }
72     
73     @Test
74     public final void testRequestTunablesSet() {
75         RequestTunables rt = new RequestTunables("reqId", "gammainternet", "service-configuration-operation", "changeactivate", msoPropertiesFactory);
76          rt.setTunables ();
77          assertNotNull(rt.getTimeout ());
78          assertEquals("changeactivate", rt.getAction ());
79          assertEquals("gammainternet", rt.getMsoAction ());
80          assertEquals("sdnc-request-header", rt.getHeaderName ());
81          assertEquals("service-configuration-operation", rt.getOperation ());
82          assertEquals("N", rt.getAsyncInd ());
83          assertEquals("reqId", rt.getReqId ());
84     }
85
86 }