summaryrefslogtreecommitdiffstats
path: root/appc-dispatcher/appc-request-handler/appc-request-handler-core/src
diff options
context:
space:
mode:
Diffstat (limited to 'appc-dispatcher/appc-request-handler/appc-request-handler-core/src')
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/messageadapter/impl/MessageAdapterImpl.java (renamed from appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/messageadapter/impl/MessageAdapterDmaapImpl.java)61
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/conv/Converter.java144
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/LCMOperationsDisabledException.java36
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/MissingVNFDataInAAIException.java33
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestRegistry.java11
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestValidator.java4
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java33
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/LCMStateManagerImpl.java62
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java47
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java38
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml4
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/org/openecomp/appc/default.properties21
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/LCMStateManagerImplTest.java55
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java65
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java69
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java51
-rw-r--r--appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/resources/org/openecomp/appc/default.properties28
17 files changed, 579 insertions, 183 deletions
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/messageadapter/impl/MessageAdapterDmaapImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/messageadapter/impl/MessageAdapterImpl.java
index 21c21db93..676c62871 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/messageadapter/impl/MessageAdapterDmaapImpl.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/messageadapter/impl/MessageAdapterImpl.java
@@ -21,26 +21,33 @@
package org.openecomp.appc.messageadapter.impl;
-import java.util.HashSet;
-import java.util.Properties;
-import org.apache.commons.lang.ObjectUtils;
-import org.openecomp.appc.adapter.dmaap.Producer;
-import org.openecomp.appc.adapter.dmaap.DmaapProducer;
+import org.openecomp.appc.adapter.factory.DmaapMessageAdapterFactoryImpl;
+import org.openecomp.appc.adapter.factory.MessageService;
+import org.openecomp.appc.adapter.message.MessageAdapterFactory;
+import org.openecomp.appc.adapter.message.Producer;
import org.openecomp.appc.configuration.Configuration;
import org.openecomp.appc.configuration.ConfigurationFactory;
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import com.fasterxml.jackson.core.JsonProcessingException;
+import org.apache.commons.lang.ObjectUtils;
import org.openecomp.appc.domainmodel.lcm.ResponseContext;
import org.openecomp.appc.domainmodel.lcm.VNFOperation;
import org.openecomp.appc.messageadapter.MessageAdapter;
import org.openecomp.appc.requesthandler.conv.Converter;
-import com.att.eelf.configuration.EELFLogger;
-import com.att.eelf.configuration.EELFManager;
+import org.osgi.framework.BundleContext;
+import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
-import com.fasterxml.jackson.core.JsonProcessingException;
+import java.util.HashSet;
+import java.util.Properties;
-public class MessageAdapterDmaapImpl implements MessageAdapter{
+public class MessageAdapterImpl implements MessageAdapter{
- private Producer dmaapProducer;
+ private MessageService messageService;
+ private Producer producer;
private String partition ;
private Configuration configuration;
private HashSet<String> pool;
@@ -48,21 +55,28 @@ public class MessageAdapterDmaapImpl implements MessageAdapter{
private String apiKey;
private String apiSecret;
- private static final EELFLogger logger = EELFManager.getInstance().getLogger(MessageAdapterDmaapImpl.class);
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(MessageAdapterImpl.class);
/**
- * Initialize dmaapProducer client to post messages using configuration properties
+ * Initialize producer client to post messages using configuration properties
*/
@Override
public void init(){
- this.dmaapProducer = getDmaapProducer();
+ this.producer = getProducer();
}
- private Producer getDmaapProducer() {
+
+ private Producer getProducer() {
configuration = ConfigurationFactory.getConfiguration();
Properties properties=configuration.getProperties();
updateProperties(properties);
- Producer producer=new DmaapProducer(pool,writeTopic);
- producer.updateCredentials(apiKey, apiSecret);
+
+ BundleContext ctx = FrameworkUtil.getBundle(MessageAdapterImpl.class).getBundleContext();
+ if (ctx != null) {
+ ServiceReference svcRef = ctx.getServiceReference(MessageAdapterFactory.class.getName());
+ if (svcRef != null) {
+ producer = ((MessageAdapterFactory) ctx.getService(svcRef)).createProducer(pool, writeTopic,apiKey, apiSecret);
+ }
+ }
return producer;
}
@@ -73,10 +87,13 @@ public class MessageAdapterDmaapImpl implements MessageAdapter{
}
pool = new HashSet<>();
if (props != null) {
- writeTopic = props.getProperty("dmaap.topic.write");
- apiKey = props.getProperty("dmaap.client.key");
- apiSecret = props.getProperty("dmaap.client.secret");
- String hostnames = props.getProperty("dmaap.poolMembers");
+ // readTopic = props.getProperty("dmaap.topic.read");
+ writeTopic = props.getProperty("appc.LCM.topic.write");
+ apiKey = props.getProperty("appc.LCM.client.key");
+ apiSecret = props.getProperty("appc.LCM.client.secret");
+ messageService = MessageService.parse(props.getProperty("message.service.type"));
+ // READ_TIMEOUT = Integer.valueOf(props.getProperty("dmaap.topic.read.timeout", String.valueOf(READ_TIMEOUT)));
+ String hostnames = props.getProperty("appc.LCM.poolMembers");
if (hostnames != null && !hostnames.isEmpty()) {
for (String name : hostnames.split(",")) {
pool.add(name);
@@ -103,9 +120,9 @@ public class MessageAdapterDmaapImpl implements MessageAdapter{
if (logger.isDebugEnabled()) {
logger.debug("DMaaP Response = " + jsonMessage);
}
- success = dmaapProducer.post(this.partition, jsonMessage);
+ success = producer.post(this.partition, jsonMessage);
} catch (JsonProcessingException e1) {
- logger.error("Error generating Jason from DMaaP message "+ e1.getMessage());
+ logger.error("Error generating Json from DMaaP message "+ e1.getMessage());
success= false;
}catch (Exception e){
logger.error("Error sending message to DMaaP "+e.getMessage());
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/conv/Converter.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/conv/Converter.java
index 3513516ae..272e02bca 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/conv/Converter.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/conv/Converter.java
@@ -21,38 +21,6 @@
package org.openecomp.appc.requesthandler.conv;
-import java.text.ParseException;
-import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.TimeZone;
-
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.Action;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.AuditOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.HealthCheckOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LiveUpgradeOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.LockOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.ModifyConfigOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.Payload;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.RollbackOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SnapshotOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SoftwareUploadOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.StopOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.SyncOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TerminateOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.TestOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.UnlockOutputBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.ZULU;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.CommonHeader;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.CommonHeaderBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.FlagsBuilder;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.status.Status;
-import org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.status.StatusBuilder;
-import org.opendaylight.yangtools.concepts.Builder;
-import org.opendaylight.yangtools.yang.binding.DataContainer;
-import org.openecomp.appc.domainmodel.lcm.ResponseContext;
-import org.openecomp.appc.domainmodel.lcm.VNFOperation;
-import org.openecomp.appc.requesthandler.impl.DmaapOutgoingMessage;
import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@@ -65,6 +33,23 @@ import com.fasterxml.jackson.databind.MapperFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.ObjectWriter;
import com.fasterxml.jackson.databind.SerializationFeature;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.*;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.CommonHeader;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.CommonHeaderBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.FlagsBuilder;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.status.Status;
+import org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.status.StatusBuilder;
+import org.opendaylight.yangtools.concepts.Builder;
+import org.opendaylight.yangtools.yang.binding.DataContainer;
+import org.openecomp.appc.domainmodel.lcm.ResponseContext;
+import org.openecomp.appc.domainmodel.lcm.VNFOperation;
+import org.openecomp.appc.requesthandler.impl.DmaapOutgoingMessage;
+
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.TimeZone;
public class Converter {
@@ -90,6 +75,7 @@ public class Converter {
Action action = Action.valueOf(vnfOperation.name());
CommonHeader commonHeader = convAsyncResponseTorev160108CommonHeader(response);
Status status = convAsyncResponseTorev160108Status(response);
+ Payload payload = convAsyncResponseTorev160108Payload(response);
switch (action){
case Rollback:
outObj = new RollbackOutputBuilder();
@@ -110,6 +96,7 @@ public class Converter {
outObj = new AuditOutputBuilder();
((AuditOutputBuilder)outObj).setCommonHeader(commonHeader);
((AuditOutputBuilder)outObj).setStatus(status);
+ ((AuditOutputBuilder)outObj).setPayload(payload);
return outObj;
case HealthCheck:
outObj = new HealthCheckOutputBuilder();
@@ -126,10 +113,29 @@ public class Converter {
((LockOutputBuilder)outObj).setCommonHeader(commonHeader);
((LockOutputBuilder)outObj).setStatus(status);
return outObj;
- case ModifyConfig:
- outObj = new ModifyConfigOutputBuilder();
- ((ModifyConfigOutputBuilder)outObj).setCommonHeader(commonHeader);
- ((ModifyConfigOutputBuilder)outObj).setStatus(status);
+ case Configure:
+ outObj = new ConfigureOutputBuilder();
+ ((ConfigureOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigureOutputBuilder)outObj).setStatus(status);
+ ((ConfigureOutputBuilder)outObj).setPayload(payload);
+ return outObj;
+ case ConfigModify:
+ outObj = new ConfigModifyOutputBuilder();
+ ((ConfigModifyOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigModifyOutputBuilder)outObj).setStatus(status);
+ ((ConfigModifyOutputBuilder)outObj).setPayload(payload);
+ return outObj;
+ case ConfigScaleOut:
+ outObj = new ConfigScaleoutOutputBuilder();
+ ((ConfigScaleoutOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigScaleoutOutputBuilder)outObj).setStatus(status);
+ ((ConfigScaleoutOutputBuilder)outObj).setPayload(payload);
+ return outObj;
+ case ConfigRestore:
+ outObj = new ConfigRestoreOutputBuilder();
+ ((ConfigRestoreOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigRestoreOutputBuilder)outObj).setStatus(status);
+ ((ConfigRestoreOutputBuilder)outObj).setPayload(payload);
return outObj;
case SoftwareUpload:
outObj = new SoftwareUploadOutputBuilder();
@@ -145,6 +151,7 @@ public class Converter {
outObj = new SyncOutputBuilder();
((SyncOutputBuilder)outObj).setCommonHeader(commonHeader);
((SyncOutputBuilder)outObj).setStatus(status);
+ ((SyncOutputBuilder)outObj).setPayload(payload);
return outObj;
case Terminate:
outObj = new TerminateOutputBuilder();
@@ -161,12 +168,54 @@ public class Converter {
((UnlockOutputBuilder)outObj).setCommonHeader(commonHeader);
((UnlockOutputBuilder)outObj).setStatus(status);
return outObj;
+ case Restart:
+ outObj = new RestartOutputBuilder();
+ ((RestartOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((RestartOutputBuilder)outObj).setStatus(status);
+ return outObj;
+ case Rebuild:
+ outObj = new RebuildOutputBuilder();
+ ((RebuildOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((RebuildOutputBuilder)outObj).setStatus(status);
+ return outObj;
+ case Migrate:
+ outObj = new MigrateOutputBuilder();
+ ((MigrateOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((MigrateOutputBuilder)outObj).setStatus(status);
+ return outObj;
+ case Evacuate:
+ outObj = new EvacuateOutputBuilder();
+ ((EvacuateOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((EvacuateOutputBuilder)outObj).setStatus(status);
+ return outObj;
+ case ConfigBackup:
+ outObj = new ConfigBackupOutputBuilder();
+ ((ConfigBackupOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigBackupOutputBuilder)outObj).setStatus(status);
+ ((ConfigBackupOutputBuilder)outObj).setPayload(payload);
+ return outObj;
+ case ConfigBackupDelete:
+ outObj = new ConfigBackupDeleteOutputBuilder();
+ ((ConfigBackupDeleteOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigBackupDeleteOutputBuilder)outObj).setStatus(status);
+ ((ConfigBackupDeleteOutputBuilder)outObj).setPayload(payload);
+ return outObj;
+ case ConfigExport:
+ outObj = new ConfigExportOutputBuilder();
+ ((ConfigExportOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((ConfigExportOutputBuilder)outObj).setStatus(status);
+ return outObj;
+ case Start:
+ outObj = new StartOutputBuilder();
+ ((StartOutputBuilder)outObj).setCommonHeader(commonHeader);
+ ((StartOutputBuilder)outObj).setStatus(status);
+ return outObj;
default:
throw new IllegalArgumentException(action+" action is not supported");
}
}
- public static Payload convAsyncResponseTorev160108Payload(ResponseContext inObj) throws ParseException {
+ public static Payload convAsyncResponseTorev160108Payload(ResponseContext inObj) {
Payload payload = null;
if(inObj.getPayload() != null) {
payload = new Payload(inObj.getPayload());
@@ -208,7 +257,7 @@ public class Converter {
}
CommonHeaderBuilder commonHeaderBuilder = new CommonHeaderBuilder();
- org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags commonHeaderFlags = null;
+ org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags commonHeaderFlags = null;
if(inObj.getCommonHeader().getFlags() != null){
commonHeaderFlags = Converter.convFlagsMapTorev160108Flags(inObj.getCommonHeader().getFlags());
commonHeaderBuilder.setFlags(commonHeaderFlags);
@@ -239,7 +288,7 @@ public class Converter {
return isoFormatter.format(timeStamp);
}
- public static org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags
+ public static org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags
convFlagsMapTorev160108Flags(org.openecomp.appc.domainmodel.lcm.Flags flags) {
Flags rev160108flags = null;
boolean anyFlag = false;
@@ -249,14 +298,14 @@ public class Converter {
*/
/*
if(flags.containsKey(FORCE_FLAG)){
- org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags.Force force =
- org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags.Force.valueOf(flags.get(FORCE_FLAG).toString());
+ org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags.Force force =
+ org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags.Force.valueOf(flags.get(FORCE_FLAG).toString());
flagsBuilder.setForce(force);
anyFlag = true;
}
if(flags.containsKey(MODE_FLAG)){
- org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags.Mode mode =
- org.opendaylight.yang.gen.v1.org.openecomp.appc.rev160108.common.header.common.header.Flags.Mode.valueOf(flags.get(MODE_FLAG).toString());
+ org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags.Mode mode =
+ org.opendaylight.yang.gen.v1.org.openecomp.appc.lcm.rev160108.common.header.common.header.Flags.Mode.valueOf(flags.get(MODE_FLAG).toString());
flagsBuilder.setMode(mode);
anyFlag = true;
}
@@ -307,6 +356,9 @@ public class Converter {
public static DmaapOutgoingMessage convAsyncResponseToDmaapOutgoingMessage(VNFOperation vnfOperation, String rpcName, ResponseContext asyncResponse) throws JsonProcessingException {
DmaapOutgoingMessage outObj = new DmaapOutgoingMessage();
+ String correlationID = getCorrelationID(asyncResponse);
+ outObj.setCorrelationID(correlationID);
+ outObj.setType("response");
outObj.setRpcName(rpcName);
Builder<?> builder = Converter.convAsyncResponseToBuilder(vnfOperation, rpcName, asyncResponse);
Object messageBody = builder.build();
@@ -315,6 +367,12 @@ public class Converter {
return outObj;
}
+ private static String getCorrelationID(ResponseContext context) {
+ return context.getCommonHeader().getRequestId()
+ + (context.getCommonHeader().getSubRequestId() == null ?
+ "":"-" + context.getCommonHeader().getSubRequestId());
+ }
+
abstract class MixIn {
@JsonIgnore
abstract Class<? extends DataContainer> getImplementedInterface(); // to be removed during serialization
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/LCMOperationsDisabledException.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/LCMOperationsDisabledException.java
new file mode 100644
index 000000000..c067f303f
--- /dev/null
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/LCMOperationsDisabledException.java
@@ -0,0 +1,36 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.requesthandler.exceptions;
+
+/**
+ */
+public class LCMOperationsDisabledException extends Exception {
+
+ /**
+ * Constructs a new exception with the specified detail message.
+ *
+ * @param message the detail message.
+ */
+ public LCMOperationsDisabledException(String message) {
+ super(message);
+ }
+}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/MissingVNFDataInAAIException.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/MissingVNFDataInAAIException.java
new file mode 100644
index 000000000..7ffdb3801
--- /dev/null
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/exceptions/MissingVNFDataInAAIException.java
@@ -0,0 +1,33 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.requesthandler.exceptions;
+
+public class MissingVNFDataInAAIException extends Exception {
+ String missingAttributeName;
+ public MissingVNFDataInAAIException(String attributeName) {
+ this.missingAttributeName = attributeName;
+ }
+
+ public String getMissingAttributeName() {
+ return missingAttributeName;
+ }
+}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestRegistry.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestRegistry.java
index 874626c78..e51d4b978 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestRegistry.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestRegistry.java
@@ -76,4 +76,15 @@ public class RequestRegistry {
set.remove(requestIdentifier);
}
+ /**
+ * This method returns the count of currently registered requests
+ * in the request registry
+ * * @return currently registered requests count
+ */
+ public int getRegisteredRequestCount() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to getRegisteredRequestCount");
+ }
+ return set.size();
+ }
}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestValidator.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestValidator.java
index 4f2986d74..a4a2beee5 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestValidator.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/helper/RequestValidator.java
@@ -28,10 +28,12 @@ import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
import org.openecomp.appc.requesthandler.exceptions.DGWorkflowNotFoundException;
import org.openecomp.appc.requesthandler.exceptions.DuplicateRequestException;
import org.openecomp.appc.requesthandler.exceptions.InvalidInputException;
+import org.openecomp.appc.requesthandler.exceptions.LCMOperationsDisabledException;
+import org.openecomp.appc.requesthandler.exceptions.MissingVNFDataInAAIException;
import org.openecomp.appc.requesthandler.exceptions.RequestExpiredException;
import org.openecomp.appc.requesthandler.exceptions.VNFNotFoundException;
import org.openecomp.appc.requesthandler.exceptions.WorkflowNotFoundException;
public interface RequestValidator {
- public void validateRequest(RuntimeContext runtimeContext) throws VNFNotFoundException, RequestExpiredException, UnstableVNFException, InvalidInputException, DuplicateRequestException, NoTransitionDefinedException, LifecycleException, WorkflowNotFoundException,DGWorkflowNotFoundException;
+ public void validateRequest(RuntimeContext runtimeContext) throws VNFNotFoundException, RequestExpiredException, UnstableVNFException, InvalidInputException, DuplicateRequestException, NoTransitionDefinedException, LifecycleException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException;
}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java
index 4546726e9..c2455a3b4 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/DmaapOutgoingMessage.java
@@ -36,6 +36,15 @@ import com.fasterxml.jackson.databind.annotation.JsonSerialize;
@JsonIgnoreProperties(ignoreUnknown = true)
public class DmaapOutgoingMessage {
+ @JsonProperty("version")
+ private String version;
+
+ @JsonProperty("type")
+ private String type;
+
+ @JsonProperty("correlation-id")
+ private String correlationID;
+
private final static String defaultCambriaPartition = "MSO";
@JsonProperty("cambria.partition")
private String cambriaPartition = defaultCambriaPartition;
@@ -49,6 +58,30 @@ public class DmaapOutgoingMessage {
public DmaapOutgoingMessage() {
}
+ public String getVersion() {
+ return version;
+ }
+
+ public void setVersion(String version) {
+ this.version = version;
+ }
+
+ public String getType() {
+ return type;
+ }
+
+ public void setType(String type) {
+ this.type = type;
+ }
+
+ public String getCorrelationID() {
+ return correlationID;
+ }
+
+ public void setCorrelationID(String correlationID) {
+ this.correlationID = correlationID;
+ }
+
public String getCambriaPartition() {
return cambriaPartition;
}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/LCMStateManagerImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/LCMStateManagerImpl.java
new file mode 100644
index 000000000..0c97ebcbe
--- /dev/null
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/LCMStateManagerImpl.java
@@ -0,0 +1,62 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.requesthandler.impl;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import java.util.concurrent.atomic.AtomicBoolean;
+
+import org.openecomp.appc.requesthandler.LCMStateManager;
+
+public class LCMStateManagerImpl implements LCMStateManager {
+ private static final EELFLogger logger = EELFManager.getInstance().getLogger(LCMStateManagerImpl.class);
+ private static AtomicBoolean isLCMEnabled = new AtomicBoolean(true);
+
+ /**
+ * This method checks if the LCM operations are enabled or not
+ * * @return true if enabled else false
+ */
+ public boolean isLCMOperationEnabled() {
+ return isLCMEnabled.get();
+ }
+
+ /**
+ * This method disables the LCM operations
+ */
+ public void disableLCMOperations() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to disableLCMOperations");
+ }
+ isLCMEnabled.set(false);
+ }
+
+ /**
+ * This method enables the LCM operations
+ */
+ public void enableLCMOperations() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to enableLCMOperations");
+ }
+ isLCMEnabled.set(true);
+ }
+}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java
index d63cb8bb8..e6f7452c9 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestHandlerImpl.java
@@ -40,7 +40,7 @@ import org.openecomp.appc.lockmanager.api.LockManager;
import org.openecomp.appc.logging.LoggingConstants;
import org.openecomp.appc.logging.LoggingUtils;
import org.openecomp.appc.messageadapter.MessageAdapter;
-import org.openecomp.appc.messageadapter.impl.MessageAdapterDmaapImpl;
+import org.openecomp.appc.messageadapter.impl.MessageAdapterImpl;
import org.openecomp.appc.metricservice.MetricRegistry;
import org.openecomp.appc.metricservice.MetricService;
import org.openecomp.appc.metricservice.metric.DispatchingFuntionMetric;
@@ -133,7 +133,7 @@ public class RequestHandlerImpl implements RequestHandler {
public RequestHandlerImpl() {
requestRegistry = new RequestRegistry();
- messageAdapter = new MessageAdapterDmaapImpl();
+ messageAdapter = new MessageAdapterImpl();
messageAdapter.init();
Properties properties = configuration.getProperties();
if (properties != null && properties.getProperty("metric.enabled") != null) {
@@ -215,7 +215,7 @@ public class RequestHandlerImpl implements RequestHandler {
} catch (LifecycleException e) {
errorMessage = e.getMessage();
params = new Params().addParam("actionName", input.getRequestContext().getAction()).addParam("currentState", e.currentState);
- output = buildRequestHandlerOutput(LCMCommandStatus.ACTION_NOT_SUPPORTED, params);
+ output = buildRequestHandlerOutput(LCMCommandStatus.INVALID_VNF_STATE, params);
} catch (UnstableVNFException e) {
errorMessage = e.getMessage();
params = new Params().addParam("vnfId", vnfId);
@@ -246,6 +246,15 @@ public class RequestHandlerImpl implements RequestHandler {
} catch (DuplicateRequestException e) {
errorMessage = e.getMessage();
output = buildRequestHandlerOutput(LCMCommandStatus.DUPLICATE_REQUEST, null);
+ } catch (MissingVNFDataInAAIException e) {
+ params = new Params().addParam("attributeName",e.getMissingAttributeName())
+ .addParam("vnfId",vnfId);
+ output = buildRequestHandlerOutput(LCMCommandStatus.MISSING_VNF_DATA_IN_AAI,params);
+ errorMessage = output.getResponseContext().getStatus().getMessage();
+ } catch (LCMOperationsDisabledException e) {
+ errorMessage = e.getMessage();
+ params = new Params().addParam("errorMsg", errorMessage);
+ output = buildRequestHandlerOutput(LCMCommandStatus.REJECTED, params);
} catch (Exception e) {
storeErrorMessageToLog(runtimeContext, "", "", "Exception = " + e.getMessage());
errorMessage = e.getMessage() != null ? e.getMessage() : e.toString();
@@ -261,7 +270,11 @@ public class RequestHandlerImpl implements RequestHandler {
runtimeContext.setResponseContext(output.getResponseContext());
if ((null == output) || !(output.getResponseContext().getStatus().getCode() == LCMCommandStatus.ACCEPTED.getResponseCode())) {
if (isMetricEnabled) {
- ((DispatchingFuntionMetric) metricRegistry.metric("DISPATCH_FUNCTION")).incrementRejectedRequest();
+ if((output.getResponseContext().getStatus().getCode() == LCMCommandStatus.SUCCESS.getResponseCode())) {
+ ((DispatchingFuntionMetric) metricRegistry.metric("DISPATCH_FUNCTION")).incrementAcceptedRequest();
+ }else {
+ ((DispatchingFuntionMetric) metricRegistry.metric("DISPATCH_FUNCTION")).incrementRejectedRequest();
+ }
}
removeRequestFromRegistry(input.getRequestContext().getCommonHeader());
}
@@ -580,14 +593,18 @@ public class RequestHandlerImpl implements RequestHandler {
if (logger.isTraceEnabled()) {
logger.trace("Entering to onRequestExecutionStart with vnfId = " + vnfId + "and requestIdentifierString = " + requestIdentifierString);
}
- try {
- boolean updated = workingStateManager.setWorkingState(vnfId, VNFWorkingState.UNSTABLE, requestIdentifierString, forceFlag);
+
+ if(!readOnlyActivity || !forceFlag || workingStateManager.isVNFStable(vnfId)) {
+ boolean updated = false;
+ try {
+ updated = workingStateManager.setWorkingState(vnfId, VNFWorkingState.UNSTABLE, requestIdentifierString, forceFlag);
+ } catch (Exception e) {
+ logger.error("Error updating working state for vnf " + vnfId + e);
+ throw new RuntimeException(e);
+ }
if (!updated) {
throw new UnstableVNFException("VNF is not stable for vnfID = " + vnfId);
}
- } catch (Exception e) {
- logger.error("Error updating working state for vnf " + vnfId + e);
- throw new RuntimeException(e);
}
if (logger.isTraceEnabled())
@@ -805,4 +822,16 @@ public class RequestHandlerImpl implements RequestHandler {
return null;
}
}
+
+ /**
+ * This method returns the count of in progress requests
+ * * @return in progress requests count
+ */
+ @Override
+ public int getInprogressRequestCount() {
+ if (logger.isTraceEnabled()) {
+ logger.trace("Entering to getInprogressRequestCount");
+ }
+ return requestRegistry.getRegisteredRequestCount();
+ }
}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java
index 509c351ea..8499937c7 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/java/org/openecomp/appc/requesthandler/impl/RequestValidatorImpl.java
@@ -24,6 +24,7 @@ package org.openecomp.appc.requesthandler.impl;
import java.time.Instant;
import org.apache.commons.lang.ObjectUtils;
+import org.apache.commons.lang.StringUtils;
import org.openecomp.appc.common.constant.Constants;
import org.openecomp.appc.configuration.Configuration;
import org.openecomp.appc.configuration.ConfigurationFactory;
@@ -40,6 +41,8 @@ import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;
import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
import org.openecomp.appc.logging.LoggingConstants;
import org.openecomp.appc.logging.LoggingUtils;
+import org.openecomp.appc.requesthandler.LCMStateManager;
+import org.openecomp.appc.requesthandler.exceptions.*;
import org.openecomp.appc.requesthandler.exceptions.DGWorkflowNotFoundException;
import org.openecomp.appc.requesthandler.exceptions.DuplicateRequestException;
import org.openecomp.appc.requesthandler.exceptions.InvalidInputException;
@@ -74,6 +77,7 @@ public class RequestValidatorImpl implements RequestValidator {
private WorkFlowManager workflowManager;
private WorkingStateManager workingStateManager;
+ private LCMStateManager lcmStateManager;
private final RequestRegistry requestRegistry = new RequestRegistry();
@@ -93,14 +97,26 @@ public class RequestValidatorImpl implements RequestValidator {
this.workingStateManager = workingStateManager;
}
+ public void setLcmStateManager(LCMStateManager lcmStateManager) {
+ this.lcmStateManager = lcmStateManager;
+ }
+
public RequestValidatorImpl() {
}
@Override
- public void validateRequest(RuntimeContext runtimeContext) throws VNFNotFoundException, RequestExpiredException, UnstableVNFException, InvalidInputException, DuplicateRequestException, NoTransitionDefinedException, LifecycleException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void validateRequest(RuntimeContext runtimeContext) throws VNFNotFoundException, RequestExpiredException, UnstableVNFException, InvalidInputException, DuplicateRequestException, NoTransitionDefinedException, LifecycleException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
if (logger.isTraceEnabled()){
logger.trace("Entering to validateRequest with RequestHandlerInput = "+ ObjectUtils.toString(runtimeContext));
}
+ if(!lcmStateManager.isLCMOperationEnabled()) {
+ LoggingUtils.logErrorMessage(
+ LoggingConstants.TargetNames.REQUEST_VALIDATOR,
+ EELFResourceManager.format(Msg.LCM_OPERATIONS_DISABLED),
+ this.getClass().getCanonicalName());
+ throw new LCMOperationsDisabledException("APPC LCM operations have been administratively disabled");
+ }
+
getAAIservice();
validateInput(runtimeContext.getRequestContext());
checkVNFWorkingState(runtimeContext);
@@ -114,9 +130,9 @@ public class RequestValidatorImpl implements RequestValidator {
// for built-in operations skip WF presence check
queryWFM(vnfContext, runtimeContext.getRequestContext());
}
- }
+ }
- private boolean isValidTTL(String ttl) {
+ private boolean isValidTTL(String ttl) {
if (logger.isTraceEnabled()){
logger.trace("Entering to isValidTTL where ttl = "+ ObjectUtils.toString(ttl));
}
@@ -206,7 +222,7 @@ public class RequestValidatorImpl implements RequestValidator {
}
}
- private VNFContext queryAAI(String vnfId) throws VNFNotFoundException {
+ private VNFContext queryAAI(String vnfId) throws VNFNotFoundException, MissingVNFDataInAAIException {
SvcLogicContext ctx = new SvcLogicContext();
ctx = getVnfdata(vnfId, "vnf", ctx);
@@ -267,9 +283,17 @@ public class RequestValidatorImpl implements RequestValidator {
}
}
- private void populateVnfContext(VNFContext vnfContext, SvcLogicContext ctx) {
- vnfContext.setType(ctx.getAttribute("vnf.vnf-type"));
- vnfContext.setStatus(ctx.getAttribute("vnf.orchestration-status"));
+ private void populateVnfContext(VNFContext vnfContext, SvcLogicContext ctx) throws MissingVNFDataInAAIException {
+ String vnfType = ctx.getAttribute("vnf.vnf-type");
+ String orchestrationStatus = ctx.getAttribute("vnf.orchestration-status");
+ if(StringUtils.isEmpty(vnfType)){
+ throw new MissingVNFDataInAAIException("vnf-type");
+ }
+ else if(StringUtils.isEmpty(orchestrationStatus)){
+ throw new MissingVNFDataInAAIException("orchestration-status");
+ }
+ vnfContext.setType(vnfType);
+ vnfContext.setStatus(orchestrationStatus);
vnfContext.setId(ctx.getAttribute("vnf.vnf-id"));
// TODO: Uncomment once A&AI supports VNF version
//vnfContext.setVersion(ctx.getAttribute("vnf.vnf-version"));
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
index 785b6cb04..984de9878 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/OSGI-INF/blueprint/blueprint.xml
@@ -39,9 +39,13 @@
<property name="lifecyclemanager" ref="lifecyclemanagerRef" />
<property name="workflowManager" ref="workflowManagerRef" />
<property name="workingStateManager" ref="workingStateManagerBean" />
+ <property name="lcmStateManager" ref="lcmStateManagerBean" />
</bean>
+ <bean id="lcmStateManagerBean" class="org.openecomp.appc.requesthandler.impl.LCMStateManagerImpl" scope="singleton" />
+
<service id="requestHandlerService" interface="org.openecomp.appc.requesthandler.RequestHandler" ref="requestHandlerBean"/>
+ <service id="lcmStateManagerService" interface="org.openecomp.appc.requesthandler.LCMStateManager" ref="lcmStateManagerBean"/>
<reference id="lifecyclemanagerRef" availability="mandatory" activation="eager" interface="org.openecomp.appc.lifecyclemanager.LifecycleManager" />
<reference id="workflowManagerRef" availability="mandatory" activation="eager" interface="org.openecomp.appc.workflow.WorkFlowManager" />
<reference id="commandExecutorRef" availability="optional" activation="eager" interface="org.openecomp.appc.executor.CommandExecutor" />
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/org/openecomp/appc/default.properties b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/org/openecomp/appc/default.properties
index 2e2763f9a..ba24304f9 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/org/openecomp/appc/default.properties
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/main/resources/org/openecomp/appc/default.properties
@@ -25,21 +25,14 @@ org.openecomp.appc.bootstrap.file=appc.properties
org.openecomp.appc.bootstrap.path=/opt/openecomp/appc/data/properties,${user.home},.
#Property below provided by appc.properties
-#dmaap.poolMembers=<DMAAP_IP>:3904
+appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm
+appc.LCM.poolMembers=<DMAAP_IP>:3904
+appc.LCM.service=dmaap
+appc.LCM.topic.write=APPC-TEST2
+appc.LCM.client.name=APPC-TEST-CLIENT-REQ-HLDR-MAIN
+appc.LCM.provider.user=test
+appc.LCM.provider.pass=test
-dmaap.topic.read=APPC-TEST2
-dmaap.topic.write=APPC-TEST2
-#dmaap.topic.read.filter={"class":"Assigned","field":"request"}
-dmaap.topic.read.filter={"class": "And","filters": [{"class": "Assigned","field": "request"},{"class": "Unassigned","field": "response"}]}
-dmaap.client.name=APPC-TEST-CLIENT-REQ-HDLR-MAIN
-dmaap.client.name.id=0
-#dmaap.client.key=random
-#dmaap.client.secret=random
-
-dmaap.threads.queuesize.min=1
-dmaap.threads.queuesize.max=1000
-dmaap.threads.poolsize.min=1
-dmaap.threads.poolsize.max=2
org.openecomp.appc.db.url.sdnctl=jdbc:mysql://127.0.0.1:3306/test
org.openecomp.appc.db.user.sdnctl=test
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/LCMStateManagerImplTest.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/LCMStateManagerImplTest.java
new file mode 100644
index 000000000..2c8d56e51
--- /dev/null
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/LCMStateManagerImplTest.java
@@ -0,0 +1,55 @@
+/*-
+ * ============LICENSE_START=======================================================
+ * openECOMP : APP-C
+ * ================================================================================
+ * Copyright (C) 2017 AT&T Intellectual Property. All rights
+ * reserved.
+ * ================================================================================
+ * 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.
+ * ============LICENSE_END=========================================================
+ */
+
+package org.openecomp.appc.requesthandler;
+
+import org.junit.Assert;
+import org.junit.Before;
+import org.junit.Test;
+import org.openecomp.appc.requesthandler.impl.LCMStateManagerImpl;
+
+public class LCMStateManagerImplTest {
+
+ LCMStateManager lcmStateManager;
+
+ @Before
+ public void init() throws Exception {
+ lcmStateManager = new LCMStateManagerImpl();
+ }
+
+ /**
+ * Test to check the disable LCM operations method
+ */
+ @Test
+ public void disableLCMOperations() throws Exception {
+ lcmStateManager.disableLCMOperations();
+ Assert.assertFalse(lcmStateManager.isLCMOperationEnabled());
+ }
+
+ /**
+ * Test to check the enable LCM operations method
+ */
+ @Test
+ public void enableLCMOperations() throws Exception {
+ lcmStateManager.enableLCMOperations();
+ Assert.assertTrue(lcmStateManager.isLCMOperationEnabled());
+ }
+}
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java
index c54f94750..17a62b17f 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestConverter.java
@@ -28,7 +28,6 @@ import org.openecomp.appc.domainmodel.lcm.*;
import org.openecomp.appc.executor.objects.LCMCommandStatus;
import org.openecomp.appc.requesthandler.conv.Converter;
-import javax.ws.rs.container.AsyncResponse;
import java.text.ParseException;
import java.time.Instant;
import java.util.Date;
@@ -37,19 +36,20 @@ import java.util.HashMap;
public class TestConverter {
private String expectedJsonBodyStr ="{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}}";
- private String expectedDmaapOutgoingMessageJsonStringTest ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"test\"}";
- private String expectedDmaapOutgoingMessageJsonStringRollback ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"rollback\"}";
- private String expectedDmaapOutgoingMessageJsonStringSnapshot ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"snapshot\"}";
- private String expectedDmaapOutgoingMessageJsonStringAudit ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"audit\"}";
- private String expectedDmaapOutgoingMessageJsonStringHealthCheck ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"health-check\"}";
- private String expectedDmaapOutgoingMessageJsonStringLiveUpgrade ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"live-upgrade\"}";
- private String expectedDmaapOutgoingMessageJsonStringLock ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"lock\"}";
- private String expectedDmaapOutgoingMessageJsonStringModifyConfig ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"modify-config\"}";
- private String expectedDmaapOutgoingMessageJsonStringSoftwareUpload ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"software-upload\"}";
- private String expectedDmaapOutgoingMessageJsonStringStop ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"stop\"}";
- private String expectedDmaapOutgoingMessageJsonStringSync ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"sync\"}";
- private String expectedDmaapOutgoingMessageJsonStringTerminate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"terminate\"}";
- private String expectedDmaapOutgoingMessageJsonStringUnlock ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"rpc-name\":\"unlock\"}";
+ private String expectedDmaapOutgoingMessageJsonStringTest ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"test\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringRollback ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"rollback\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringSnapshot ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"snapshot\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringAudit ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"audit\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringHealthCheck ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"health-check\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringLiveUpgrade ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"live-upgrade\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringLock ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"lock\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringModifyConfig ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"config-modify\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringSoftwareUpload ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"software-upload\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringStop ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"stop\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringSync ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"sync\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringTerminate ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"terminate\",\"type\":\"response\"}";
+ private String expectedDmaapOutgoingMessageJsonStringUnlock ="{\"body\":{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}},\"cambria.partition\":\"MSO\",\"correlation-id\":\"reqid\",\"rpc-name\":\"unlock\",\"type\":\"response\"}";
+ private String expectedJsonBodyStrwithPayload ="{\"output\":{\"common-header\":{\"api-ver\":\"2.0.0\",\"flags\":{},\"originator-id\":\"oid\",\"request-id\":\"reqid\",\"timestamp\":\"1970-01-01T00:00:01.000Z\"},\"payload\":\"{}\",\"status\":{\"code\":400,\"message\":\"SUCCESS - request has been processed successfully\"}}}";
@Test
public void convDateToZuluStringTest(){
@@ -126,16 +126,16 @@ public class TestConverter {
}
@Test
public void convAsyncResponseToBuilderAuditTest() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
VNFOperation action = VNFOperation.Audit;
String rpcName = action.name().toLowerCase();
String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
- Assert.assertEquals(expectedJsonBodyStr,jsonStr);
+ Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
}
@Test
public void convAsyncResponseToDmaapOutgoingMessageJsonStringAuditTest() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
VNFOperation action = VNFOperation.Audit;
String rpcName = action.name().toLowerCase();
String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
@@ -199,17 +199,17 @@ public class TestConverter {
}
@Test
public void convAsyncResponseToBuilderModifyConfigTest() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
- VNFOperation action = VNFOperation.ModifyConfig;
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
+ VNFOperation action = VNFOperation.ConfigModify;
String rpcName = convertActionNameToUrl(action.name());
String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
- Assert.assertEquals(expectedJsonBodyStr,jsonStr);
+ Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
}
@Test
public void convAsyncResponseToDmaapOutgoingMessageJsonStringModifyConfigTest() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
- VNFOperation action = VNFOperation.ModifyConfig;
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
+ VNFOperation action = VNFOperation.ConfigModify;
String rpcName = convertActionNameToUrl(action.name());
String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
System.out.println("jsonStr = " + jsonStr);
@@ -254,17 +254,17 @@ public class TestConverter {
}
@Test
public void convAsyncResponseToBuilderSync() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
VNFOperation action = VNFOperation.Sync;
String rpcName = convertActionNameToUrl(action.name());
String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
- Assert.assertEquals(expectedJsonBodyStr,jsonStr);
+ Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
}
@Test
public void convAsyncResponseToDmaapOutgoingMessageJsonStringSync() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
VNFOperation action = VNFOperation.Sync;
String rpcName = convertActionNameToUrl(action.name());
String jsonStr = Converter.convAsyncResponseToDmaapOutgoingMessageJsonString(action, rpcName, asyncResponse);
@@ -273,11 +273,11 @@ public class TestConverter {
}
@Test
public void convAsyncResponseToBuilderTerminateTest() throws JsonProcessingException {
- ResponseContext asyncResponse = buildAsyncResponse();
+ ResponseContext asyncResponse = buildAsyncResponsewithPayload();
VNFOperation action = VNFOperation.Sync;
String rpcName = convertActionNameToUrl(action.name());
String jsonStr = Converter.convAsyncResponseToJsonStringBody(action, rpcName, asyncResponse);
- Assert.assertEquals(expectedJsonBodyStr,jsonStr);
+ Assert.assertEquals(expectedJsonBodyStrwithPayload,jsonStr);
}
@Test
@@ -334,6 +334,17 @@ public class TestConverter {
return asyncResponse;
}
+ private ResponseContext buildAsyncResponsewithPayload() {
+ ResponseContext asyncResponse = createResponseContextWithSubObjects();
+ asyncResponse.setStatus(LCMCommandStatus.SUCCESS.toStatus(null));
+ asyncResponse.getCommonHeader().setOriginatorId("oid");
+ asyncResponse.getCommonHeader().setApiVer("2.0.0");
+ asyncResponse.getCommonHeader().setRequestId("reqid");
+ asyncResponse.getCommonHeader().setTimestamp(Instant.ofEpochMilli(1000L));
+ asyncResponse.setPayload("{}");
+ return asyncResponse;
+ }
+
private ResponseContext createResponseContextWithSubObjects() {
ResponseContext responseContext = new ResponseContext();
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java
index 1af658f0a..112965575 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestHandler.java
@@ -38,6 +38,13 @@ import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Matchers;
import org.mockito.Mockito;
+import org.openecomp.appc.adapter.factory.DmaapMessageAdapterFactoryImpl;
+import org.openecomp.appc.adapter.message.MessageAdapterFactory;
+import org.openecomp.appc.adapter.messaging.dmaap.impl.DmaapProducerImpl;
+import org.openecomp.appc.configuration.Configuration;
+import org.openecomp.appc.configuration.ConfigurationFactory;
+import org.openecomp.appc.domainmodel.lcm.*;
+import org.openecomp.appc.domainmodel.lcm.Flags.Mode;
import org.openecomp.appc.domainmodel.lcm.ActionIdentifiers;
import org.openecomp.appc.domainmodel.lcm.CommonHeader;
import org.openecomp.appc.domainmodel.lcm.Flags;
@@ -56,6 +63,8 @@ import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
import org.openecomp.appc.lockmanager.api.LockException;
import org.openecomp.appc.lockmanager.api.LockManager;
import org.openecomp.appc.messageadapter.MessageAdapter;
+import org.openecomp.appc.messageadapter.impl.MessageAdapterImpl;
+import org.openecomp.appc.requesthandler.exceptions.*;
import org.openecomp.appc.requesthandler.exceptions.DGWorkflowNotFoundException;
import org.openecomp.appc.requesthandler.exceptions.DuplicateRequestException;
import org.openecomp.appc.requesthandler.exceptions.InvalidInputException;
@@ -73,7 +82,15 @@ import org.openecomp.appc.workflow.objects.WorkflowExistsOutput;
import org.openecomp.appc.workflow.objects.WorkflowRequest;
import org.openecomp.appc.workingstatemanager.WorkingStateManager;
import org.openecomp.appc.workingstatemanager.objects.VNFWorkingState;
+import org.openecomp.sdnc.sli.aai.AAIService;
+
+import com.att.eelf.configuration.EELFLogger;
+import com.att.eelf.configuration.EELFManager;
+
+import org.osgi.framework.Bundle;
+import org.osgi.framework.BundleContext;
import org.osgi.framework.FrameworkUtil;
+import org.osgi.framework.ServiceReference;
import org.powermock.api.mockito.PowerMockito;
import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner;
@@ -82,7 +99,7 @@ import com.att.eelf.configuration.EELFLogger;
import com.att.eelf.configuration.EELFManager;
@RunWith(PowerMockRunner.class)
-@PrepareForTest( {WorkingStateManager.class,FrameworkUtil.class, TransactionRecorder.class, RequestHandlerImpl.class,RequestValidatorImpl.class, TransactionRecorder.class})
+@PrepareForTest( {WorkingStateManager.class,FrameworkUtil.class, TransactionRecorder.class, RequestHandlerImpl.class,RequestValidatorImpl.class, TransactionRecorder.class, MessageAdapterImpl.class})
public class TestRequestHandler {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(TestRequestHandler.class);
@@ -92,10 +109,29 @@ public class TestRequestHandler {
private WorkFlowManager workflowManager;
private WorkingStateManager workingStateManager ;
private LockManager lockManager;
+ private Configuration configuration;
+ private final BundleContext bundleContext=Mockito.mock(BundleContext.class);
+ private final Bundle bundleService=Mockito.mock(Bundle.class);
+ private final ServiceReference sref=Mockito.mock(ServiceReference.class);
+ MessageAdapterFactory factory = new DmaapMessageAdapterFactoryImpl();
+
+
@Before
public void init() throws Exception {
-
+ configuration = ConfigurationFactory.getConfiguration();
+
+ configuration.setProperty("appc.LCM.topic.write" , "TEST");
+ configuration.setProperty("appc.LCM.client.key" , "TEST");
+ configuration.setProperty("appc.LCM.client.secret" , "TEST");
+
+ PowerMockito.mockStatic(FrameworkUtil.class);
+ PowerMockito.when(FrameworkUtil.getBundle(MessageAdapterImpl.class)).thenReturn(bundleService);
+ PowerMockito.when(bundleService.getBundleContext()).thenReturn(bundleContext);
+ PowerMockito.when(bundleContext.getServiceReference(MessageAdapterFactory.class.getName())).thenReturn(sref);
+ PowerMockito.when(bundleContext.getService(sref)).thenReturn(factory);
+
+
requestHandler = new RequestHandlerImpl();
LifecycleManager lifecyclemanager= mock(LifecycleManager.class);
workflowManager= mock(WorkFlowManager.class);
@@ -161,7 +197,7 @@ public class TestRequestHandler {
}
@Test
- public void testInvalidVNFExceptionRequest() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testInvalidVNFExceptionRequest() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
@@ -174,7 +210,7 @@ public class TestRequestHandler {
}
@Test
- public void testLifecycleException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testLifecycleException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
@@ -183,12 +219,12 @@ public class TestRequestHandler {
RequestHandlerInput input = this.getRequestHandlerInput("3009", VNFOperation.Configure,0,false,originatorID, requestID, subRequestID, Instant.now());
PowerMockito.doThrow(new LifecycleException(new Exception(),"Configured","test event")).when(requestValidator).validateRequest(Matchers.any(RuntimeContext.class));
RequestHandlerOutput output = requestHandler.handleRequest(input);
- Assert.assertEquals(LCMCommandStatus.ACTION_NOT_SUPPORTED.getResponseCode(), output.getResponseContext().getStatus().getCode());
+ Assert.assertEquals(LCMCommandStatus.INVALID_VNF_STATE.getResponseCode(), output.getResponseContext().getStatus().getCode());
}
@Test
- public void testRequestExpiredException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testRequestExpiredException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
@@ -200,7 +236,19 @@ public class TestRequestHandler {
}
@Test
- public void testWorkflowNotFoundException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testMissingVNFdata() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
+ String originatorID = UUID.randomUUID().toString();
+ String requestID = UUID.randomUUID().toString();
+ String subRequestID = UUID.randomUUID().toString();
+
+ RequestHandlerInput input = this.getRequestHandlerInput("3009", VNFOperation.Configure,0,false,originatorID, requestID, subRequestID,Instant.now());
+ PowerMockito.doThrow(new MissingVNFDataInAAIException("vnf-type")).when(requestValidator).validateRequest(Matchers.any(RuntimeContext.class));
+ RequestHandlerOutput output = requestHandler.handleRequest(input);
+ Assert.assertEquals(LCMCommandStatus.MISSING_VNF_DATA_IN_AAI.getResponseCode(), output.getResponseContext().getStatus().getCode());
+ }
+
+ @Test
+ public void testWorkflowNotFoundException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
@@ -224,7 +272,7 @@ public class TestRequestHandler {
}
@Test
- public void testInvalidInputException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testInvalidInputException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID1 = UUID.randomUUID().toString();
String requestID1 = UUID.randomUUID().toString();
String subRequestID1 = UUID.randomUUID().toString();
@@ -236,7 +284,7 @@ public class TestRequestHandler {
}
@Test
- public void testNoTransitionDefinedException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testNoTransitionDefinedException() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
@@ -249,7 +297,7 @@ public class TestRequestHandler {
}
@Test
- public void rejectInvalidRequest() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void rejectInvalidRequest() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
@@ -331,7 +379,6 @@ public class TestRequestHandler {
}
-
@Test
public void testOnRequestExecutionEndFailureForWorkingState() throws Exception {
logger.debug("=====================testOnRequestExecutionEndFailureForWorkingState=============================");
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java
index 16caf5860..6d2b4a168 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/java/org/openecomp/appc/requesthandler/TestRequestValidator.java
@@ -34,31 +34,17 @@ import java.util.Map;
import java.util.UUID;
import org.junit.Before;
-import org.junit.Ignore;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.mockito.Mockito;
import org.mockito.invocation.InvocationOnMock;
import org.mockito.stubbing.Answer;
-import org.openecomp.appc.domainmodel.lcm.ActionIdentifiers;
-import org.openecomp.appc.domainmodel.lcm.CommonHeader;
-import org.openecomp.appc.domainmodel.lcm.Flags;
-import org.openecomp.appc.domainmodel.lcm.RequestContext;
-import org.openecomp.appc.domainmodel.lcm.ResponseContext;
-import org.openecomp.appc.domainmodel.lcm.RuntimeContext;
-import org.openecomp.appc.domainmodel.lcm.Status;
-import org.openecomp.appc.domainmodel.lcm.VNFContext;
-import org.openecomp.appc.domainmodel.lcm.VNFOperation;
+import org.openecomp.appc.domainmodel.lcm.*;
import org.openecomp.appc.executor.UnstableVNFException;
import org.openecomp.appc.lifecyclemanager.LifecycleManager;
import org.openecomp.appc.lifecyclemanager.objects.LifecycleException;
import org.openecomp.appc.lifecyclemanager.objects.NoTransitionDefinedException;
-import org.openecomp.appc.requesthandler.exceptions.DGWorkflowNotFoundException;
-import org.openecomp.appc.requesthandler.exceptions.DuplicateRequestException;
-import org.openecomp.appc.requesthandler.exceptions.InvalidInputException;
-import org.openecomp.appc.requesthandler.exceptions.RequestExpiredException;
-import org.openecomp.appc.requesthandler.exceptions.VNFNotFoundException;
-import org.openecomp.appc.requesthandler.exceptions.WorkflowNotFoundException;
+import org.openecomp.appc.requesthandler.exceptions.*;
import org.openecomp.appc.requesthandler.impl.RequestHandlerImpl;
import org.openecomp.appc.requesthandler.impl.RequestValidatorImpl;
import org.openecomp.appc.requesthandler.objects.RequestHandlerInput;
@@ -84,7 +70,6 @@ import com.att.eelf.configuration.EELFManager;
@RunWith(PowerMockRunner.class)
@PrepareForTest( {WorkingStateManager.class,FrameworkUtil.class, TransactionRecorder.class, RequestHandlerImpl.class,RequestValidatorImpl.class, TransactionRecorder.class})
-@Ignore
public class TestRequestValidator {
private static final EELFLogger logger = EELFManager.getInstance().getLogger(TestRequestHandler.class);
@@ -97,6 +82,7 @@ public class TestRequestValidator {
LifecycleManager lifecyclemanager;
WorkFlowManager workflowManager;
WorkingStateManager workingStateManager ;
+ LCMStateManager lcmStateManager;
// AppcDAOImpl dao ;
private final BundleContext bundleContext= Mockito.mock(BundleContext.class);
@@ -147,6 +133,7 @@ public class TestRequestValidator {
lifecyclemanager= Mockito.mock(LifecycleManager.class);
workflowManager= Mockito.mock(WorkFlowManager.class);
workingStateManager = Mockito.mock(WorkingStateManager.class);
+ lcmStateManager = Mockito.mock(LCMStateManager.class);
// transactionRecorder= spy(TransactionRecorder.class);
requestValidator = new RequestValidatorImpl();
@@ -154,8 +141,9 @@ public class TestRequestValidator {
requestValidator.setWorkflowManager(workflowManager);
requestValidator.setLifecyclemanager(lifecyclemanager);
requestValidator.setWorkingStateManager(workingStateManager);
+ requestValidator.setLcmStateManager(lcmStateManager);
-
+ Mockito.when(lcmStateManager.isLCMOperationEnabled()).thenReturn(true);
/* Mockito.when(workingStateManager.isVNFStable("1")).thenReturn(true);
Mockito.when(aaiAdapter.requestGenericVnfData("1")).thenReturn(getGenericVnf("FIREWALL","INSTNATIATED"));*/
// Mockito.when(workflowManager.workflowExists((WorkflowRequest)anyObject())).thenReturn(true);
@@ -254,7 +242,7 @@ public class TestRequestValidator {
return input;
}
@Test
- public void testNullVnfID() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testNullVnfID() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
logger.debug("=====================testNullVnfID=============================");
Mockito.when(workflowManager.workflowExists((WorkflowRequest)anyObject())).thenReturn(new WorkflowExistsOutput(true,true));
RequestHandlerInput input = this.getRequestHandlerInput(null, VNFOperation.Configure, 30,
@@ -309,8 +297,8 @@ public class TestRequestValidator {
- @Test
- public void testNullCommand() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ @Test
+ public void testNullCommand() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
logger.debug("=====================testNullCommand=============================");
Mockito.when(workflowManager.workflowExists((WorkflowRequest)anyObject())).thenReturn(new WorkflowExistsOutput(true,true));
RequestHandlerInput input = this.getRequestHandlerInput("7", null,30,
@@ -327,7 +315,7 @@ public class TestRequestValidator {
}
@Test
- public void testNullVnfIDAndCommand() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException,DGWorkflowNotFoundException {
+ public void testNullVnfIDAndCommand() throws NoTransitionDefinedException, LifecycleException, InvalidInputException, RequestExpiredException, UnstableVNFException, DuplicateRequestException, VNFNotFoundException, WorkflowNotFoundException, DGWorkflowNotFoundException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
logger.debug("=====================testNullVnfIDAndCommand=============================");
Mockito.when(workflowManager.workflowExists((WorkflowRequest)anyObject())).thenReturn(new WorkflowExistsOutput(true,true));
RequestHandlerInput input = this.getRequestHandlerInput(null, null,30,
@@ -545,45 +533,50 @@ public class TestRequestValidator {
}
@Test
- public void testLockOperation() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException {
+ public void testLockOperation() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
testOperation("no-matter", VNFOperation.Lock);
}
@Test
- public void testUnlockOperation() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException {
+ public void testUnlockOperation() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
testOperation("no-matter", VNFOperation.Unlock);
}
@Test
- public void testCheckLockOperation() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException {
+ public void testCheckLockOperation() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
testOperation("no-matter", VNFOperation.CheckLock);
}
@Test(expected = NoTransitionDefinedException.class)
- public void testLockOperationNegative() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException {
+ public void testLockOperationNegative() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(), eq(VNFOperation.Lock.toString()))).thenThrow(new NoTransitionDefinedException("", "", ""));
Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
testOperation("no-matter", VNFOperation.Lock);
}
@Test(expected = NoTransitionDefinedException.class)
- public void testUnlockOperationNegative() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException {
+ public void testUnlockOperationNegative() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(), eq(VNFOperation.Unlock.toString()))).thenThrow(new NoTransitionDefinedException("", "", ""));
Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
testOperation("no-matter", VNFOperation.Unlock);
}
@Test(expected = NoTransitionDefinedException.class)
- public void testCheckLockOperationNegative() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException {
+ public void testCheckLockOperationNegative() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
Mockito.when(lifecyclemanager.getNextState(anyString(), anyString(), eq(VNFOperation.CheckLock.toString()))).thenThrow(new NoTransitionDefinedException("", "", ""));
Mockito.when(workingStateManager.isVNFStable("no-matter")).thenReturn(true);
testOperation("no-matter", VNFOperation.CheckLock);
}
- private void testOperation(String resource, VNFOperation operation) throws WorkflowNotFoundException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, InvalidInputException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, RequestExpiredException {
+ @Test(expected = LCMOperationsDisabledException.class)
+ public void testLCMOperationsDisabled() throws RequestExpiredException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, WorkflowNotFoundException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, InvalidInputException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
+ Mockito.when(lcmStateManager.isLCMOperationEnabled()).thenReturn(false);
+ testOperation("no-matter", VNFOperation.Configure);
+ }
+ private void testOperation(String resource, VNFOperation operation) throws WorkflowNotFoundException, DuplicateRequestException, DGWorkflowNotFoundException, VNFNotFoundException, InvalidInputException, LifecycleException, UnstableVNFException, NoTransitionDefinedException, RequestExpiredException, MissingVNFDataInAAIException, LCMOperationsDisabledException {
String originatorID = UUID.randomUUID().toString();
String requestID = UUID.randomUUID().toString();
String subRequestID = UUID.randomUUID().toString();
diff --git a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/resources/org/openecomp/appc/default.properties b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/resources/org/openecomp/appc/default.properties
index 2d75df419..0659d4dc5 100644
--- a/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/resources/org/openecomp/appc/default.properties
+++ b/appc-dispatcher/appc-request-handler/appc-request-handler-core/src/test/resources/org/openecomp/appc/default.properties
@@ -77,27 +77,15 @@ org.openecomp.appc.db.pass.%s", schema), "");
#Property below provided by appc.properties
-#dmaap.poolMembers=<DMAAP_IP>:3904
-
-dmaap.topic.read=APPC-TEST2
-dmaap.topic.write=APPC-TEST2
-#dmaap.topic.read.filter={"class":"Assigned","field":"request"}
-dmaap.topic.read.filter={"class": "And","filters": [{"class": "Assigned","field": "request"},{"class": "Unassigned","field": "response"}]}
-dmaap.client.name=APPC-TEST-CLIENT-REQ-HDLR-TEST
-dmaap.client.name.id=0
-#dmaap.client.key=random
-#dmaap.client.secret=random
-
-dmaap.threads.queuesize.min=1
-dmaap.threads.queuesize.max=1000
-dmaap.threads.poolsize.min=1
-dmaap.threads.poolsize.max=2
+appc.LCM.provider.url=https://localhost:8443/restconf/operations/appc-provider-lcm
+appc.LCM.poolMembers=<DMAAP_IP>:3904
+appc.LCM.service=dmaap
+appc.LCM.topic.write=APPC-TEST2
+appc.LCM.client.name=APPC-TEST-CLIENT-REQ-HDLR-TEST
+appc.LCM.provider.user=test
+appc.LCM.provider.pass=test
+
-#
-# This needs to be changed so that the action can be appended to the end of the URL path
-#
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:topology-service
-#provider.urls.topology=https://admin:password@<IP_ADDRESS>:8443/restconf/operations/appc-provider:
mysqlIp=127.0.0.1
org.openecomp.appc.db.url.sdnctl=jdbc:mysql://${mysqlIp}:3306/test