aboutsummaryrefslogtreecommitdiffstats
path: root/sdnr/northbound/a1Adapter/provider
diff options
context:
space:
mode:
Diffstat (limited to 'sdnr/northbound/a1Adapter/provider')
-rw-r--r--sdnr/northbound/a1Adapter/provider/pom.xml1
-rw-r--r--sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterClient.java806
-rw-r--r--sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProvider.java1863
-rw-r--r--sdnr/northbound/a1Adapter/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProviderTest.java852
4 files changed, 2174 insertions, 1348 deletions
diff --git a/sdnr/northbound/a1Adapter/provider/pom.xml b/sdnr/northbound/a1Adapter/provider/pom.xml
index 45f07c487..cf65e8545 100644
--- a/sdnr/northbound/a1Adapter/provider/pom.xml
+++ b/sdnr/northbound/a1Adapter/provider/pom.xml
@@ -78,7 +78,6 @@
<artifactId>mockito-core</artifactId>
<scope>test</scope>
</dependency>
-
<dependency>
<groupId>org.onap.ccsdk.sli.core</groupId>
<artifactId>sli-common</artifactId>
diff --git a/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterClient.java b/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterClient.java
index 429c57f92..324e0eae1 100644
--- a/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterClient.java
+++ b/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterClient.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
* reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,653 +23,636 @@
package org.onap.ccsdk.features.sdnr.northbound.a1Adapter;
import java.util.Properties;
-
import org.onap.ccsdk.sli.core.sli.SvcLogicException;
import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
import org.onap.ccsdk.sli.core.sli.provider.SvcLogicService;
-import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.*;
-
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyInstanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetStatusOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.NotifyPolicyEnforcementUpdateOutputBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
public class A1AdapterClient {
- private static final Logger LOG = LoggerFactory.getLogger(A1AdapterClient.class);
+ private static final Logger LOG = LoggerFactory.getLogger(A1AdapterClient.class);
- private SvcLogicService svcLogicService = null;
+ private SvcLogicService svcLogicService = null;
- public A1AdapterClient(final SvcLogicService svcLogicService) {
- this.svcLogicService = svcLogicService;
- }
+ public A1AdapterClient(final SvcLogicService svcLogicService) {
+ this.svcLogicService = svcLogicService;
+ }
- public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException
- {
- return svcLogicService.hasGraph(module, rpc, version, mode);
- }
+ public boolean hasGraph(String module, String rpc, String version, String mode) throws SvcLogicException {
+ return svcLogicService.hasGraph(module, rpc, version, mode);
+ }
-// Client for GetNearRTRICs
+ // Client for GetNearRTRICs
-public Properties execute(String module, String rpc, String version, String mode, GetNearRTRICsOutputBuilder serviceData)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetNearRTRICsOutputBuilder serviceData) throws SvcLogicException {
- Properties parms = new Properties();
+ Properties parms = new Properties();
- return execute(module,rpc,version, mode,serviceData,parms);
-}
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
-public Properties execute(String module, String rpc, String version, String mode, GetNearRTRICsOutputBuilder serviceData, Properties parms)
- throws SvcLogicException {
- Properties localProp;
- localProp = MdsalHelper.toProperties(parms, serviceData);
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetNearRTRICsOutputBuilder serviceData, Properties parms) throws SvcLogicException {
+ Properties localProp;
+ localProp = MdsalHelper.toProperties(parms, serviceData);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters passed to SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
- for (Object key : localProp.keySet()) {
- String parmName = (String) key;
- String parmValue = localProp.getProperty(parmName);
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
+ }
+ }
- Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters returned by SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
- for (Object key : respProps.keySet()) {
- String parmName = (String) key;
- String parmValue = respProps.getProperty(parmName);
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
- if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
- return respProps;
- }
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
- MdsalHelper.toBuilder(respProps, serviceData);
+ MdsalHelper.toBuilder(respProps, serviceData);
- return respProps;
-}
+ return respProps;
+ }
-// Client for GetHealthCheck
+ // Client for GetHealthCheck
- public Properties execute(String module, String rpc, String version, String mode, GetHealthCheckOutputBuilder serviceData)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetHealthCheckOutputBuilder serviceData) throws SvcLogicException {
- Properties parms = new Properties();
+ Properties parms = new Properties();
- return execute(module,rpc,version, mode,serviceData,parms);
- }
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
- public Properties execute(String module, String rpc, String version, String mode, GetHealthCheckOutputBuilder serviceData, Properties parms)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetHealthCheckOutputBuilder serviceData, Properties parms) throws SvcLogicException {
Properties localProp;
localProp = MdsalHelper.toProperties(parms, serviceData);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters passed to SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
- for (Object key : localProp.keySet()) {
- String parmName = (String) key;
- String parmValue = localProp.getProperty(parmName);
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
+ }
+ }
- Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters returned by SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
- for (Object key : respProps.keySet()) {
- String parmName = (String) key;
- String parmValue = respProps.getProperty(parmName);
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
- if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
- return respProps;
- }
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
- MdsalHelper.toBuilder(respProps, serviceData);
+ MdsalHelper.toBuilder(respProps, serviceData);
- return respProps;
- }
+ return respProps;
+ }
- // Client for getPolicyTypes
+ // Client for getPolicyTypes
- public Properties execute(String module, String rpc, String version, String mode, GetPolicyTypesOutputBuilder serviceData)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetPolicyTypesOutputBuilder serviceData) throws SvcLogicException {
- Properties parms = new Properties();
+ Properties parms = new Properties();
- return execute(module,rpc,version, mode,serviceData,parms);
- }
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
- public Properties execute(String module, String rpc, String version, String mode, GetPolicyTypesOutputBuilder serviceData, Properties parms)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetPolicyTypesOutputBuilder serviceData, Properties parms) throws SvcLogicException {
Properties localProp;
localProp = MdsalHelper.toProperties(parms, serviceData);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters passed to SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
- for (Object key : localProp.keySet()) {
- String parmName = (String) key;
- String parmValue = localProp.getProperty(parmName);
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
+ }
+ }
- Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters returned by SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
- for (Object key : respProps.keySet()) {
- String parmName = (String) key;
- String parmValue = respProps.getProperty(parmName);
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
- if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
- return respProps;
- }
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
- MdsalHelper.toBuilder(respProps, serviceData);
+ MdsalHelper.toBuilder(respProps, serviceData);
- return respProps;
- }
+ return respProps;
+ }
- // Client for createPolicyType
+ // Client for createPolicyType
- public Properties execute(String module, String rpc, String version, String mode, CreatePolicyTypeOutputBuilder serviceData)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ CreatePolicyTypeOutputBuilder serviceData) throws SvcLogicException {
- Properties parms = new Properties();
+ Properties parms = new Properties();
- return execute(module,rpc,version, mode,serviceData,parms);
- }
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
- public Properties execute(String module, String rpc, String version, String mode, CreatePolicyTypeOutputBuilder serviceData, Properties parms)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ CreatePolicyTypeOutputBuilder serviceData, Properties parms) throws SvcLogicException {
Properties localProp;
localProp = MdsalHelper.toProperties(parms, serviceData);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters passed to SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
- for (Object key : localProp.keySet()) {
- String parmName = (String) key;
- String parmValue = localProp.getProperty(parmName);
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
+ }
+ }
- Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters returned by SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
- for (Object key : respProps.keySet()) {
- String parmName = (String) key;
- String parmValue = respProps.getProperty(parmName);
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
- if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
- return respProps;
- }
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
- MdsalHelper.toBuilder(respProps, serviceData);
+ MdsalHelper.toBuilder(respProps, serviceData);
- return respProps;
- }
+ return respProps;
+ }
- // Client for getPolicyType
+ // Client for getPolicyType
- public Properties execute(String module, String rpc, String version, String mode, GetPolicyTypeOutputBuilder serviceData)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetPolicyTypeOutputBuilder serviceData) throws SvcLogicException {
- Properties parms = new Properties();
+ Properties parms = new Properties();
- return execute(module,rpc,version, mode,serviceData,parms);
- }
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
- public Properties execute(String module, String rpc, String version, String mode, GetPolicyTypeOutputBuilder serviceData, Properties parms)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetPolicyTypeOutputBuilder serviceData, Properties parms) throws SvcLogicException {
Properties localProp;
localProp = MdsalHelper.toProperties(parms, serviceData);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters passed to SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
- for (Object key : localProp.keySet()) {
- String parmName = (String) key;
- String parmValue = localProp.getProperty(parmName);
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
+ }
+ }
- Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters returned by SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
- for (Object key : respProps.keySet()) {
- String parmName = (String) key;
- String parmValue = respProps.getProperty(parmName);
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
- if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
- return respProps;
- }
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
- MdsalHelper.toBuilder(respProps, serviceData);
+ MdsalHelper.toBuilder(respProps, serviceData);
- return respProps;
- }
+ return respProps;
+ }
- // Client for deletePolicyType
+ // Client for deletePolicyType
- public Properties execute(String module, String rpc, String version, String mode, DeletePolicyTypeOutputBuilder serviceData)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ DeletePolicyTypeOutputBuilder serviceData) throws SvcLogicException {
- Properties parms = new Properties();
+ Properties parms = new Properties();
- return execute(module,rpc,version, mode,serviceData,parms);
- }
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
- public Properties execute(String module, String rpc, String version, String mode, DeletePolicyTypeOutputBuilder serviceData, Properties parms)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ DeletePolicyTypeOutputBuilder serviceData, Properties parms) throws SvcLogicException {
Properties localProp;
localProp = MdsalHelper.toProperties(parms, serviceData);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters passed to SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
- for (Object key : localProp.keySet()) {
- String parmName = (String) key;
- String parmValue = localProp.getProperty(parmName);
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
+ }
+ }
- Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters returned by SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
- for (Object key : respProps.keySet()) {
- String parmName = (String) key;
- String parmValue = respProps.getProperty(parmName);
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
- if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
- return respProps;
- }
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
- MdsalHelper.toBuilder(respProps, serviceData);
+ MdsalHelper.toBuilder(respProps, serviceData);
- return respProps;
- }
+ return respProps;
+ }
- // Client for getPolicyInstances
+ // Client for getPolicyInstances
- public Properties execute(String module, String rpc, String version, String mode, GetPolicyInstancesOutputBuilder serviceData)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetPolicyInstancesOutputBuilder serviceData) throws SvcLogicException {
- Properties parms = new Properties();
+ Properties parms = new Properties();
- return execute(module,rpc,version, mode,serviceData,parms);
- }
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
- public Properties execute(String module, String rpc, String version, String mode, GetPolicyInstancesOutputBuilder serviceData, Properties parms)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetPolicyInstancesOutputBuilder serviceData, Properties parms) throws SvcLogicException {
Properties localProp;
localProp = MdsalHelper.toProperties(parms, serviceData);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters passed to SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
- for (Object key : localProp.keySet()) {
- String parmName = (String) key;
- String parmValue = localProp.getProperty(parmName);
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
+ }
+ }
- Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters returned by SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
- for (Object key : respProps.keySet()) {
- String parmName = (String) key;
- String parmValue = respProps.getProperty(parmName);
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
- if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
- return respProps;
- }
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
- MdsalHelper.toBuilder(respProps, serviceData);
+ MdsalHelper.toBuilder(respProps, serviceData);
- return respProps;
- }
+ return respProps;
+ }
- // Client for createPolicyInstance
+ // Client for createPolicyInstance
- public Properties execute(String module, String rpc, String version, String mode, CreatePolicyInstanceOutputBuilder serviceData)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ CreatePolicyInstanceOutputBuilder serviceData) throws SvcLogicException {
- Properties parms = new Properties();
+ Properties parms = new Properties();
- return execute(module,rpc,version, mode,serviceData,parms);
- }
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
- public Properties execute(String module, String rpc, String version, String mode, CreatePolicyInstanceOutputBuilder serviceData, Properties parms)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ CreatePolicyInstanceOutputBuilder serviceData, Properties parms) throws SvcLogicException {
Properties localProp;
localProp = MdsalHelper.toProperties(parms, serviceData);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters passed to SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
- for (Object key : localProp.keySet()) {
- String parmName = (String) key;
- String parmValue = localProp.getProperty(parmName);
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
+ }
+ }
- Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters returned by SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
- for (Object key : respProps.keySet()) {
- String parmName = (String) key;
- String parmValue = respProps.getProperty(parmName);
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
- if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
- return respProps;
- }
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
- MdsalHelper.toBuilder(respProps, serviceData);
+ MdsalHelper.toBuilder(respProps, serviceData);
- return respProps;
- }
+ return respProps;
+ }
- // Client for getPolicyInstance
+ // Client for getPolicyInstance
- public Properties execute(String module, String rpc, String version, String mode, GetPolicyInstanceOutputBuilder serviceData)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetPolicyInstanceOutputBuilder serviceData) throws SvcLogicException {
- Properties parms = new Properties();
+ Properties parms = new Properties();
- return execute(module,rpc,version, mode,serviceData,parms);
- }
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
- public Properties execute(String module, String rpc, String version, String mode, GetPolicyInstanceOutputBuilder serviceData, Properties parms)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetPolicyInstanceOutputBuilder serviceData, Properties parms) throws SvcLogicException {
Properties localProp;
localProp = MdsalHelper.toProperties(parms, serviceData);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters passed to SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
- for (Object key : localProp.keySet()) {
- String parmName = (String) key;
- String parmValue = localProp.getProperty(parmName);
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
+ }
+ }
- Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters returned by SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
- for (Object key : respProps.keySet()) {
- String parmName = (String) key;
- String parmValue = respProps.getProperty(parmName);
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
- if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
- return respProps;
- }
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
- MdsalHelper.toBuilder(respProps, serviceData);
+ MdsalHelper.toBuilder(respProps, serviceData);
- return respProps;
- }
+ return respProps;
+ }
- // Client for deletePolicyInstance
+ // Client for deletePolicyInstance
- public Properties execute(String module, String rpc, String version, String mode, DeletePolicyInstanceOutputBuilder serviceData)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ DeletePolicyInstanceOutputBuilder serviceData) throws SvcLogicException {
- Properties parms = new Properties();
+ Properties parms = new Properties();
- return execute(module,rpc,version, mode,serviceData,parms);
- }
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
- public Properties execute(String module, String rpc, String version, String mode, DeletePolicyInstanceOutputBuilder serviceData, Properties parms)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ DeletePolicyInstanceOutputBuilder serviceData, Properties parms) throws SvcLogicException {
Properties localProp;
localProp = MdsalHelper.toProperties(parms, serviceData);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters passed to SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
- for (Object key : localProp.keySet()) {
- String parmName = (String) key;
- String parmValue = localProp.getProperty(parmName);
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
+ }
+ }
- Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters returned by SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
- for (Object key : respProps.keySet()) {
- String parmName = (String) key;
- String parmValue = respProps.getProperty(parmName);
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
- if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
- return respProps;
- }
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
- MdsalHelper.toBuilder(respProps, serviceData);
+ MdsalHelper.toBuilder(respProps, serviceData);
- return respProps;
- }
+ return respProps;
+ }
- // Client for getStatus
+ // Client for getStatus
- public Properties execute(String module, String rpc, String version, String mode, GetStatusOutputBuilder serviceData)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetStatusOutputBuilder serviceData) throws SvcLogicException {
- Properties parms = new Properties();
+ Properties parms = new Properties();
- return execute(module,rpc,version, mode,serviceData,parms);
- }
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
- public Properties execute(String module, String rpc, String version, String mode, GetStatusOutputBuilder serviceData, Properties parms)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ GetStatusOutputBuilder serviceData, Properties parms) throws SvcLogicException {
Properties localProp;
localProp = MdsalHelper.toProperties(parms, serviceData);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters passed to SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
- for (Object key : localProp.keySet()) {
- String parmName = (String) key;
- String parmValue = localProp.getProperty(parmName);
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
+ }
+ }
- Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters returned by SLI");
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
- for (Object key : respProps.keySet()) {
- String parmName = (String) key;
- String parmValue = respProps.getProperty(parmName);
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
- LOG.debug(parmName+" = "+parmValue);
+ LOG.debug(parmName + " = " + parmValue);
- }
- }
- if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
- return respProps;
- }
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
- MdsalHelper.toBuilder(respProps, serviceData);
+ MdsalHelper.toBuilder(respProps, serviceData);
- return respProps;
- }
+ return respProps;
+ }
- // Client for notifyPolicyEnforcementUpdate
+ // Client for notifyPolicyEnforcementUpdate
- public Properties execute(String module, String rpc, String version, String mode, NotifyPolicyEnforcementUpdateOutputBuilder serviceData)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ NotifyPolicyEnforcementUpdateOutputBuilder serviceData) throws SvcLogicException {
- Properties parms = new Properties();
+ Properties parms = new Properties();
- return execute(module,rpc,version, mode,serviceData,parms);
- }
+ return execute(module, rpc, version, mode, serviceData, parms);
+ }
- public Properties execute(String module, String rpc, String version, String mode, NotifyPolicyEnforcementUpdateOutputBuilder serviceData, Properties parms)
- throws SvcLogicException {
+ public Properties execute(String module, String rpc, String version, String mode,
+ NotifyPolicyEnforcementUpdateOutputBuilder serviceData, Properties parms) throws SvcLogicException {
Properties localProp;
localProp = MdsalHelper.toProperties(parms, serviceData);
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters passed to SLI");
-
- for (Object key : localProp.keySet()) {
- String parmName = (String) key;
- String parmValue = localProp.getProperty(parmName);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters passed to SLI");
- LOG.debug(parmName+" = "+parmValue);
+ for (Object key : localProp.keySet()) {
+ String parmName = (String) key;
+ String parmValue = localProp.getProperty(parmName);
- }
- }
+ LOG.debug(parmName + " = " + parmValue);
- Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
+ }
+ }
- if (LOG.isDebugEnabled())
- {
- LOG.debug("Parameters returned by SLI");
+ Properties respProps = svcLogicService.execute(module, rpc, version, mode, localProp);
- for (Object key : respProps.keySet()) {
- String parmName = (String) key;
- String parmValue = respProps.getProperty(parmName);
+ if (LOG.isDebugEnabled()) {
+ LOG.debug("Parameters returned by SLI");
- LOG.debug(parmName+" = "+parmValue);
+ for (Object key : respProps.keySet()) {
+ String parmName = (String) key;
+ String parmValue = respProps.getProperty(parmName);
- }
- }
- if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
- return respProps;
- }
+ LOG.debug(parmName + " = " + parmValue);
- MdsalHelper.toBuilder(respProps, serviceData);
+ }
+ }
+ if ("failure".equalsIgnoreCase(respProps.getProperty("SvcLogic.status"))) {
+ return respProps;
+ }
- return respProps;
- }
+ MdsalHelper.toBuilder(respProps, serviceData);
+ return respProps;
+ }
diff --git a/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProvider.java b/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProvider.java
index 986ebb33d..9e6e59391 100644
--- a/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProvider.java
+++ b/sdnr/northbound/a1Adapter/provider/src/main/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProvider.java
@@ -4,6 +4,7 @@
* ================================================================================
* Copyright (C) 2017 AT&T Intellectual Property. All rights
* reserved.
+ * Modifications Copyright (C) 2020 Nordix Foundation.
* ================================================================================
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -21,33 +22,75 @@
package org.onap.ccsdk.features.sdnr.northbound.a1Adapter;
+import com.google.common.util.concurrent.Futures;
+import com.google.common.util.concurrent.ListenableFuture;
import java.util.Properties;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
-
import org.onap.ccsdk.sli.core.sli.provider.MdsalHelper;
import org.opendaylight.controller.md.sal.binding.api.DataBroker;
import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
import org.opendaylight.controller.sal.binding.api.BindingAwareBroker;
-import org.opendaylight.controller.sal.binding.api.NotificationProviderService;
import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
-import org.opendaylight.controller.sal.binding.api.BindingAwareBroker.RpcRegistration;
-import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.*;
-
-import com.google.common.base.Preconditions;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.A1ADAPTERAPIService;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyInstanceInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyInstanceInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyInstanceOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyInstanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetStatusInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetStatusInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetStatusOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetStatusOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.NotifyPolicyEnforcementUpdateInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.NotifyPolicyEnforcementUpdateInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.NotifyPolicyEnforcementUpdateOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.NotifyPolicyEnforcementUpdateOutputBuilder;
+import org.opendaylight.yangtools.concepts.Builder;
import org.opendaylight.yangtools.yang.common.RpcResult;
import org.opendaylight.yangtools.yang.common.RpcResultBuilder;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import com.google.common.base.Preconditions;
-import com.google.common.util.concurrent.Futures;
-import com.google.common.util.concurrent.ListenableFuture;
-
/**
- * Defines a base implementation for your provider. This class extends from a helper class
- * which provides storage for the most commonly used components of the MD-SAL. Additionally the
- * base class provides some basic logging and initialization / clean up methods.
+ * Defines a base implementation for your provider. This class extends from a helper class which
+ * provides storage for the most commonly used components of the MD-SAL. Additionally the base class
+ * provides some basic logging and initialization / clean up methods.
*
*/
public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService {
@@ -55,993 +98,941 @@ public class A1AdapterProvider implements AutoCloseable, A1ADAPTERAPIService {
private static final Logger LOG = LoggerFactory.getLogger(A1AdapterProvider.class);
private static final String APPLICATION_NAME = "a1Adapter-api";
+ private static final String GET_NEARRT_RICS = "getNearRT-RICs";
+ private static final String GET_HEALTH_CHECK = "getHealthCheck";
+ private static final String GET_POLICY_TYPES = "getPolicyTypes";
+ private static final String CREATE_POLICY_TYPE = "createPolicyType";
+ private static final String GET_POLICY_TYPE = "getPolicyType";
+ private static final String DELETE_POLICY_TYPE = "deletePolicyType";
+ private static final String GET_POLICY_INSTANCES = "getPolicyInstances";
+ private static final String CREATE_POLICY_INSTANCES = "createPolicyInstance";
+ private static final String GET_POLICY_INSTANCE = "getPolicyInstance";
+ private static final String DELETE_POLICY_INSTANCE = "deletePolicyInstance";
+ private static final String GET_STATUS = "getStatus";
+ private static final String NOTIFICATION_ENFORECEMENT = "notifyPolicyEnforcementUpdate";
private final ExecutorService executor;
-
protected DataBroker dataBroker;
protected NotificationPublishService notificationService;
protected RpcProviderRegistry rpcRegistry;
protected BindingAwareBroker.RpcRegistration<A1ADAPTERAPIService> rpcRegistration;
private final A1AdapterClient A1AdapterClient;
+ public A1AdapterProvider(final DataBroker dataBroker, final NotificationPublishService notificationPublishService,
+ final RpcProviderRegistry rpcProviderRegistry, final A1AdapterClient A1AdapterClient) {
- public A1AdapterProvider(final DataBroker dataBroker,
- final NotificationPublishService notificationPublishService,
- final RpcProviderRegistry rpcProviderRegistry,
- final A1AdapterClient A1AdapterClient) {
-
- this.LOG.info( "Creating provider for {}", APPLICATION_NAME);
+ LOG.info("Creating provider for {}", APPLICATION_NAME);
executor = Executors.newFixedThreadPool(1);
- this.dataBroker = dataBroker;
- this.notificationService = notificationPublishService;
- this.rpcRegistry = rpcProviderRegistry;
- this.A1AdapterClient = A1AdapterClient;
- initialize();
+ this.dataBroker = dataBroker;
+ this.notificationService = notificationPublishService;
+ this.rpcRegistry = rpcProviderRegistry;
+ this.A1AdapterClient = A1AdapterClient;
+ initialize();
}
- public void initialize(){
- LOG.info( "Initializing provider for {}", APPLICATION_NAME);
+ public void initialize() {
+ LOG.info("Initializing provider for {}", APPLICATION_NAME);
rpcRegistration = rpcRegistry.addRpcImplementation(A1ADAPTERAPIService.class, this);
- LOG.info( "Initialization complete for {}", APPLICATION_NAME);
+ LOG.info("Initialization complete for {}", APPLICATION_NAME);
}
protected void initializeChild() {
- //Override if you have custom initialization intelligence
+ // Override if you have custom initialization intelligence
}
@Override
public void close() throws Exception {
- LOG.info( "Closing provider for {}", APPLICATION_NAME);
- executor.shutdown();
- rpcRegistration.close();
- LOG.info( "Successfully closed provider for {}", APPLICATION_NAME);
+ LOG.info("Closing provider for {}", APPLICATION_NAME);
+ executor.shutdown();
+ rpcRegistration.close();
+ LOG.info("Successfully closed provider for {}", APPLICATION_NAME);
}
-// RPC getNearRT-RICs
-
-@Override
-public ListenableFuture<RpcResult<GetNearRTRICsOutput>> getNearRTRICs(
- GetNearRTRICsInput input) {
- final String svcOperation = "getNearRT-RICs";
-
- Properties parms = new Properties();
- GetNearRTRICsOutputBuilder serviceDataBuilder = new GetNearRTRICsOutputBuilder();
-
- LOG.info( "Reached RPC getNearRT-RICs");
+ // RPC getNearRT-RICs
- LOG.info( svcOperation +" called." );
-
- if(input == null ) {
- LOG.debug("exiting " +svcOperation+ " because of invalid input");
- serviceDataBuilder.setResponseCode("Input is null");
- RpcResult<GetNearRTRICsOutput> rpcResult =
- RpcResultBuilder.<GetNearRTRICsOutput> status(true).withResult(serviceDataBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // add input to parms
- LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
- GetNearRTRICsInputBuilder inputBuilder = new GetNearRTRICsInputBuilder(input);
- MdsalHelper.toProperties(parms, inputBuilder.build());
-
- LOG.info("Printing SLI parameters to be passed");
-
- // iterate properties file to get key-value pairs
- for (String key : parms.stringPropertyNames()) {
- String value = parms.getProperty(key);
- LOG.info("The SLI parameter in " + key + " is: " + value);
- }
-
- // Call SLI sync method
- try
- {
- if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation , null, "sync"))
- {
- LOG.info( "A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
- try
- {
- A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
- }
- catch (Exception e)
- {
- LOG.error("Caught exception executing service logic for "+ svcOperation, e);
- serviceDataBuilder.setResponseCode("500");
- }
- } else {
- LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
- serviceDataBuilder.setResponseCode("503");
+ @Override
+ public ListenableFuture<RpcResult<GetNearRTRICsOutput>> getNearRTRICs(GetNearRTRICsInput input) {
+ final String svcOperation = "getNearRT-RICs";
+
+ Properties parms = new Properties();
+ GetNearRTRICsOutputBuilder serviceDataBuilder = (GetNearRTRICsOutputBuilder) getServiceData(GET_NEARRT_RICS);
+
+ LOG.info("Reached RPC getNearRT-RICs");
+
+ LOG.info(svcOperation + " called.");
+
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<GetNearRTRICsOutput> rpcResult =
+ RpcResultBuilder.<GetNearRTRICsOutput>status(true).withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ GetNearRTRICsInputBuilder inputBuilder = new GetNearRTRICsInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+
+ LOG.info("Printing SLI parameters to be passed");
+
+ // iterate properties file to get key-value pairs
+ for (String key : parms.stringPropertyNames()) {
+ String value = parms.getProperty(key);
+ LOG.info("The SLI parameter in " + key + " is: " + value);
+ }
+
+ // Call SLI sync method
+ try {
+ if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
+ LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
+ try {
+ A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service logic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service logic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetNearRTRICs ");
+ }
+
+ RpcResult<GetNearRTRICsOutput> rpcResult =
+ RpcResultBuilder.<GetNearRTRICsOutput>status(true).withResult(serviceDataBuilder.build()).build();
+
+ LOG.info("Successful exit from getNearRT-RICs ");
+
+ return Futures.immediateFuture(rpcResult);
}
- }
- catch (Exception e)
- {
- LOG.error("Caught exception looking for service logic", e);
- serviceDataBuilder.setResponseCode("500");
- }
-
- String errorCode = serviceDataBuilder.getResponseCode();
-
- if (!("0".equals(errorCode) || "200".equals(errorCode))) {
- LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
- } else {
- LOG.info("Returned SUCCESS for "+svcOperation+" ");
- serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetNearRTRICs " );
- }
- RpcResult<GetNearRTRICsOutput> rpcResult =
- RpcResultBuilder.<GetNearRTRICsOutput> status(true).withResult(serviceDataBuilder.build()).build();
+ // RPC getHealthCheck
- LOG.info("Successful exit from getNearRT-RICs ");
-
- return Futures.immediateFuture(rpcResult);
-}
-
-// RPC getHealthCheck
-
- @Override
- public ListenableFuture<RpcResult<GetHealthCheckOutput>> getHealthCheck(
- GetHealthCheckInput input) {
- final String svcOperation = "getHealthCheck";
-
- Properties parms = new Properties();
- GetHealthCheckOutputBuilder serviceDataBuilder = new GetHealthCheckOutputBuilder();
-
- LOG.info( "Reached RPC getHealthCheck");
-
- LOG.info( svcOperation +" called." );
-
- if(input == null ) {
- LOG.debug("exiting " +svcOperation+ " because of invalid input");
- serviceDataBuilder.setResponseCode("Input is null");
- RpcResult<GetHealthCheckOutput> rpcResult =
- RpcResultBuilder.<GetHealthCheckOutput> status(true).withResult(serviceDataBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // add input to parms
- LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
- GetHealthCheckInputBuilder inputBuilder = new GetHealthCheckInputBuilder(input);
- MdsalHelper.toProperties(parms, inputBuilder.build());
-
- LOG.info("Printing SLI parameters to be passed");
-
- // iterate properties file to get key-value pairs
- for (String key : parms.stringPropertyNames()) {
- String value = parms.getProperty(key);
- LOG.info("The SLI parameter in " + key + " is: " + value);
- }
-
- // Call SLI sync method
- try
- {
- if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation , null, "sync"))
- {
- LOG.info( "A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
- try
- {
- A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
- }
- catch (Exception e)
- {
- LOG.error("Caught exception executing service logic for "+ svcOperation, e);
- serviceDataBuilder.setResponseCode("500");
- }
- } else {
- LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
- serviceDataBuilder.setResponseCode("503");
- }
- }
- catch (Exception e)
- {
- LOG.error("Caught exception looking for service logic", e);
- serviceDataBuilder.setResponseCode("500");
- }
-
- String errorCode = serviceDataBuilder.getResponseCode();
-
- if (!("0".equals(errorCode) || "200".equals(errorCode))) {
- LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
- } else {
- LOG.info("Returned SUCCESS for "+svcOperation+" ");
- serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetHealthCheck. " );
- }
-
- RpcResult<GetHealthCheckOutput> rpcResult =
- RpcResultBuilder.<GetHealthCheckOutput> status(true).withResult(serviceDataBuilder.build()).build();
-
- LOG.info("Successful exit from getHealthCheck ");
-
- return Futures.immediateFuture(rpcResult);
- }
-
-// RPC getPolicyTypes
-
-@Override
-public ListenableFuture<RpcResult<GetPolicyTypesOutput>> getPolicyTypes(
- GetPolicyTypesInput input) {
- final String svcOperation = "getPolicyTypes";
-
- Properties parms = new Properties();
- GetPolicyTypesOutputBuilder serviceDataBuilder = new GetPolicyTypesOutputBuilder();
-
- LOG.info( "Reached RPC getPolicyTypes");
-
- LOG.info( svcOperation +" called." );
-
- if(input == null ) {
- LOG.debug("exiting " +svcOperation+ " because of invalid input");
- serviceDataBuilder.setResponseCode("Input is null");
- RpcResult<GetPolicyTypesOutput> rpcResult =
- RpcResultBuilder.<GetPolicyTypesOutput> status(true).withResult(serviceDataBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // add input to parms
- LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
- GetPolicyTypesInputBuilder inputBuilder = new GetPolicyTypesInputBuilder(input);
- MdsalHelper.toProperties(parms, inputBuilder.build());
-
- LOG.info("Printing SLI parameters to be passed");
-
- // iterate properties file to get key-value pairs
- for (String key : parms.stringPropertyNames()) {
- String value = parms.getProperty(key);
- LOG.info("The SLI parameter in " + key + " is: " + value);
- }
-
- // Call SLI sync method
- try
- {
- if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation , null, "sync"))
- {
- LOG.info( "A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
- try
- {
- A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
- }
- catch (Exception e)
- {
- LOG.error("Caught exception executing service logic for "+ svcOperation, e);
- serviceDataBuilder.setResponseCode("500");
- }
- } else {
- LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
- serviceDataBuilder.setResponseCode("503");
+ @Override
+ public ListenableFuture<RpcResult<GetHealthCheckOutput>> getHealthCheck(GetHealthCheckInput input) {
+ final String svcOperation = "getHealthCheck";
+
+ Properties parms = new Properties();
+ GetHealthCheckOutputBuilder serviceDataBuilder = (GetHealthCheckOutputBuilder) getServiceData(GET_HEALTH_CHECK);
+
+ LOG.info("Reached RPC getHealthCheck");
+
+ LOG.info(svcOperation + " called.");
+
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<GetHealthCheckOutput> rpcResult =
+ RpcResultBuilder.<GetHealthCheckOutput>status(true).withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ GetHealthCheckInputBuilder inputBuilder = new GetHealthCheckInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+
+ LOG.info("Printing SLI parameters to be passed");
+
+ // iterate properties file to get key-value pairs
+ for (String key : parms.stringPropertyNames()) {
+ String value = parms.getProperty(key);
+ LOG.info("The SLI parameter in " + key + " is: " + value);
+ }
+
+ // Call SLI sync method
+ try {
+ if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
+ LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
+ try {
+ A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service logic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service logic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetHealthCheck. ");
+ }
+
+ RpcResult<GetHealthCheckOutput> rpcResult =
+ RpcResultBuilder.<GetHealthCheckOutput>status(true).withResult(serviceDataBuilder.build()).build();
+
+ LOG.info("Successful exit from getHealthCheck ");
+
+ return Futures.immediateFuture(rpcResult);
}
- }
- catch (Exception e)
- {
- LOG.error("Caught exception looking for service logic", e);
- serviceDataBuilder.setResponseCode("500");
- }
-
- String errorCode = serviceDataBuilder.getResponseCode();
-
- if (!("0".equals(errorCode) || "200".equals(errorCode))) {
- LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
- } else {
- LOG.info("Returned SUCCESS for "+svcOperation+" ");
- serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetPolicyTypes ");
- }
-
- RpcResult<GetPolicyTypesOutput> rpcResult =
- RpcResultBuilder.<GetPolicyTypesOutput> status(true).withResult(serviceDataBuilder.build()).build();
-
- LOG.info("Successful exit from getPolicyTypes ");
-
- return Futures.immediateFuture(rpcResult);
-}
-
-// RPC createPolicyType
-@Override
-public ListenableFuture<RpcResult<CreatePolicyTypeOutput>> createPolicyType(
- CreatePolicyTypeInput input) {
- final String svcOperation = "createPolicyType";
+ // RPC getPolicyTypes
- Properties parms = new Properties();
- CreatePolicyTypeOutputBuilder serviceDataBuilder = new CreatePolicyTypeOutputBuilder();
-
- LOG.info( "Reached RPC createPolicyType");
-
- LOG.info( svcOperation +" called." );
-
- if(input == null ) {
- LOG.debug("exiting " +svcOperation+ " because of invalid input");
- serviceDataBuilder.setResponseCode("Input is null");
- RpcResult<CreatePolicyTypeOutput> rpcResult =
- RpcResultBuilder.<CreatePolicyTypeOutput> status(true).withResult(serviceDataBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // add input to parms
- LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
- CreatePolicyTypeInputBuilder inputBuilder = new CreatePolicyTypeInputBuilder(input);
- MdsalHelper.toProperties(parms, inputBuilder.build());
-
- LOG.info("Printing SLI parameters to be passed");
-
- // iterate properties file to get key-value pairs
- for (String key : parms.stringPropertyNames()) {
- String value = parms.getProperty(key);
- LOG.info("The SLI parameter in " + key + " is: " + value);
- }
-
- // Call SLI sync method
- try
- {
- if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation , null, "sync"))
- {
- LOG.info( "A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
- try
- {
- A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
- }
- catch (Exception e)
- {
- LOG.error("Caught exception executing service logic for "+ svcOperation, e);
- serviceDataBuilder.setResponseCode("500");
- }
- } else {
- LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
- serviceDataBuilder.setResponseCode("503");
+ @Override
+ public ListenableFuture<RpcResult<GetPolicyTypesOutput>> getPolicyTypes(GetPolicyTypesInput input) {
+ final String svcOperation = "getPolicyTypes";
+
+ Properties parms = new Properties();
+ GetPolicyTypesOutputBuilder serviceDataBuilder = (GetPolicyTypesOutputBuilder) getServiceData(GET_POLICY_TYPES);
+
+ LOG.info("Reached RPC getPolicyTypes");
+
+ LOG.info(svcOperation + " called.");
+
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<GetPolicyTypesOutput> rpcResult =
+ RpcResultBuilder.<GetPolicyTypesOutput>status(true).withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ GetPolicyTypesInputBuilder inputBuilder = new GetPolicyTypesInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+
+ LOG.info("Printing SLI parameters to be passed");
+
+ // iterate properties file to get key-value pairs
+ for (String key : parms.stringPropertyNames()) {
+ String value = parms.getProperty(key);
+ LOG.info("The SLI parameter in " + key + " is: " + value);
+ }
+
+ // Call SLI sync method
+ try {
+ if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
+ LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
+ try {
+ A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service logic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service logic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetPolicyTypes ");
+ }
+
+ RpcResult<GetPolicyTypesOutput> rpcResult =
+ RpcResultBuilder.<GetPolicyTypesOutput>status(true).withResult(serviceDataBuilder.build()).build();
+
+ LOG.info("Successful exit from getPolicyTypes ");
+
+ return Futures.immediateFuture(rpcResult);
}
- }
- catch (Exception e)
- {
- LOG.error("Caught exception looking for service logic", e);
- serviceDataBuilder.setResponseCode("500");
- }
-
- String errorCode = serviceDataBuilder.getResponseCode();
-
- if (!("0".equals(errorCode) || "200".equals(errorCode))) {
- LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
- } else {
- LOG.info("Returned SUCCESS for "+svcOperation+" ");
- serviceDataBuilder.setResponseCode("A1 Adapter Executed for CreatePolicyType" );
- }
- RpcResult<CreatePolicyTypeOutput> rpcResult =
- RpcResultBuilder.<CreatePolicyTypeOutput> status(true).withResult(serviceDataBuilder.build()).build();
+ // RPC createPolicyType
- LOG.info("Successful exit from createPolicyType ");
-
- return Futures.immediateFuture(rpcResult);
-}
-
-// RPC getPolicyType
-
-@Override
-public ListenableFuture<RpcResult<GetPolicyTypeOutput>> getPolicyType(
- GetPolicyTypeInput input) {
- final String svcOperation = "getPolicyType";
-
- Properties parms = new Properties();
- GetPolicyTypeOutputBuilder serviceDataBuilder = new GetPolicyTypeOutputBuilder();
-
- LOG.info( "Reached RPC getPolicyType");
-
- LOG.info( svcOperation +" called." );
-
- if(input == null ) {
- LOG.debug("exiting " +svcOperation+ " because of invalid input");
- serviceDataBuilder.setResponseCode("Input is null");
- RpcResult<GetPolicyTypeOutput> rpcResult =
- RpcResultBuilder.<GetPolicyTypeOutput> status(true).withResult(serviceDataBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // add input to parms
- LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
- GetPolicyTypeInputBuilder inputBuilder = new GetPolicyTypeInputBuilder(input);
- MdsalHelper.toProperties(parms, inputBuilder.build());
-
- LOG.info("Printing SLI parameters to be passed");
-
- // iterate properties file to get key-value pairs
- for (String key : parms.stringPropertyNames()) {
- String value = parms.getProperty(key);
- LOG.info("The SLI parameter in " + key + " is: " + value);
- }
-
- // Call SLI sync method
- try
- {
- if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation , null, "sync"))
- {
- LOG.info( "A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
- try
- {
- A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
- }
- catch (Exception e)
- {
- LOG.error("Caught exception executing service logic for "+ svcOperation, e);
- serviceDataBuilder.setResponseCode("500");
- }
- } else {
- LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
- serviceDataBuilder.setResponseCode("503");
+ @Override
+ public ListenableFuture<RpcResult<CreatePolicyTypeOutput>> createPolicyType(CreatePolicyTypeInput input) {
+ final String svcOperation = "createPolicyType";
+
+ Properties parms = new Properties();
+ CreatePolicyTypeOutputBuilder serviceDataBuilder =
+ (CreatePolicyTypeOutputBuilder) getServiceData(CREATE_POLICY_TYPE);
+
+ LOG.info("Reached RPC createPolicyType");
+
+ LOG.info(svcOperation + " called.");
+
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<CreatePolicyTypeOutput> rpcResult = RpcResultBuilder.<CreatePolicyTypeOutput>status(true)
+ .withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ CreatePolicyTypeInputBuilder inputBuilder = new CreatePolicyTypeInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+
+ LOG.info("Printing SLI parameters to be passed");
+
+ // iterate properties file to get key-value pairs
+ for (String key : parms.stringPropertyNames()) {
+ String value = parms.getProperty(key);
+ LOG.info("The SLI parameter in " + key + " is: " + value);
+ }
+
+ // Call SLI sync method
+ try {
+ if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
+ LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
+ try {
+ A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service logic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service logic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ serviceDataBuilder.setResponseCode("A1 Adapter Executed for CreatePolicyType");
+ }
+
+ RpcResult<CreatePolicyTypeOutput> rpcResult =
+ RpcResultBuilder.<CreatePolicyTypeOutput>status(true).withResult(serviceDataBuilder.build()).build();
+
+ LOG.info("Successful exit from createPolicyType ");
+
+ return Futures.immediateFuture(rpcResult);
}
- }
- catch (Exception e)
- {
- LOG.error("Caught exception looking for service logic", e);
- serviceDataBuilder.setResponseCode("500");
- }
-
- String errorCode = serviceDataBuilder.getResponseCode();
-
- if (!("0".equals(errorCode) || "200".equals(errorCode))) {
- LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
- } else {
- LOG.info("Returned SUCCESS for "+svcOperation+" ");
- serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetPolicyType. " );
- }
-
- RpcResult<GetPolicyTypeOutput> rpcResult =
- RpcResultBuilder.<GetPolicyTypeOutput> status(true).withResult(serviceDataBuilder.build()).build();
-
- LOG.info("Successful exit from getPolicyType ");
-
- return Futures.immediateFuture(rpcResult);
-}
-
-// RPC deletePolicyType
-
-@Override
-public ListenableFuture<RpcResult<DeletePolicyTypeOutput>> deletePolicyType(
- DeletePolicyTypeInput input) {
- final String svcOperation = "deletePolicyType";
-
- Properties parms = new Properties();
- DeletePolicyTypeOutputBuilder serviceDataBuilder = new DeletePolicyTypeOutputBuilder();
- LOG.info( "Reached RPC deletePolicyType");
+ // RPC getPolicyType
- LOG.info( svcOperation +" called." );
-
- if(input == null ) {
- LOG.debug("exiting " +svcOperation+ " because of invalid input");
- serviceDataBuilder.setResponseCode("Input is null");
- RpcResult<DeletePolicyTypeOutput> rpcResult =
- RpcResultBuilder.<DeletePolicyTypeOutput> status(true).withResult(serviceDataBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // add input to parms
- LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
- DeletePolicyTypeInputBuilder inputBuilder = new DeletePolicyTypeInputBuilder(input);
- MdsalHelper.toProperties(parms, inputBuilder.build());
-
- LOG.info("Printing SLI parameters to be passed");
-
- // iterate properties file to get key-value pairs
- for (String key : parms.stringPropertyNames()) {
- String value = parms.getProperty(key);
- LOG.info("The SLI parameter in " + key + " is: " + value);
- }
-
- // Call SLI sync method
- try
- {
- if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation , null, "sync"))
- {
- LOG.info( "A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
- try
- {
- A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
- }
- catch (Exception e)
- {
- LOG.error("Caught exception executing service logic for "+ svcOperation, e);
- serviceDataBuilder.setResponseCode("500");
- }
- } else {
- LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
- serviceDataBuilder.setResponseCode("503");
+ @Override
+ public ListenableFuture<RpcResult<GetPolicyTypeOutput>> getPolicyType(GetPolicyTypeInput input) {
+ final String svcOperation = "getPolicyType";
+
+ Properties parms = new Properties();
+ GetPolicyTypeOutputBuilder serviceDataBuilder = (GetPolicyTypeOutputBuilder) getServiceData(GET_POLICY_TYPE);
+
+ LOG.info("Reached RPC getPolicyType");
+
+ LOG.info(svcOperation + " called.");
+
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<GetPolicyTypeOutput> rpcResult =
+ RpcResultBuilder.<GetPolicyTypeOutput>status(true).withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ GetPolicyTypeInputBuilder inputBuilder = new GetPolicyTypeInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+
+ LOG.info("Printing SLI parameters to be passed");
+
+ // iterate properties file to get key-value pairs
+ for (String key : parms.stringPropertyNames()) {
+ String value = parms.getProperty(key);
+ LOG.info("The SLI parameter in " + key + " is: " + value);
+ }
+
+ // Call SLI sync method
+ try {
+ if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
+ LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
+ try {
+ A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service logic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service logic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetPolicyType. ");
+ }
+
+ RpcResult<GetPolicyTypeOutput> rpcResult =
+ RpcResultBuilder.<GetPolicyTypeOutput>status(true).withResult(serviceDataBuilder.build()).build();
+
+ LOG.info("Successful exit from getPolicyType ");
+
+ return Futures.immediateFuture(rpcResult);
}
- }
- catch (Exception e)
- {
- LOG.error("Caught exception looking for service logic", e);
- serviceDataBuilder.setResponseCode("500");
- }
-
- String errorCode = serviceDataBuilder.getResponseCode();
-
- if (!("0".equals(errorCode) || "200".equals(errorCode))) {
- LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
- } else {
- LOG.info("Returned SUCCESS for "+svcOperation+" ");
- serviceDataBuilder.setResponseCode("A1 Adapter Executed for DeletePolicyType ");
- }
-
- RpcResult<DeletePolicyTypeOutput> rpcResult =
- RpcResultBuilder.<DeletePolicyTypeOutput> status(true).withResult(serviceDataBuilder.build()).build();
-
- LOG.info("Successful exit from deletePolicyType ");
- return Futures.immediateFuture(rpcResult);
-}
-
-// RPC getPolicyInstances
-
-@Override
-public ListenableFuture<RpcResult<GetPolicyInstancesOutput>> getPolicyInstances(
- GetPolicyInstancesInput input) {
- final String svcOperation = "getPolicyInstances";
-
- Properties parms = new Properties();
- GetPolicyInstancesOutputBuilder serviceDataBuilder = new GetPolicyInstancesOutputBuilder();
-
- LOG.info( "Reached RPC getPolicyInstances");
-
- LOG.info( svcOperation +" called." );
-
- if(input == null ) {
- LOG.debug("exiting " +svcOperation+ " because of invalid input");
- serviceDataBuilder.setResponseCode("Input is null");
- RpcResult<GetPolicyInstancesOutput> rpcResult =
- RpcResultBuilder.<GetPolicyInstancesOutput> status(true).withResult(serviceDataBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // add input to parms
- LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
- GetPolicyInstancesInputBuilder inputBuilder = new GetPolicyInstancesInputBuilder(input);
- MdsalHelper.toProperties(parms, inputBuilder.build());
-
- LOG.info("Printing SLI parameters to be passed");
-
- // iterate properties file to get key-value pairs
- for (String key : parms.stringPropertyNames()) {
- String value = parms.getProperty(key);
- LOG.info("The SLI parameter in " + key + " is: " + value);
- }
+ // RPC deletePolicyType
- // Call SLI sync method
- try
- {
- if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation , null, "sync"))
- {
- LOG.info( "A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
- try
- {
- A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
- }
- catch (Exception e)
- {
- LOG.error("Caught exception executing service logic for "+ svcOperation, e);
- serviceDataBuilder.setResponseCode("500");
- }
- } else {
- LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
- serviceDataBuilder.setResponseCode("503");
+ @Override
+ public ListenableFuture<RpcResult<DeletePolicyTypeOutput>> deletePolicyType(DeletePolicyTypeInput input) {
+ final String svcOperation = "deletePolicyType";
+
+ Properties parms = new Properties();
+ DeletePolicyTypeOutputBuilder serviceDataBuilder =
+ (DeletePolicyTypeOutputBuilder) getServiceData(DELETE_POLICY_TYPE);
+
+ LOG.info("Reached RPC deletePolicyType");
+
+ LOG.info(svcOperation + " called.");
+
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<DeletePolicyTypeOutput> rpcResult = RpcResultBuilder.<DeletePolicyTypeOutput>status(true)
+ .withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ DeletePolicyTypeInputBuilder inputBuilder = new DeletePolicyTypeInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+
+ LOG.info("Printing SLI parameters to be passed");
+
+ // iterate properties file to get key-value pairs
+ for (String key : parms.stringPropertyNames()) {
+ String value = parms.getProperty(key);
+ LOG.info("The SLI parameter in " + key + " is: " + value);
+ }
+
+ // Call SLI sync method
+ try {
+ if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
+ LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
+ try {
+ A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service logic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service logic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ serviceDataBuilder.setResponseCode("A1 Adapter Executed for DeletePolicyType ");
+ }
+
+ RpcResult<DeletePolicyTypeOutput> rpcResult =
+ RpcResultBuilder.<DeletePolicyTypeOutput>status(true).withResult(serviceDataBuilder.build()).build();
+
+ LOG.info("Successful exit from deletePolicyType ");
+
+ return Futures.immediateFuture(rpcResult);
}
- }
- catch (Exception e)
- {
- LOG.error("Caught exception looking for service logic", e);
- serviceDataBuilder.setResponseCode("500");
- }
-
- String errorCode = serviceDataBuilder.getResponseCode();
-
- if (!("0".equals(errorCode) || "200".equals(errorCode))) {
- LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
- } else {
- LOG.info("Returned SUCCESS for "+svcOperation+" ");
- serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetPolicyInstances " );
- }
-
- RpcResult<GetPolicyInstancesOutput> rpcResult =
- RpcResultBuilder.<GetPolicyInstancesOutput> status(true).withResult(serviceDataBuilder.build()).build();
-
- LOG.info("Successful exit from getPolicyInstances ");
-
- return Futures.immediateFuture(rpcResult);
-}
-
-
-// RPC createPolicyInstance
-
-@Override
-public ListenableFuture<RpcResult<CreatePolicyInstanceOutput>> createPolicyInstance(
- CreatePolicyInstanceInput input) {
- final String svcOperation = "createPolicyInstance";
-
- Properties parms = new Properties();
- CreatePolicyInstanceOutputBuilder serviceDataBuilder = new CreatePolicyInstanceOutputBuilder();
-
- LOG.info( "Reached RPC createPolicyInstance");
- LOG.info( svcOperation +" called." );
+ // RPC getPolicyInstances
- if(input == null ) {
- LOG.debug("exiting " +svcOperation+ " because of invalid input");
- serviceDataBuilder.setResponseCode("Input is null");
- RpcResult<CreatePolicyInstanceOutput> rpcResult =
- RpcResultBuilder.<CreatePolicyInstanceOutput> status(true).withResult(serviceDataBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // add input to parms
- LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
- CreatePolicyInstanceInputBuilder inputBuilder = new CreatePolicyInstanceInputBuilder(input);
- MdsalHelper.toProperties(parms, inputBuilder.build());
-
- LOG.info("Printing SLI parameters to be passed");
-
- // iterate properties file to get key-value pairs
- for (String key : parms.stringPropertyNames()) {
- String value = parms.getProperty(key);
- LOG.info("The SLI parameter in " + key + " is: " + value);
- }
-
- // Call SLI sync method
- try
- {
- if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation , null, "sync"))
- {
- LOG.info( "A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
- try
- {
- A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
- }
- catch (Exception e)
- {
- LOG.error("Caught exception executing service logic for "+ svcOperation, e);
- serviceDataBuilder.setResponseCode("500");
- }
- } else {
- LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
- serviceDataBuilder.setResponseCode("503");
+ @Override
+ public ListenableFuture<RpcResult<GetPolicyInstancesOutput>> getPolicyInstances(GetPolicyInstancesInput input) {
+ final String svcOperation = "getPolicyInstances";
+
+ Properties parms = new Properties();
+ GetPolicyInstancesOutputBuilder serviceDataBuilder =
+ (GetPolicyInstancesOutputBuilder) getServiceData(GET_POLICY_INSTANCES);
+
+ LOG.info("Reached RPC getPolicyInstances");
+
+ LOG.info(svcOperation + " called.");
+
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<GetPolicyInstancesOutput> rpcResult = RpcResultBuilder.<GetPolicyInstancesOutput>status(true)
+ .withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ GetPolicyInstancesInputBuilder inputBuilder = new GetPolicyInstancesInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+
+ LOG.info("Printing SLI parameters to be passed");
+
+ // iterate properties file to get key-value pairs
+ for (String key : parms.stringPropertyNames()) {
+ String value = parms.getProperty(key);
+ LOG.info("The SLI parameter in " + key + " is: " + value);
+ }
+
+ // Call SLI sync method
+ try {
+ if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
+ LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
+ try {
+ A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service logic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service logic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetPolicyInstances ");
+ }
+
+ RpcResult<GetPolicyInstancesOutput> rpcResult =
+ RpcResultBuilder.<GetPolicyInstancesOutput>status(true).withResult(serviceDataBuilder.build()).build();
+
+ LOG.info("Successful exit from getPolicyInstances ");
+
+ return Futures.immediateFuture(rpcResult);
}
- }
- catch (Exception e)
- {
- LOG.error("Caught exception looking for service logic", e);
- serviceDataBuilder.setResponseCode("500");
- }
- String errorCode = serviceDataBuilder.getResponseCode();
-
- if (!("0".equals(errorCode) || "200".equals(errorCode))) {
- LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
- } else {
- LOG.info("Returned SUCCESS for "+svcOperation+" ");
- serviceDataBuilder.setResponseCode("A1 Adapter Executed for CreatePolicyInstance. " );
- }
-
- RpcResult<CreatePolicyInstanceOutput> rpcResult =
- RpcResultBuilder.<CreatePolicyInstanceOutput> status(true).withResult(serviceDataBuilder.build()).build();
-
- LOG.info("Successful exit from createPolicyInstance ");
-
- return Futures.immediateFuture(rpcResult);
-}
+ // RPC createPolicyInstance
-
-// RPC getPolicyInstance
-
-@Override
-public ListenableFuture<RpcResult<GetPolicyInstanceOutput>> getPolicyInstance(
- GetPolicyInstanceInput input) {
- final String svcOperation = "getPolicyInstance";
-
- Properties parms = new Properties();
- GetPolicyInstanceOutputBuilder serviceDataBuilder = new GetPolicyInstanceOutputBuilder();
-
- LOG.info( "Reached RPC getPolicyInstance");
-
- LOG.info( svcOperation +" called." );
-
- if(input == null ) {
- LOG.debug("exiting " +svcOperation+ " because of invalid input");
- serviceDataBuilder.setResponseCode("Input is null");
- RpcResult<GetPolicyInstanceOutput> rpcResult =
- RpcResultBuilder.<GetPolicyInstanceOutput> status(true).withResult(serviceDataBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // add input to parms
- LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
- GetPolicyInstanceInputBuilder inputBuilder = new GetPolicyInstanceInputBuilder(input);
- MdsalHelper.toProperties(parms, inputBuilder.build());
-
- LOG.info("Printing SLI parameters to be passed");
-
- // iterate properties file to get key-value pairs
- for (String key : parms.stringPropertyNames()) {
- String value = parms.getProperty(key);
- LOG.info("The SLI parameter in " + key + " is: " + value);
- }
-
- // Call SLI sync method
- try
- {
- if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation , null, "sync"))
- {
- LOG.info( "A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
- try
- {
- A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
- }
- catch (Exception e)
- {
- LOG.error("Caught exception executing service logic for "+ svcOperation, e);
- serviceDataBuilder.setResponseCode("500");
- }
- } else {
- LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
- serviceDataBuilder.setResponseCode("503");
+ @Override
+ public ListenableFuture<RpcResult<CreatePolicyInstanceOutput>> createPolicyInstance(
+ CreatePolicyInstanceInput input) {
+ final String svcOperation = "createPolicyInstance";
+
+ Properties parms = new Properties();
+ CreatePolicyInstanceOutputBuilder serviceDataBuilder =
+ (CreatePolicyInstanceOutputBuilder) getServiceData(CREATE_POLICY_INSTANCES);
+
+ LOG.info("Reached RPC createPolicyInstance");
+
+ LOG.info(svcOperation + " called.");
+
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<CreatePolicyInstanceOutput> rpcResult = RpcResultBuilder.<CreatePolicyInstanceOutput>status(true)
+ .withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ CreatePolicyInstanceInputBuilder inputBuilder = new CreatePolicyInstanceInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+
+ LOG.info("Printing SLI parameters to be passed");
+
+ // iterate properties file to get key-value pairs
+ for (String key : parms.stringPropertyNames()) {
+ String value = parms.getProperty(key);
+ LOG.info("The SLI parameter in " + key + " is: " + value);
+ }
+
+ // Call SLI sync method
+ try {
+ if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
+ LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
+ try {
+ A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service logic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service logic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ serviceDataBuilder.setResponseCode("A1 Adapter Executed for CreatePolicyInstance. ");
+ }
+
+ RpcResult<CreatePolicyInstanceOutput> rpcResult = RpcResultBuilder.<CreatePolicyInstanceOutput>status(true)
+ .withResult(serviceDataBuilder.build()).build();
+
+ LOG.info("Successful exit from createPolicyInstance ");
+
+ return Futures.immediateFuture(rpcResult);
}
- }
- catch (Exception e)
- {
- LOG.error("Caught exception looking for service logic", e);
- serviceDataBuilder.setResponseCode("500");
- }
-
- String errorCode = serviceDataBuilder.getResponseCode();
-
- if (!("0".equals(errorCode) || "200".equals(errorCode))) {
- LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
- } else {
- LOG.info("Returned SUCCESS for "+svcOperation+" ");
- serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetPolicyInstance. " );
- }
-
- RpcResult<GetPolicyInstanceOutput> rpcResult =
- RpcResultBuilder.<GetPolicyInstanceOutput> status(true).withResult(serviceDataBuilder.build()).build();
-
- LOG.info("Successful exit from getPolicyInstance ");
-
- return Futures.immediateFuture(rpcResult);
-}
-
-
-
-// RPC deletePolicyInstance
-
-@Override
-public ListenableFuture<RpcResult<DeletePolicyInstanceOutput>> deletePolicyInstance(
- DeletePolicyInstanceInput input) {
- final String svcOperation = "deletePolicyInstance";
- Properties parms = new Properties();
- DeletePolicyInstanceOutputBuilder serviceDataBuilder = new DeletePolicyInstanceOutputBuilder();
- LOG.info( "Reached RPC deletePolicyInstance");
- LOG.info( svcOperation +" called." );
+ // RPC getPolicyInstance
- if(input == null ) {
- LOG.debug("exiting " +svcOperation+ " because of invalid input");
- serviceDataBuilder.setResponseCode("Input is null");
- RpcResult<DeletePolicyInstanceOutput> rpcResult =
- RpcResultBuilder.<DeletePolicyInstanceOutput> status(true).withResult(serviceDataBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
-
- // add input to parms
- LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
- DeletePolicyInstanceInputBuilder inputBuilder = new DeletePolicyInstanceInputBuilder(input);
- MdsalHelper.toProperties(parms, inputBuilder.build());
-
- LOG.info("Printing SLI parameters to be passed");
-
- // iterate properties file to get key-value pairs
- for (String key : parms.stringPropertyNames()) {
- String value = parms.getProperty(key);
- LOG.info("The SLI parameter in " + key + " is: " + value);
- }
-
- // Call SLI sync method
- try
- {
- if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation , null, "sync"))
- {
- LOG.info( "A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
- try
- {
- A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
- }
- catch (Exception e)
- {
- LOG.error("Caught exception executing service logic for "+ svcOperation, e);
- serviceDataBuilder.setResponseCode("500");
- }
- } else {
- LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
- serviceDataBuilder.setResponseCode("503");
+ @Override
+ public ListenableFuture<RpcResult<GetPolicyInstanceOutput>> getPolicyInstance(GetPolicyInstanceInput input) {
+ final String svcOperation = "getPolicyInstance";
+
+ Properties parms = new Properties();
+ GetPolicyInstanceOutputBuilder serviceDataBuilder =
+ (GetPolicyInstanceOutputBuilder) getServiceData(GET_POLICY_INSTANCE);
+
+ LOG.info("Reached RPC getPolicyInstance");
+
+ LOG.info(svcOperation + " called.");
+
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<GetPolicyInstanceOutput> rpcResult = RpcResultBuilder.<GetPolicyInstanceOutput>status(true)
+ .withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ GetPolicyInstanceInputBuilder inputBuilder = new GetPolicyInstanceInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+
+ LOG.info("Printing SLI parameters to be passed");
+
+ // iterate properties file to get key-value pairs
+ for (String key : parms.stringPropertyNames()) {
+ String value = parms.getProperty(key);
+ LOG.info("The SLI parameter in " + key + " is: " + value);
+ }
+
+ // Call SLI sync method
+ try {
+ if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
+ LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
+ try {
+ A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service logic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service logic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetPolicyInstance. ");
+ }
+
+ RpcResult<GetPolicyInstanceOutput> rpcResult =
+ RpcResultBuilder.<GetPolicyInstanceOutput>status(true).withResult(serviceDataBuilder.build()).build();
+
+ LOG.info("Successful exit from getPolicyInstance ");
+
+ return Futures.immediateFuture(rpcResult);
}
- }
- catch (Exception e)
- {
- LOG.error("Caught exception looking for service logic", e);
- serviceDataBuilder.setResponseCode("500");
- }
-
- String errorCode = serviceDataBuilder.getResponseCode();
-
- if (!("0".equals(errorCode) || "200".equals(errorCode))) {
- LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
- } else {
- LOG.info("Returned SUCCESS for "+svcOperation+" ");
- serviceDataBuilder.setResponseCode("A1 Adapter Executed for DeletePolicyInstance. ");
- }
-
- RpcResult<DeletePolicyInstanceOutput> rpcResult =
- RpcResultBuilder.<DeletePolicyInstanceOutput> status(true).withResult(serviceDataBuilder.build()).build();
-
- LOG.info("Successful exit from deletePolicyInstance ");
-
- return Futures.immediateFuture(rpcResult);
-}
-
-
-
-// RPC getStatus
-
-@Override
-public ListenableFuture<RpcResult<GetStatusOutput>> getStatus(
- GetStatusInput input) {
- final String svcOperation = "getStatus";
-
- Properties parms = new Properties();
- GetStatusOutputBuilder serviceDataBuilder = new GetStatusOutputBuilder();
- LOG.info( "Reached RPC getStatus");
- LOG.info( svcOperation +" called." );
- if(input == null ) {
- LOG.debug("exiting " +svcOperation+ " because of invalid input");
- serviceDataBuilder.setResponseCode("Input is null");
- RpcResult<GetStatusOutput> rpcResult =
- RpcResultBuilder.<GetStatusOutput> status(true).withResult(serviceDataBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
+ // RPC deletePolicyInstance
- // add input to parms
- LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
- GetStatusInputBuilder inputBuilder = new GetStatusInputBuilder(input);
- MdsalHelper.toProperties(parms, inputBuilder.build());
-
- LOG.info("Printing SLI parameters to be passed");
-
- // iterate properties file to get key-value pairs
- for (String key : parms.stringPropertyNames()) {
- String value = parms.getProperty(key);
- LOG.info("The SLI parameter in " + key + " is: " + value);
- }
-
- // Call SLI sync method
- try
- {
- if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation , null, "sync"))
- {
- LOG.info( "A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
- try
- {
- A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
- }
- catch (Exception e)
- {
- LOG.error("Caught exception executing service logic for "+ svcOperation, e);
- serviceDataBuilder.setResponseCode("500");
- }
- } else {
- LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
- serviceDataBuilder.setResponseCode("503");
+ @Override
+ public ListenableFuture<RpcResult<DeletePolicyInstanceOutput>> deletePolicyInstance(
+ DeletePolicyInstanceInput input) {
+ final String svcOperation = "deletePolicyInstance";
+
+ Properties parms = new Properties();
+ DeletePolicyInstanceOutputBuilder serviceDataBuilder =
+ (DeletePolicyInstanceOutputBuilder) getServiceData(DELETE_POLICY_INSTANCE);
+
+ LOG.info("Reached RPC deletePolicyInstance");
+
+ LOG.info(svcOperation + " called.");
+
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<DeletePolicyInstanceOutput> rpcResult = RpcResultBuilder.<DeletePolicyInstanceOutput>status(true)
+ .withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ DeletePolicyInstanceInputBuilder inputBuilder = new DeletePolicyInstanceInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+
+ LOG.info("Printing SLI parameters to be passed");
+
+ // iterate properties file to get key-value pairs
+ for (String key : parms.stringPropertyNames()) {
+ String value = parms.getProperty(key);
+ LOG.info("The SLI parameter in " + key + " is: " + value);
+ }
+
+ // Call SLI sync method
+ try {
+ if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
+ LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
+ try {
+ A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service logic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service logic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ serviceDataBuilder.setResponseCode("A1 Adapter Executed for DeletePolicyInstance. ");
+ }
+
+ RpcResult<DeletePolicyInstanceOutput> rpcResult = RpcResultBuilder.<DeletePolicyInstanceOutput>status(true)
+ .withResult(serviceDataBuilder.build()).build();
+
+ LOG.info("Successful exit from deletePolicyInstance ");
+
+ return Futures.immediateFuture(rpcResult);
}
- }
- catch (Exception e)
- {
- LOG.error("Caught exception looking for service logic", e);
- serviceDataBuilder.setResponseCode("500");
- }
- String errorCode = serviceDataBuilder.getResponseCode();
- if (!("0".equals(errorCode) || "200".equals(errorCode))) {
- LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
- } else {
- LOG.info("Returned SUCCESS for "+svcOperation+" ");
- serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetStatus. " );
- }
- RpcResult<GetStatusOutput> rpcResult =
- RpcResultBuilder.<GetStatusOutput> status(true).withResult(serviceDataBuilder.build()).build();
+ // RPC getStatus
- LOG.info("Successful exit from getStatus ");
-
- return Futures.immediateFuture(rpcResult);
-}
-
-
-// RPC notifyPolicyEnforcementUpdate
-
-@Override
-public ListenableFuture<RpcResult<NotifyPolicyEnforcementUpdateOutput>> notifyPolicyEnforcementUpdate(
- NotifyPolicyEnforcementUpdateInput input) {
- final String svcOperation = "notifyPolicyEnforcementUpdate";
-
- Properties parms = new Properties();
- NotifyPolicyEnforcementUpdateOutputBuilder serviceDataBuilder = new NotifyPolicyEnforcementUpdateOutputBuilder();
-
- LOG.info( "Reached RPC notifyPolicyEnforcementUpdate");
-
- LOG.info( svcOperation +" called." );
-
- if(input == null ) {
- LOG.debug("exiting " +svcOperation+ " because of invalid input");
- serviceDataBuilder.setResponseCode("Input is null");
- RpcResult<NotifyPolicyEnforcementUpdateOutput> rpcResult =
- RpcResultBuilder.<NotifyPolicyEnforcementUpdateOutput> status(true).withResult(serviceDataBuilder.build()).build();
- return Futures.immediateFuture(rpcResult);
- }
+ @Override
+ public ListenableFuture<RpcResult<GetStatusOutput>> getStatus(GetStatusInput input) {
+ final String svcOperation = "getStatus";
+
+ Properties parms = new Properties();
+ GetStatusOutputBuilder serviceDataBuilder = (GetStatusOutputBuilder) getServiceData(GET_STATUS);
+
+ LOG.info("Reached RPC getStatus");
+
+ LOG.info(svcOperation + " called.");
+
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<GetStatusOutput> rpcResult =
+ RpcResultBuilder.<GetStatusOutput>status(true).withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ GetStatusInputBuilder inputBuilder = new GetStatusInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+
+ LOG.info("Printing SLI parameters to be passed");
+
+ // iterate properties file to get key-value pairs
+ for (String key : parms.stringPropertyNames()) {
+ String value = parms.getProperty(key);
+ LOG.info("The SLI parameter in " + key + " is: " + value);
+ }
+
+ // Call SLI sync method
+ try {
+ if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
+ LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
+ try {
+ A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service logic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service logic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ serviceDataBuilder.setResponseCode("A1 Adapter Executed for GetStatus. ");
+ }
+
+ RpcResult<GetStatusOutput> rpcResult =
+ RpcResultBuilder.<GetStatusOutput>status(true).withResult(serviceDataBuilder.build()).build();
+
+ LOG.info("Successful exit from getStatus ");
+
+ return Futures.immediateFuture(rpcResult);
+ }
- // add input to parms
- LOG.info("Adding INPUT data for "+svcOperation+" input: " + input);
- NotifyPolicyEnforcementUpdateInputBuilder inputBuilder = new NotifyPolicyEnforcementUpdateInputBuilder(input);
- MdsalHelper.toProperties(parms, inputBuilder.build());
- LOG.info("Printing SLI parameters to be passed");
+ // RPC notifyPolicyEnforcementUpdate
- // iterate properties file to get key-value pairs
- for (String key : parms.stringPropertyNames()) {
- String value = parms.getProperty(key);
- LOG.info("The SLI parameter in " + key + " is: " + value);
+ @Override
+ public ListenableFuture<RpcResult<NotifyPolicyEnforcementUpdateOutput>> notifyPolicyEnforcementUpdate(
+ NotifyPolicyEnforcementUpdateInput input) {
+ final String svcOperation = "notifyPolicyEnforcementUpdate";
+
+ Properties parms = new Properties();
+ NotifyPolicyEnforcementUpdateOutputBuilder serviceDataBuilder =
+ (NotifyPolicyEnforcementUpdateOutputBuilder) getServiceData(NOTIFICATION_ENFORECEMENT);
+
+ LOG.info("Reached RPC notifyPolicyEnforcementUpdate");
+
+ LOG.info(svcOperation + " called.");
+
+ if (input == null) {
+ LOG.debug("exiting " + svcOperation + " because of invalid input");
+ serviceDataBuilder.setResponseCode("Input is null");
+ RpcResult<NotifyPolicyEnforcementUpdateOutput> rpcResult = RpcResultBuilder
+ .<NotifyPolicyEnforcementUpdateOutput>status(true).withResult(serviceDataBuilder.build()).build();
+ return Futures.immediateFuture(rpcResult);
+ }
+
+ // add input to parms
+ LOG.info("Adding INPUT data for " + svcOperation + " input: " + input);
+ NotifyPolicyEnforcementUpdateInputBuilder inputBuilder = new NotifyPolicyEnforcementUpdateInputBuilder(input);
+ MdsalHelper.toProperties(parms, inputBuilder.build());
+
+ LOG.info("Printing SLI parameters to be passed");
+
+ // iterate properties file to get key-value pairs
+ for (String key : parms.stringPropertyNames()) {
+ String value = parms.getProperty(key);
+ LOG.info("The SLI parameter in " + key + " is: " + value);
+ }
+
+ // Call SLI sync method
+ try {
+ if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation, null, "sync")) {
+ LOG.info("A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
+ try {
+ A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
+ } catch (Exception e) {
+ LOG.error("Caught exception executing service logic for " + svcOperation, e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+ } else {
+ LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
+ serviceDataBuilder.setResponseCode("503");
+ }
+ } catch (Exception e) {
+ LOG.error("Caught exception looking for service logic", e);
+ serviceDataBuilder.setResponseCode("500");
+ }
+
+ String errorCode = serviceDataBuilder.getResponseCode();
+
+ if (!("0".equals(errorCode) || "200".equals(errorCode))) {
+ LOG.error("Returned FAILED for " + svcOperation + " error code: '" + errorCode + "'");
+ } else {
+ LOG.info("Returned SUCCESS for " + svcOperation + " ");
+ serviceDataBuilder.setResponseCode("A1 Adapter Executed for notifyPolicyEnforcementUpdate. ");
+ }
+
+ RpcResult<NotifyPolicyEnforcementUpdateOutput> rpcResult = RpcResultBuilder
+ .<NotifyPolicyEnforcementUpdateOutput>status(true).withResult(serviceDataBuilder.build()).build();
+
+ LOG.info("Successful exit from notifyPolicyEnforcementUpdate ");
+
+ return Futures.immediateFuture(rpcResult);
}
- // Call SLI sync method
- try
- {
- if (A1AdapterClient.hasGraph("A1-ADAPTER-API", svcOperation , null, "sync"))
- {
- LOG.info( "A1AdapterClient has a Directed Graph for '" + svcOperation + "'");
- try
- {
- A1AdapterClient.execute("A1-ADAPTER-API", svcOperation, null, "sync", serviceDataBuilder, parms);
- }
- catch (Exception e)
- {
- LOG.error("Caught exception executing service logic for "+ svcOperation, e);
- serviceDataBuilder.setResponseCode("500");
- }
- } else {
- LOG.error("No service logic active for A1Adapter: '" + svcOperation + "'");
- serviceDataBuilder.setResponseCode("503");
+ protected Builder<?> getServiceData(String svcOperation) {
+ switch (svcOperation) {
+ case GET_NEARRT_RICS:
+ return new GetNearRTRICsOutputBuilder();
+ case GET_HEALTH_CHECK:
+ return new GetHealthCheckOutputBuilder();
+ case GET_POLICY_TYPES:
+ return new GetPolicyTypesOutputBuilder();
+ case CREATE_POLICY_TYPE:
+ return new CreatePolicyTypeOutputBuilder();
+ case GET_POLICY_TYPE:
+ return new GetPolicyTypeOutputBuilder();
+ case DELETE_POLICY_TYPE:
+ return new DeletePolicyTypeOutputBuilder();
+ case GET_POLICY_INSTANCES:
+ return new GetPolicyInstancesOutputBuilder();
+ case CREATE_POLICY_INSTANCES:
+ return new CreatePolicyInstanceOutputBuilder();
+ case GET_POLICY_INSTANCE:
+ return new GetPolicyInstanceOutputBuilder();
+ case DELETE_POLICY_INSTANCE:
+ return new DeletePolicyInstanceOutputBuilder();
+ case GET_STATUS:
+ return new GetStatusOutputBuilder();
+ case NOTIFICATION_ENFORECEMENT:
+ return new NotifyPolicyEnforcementUpdateOutputBuilder();
+ }
+ return null;
}
- }
- catch (Exception e)
- {
- LOG.error("Caught exception looking for service logic", e);
- serviceDataBuilder.setResponseCode("500");
- }
-
- String errorCode = serviceDataBuilder.getResponseCode();
-
- if (!("0".equals(errorCode) || "200".equals(errorCode))) {
- LOG.error("Returned FAILED for "+svcOperation+" error code: '" + errorCode + "'");
- } else {
- LOG.info("Returned SUCCESS for "+svcOperation+" ");
- serviceDataBuilder.setResponseCode("A1 Adapter Executed for notifyPolicyEnforcementUpdate. " );
- }
-
- RpcResult<NotifyPolicyEnforcementUpdateOutput> rpcResult =
- RpcResultBuilder.<NotifyPolicyEnforcementUpdateOutput> status(true).withResult(serviceDataBuilder.build()).build();
-
- LOG.info("Successful exit from notifyPolicyEnforcementUpdate ");
-
- return Futures.immediateFuture(rpcResult);
-}
-
-
-
-
}
diff --git a/sdnr/northbound/a1Adapter/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProviderTest.java b/sdnr/northbound/a1Adapter/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProviderTest.java
new file mode 100644
index 000000000..c5bdb99f7
--- /dev/null
+++ b/sdnr/northbound/a1Adapter/provider/src/test/java/org/onap/ccsdk/features/sdnr/northbound/a1Adapter/A1AdapterProviderTest.java
@@ -0,0 +1,852 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * Copyright (C) 2020 Nordix Foundation.
+ * ================================================================================
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ *
+ * SPDX-License-Identifier: Apache-2.0
+ * ============LICENSE_END=========================================================
+ */
+
+package org.onap.ccsdk.features.sdnr.northbound.a1Adapter;
+
+import static org.junit.Assert.assertEquals;
+import static org.junit.Assert.assertNotNull;
+import static org.mockito.ArgumentMatchers.any;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.when;
+import com.google.common.util.concurrent.ListenableFuture;
+import java.util.Properties;
+import java.util.concurrent.ExecutionException;
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+import org.mockito.Mock;
+import org.mockito.Mockito;
+import org.mockito.junit.MockitoJUnitRunner;
+import org.onap.ccsdk.sli.core.sli.SvcLogicException;
+import org.opendaylight.controller.md.sal.binding.api.DataBroker;
+import org.opendaylight.controller.md.sal.binding.api.NotificationPublishService;
+import org.opendaylight.controller.sal.binding.api.RpcProviderRegistry;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyInstanceInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyInstanceInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyInstanceOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyInstanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.CreatePolicyTypeOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyInstanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.DeletePolicyTypeOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetHealthCheckOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetNearRTRICsOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstanceOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyInstancesOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypeOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesInput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetPolicyTypesOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetStatusInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetStatusOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.GetStatusOutputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.NotifyPolicyEnforcementUpdateInputBuilder;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.NotifyPolicyEnforcementUpdateOutput;
+import org.opendaylight.yang.gen.v1.org.onap.ccsdk.rev191212.NotifyPolicyEnforcementUpdateOutputBuilder;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.common.RpcResult;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+
+/**
+ * This class Tests all the methods in A1AdapterProvider
+ *
+ * @author lathishbabu.ganesan@est.tech
+ *
+ */
+
+@RunWith(MockitoJUnitRunner.Silent.class)
+public class A1AdapterProviderTest {
+
+ protected static final Logger LOG = LoggerFactory.getLogger(A1AdapterProviderTest.class);
+
+ class A1AdapterProviderMock extends A1AdapterProvider {
+
+ A1AdapterProviderMock(final DataBroker dataBroker, final NotificationPublishService notificationPublishService,
+ final RpcProviderRegistry rpcProviderRegistry, final A1AdapterClient A1AdapterClient) {
+ super(dataBroker, mockNotificationPublishService, mockRpcProviderRegistry, a1AdapterClient);
+ }
+
+ @Override
+ public Builder<?> getServiceData(String svcOperation) {
+ return null;
+ }
+ }
+
+ private A1AdapterProviderMock a1AdapterProviderMock = null;
+ @Mock
+ private DataBroker dataBroker;
+ @Mock
+ private NotificationPublishService mockNotificationPublishService;
+ @Mock
+ private RpcProviderRegistry mockRpcProviderRegistry;
+ @Mock
+ private A1AdapterClient a1AdapterClient;
+ private static String module = "A1-ADAPTER-API";
+ private static String mode = "sync";
+
+ @Before
+ public void setUp() throws Exception {
+
+ a1AdapterProviderMock = new A1AdapterProviderMock(dataBroker, mockNotificationPublishService,
+ mockRpcProviderRegistry, a1AdapterClient);
+ a1AdapterProviderMock = Mockito.spy(a1AdapterProviderMock);
+
+ }
+
+ @Test
+ public void test_GetNearRT_RICs() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetNearRTRICsOutputBuilder nearRTRICsOutputBuilder = new GetNearRTRICsOutputBuilder();
+ nearRTRICsOutputBuilder.setResponseCode("200");
+ String rpc = "getNearRT-RICs";
+ Properties respProps = new Properties();
+ GetNearRTRICsInputBuilder inputBuilder = new GetNearRTRICsInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetNearRTRICsOutputBuilder.class),
+ any(Properties.class))).thenReturn(respProps);
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) nearRTRICsOutputBuilder);
+ ListenableFuture<RpcResult<GetNearRTRICsOutput>> result =
+ a1AdapterProviderMock.getNearRTRICs(inputBuilder.build());
+ assertNotNull(result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_GetNearRT_RICs_With_No_Input() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetNearRTRICsInput getNearRTRICsInput = null;
+ String rpc = "getNearRT-RICs";
+ GetNearRTRICsOutputBuilder nearRTRICsOutputBuilder = new GetNearRTRICsOutputBuilder();
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) nearRTRICsOutputBuilder);
+ ListenableFuture<RpcResult<GetNearRTRICsOutput>> result =
+ a1AdapterProviderMock.getNearRTRICs(getNearRTRICsInput);
+ assertEquals("Input is null", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_GetNearRT_RICs_With_No_DG() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetNearRTRICsOutputBuilder nearRTRICsOutputBuilder = new GetNearRTRICsOutputBuilder();
+ String rpc = "getNearRT-RICs";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) nearRTRICsOutputBuilder);
+ GetNearRTRICsInputBuilder inputBuilder = new GetNearRTRICsInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(Boolean.FALSE);
+ ListenableFuture<RpcResult<GetNearRTRICsOutput>> result =
+ a1AdapterProviderMock.getNearRTRICs(inputBuilder.build());
+ assertEquals("503", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_GetNearRT_RICs_With_DG_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetNearRTRICsOutputBuilder nearRTRICsOutputBuilder = new GetNearRTRICsOutputBuilder();
+ String rpc = "getNearRT-RICs";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) nearRTRICsOutputBuilder);
+ GetNearRTRICsInputBuilder inputBuilder = new GetNearRTRICsInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<GetNearRTRICsOutput>> result =
+ a1AdapterProviderMock.getNearRTRICs(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_GetNearRT_RICs_With_DG_Execute_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetNearRTRICsOutputBuilder nearRTRICsOutputBuilder = new GetNearRTRICsOutputBuilder();
+ String rpc = "getNearRT-RICs";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) nearRTRICsOutputBuilder);
+ GetNearRTRICsInputBuilder inputBuilder = new GetNearRTRICsInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetNearRTRICsOutputBuilder.class),
+ any(Properties.class))).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<GetNearRTRICsOutput>> result =
+ a1AdapterProviderMock.getNearRTRICs(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getHealthCheck() throws SvcLogicException, InterruptedException, ExecutionException {
+ String rpc = "getHealthCheck";
+ Properties respProps = new Properties();
+ GetHealthCheckOutputBuilder healthCheckOutputBuilder = new GetHealthCheckOutputBuilder();
+ healthCheckOutputBuilder.setResponseCode("200");
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) healthCheckOutputBuilder);
+ GetHealthCheckInputBuilder inputBuilder = new GetHealthCheckInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetHealthCheckOutputBuilder.class),
+ any(Properties.class))).thenReturn(respProps);
+ ListenableFuture<RpcResult<GetHealthCheckOutput>> result =
+ a1AdapterProviderMock.getHealthCheck(inputBuilder.build());
+ assertNotNull(result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getHealthCheck_With_No_Input() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetHealthCheckInput getHealthCheckInput = null;
+ String rpc = "getHealthCheck";
+ GetHealthCheckOutputBuilder healthCheckOutputBuilder = new GetHealthCheckOutputBuilder();
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) healthCheckOutputBuilder);
+ ListenableFuture<RpcResult<GetHealthCheckOutput>> result =
+ a1AdapterProviderMock.getHealthCheck(getHealthCheckInput);
+ assertEquals("Input is null", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getHealthCheck_With_No_DG() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetHealthCheckOutputBuilder healthCheckOutputBuilder = new GetHealthCheckOutputBuilder();
+ String rpc = "getHealthCheck";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) healthCheckOutputBuilder);
+ GetHealthCheckInputBuilder inputBuilder = new GetHealthCheckInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(Boolean.FALSE);
+ ListenableFuture<RpcResult<GetHealthCheckOutput>> result =
+ a1AdapterProviderMock.getHealthCheck(inputBuilder.build());
+ assertEquals("503", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getHealthCheck_With_DG_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetHealthCheckOutputBuilder healthCheckOutputBuilder = new GetHealthCheckOutputBuilder();
+ String rpc = "getHealthCheck";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) healthCheckOutputBuilder);
+ GetHealthCheckInputBuilder inputBuilder = new GetHealthCheckInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<GetHealthCheckOutput>> result =
+ a1AdapterProviderMock.getHealthCheck(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getHealthCheck_With_DG_Execute_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetHealthCheckOutputBuilder healthCheckOutputBuilder = new GetHealthCheckOutputBuilder();
+ String rpc = "getHealthCheck";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) healthCheckOutputBuilder);
+ GetHealthCheckInputBuilder inputBuilder = new GetHealthCheckInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetHealthCheckOutputBuilder.class),
+ any(Properties.class))).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<GetHealthCheckOutput>> result =
+ a1AdapterProviderMock.getHealthCheck(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyTypes() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyTypesOutputBuilder policyTypesOutputBuilder = new GetPolicyTypesOutputBuilder();
+ policyTypesOutputBuilder.setResponseCode("200");
+ String rpc = "getPolicyTypes";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyTypesOutputBuilder);
+ Properties respProps = new Properties();
+ GetPolicyTypesInputBuilder inputBuilder = new GetPolicyTypesInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetPolicyTypesOutputBuilder.class),
+ eq(null))).thenReturn(respProps);
+ ListenableFuture<RpcResult<GetPolicyTypesOutput>> result =
+ a1AdapterProviderMock.getPolicyTypes(inputBuilder.build());
+ assertNotNull(result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyTypes_With_No_Input() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyTypesInput getHealthCheckInput = null;
+ String rpc = "getPolicyTypes";
+ GetPolicyTypesOutputBuilder policyTypesOutputBuilder = new GetPolicyTypesOutputBuilder();
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyTypesOutputBuilder);
+ ListenableFuture<RpcResult<GetPolicyTypesOutput>> result =
+ a1AdapterProviderMock.getPolicyTypes(getHealthCheckInput);
+ assertEquals("Input is null", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyTypes_With_No_DG() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyTypesOutputBuilder policyTypesOutputBuilder = new GetPolicyTypesOutputBuilder();
+ String rpc = "getPolicyTypes";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyTypesOutputBuilder);
+ GetPolicyTypesInputBuilder inputBuilder = new GetPolicyTypesInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(Boolean.FALSE);
+ ListenableFuture<RpcResult<GetPolicyTypesOutput>> result =
+ a1AdapterProviderMock.getPolicyTypes(inputBuilder.build());
+ assertEquals("503", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyTypes_With_DG_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyTypesOutputBuilder policyTypesOutputBuilder = new GetPolicyTypesOutputBuilder();
+ String rpc = "getPolicyTypes";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyTypesOutputBuilder);
+ GetPolicyTypesInputBuilder inputBuilder = new GetPolicyTypesInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<GetPolicyTypesOutput>> result =
+ a1AdapterProviderMock.getPolicyTypes(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyTypes_With_DG_Execute_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyTypesOutputBuilder policyTypesOutputBuilder = new GetPolicyTypesOutputBuilder();
+ String rpc = "getPolicyTypes";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyTypesOutputBuilder);
+ GetPolicyTypesInputBuilder inputBuilder = new GetPolicyTypesInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetPolicyTypesOutputBuilder.class),
+ any(Properties.class))).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<GetPolicyTypesOutput>> result =
+ a1AdapterProviderMock.getPolicyTypes(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_createPolicyType() throws SvcLogicException, InterruptedException, ExecutionException {
+ CreatePolicyTypeOutputBuilder createPolicyTypeOutputBuilder = new CreatePolicyTypeOutputBuilder();
+ createPolicyTypeOutputBuilder.setResponseCode("200");
+ String rpc = "createPolicyType";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) createPolicyTypeOutputBuilder);
+ Properties respProps = new Properties();
+ CreatePolicyTypeInputBuilder inputBuilder = new CreatePolicyTypeInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(CreatePolicyTypeOutputBuilder.class),
+ eq(null))).thenReturn(respProps);
+ ListenableFuture<RpcResult<CreatePolicyTypeOutput>> result =
+ a1AdapterProviderMock.createPolicyType(inputBuilder.build());
+ assertNotNull(result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_createPolicyType_With_No_Input()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ CreatePolicyTypeInput createPolicyTypeInput = null;
+ String rpc = "createPolicyType";
+ CreatePolicyTypeOutputBuilder createPolicyTypeOutputBuilder = new CreatePolicyTypeOutputBuilder();
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) createPolicyTypeOutputBuilder);
+ ListenableFuture<RpcResult<CreatePolicyTypeOutput>> result =
+ a1AdapterProviderMock.createPolicyType(createPolicyTypeInput);
+ assertEquals("Input is null", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_createPolicyType_With_No_DG() throws SvcLogicException, InterruptedException, ExecutionException {
+ CreatePolicyTypeOutputBuilder createPolicyTypeOutputBuilder = new CreatePolicyTypeOutputBuilder();
+ String rpc = "createPolicyType";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) createPolicyTypeOutputBuilder);
+ CreatePolicyTypeInputBuilder inputBuilder = new CreatePolicyTypeInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(Boolean.FALSE);
+ ListenableFuture<RpcResult<CreatePolicyTypeOutput>> result =
+ a1AdapterProviderMock.createPolicyType(inputBuilder.build());
+ assertEquals("503", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_createPolicyType_With_DG_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ CreatePolicyTypeOutputBuilder createPolicyTypeOutputBuilder = new CreatePolicyTypeOutputBuilder();
+ String rpc = "createPolicyType";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) createPolicyTypeOutputBuilder);
+ CreatePolicyTypeInputBuilder inputBuilder = new CreatePolicyTypeInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<CreatePolicyTypeOutput>> result =
+ a1AdapterProviderMock.createPolicyType(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_createPolicyType_With_DG_Execute_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ CreatePolicyTypeOutputBuilder createPolicyTypeOutputBuilder = new CreatePolicyTypeOutputBuilder();
+ String rpc = "createPolicyType";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) createPolicyTypeOutputBuilder);
+ CreatePolicyTypeInputBuilder inputBuilder = new CreatePolicyTypeInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(CreatePolicyTypeOutputBuilder.class),
+ any(Properties.class))).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<CreatePolicyTypeOutput>> result =
+ a1AdapterProviderMock.createPolicyType(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyType() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyTypeOutputBuilder policyTypeOutputBuilder = new GetPolicyTypeOutputBuilder();
+ policyTypeOutputBuilder.setResponseCode("200");
+ String rpc = "getPolicyType";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyTypeOutputBuilder);
+ Properties respProps = new Properties();
+ GetPolicyTypeInputBuilder inputBuilder = new GetPolicyTypeInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetPolicyTypeOutputBuilder.class),
+ eq(null))).thenReturn(respProps);
+ ListenableFuture<RpcResult<GetPolicyTypeOutput>> result =
+ a1AdapterProviderMock.getPolicyType(inputBuilder.build());
+ assertNotNull(result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyType_With_No_Input() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyTypeInput getPolicyTypeInput = null;
+ String rpc = "getPolicyType";
+ GetPolicyTypeOutputBuilder policyTypeOutputBuilder = new GetPolicyTypeOutputBuilder();
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyTypeOutputBuilder);
+ ListenableFuture<RpcResult<GetPolicyTypeOutput>> result =
+ a1AdapterProviderMock.getPolicyType(getPolicyTypeInput);
+ assertEquals("Input is null", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyType_With_No_DG() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyTypeOutputBuilder policyTypeOutputBuilder = new GetPolicyTypeOutputBuilder();
+ String rpc = "getPolicyType";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyTypeOutputBuilder);
+ GetPolicyTypeInputBuilder inputBuilder = new GetPolicyTypeInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(Boolean.FALSE);
+ ListenableFuture<RpcResult<GetPolicyTypeOutput>> result =
+ a1AdapterProviderMock.getPolicyType(inputBuilder.build());
+ assertEquals("503", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyType_With_DG_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyTypeOutputBuilder policyTypeOutputBuilder = new GetPolicyTypeOutputBuilder();
+ String rpc = "getPolicyType";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyTypeOutputBuilder);
+ GetPolicyTypeInputBuilder inputBuilder = new GetPolicyTypeInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<GetPolicyTypeOutput>> result =
+ a1AdapterProviderMock.getPolicyType(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyType_With_DG_Execute_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyTypeOutputBuilder policyTypeOutputBuilder = new GetPolicyTypeOutputBuilder();
+ String rpc = "getPolicyType";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyTypeOutputBuilder);
+ GetPolicyTypeInputBuilder inputBuilder = new GetPolicyTypeInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetPolicyTypeOutputBuilder.class),
+ any(Properties.class))).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<GetPolicyTypeOutput>> result =
+ a1AdapterProviderMock.getPolicyType(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_deletePolicyType() throws SvcLogicException, InterruptedException, ExecutionException {
+ DeletePolicyTypeOutputBuilder deletePolicyTypeOutputBuilder = new DeletePolicyTypeOutputBuilder();
+ deletePolicyTypeOutputBuilder.setResponseCode("200");
+ String rpc = "deletePolicyType";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) deletePolicyTypeOutputBuilder);
+ Properties respProps = new Properties();
+ DeletePolicyTypeInputBuilder inputBuilder = new DeletePolicyTypeInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetPolicyTypeOutputBuilder.class),
+ eq(null))).thenReturn(respProps);
+ ListenableFuture<RpcResult<DeletePolicyTypeOutput>> result =
+ a1AdapterProviderMock.deletePolicyType(inputBuilder.build());
+ assertNotNull(result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_deletePolicyType_With_No_Input()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ DeletePolicyTypeInput deletePolicyTypeInput = null;
+ String rpc = "deletePolicyType";
+ DeletePolicyTypeOutputBuilder deletePolicyTypeOutputBuilder = new DeletePolicyTypeOutputBuilder();
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) deletePolicyTypeOutputBuilder);
+ ListenableFuture<RpcResult<DeletePolicyTypeOutput>> result =
+ a1AdapterProviderMock.deletePolicyType(deletePolicyTypeInput);
+ assertEquals("Input is null", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_deletePolicyType_With_No_DG() throws SvcLogicException, InterruptedException, ExecutionException {
+ DeletePolicyTypeOutputBuilder deletePolicyTypeOutputBuilder = new DeletePolicyTypeOutputBuilder();
+ String rpc = "deletePolicyType";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) deletePolicyTypeOutputBuilder);
+ DeletePolicyTypeInputBuilder inputBuilder = new DeletePolicyTypeInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(Boolean.FALSE);
+ ListenableFuture<RpcResult<DeletePolicyTypeOutput>> result =
+ a1AdapterProviderMock.deletePolicyType(inputBuilder.build());
+ assertEquals("503", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_deletePolicyType_With_DG_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ DeletePolicyTypeOutputBuilder deletePolicyTypeOutputBuilder = new DeletePolicyTypeOutputBuilder();
+ String rpc = "deletePolicyType";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) deletePolicyTypeOutputBuilder);
+ DeletePolicyTypeInputBuilder inputBuilder = new DeletePolicyTypeInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<DeletePolicyTypeOutput>> result =
+ a1AdapterProviderMock.deletePolicyType(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_deletePolicyType_With_DG_Execute_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ DeletePolicyTypeOutputBuilder deletePolicyTypeOutputBuilder = new DeletePolicyTypeOutputBuilder();
+ String rpc = "deletePolicyType";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) deletePolicyTypeOutputBuilder);
+ DeletePolicyTypeInputBuilder inputBuilder = new DeletePolicyTypeInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(DeletePolicyTypeOutputBuilder.class),
+ any(Properties.class))).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<DeletePolicyTypeOutput>> result =
+ a1AdapterProviderMock.deletePolicyType(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyInstances() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyInstancesOutputBuilder policyInstancesOutputBuilder = new GetPolicyInstancesOutputBuilder();
+ policyInstancesOutputBuilder.setResponseCode("200");
+ String rpc = "getPolicyInstances";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyInstancesOutputBuilder);
+ Properties respProps = new Properties();
+ GetPolicyInstancesInputBuilder inputBuilder = new GetPolicyInstancesInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetPolicyTypeOutputBuilder.class),
+ eq(null))).thenReturn(respProps);
+ ListenableFuture<RpcResult<GetPolicyInstancesOutput>> result =
+ a1AdapterProviderMock.getPolicyInstances(inputBuilder.build());
+ assertNotNull(result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyInstances_With_No_Input()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyInstancesInput getPolicyInstancesInput = null;
+ String rpc = "getPolicyInstances";
+ GetPolicyInstancesOutputBuilder policyInstancesOutputBuilder = new GetPolicyInstancesOutputBuilder();
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyInstancesOutputBuilder);
+ ListenableFuture<RpcResult<GetPolicyInstancesOutput>> result =
+ a1AdapterProviderMock.getPolicyInstances(getPolicyInstancesInput);
+ assertEquals("Input is null", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyInstances_With_No_DG()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyInstancesOutputBuilder policyInstancesOutputBuilder = new GetPolicyInstancesOutputBuilder();
+ String rpc = "getPolicyInstances";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyInstancesOutputBuilder);
+ GetPolicyInstancesInputBuilder inputBuilder = new GetPolicyInstancesInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(Boolean.FALSE);
+ ListenableFuture<RpcResult<GetPolicyInstancesOutput>> result =
+ a1AdapterProviderMock.getPolicyInstances(inputBuilder.build());
+ assertEquals("503", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyInstances_With_DG_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyInstancesOutputBuilder policyInstancesOutputBuilder = new GetPolicyInstancesOutputBuilder();
+ String rpc = "getPolicyInstances";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyInstancesOutputBuilder);
+ GetPolicyInstancesInputBuilder inputBuilder = new GetPolicyInstancesInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<GetPolicyInstancesOutput>> result =
+ a1AdapterProviderMock.getPolicyInstances(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyInstances_With_DG_Execute_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyInstancesOutputBuilder policyInstancesOutputBuilder = new GetPolicyInstancesOutputBuilder();
+ String rpc = "getPolicyInstances";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyInstancesOutputBuilder);
+ GetPolicyInstancesInputBuilder inputBuilder = new GetPolicyInstancesInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode),
+ any(GetPolicyInstancesOutputBuilder.class), any(Properties.class))).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<GetPolicyInstancesOutput>> result =
+ a1AdapterProviderMock.getPolicyInstances(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_createPolicyInstance() throws SvcLogicException, InterruptedException, ExecutionException {
+ CreatePolicyInstanceOutputBuilder createPolicyInstanceOutputBuilder = new CreatePolicyInstanceOutputBuilder();
+ createPolicyInstanceOutputBuilder.setResponseCode("200");
+ String rpc = "createPolicyInstance";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) createPolicyInstanceOutputBuilder);
+ Properties respProps = new Properties();
+ CreatePolicyInstanceInputBuilder inputBuilder = new CreatePolicyInstanceInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode),
+ any(CreatePolicyInstanceOutputBuilder.class), eq(null))).thenReturn(respProps);
+ ListenableFuture<RpcResult<CreatePolicyInstanceOutput>> result =
+ a1AdapterProviderMock.createPolicyInstance(inputBuilder.build());
+ assertNotNull(result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_createPolicyInstance_With_No_Input()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ CreatePolicyInstanceInput createPolicyInstanceInput = null;
+ String rpc = "createPolicyInstance";
+ CreatePolicyInstanceOutputBuilder createPolicyInstanceOutputBuilder = new CreatePolicyInstanceOutputBuilder();
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) createPolicyInstanceOutputBuilder);
+ ListenableFuture<RpcResult<CreatePolicyInstanceOutput>> result =
+ a1AdapterProviderMock.createPolicyInstance(createPolicyInstanceInput);
+ assertEquals("Input is null", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_createPolicyInstance_With_No_DG()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ CreatePolicyInstanceOutputBuilder createPolicyInstanceOutputBuilder = new CreatePolicyInstanceOutputBuilder();
+ String rpc = "createPolicyInstance";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) createPolicyInstanceOutputBuilder);
+ CreatePolicyInstanceInputBuilder inputBuilder = new CreatePolicyInstanceInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(Boolean.FALSE);
+ ListenableFuture<RpcResult<CreatePolicyInstanceOutput>> result =
+ a1AdapterProviderMock.createPolicyInstance(inputBuilder.build());
+ assertEquals("503", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_createPolicyInstance_With_DG_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ CreatePolicyInstanceOutputBuilder createPolicyInstanceOutputBuilder = new CreatePolicyInstanceOutputBuilder();
+ String rpc = "createPolicyInstance";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) createPolicyInstanceOutputBuilder);
+ CreatePolicyInstanceInputBuilder inputBuilder = new CreatePolicyInstanceInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<CreatePolicyInstanceOutput>> result =
+ a1AdapterProviderMock.createPolicyInstance(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_createPolicyInstance_With_DG_Execute_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ CreatePolicyInstanceOutputBuilder createPolicyInstanceOutputBuilder = new CreatePolicyInstanceOutputBuilder();
+ String rpc = "createPolicyInstance";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) createPolicyInstanceOutputBuilder);
+ CreatePolicyInstanceInputBuilder inputBuilder = new CreatePolicyInstanceInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode),
+ any(CreatePolicyInstanceOutputBuilder.class), any(Properties.class)))
+ .thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<CreatePolicyInstanceOutput>> result =
+ a1AdapterProviderMock.createPolicyInstance(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyInstance() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyInstanceOutputBuilder policyInstanceOutputBuilder = new GetPolicyInstanceOutputBuilder();
+ policyInstanceOutputBuilder.setResponseCode("200");
+ String rpc = "getPolicyInstance";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyInstanceOutputBuilder);
+ Properties respProps = new Properties();
+ GetPolicyInstanceInputBuilder inputBuilder = new GetPolicyInstanceInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetPolicyTypeOutputBuilder.class),
+ eq(null))).thenReturn(respProps);
+ ListenableFuture<RpcResult<GetPolicyInstanceOutput>> result =
+ a1AdapterProviderMock.getPolicyInstance(inputBuilder.build());
+ assertNotNull(result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyInstance_With_No_Input()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyInstanceInput getPolicyInstanceInput = null;
+ String rpc = "getPolicyInstance";
+ GetPolicyInstanceOutputBuilder policyInstanceOutputBuilder = new GetPolicyInstanceOutputBuilder();
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyInstanceOutputBuilder);
+ ListenableFuture<RpcResult<GetPolicyInstanceOutput>> result =
+ a1AdapterProviderMock.getPolicyInstance(getPolicyInstanceInput);
+ assertEquals("Input is null", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyInstance_With_No_DG() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyInstanceOutputBuilder policyInstanceOutputBuilder = new GetPolicyInstanceOutputBuilder();
+ String rpc = "getPolicyInstance";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyInstanceOutputBuilder);
+ GetPolicyInstanceInputBuilder inputBuilder = new GetPolicyInstanceInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(Boolean.FALSE);
+ ListenableFuture<RpcResult<GetPolicyInstanceOutput>> result =
+ a1AdapterProviderMock.getPolicyInstance(inputBuilder.build());
+ assertEquals("503", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyInstance_With_DG_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyInstanceOutputBuilder policyInstanceOutputBuilder = new GetPolicyInstanceOutputBuilder();
+ String rpc = "getPolicyInstance";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyInstanceOutputBuilder);
+ GetPolicyInstanceInputBuilder inputBuilder = new GetPolicyInstanceInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<GetPolicyInstanceOutput>> result =
+ a1AdapterProviderMock.getPolicyInstance(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getPolicyInstance_With_DG_Execute_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ GetPolicyInstanceOutputBuilder policyInstanceOutputBuilder = new GetPolicyInstanceOutputBuilder();
+ String rpc = "getPolicyInstance";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) policyInstanceOutputBuilder);
+ GetPolicyInstanceInputBuilder inputBuilder = new GetPolicyInstanceInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetPolicyInstanceOutputBuilder.class),
+ any(Properties.class))).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<GetPolicyInstanceOutput>> result =
+ a1AdapterProviderMock.getPolicyInstance(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_deletePolicyInstance() throws SvcLogicException, InterruptedException, ExecutionException {
+ DeletePolicyInstanceOutputBuilder deletePolicyInstanceOutputBuilder = new DeletePolicyInstanceOutputBuilder();
+ deletePolicyInstanceOutputBuilder.setResponseCode("200");
+ String rpc = "deletePolicyInstance";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) deletePolicyInstanceOutputBuilder);
+ Properties respProps = new Properties();
+ DeletePolicyInstanceInputBuilder inputBuilder = new DeletePolicyInstanceInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetPolicyTypeOutputBuilder.class),
+ eq(null))).thenReturn(respProps);
+ ListenableFuture<RpcResult<DeletePolicyInstanceOutput>> result =
+ a1AdapterProviderMock.deletePolicyInstance(inputBuilder.build());
+ assertNotNull(result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_deletePolicyInstance_With_No_Input()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ DeletePolicyInstanceInput deletePolicyInstanceInput = null;
+ String rpc = "deletePolicyInstance";
+ DeletePolicyInstanceOutputBuilder deletePolicyInstanceOutputBuilder = new DeletePolicyInstanceOutputBuilder();
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) deletePolicyInstanceOutputBuilder);
+ ListenableFuture<RpcResult<DeletePolicyInstanceOutput>> result =
+ a1AdapterProviderMock.deletePolicyInstance(deletePolicyInstanceInput);
+ assertEquals("Input is null", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_deletePolicyInstance_With_No_DG() throws SvcLogicException, InterruptedException, ExecutionException {
+ DeletePolicyInstanceOutputBuilder deletePolicyInstanceOutputBuilder = new DeletePolicyInstanceOutputBuilder();
+ String rpc = "deletePolicyInstance";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) deletePolicyInstanceOutputBuilder);
+ DeletePolicyInstanceInputBuilder inputBuilder = new DeletePolicyInstanceInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(Boolean.FALSE);
+ ListenableFuture<RpcResult<DeletePolicyInstanceOutput>> result =
+ a1AdapterProviderMock.deletePolicyInstance(inputBuilder.build());
+ assertEquals("503", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_deletePolicyInstance_With_DG_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ DeletePolicyInstanceOutputBuilder deletePolicyInstanceOutputBuilder = new DeletePolicyInstanceOutputBuilder();
+ String rpc = "deletePolicyInstance";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) deletePolicyInstanceOutputBuilder);
+ DeletePolicyInstanceInputBuilder inputBuilder = new DeletePolicyInstanceInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<DeletePolicyInstanceOutput>> result =
+ a1AdapterProviderMock.deletePolicyInstance(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_deletePolicyInstance_With_DG_Execute_Exception()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ DeletePolicyInstanceOutputBuilder deletePolicyInstanceOutputBuilder = new DeletePolicyInstanceOutputBuilder();
+ String rpc = "deletePolicyInstance";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) deletePolicyInstanceOutputBuilder);
+ DeletePolicyInstanceInputBuilder inputBuilder = new DeletePolicyInstanceInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(DeletePolicyInstanceOutputBuilder.class),
+ any(Properties.class))).thenThrow(new SvcLogicException());
+ ListenableFuture<RpcResult<DeletePolicyInstanceOutput>> result =
+ a1AdapterProviderMock.deletePolicyInstance(inputBuilder.build());
+ assertEquals("500", result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_getStatus() throws SvcLogicException, InterruptedException, ExecutionException {
+ GetStatusOutputBuilder statusOutputBuilder = new GetStatusOutputBuilder();
+ statusOutputBuilder.setResponseCode("200");
+ String rpc = "getStatus";
+ when(a1AdapterProviderMock.getServiceData(rpc)).thenReturn((Builder) statusOutputBuilder);
+ Properties respProps = new Properties();
+ GetStatusInputBuilder inputBuilder = new GetStatusInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetPolicyTypeOutputBuilder.class),
+ eq(null))).thenReturn(respProps);
+ ListenableFuture<RpcResult<GetStatusOutput>> result = a1AdapterProviderMock.getStatus(inputBuilder.build());
+ assertNotNull(result.get().getResult().getResponseCode());
+ }
+
+ @Test
+ public void test_notifyPolicyEnforcementUpdate()
+ throws SvcLogicException, InterruptedException, ExecutionException {
+ NotifyPolicyEnforcementUpdateOutputBuilder notifyPolicyEnforcementUpdateOutputBuilder =
+ new NotifyPolicyEnforcementUpdateOutputBuilder();
+ notifyPolicyEnforcementUpdateOutputBuilder.setResponseCode("200");
+ String rpc = "notifyPolicyEnforcementUpdate";
+ when(a1AdapterProviderMock.getServiceData(rpc))
+ .thenReturn((Builder) notifyPolicyEnforcementUpdateOutputBuilder);
+ Properties respProps = new Properties();
+ NotifyPolicyEnforcementUpdateInputBuilder inputBuilder = new NotifyPolicyEnforcementUpdateInputBuilder();
+ when(a1AdapterClient.hasGraph(module, rpc, null, mode)).thenReturn(true);
+ when(a1AdapterClient.execute(eq(module), eq(rpc), eq(null), eq(mode), any(GetPolicyTypeOutputBuilder.class),
+ eq(null))).thenReturn(respProps);
+ ListenableFuture<RpcResult<NotifyPolicyEnforcementUpdateOutput>> result =
+ a1AdapterProviderMock.notifyPolicyEnforcementUpdate(inputBuilder.build());
+ assertNotNull(result.get().getResult().getResponseCode());
+ }
+
+
+}