Adjust sparky parent pom
[aai/sparky-be.git] / sparkybe-onap-service / src / test / java / org / onap / aai / sparky / synchronizer / task / PerformActiveInventoryRetrievalTest.java
1 /**
2  * ============LICENSE_START=======================================================
3  * org.onap.aai
4  * ================================================================================
5  * Copyright © 2017-2018 AT&T Intellectual Property. All rights reserved.
6  * Copyright © 2017-2018 Amdocs
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.onap.aai.sparky.synchronizer.task;
23
24 import org.junit.BeforeClass;
25 import org.onap.aai.sparky.sync.task.PerformActiveInventoryRetrieval;
26 /*
27  * 
28  * TODO-> RestClientBuilder is no longer being use neither is RestAuthenticationMode class 
29  * need to be rewritten to use ONAP RestAuthenticationMode 
30  */
31 /*
32 public class PerformActiveInventoryRetrievalTest {
33
34   private PerformActiveInventoryRetrieval sut;
35
36   @BeforeClass
37   public static void initBeforeClass() throws Exception {
38     /* Mock aai.properties values which are used by repairSelfLink(), which is used both to build this
39      * test's expected URI and also used by PerformActiveInventoryRetrieval.get() which is the method under test
40      *
41     ActiveInventoryRestConfig aaiRestConfig = new ActiveInventoryRestConfig(null);
42     ActiveInventoryConfig.getConfig().setAaiRestConfig(aaiRestConfig);
43     ActiveInventoryConfig.getConfig().getAaiRestConfig().setHost("localhost");
44     ActiveInventoryConfig.getConfig().getAaiRestConfig().setPort("8443");
45     ActiveInventoryConfig.getConfig().getAaiRestConfig().setAuthenticationMode(RestAuthenticationMode.SSL_CERT);
46   }
47   
48
49 /*  @Test
50   public void testGet_relativeURI() throws Exception {
51     String uriToProcess = "/my/relative/uri"; // URI to perform test with
52
53      Use uriToProcess + repairSelfLink() method to build the URI that we expect to see:
54        "https://localhost:8443/my/relative/uri" 
55     String expectedURI = ActiveInventoryConfig.getConfig().repairSelfLink(uriToProcess);
56
57     // Set up PerformActiveInventoryRetrieval dependencies
58     ActiveInventoryDataProvider aaiProvider = new ActiveInventoryAdapter(new OxmModelLoader(), new RestClientBuilder());
59     NetworkTransaction txn = new NetworkTransaction();
60     txn.setLink(uriToProcess);
61
62     sut = new PerformActiveInventoryRetrieval(txn, aaiProvider);
63     sut.setContextMap(new HashMap<>());
64
65     // Call method under test which should add the missing scheme/host/port to the relative path given in this test
66     sut.get();
67
68     assertEquals(expectedURI, txn.getOperationResult().getRequestLink());
69   }
70
71   @Test
72   public void testGet_relativeURIWithSchemaAndAuthority() throws Exception {
73     String uriToProcess = "https://localhost:8443/my/relative/uri"; // URI to perform test with
74
75      Use uriToProcess + repairSelfLink() method to build the URI that we expect to see:
76        "https://localhost:8443/my/relative/uri" 
77     String expectedURI = ActiveInventoryConfig.getConfig().repairSelfLink(uriToProcess);
78
79     // Set up PerformActiveInventoryRetrieval dependencies
80     ActiveInventoryDataProvider aaiProvider = new ActiveInventoryAdapter(new OxmModelLoader(), new RestClientBuilder());
81     NetworkTransaction txn = new NetworkTransaction();
82     txn.setLink(uriToProcess);
83
84     sut = new PerformActiveInventoryRetrieval(txn, aaiProvider);
85     sut.setContextMap(new HashMap<>());
86
87     // Call method under test which shouldn't change the absolute path given in this test
88     sut.get();
89
90     assertEquals(expectedURI, txn.getOperationResult().getRequestLink());
91   }
92
93   @Test
94   public void testGet_emptyURI() throws Exception {
95     String uriToProcess = ""; // URI to perform test with
96
97      Use uriToProcess + repairSelfLink() method to build the URI that we expect to see:
98        "https://localhost:8443" 
99     String expectedURI = ActiveInventoryConfig.getConfig().repairSelfLink(uriToProcess);
100
101     // Set up PerformActiveInventoryRetrieval dependencies
102     ActiveInventoryDataProvider aaiProvider = new ActiveInventoryAdapter(new OxmModelLoader(), new RestClientBuilder());
103     NetworkTransaction txn = new NetworkTransaction();
104     txn.setLink(uriToProcess);
105
106     sut = new PerformActiveInventoryRetrieval(txn, aaiProvider);
107     sut.setContextMap(new HashMap<>());
108
109     // Call method under test which should add the missing scheme/host/port to the empty URI given in this test
110     sut.get();
111
112     assertEquals(expectedURI, txn.getOperationResult().getRequestLink());
113   }
114 }*/