UI Exensibility config cleanup
[aai/sparky-be.git] / src / test / java / org / onap / aai / sparky / synchronizer / task / PerformActiveInventoryRetrievalTest.java
1 package org.onap.aai.sparky.synchronizer.task;
2
3 import org.junit.BeforeClass;
4 import org.onap.aai.sparky.sync.task.PerformActiveInventoryRetrieval;
5 /*
6  * 
7  * TODO-> RestClientBuilder is no longer being use neither is RestAuthenticationMode class 
8  * need to be rewritten to use ONAP RestAuthenticationMode 
9  */
10 /*
11 public class PerformActiveInventoryRetrievalTest {
12
13   private PerformActiveInventoryRetrieval sut;
14
15   @BeforeClass
16   public static void initBeforeClass() throws Exception {
17     /* Mock aai.properties values which are used by repairSelfLink(), which is used both to build this
18      * test's expected URI and also used by PerformActiveInventoryRetrieval.get() which is the method under test
19      *
20     ActiveInventoryRestConfig aaiRestConfig = new ActiveInventoryRestConfig(null);
21     ActiveInventoryConfig.getConfig().setAaiRestConfig(aaiRestConfig);
22     ActiveInventoryConfig.getConfig().getAaiRestConfig().setHost("localhost");
23     ActiveInventoryConfig.getConfig().getAaiRestConfig().setPort("8443");
24     ActiveInventoryConfig.getConfig().getAaiRestConfig().setAuthenticationMode(RestAuthenticationMode.SSL_CERT);
25   }
26   
27
28 /*  @Test
29   public void testGet_relativeURI() throws Exception {
30     String uriToProcess = "/my/relative/uri"; // URI to perform test with
31
32      Use uriToProcess + repairSelfLink() method to build the URI that we expect to see:
33        "https://localhost:8443/my/relative/uri" 
34     String expectedURI = ActiveInventoryConfig.getConfig().repairSelfLink(uriToProcess);
35
36     // Set up PerformActiveInventoryRetrieval dependencies
37     ActiveInventoryDataProvider aaiProvider = new ActiveInventoryAdapter(new OxmModelLoader(), new RestClientBuilder());
38     NetworkTransaction txn = new NetworkTransaction();
39     txn.setLink(uriToProcess);
40
41     sut = new PerformActiveInventoryRetrieval(txn, aaiProvider);
42     sut.setContextMap(new HashMap<>());
43
44     // Call method under test which should add the missing scheme/host/port to the relative path given in this test
45     sut.get();
46
47     assertEquals(expectedURI, txn.getOperationResult().getRequestLink());
48   }
49
50   @Test
51   public void testGet_relativeURIWithSchemaAndAuthority() throws Exception {
52     String uriToProcess = "https://localhost:8443/my/relative/uri"; // URI to perform test with
53
54      Use uriToProcess + repairSelfLink() method to build the URI that we expect to see:
55        "https://localhost:8443/my/relative/uri" 
56     String expectedURI = ActiveInventoryConfig.getConfig().repairSelfLink(uriToProcess);
57
58     // Set up PerformActiveInventoryRetrieval dependencies
59     ActiveInventoryDataProvider aaiProvider = new ActiveInventoryAdapter(new OxmModelLoader(), new RestClientBuilder());
60     NetworkTransaction txn = new NetworkTransaction();
61     txn.setLink(uriToProcess);
62
63     sut = new PerformActiveInventoryRetrieval(txn, aaiProvider);
64     sut.setContextMap(new HashMap<>());
65
66     // Call method under test which shouldn't change the absolute path given in this test
67     sut.get();
68
69     assertEquals(expectedURI, txn.getOperationResult().getRequestLink());
70   }
71
72   @Test
73   public void testGet_emptyURI() throws Exception {
74     String uriToProcess = ""; // URI to perform test with
75
76      Use uriToProcess + repairSelfLink() method to build the URI that we expect to see:
77        "https://localhost:8443" 
78     String expectedURI = ActiveInventoryConfig.getConfig().repairSelfLink(uriToProcess);
79
80     // Set up PerformActiveInventoryRetrieval dependencies
81     ActiveInventoryDataProvider aaiProvider = new ActiveInventoryAdapter(new OxmModelLoader(), new RestClientBuilder());
82     NetworkTransaction txn = new NetworkTransaction();
83     txn.setLink(uriToProcess);
84
85     sut = new PerformActiveInventoryRetrieval(txn, aaiProvider);
86     sut.setContextMap(new HashMap<>());
87
88     // Call method under test which should add the missing scheme/host/port to the empty URI given in this test
89     sut.get();
90
91     assertEquals(expectedURI, txn.getOperationResult().getRequestLink());
92   }
93 }*/