Added tests for dcae dispacher services
[clamp.git] / src / main / java / org / onap / clamp / clds / client / DcaeInventoryServices.java
index 5f21596..b63bb64 100644 (file)
@@ -17,6 +17,7 @@
  * See the License for the specific language governing permissions and\r
  * limitations under the License.\r
  * ============LICENSE_END============================================\r
+ * Modifications copyright (c) 2018 Nokia\r
  * ===================================================================\r
  * \r
  */\r
@@ -60,15 +61,22 @@ public class DcaeInventoryServices {
     protected static final EELFLogger logger = EELFManager.getInstance().getLogger(DcaeInventoryServices.class);\r
     protected static final EELFLogger auditLogger = EELFManager.getInstance().getAuditLogger();\r
     protected static final EELFLogger metricsLogger = EELFManager.getInstance().getMetricsLogger();\r
-    public static final String DCAE_INVENTORY_URL = "dcae.inventory.url";\r
-    public static final String DCAE_INVENTORY_RETRY_INTERVAL = "dcae.intentory.retry.interval";\r
-    public static final String DCAE_INVENTORY_RETRY_LIMIT = "dcae.intentory.retry.limit";\r
+    private static final String DCAE_INVENTORY_URL = "dcae.inventory.url";\r
+    private static final String DCAE_INVENTORY_RETRY_INTERVAL = "dcae.intentory.retry.interval";\r
+    private static final String DCAE_INVENTORY_RETRY_LIMIT = "dcae.intentory.retry.limit";\r
     public static final String DCAE_TYPE_NAME = "typeName";\r
     public static final String DCAE_TYPE_ID = "typeId";\r
+    private final ClampProperties refProp;\r
+    private final CldsDao cldsDao;\r
+    private final DcaeHttpConnectionManager dcaeHttpConnectionManager;\r
+\r
     @Autowired\r
-    private ClampProperties refProp;\r
-    @Autowired\r
-    private CldsDao cldsDao;\r
+    public DcaeInventoryServices(ClampProperties refProp, CldsDao cldsDao, DcaeHttpConnectionManager dcaeHttpConnectionManager) {\r
+        this.refProp = refProp;\r
+        this.cldsDao = cldsDao;\r
+        this.dcaeHttpConnectionManager = dcaeHttpConnectionManager;\r
+    }\r
+\r
 \r
     /**\r
      * Set the event inventory.\r
@@ -203,7 +211,7 @@ public class DcaeInventoryServices {
         }\r
         for (int i = 0; i < retryLimit; i++) {\r
             metricsLogger.info("Attempt n°" + i + " to contact DCAE inventory");\r
-            String response = DcaeHttpConnectionManager.doDcaeHttpQuery(fullUrl, "GET", null, null);\r
+            String response = dcaeHttpConnectionManager.doDcaeHttpQuery(fullUrl, "GET", null, null);\r
             int totalCount = getTotalCountFromDcaeInventoryResponse(response);\r
             metricsLogger.info("getDcaeInformation complete: totalCount returned=" + totalCount);\r
             if (totalCount > 0) {\r
@@ -254,7 +262,7 @@ public class DcaeInventoryServices {
             String apiBodyString = dcaeServiceTypeRequest.toString();\r
             logger.info("Dcae api Body String - " + apiBodyString);\r
             String url = refProp.getStringValue(DCAE_INVENTORY_URL) + "/dcae-service-types";\r
-            String responseStr = DcaeHttpConnectionManager.doDcaeHttpQuery(url, "POST", apiBodyString,\r
+            String responseStr = dcaeHttpConnectionManager.doDcaeHttpQuery(url, "POST", apiBodyString,\r
                     "application/json");\r
             // If the DCAEServiceTypeRequest is created successfully it will\r
             // return a json object responce containing a node for newly created\r
@@ -305,7 +313,7 @@ public class DcaeInventoryServices {
             if (inventoryResponse != null && inventoryResponse.getTypeId() != null) {\r
                 String fullUrl = refProp.getStringValue(DCAE_INVENTORY_URL) + "/dcae-service-types/"\r
                         + inventoryResponse.getTypeId();\r
-                DcaeHttpConnectionManager.doDcaeHttpQuery(fullUrl, "DELETE", null, null);\r
+                dcaeHttpConnectionManager.doDcaeHttpQuery(fullUrl, "DELETE", null, null);\r
             }\r
             result = true;\r
         } catch (IOException | ParseException e) {\r