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