summaryrefslogtreecommitdiffstats
path: root/adapters/mso-tenant-adapter/src
diff options
context:
space:
mode:
Diffstat (limited to 'adapters/mso-tenant-adapter/src')
-rw-r--r--adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/HealthCheckHandler.java59
-rw-r--r--adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapter.java77
-rw-r--r--adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImpl.java290
-rw-r--r--adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/TenantAdapterRest.java307
-rw-r--r--adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantAlreadyExists.java45
-rw-r--r--adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantException.java76
-rw-r--r--adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionBean.java64
-rw-r--r--adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImplTest.java82
-rw-r--r--adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/TenantAdapterRestTest.java60
-rw-r--r--adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/exceptions/TenantAlreadyExistsTest.java32
-rw-r--r--adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionBeanTest.java47
-rw-r--r--adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionTest.java49
-rw-r--r--adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java132
-rw-r--r--adapters/mso-tenant-adapter/src/test/resources/logback-test.xml47
14 files changed, 0 insertions, 1367 deletions
diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/HealthCheckHandler.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/HealthCheckHandler.java
deleted file mode 100644
index 1a4bec4798..0000000000
--- a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/HealthCheckHandler.java
+++ /dev/null
@@ -1,59 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.mso.adapters.tenant;
-
-
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.Path;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.Response;
-
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.HealthCheckUtils;
-import org.openecomp.mso.utils.UUIDChecker;
-
-@Path("/")
- public class HealthCheckHandler {
-
- private static MsoLogger msoLogger = MsoLogger.getMsoLogger(MsoLogger.Catalog.RA);
- @HEAD
- @GET
- @Path("/healthcheck")
- @Produces("text/html")
- public Response healthcheck (@QueryParam("requestId") String requestId) {
- long startTime = System.currentTimeMillis ();
- MsoLogger.setServiceName ("Healthcheck");
- UUIDChecker.verifyOldUUID(requestId, msoLogger);
- HealthCheckUtils healthCheck = new HealthCheckUtils ();
- if (!healthCheck.siteStatusCheck(msoLogger)) {
- return HealthCheckUtils.HEALTH_CHECK_NOK_RESPONSE;
- }
-
- if (!healthCheck.catalogDBCheck (msoLogger, startTime)) {
- return HealthCheckUtils.NOT_STARTED_RESPONSE;
- }
- msoLogger.debug("healthcheck - Successful");
- return HealthCheckUtils.HEALTH_CHECK_RESPONSE;
- }
-
-}
diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapter.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapter.java
deleted file mode 100644
index 4141e8951f..0000000000
--- a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapter.java
+++ /dev/null
@@ -1,77 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.mso.adapters.tenant;
-
-
-import java.util.Map;
-
-import javax.jws.WebMethod;
-import javax.jws.WebParam;
-import javax.jws.WebParam.Mode;
-import javax.jws.WebService;
-import javax.xml.bind.annotation.XmlElement;
-import javax.xml.ws.Holder;
-
-import org.openecomp.mso.adapters.tenant.exceptions.TenantAlreadyExists;
-import org.openecomp.mso.adapters.tenant.exceptions.TenantException;
-import org.openecomp.mso.adapters.tenantrest.TenantRollback;
-import org.openecomp.mso.entity.MsoRequest;
-
-@WebService (name="TenantAdapter", targetNamespace="http://org.openecomp.mso/tenant")
-public interface MsoTenantAdapter
-{
- /**
- * This is the "Create Tenant" Web Service Endpoint definition.
- */
- @WebMethod
- public void createTenant (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantName") @XmlElement(required=true) String tenantName,
- @WebParam(name="metadata") Map<String,String> metadata,
- @WebParam(name="failIfExists") Boolean failIfExists,
- @WebParam(name="backout") Boolean backout,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="tenantId", mode=Mode.OUT) Holder<String> tenantId,
- @WebParam(name="rollback", mode=Mode.OUT) Holder<TenantRollback> rollback )
- throws TenantException, TenantAlreadyExists;
-
- @WebMethod
- public void queryTenant (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantNameOrId") @XmlElement(required=true) String tenantNameOrId,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="tenantId", mode=Mode.OUT) Holder<String> tenantId,
- @WebParam(name="tenantName", mode=Mode.OUT) Holder<String> tenantName,
- @WebParam(name="metadata", mode=Mode.OUT) Holder<Map<String,String>> metadata )
- throws TenantException;
-
- @WebMethod
- public void deleteTenant (@WebParam(name="cloudSiteId") @XmlElement(required=true) String cloudSiteId,
- @WebParam(name="tenantId") @XmlElement(required=true) String tenantId,
- @WebParam(name="request") MsoRequest msoRequest,
- @WebParam(name="tenantDeleted", mode=Mode.OUT) Holder<Boolean> tenantDeleted)
- throws TenantException;
-
- @WebMethod
- public void rollbackTenant (@WebParam(name="rollback") @XmlElement(required=true) TenantRollback rollback)
- throws TenantException;
-
- @WebMethod
- public void healthCheck ();
-}
diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImpl.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImpl.java
deleted file mode 100644
index 85d50aee47..0000000000
--- a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImpl.java
+++ /dev/null
@@ -1,290 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.mso.adapters.tenant;
-
-
-import java.util.Map;
-
-import javax.annotation.Resource;
-import javax.jws.WebService;
-import javax.xml.ws.Holder;
-import javax.xml.ws.WebServiceContext;
-
-import org.openecomp.mso.openstack.exceptions.MsoCloudSiteNotFound;
-import org.openecomp.mso.properties.MsoPropertiesFactory;
-import org.openecomp.mso.adapters.tenant.exceptions.TenantAlreadyExists;
-import org.openecomp.mso.adapters.tenant.exceptions.TenantException;
-import org.openecomp.mso.adapters.tenantrest.TenantRollback;
-import org.openecomp.mso.entity.MsoRequest;
-import org.openecomp.mso.logger.MessageEnum;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.openstack.beans.MsoTenant;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.utils.MsoTenantUtils;
-import org.openecomp.mso.openstack.utils.MsoTenantUtilsFactory;
-
-@WebService(serviceName = "TenantAdapter", endpointInterface = "org.openecomp.mso.adapters.tenant.MsoTenantAdapter", targetNamespace = "http://org.openecomp.mso/tenant")
-public class MsoTenantAdapterImpl implements MsoTenantAdapter {
-
- MsoPropertiesFactory msoPropertiesFactory = new MsoPropertiesFactory();
- MsoTenantUtilsFactory tFactory = new MsoTenantUtilsFactory(MSO_PROP_TENANT_ADAPTER);
-
- public static final String MSO_PROP_TENANT_ADAPTER="MSO_PROP_TENANT_ADAPTER";
- public static final String CREATE_TENANT = "CreateTenant";
- public static final String OPENSTACK = "OpenStack";
- public static final String QUERY_TENANT = "QueryTenant";
- public static final String DELETE_TENANT = "DeleteTenant";
- public static final String ROLLBACK_TENANT = "RollbackTenant";
-
- @Resource
- WebServiceContext wsContext;
-
- private static MsoLogger logger = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
-
- protected MsoTenantUtilsFactory getTenantUtilsFactory() {
- return tFactory;
- }
-
- /**
- * Health Check web method. Does nothing but return to show the adapter is deployed.
- */
- @Override
- public void healthCheck () {
- logger.debug ("Health check call in Tenant Adapter");
- }
-
- /**
- * This is the "Create Tenant" web service implementation. It will create
- * a new Tenant in the specified cloud. If the tenant already exists, this
- * can be considered a success or failure, depending on the value of the
- * 'failIfExists' parameter.
- *
- * The method returns the tenantId (the Openstack ID), and a TenantRollback
- * object. This last object can be passed as-is to the rollbackTenant method
- * to undo what (if anything) was created. This is useful if a Tenant is
- * successfully created but the orchestrator fails on a subsequent operation.
- */
- @Override
- public void createTenant (String cloudSiteId,
- String tenantName,
- Map <String, String> metadata,
- Boolean failIfExists,
- Boolean backout,
- MsoRequest msoRequest,
- Holder <String> tenantId,
- Holder <TenantRollback> rollback) throws TenantException {
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName (CREATE_TENANT);
-
- logger.debug ("Call to MSO createTenant adapter. Creating Tenant: " + tenantName
- + "in "
- + cloudSiteId);
-
- // Will capture total time for metrics
- long startTime = System.currentTimeMillis ();
-
- // Start building up rollback object
- TenantRollback tenantRollback = new TenantRollback ();
- tenantRollback.setCloudId (cloudSiteId);
- tenantRollback.setMsoRequest (msoRequest);
-
- MsoTenantUtils tUtils;
- MsoTenant newTenant = null;
- String newTenantId;
- long queryTenantStartTime = System.currentTimeMillis ();
- try {
- tUtils = tFactory.getTenantUtils (cloudSiteId);
- newTenant = tUtils.queryTenantByName (tenantName, cloudSiteId);
- logger.recordMetricEvent (queryTenantStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", OPENSTACK, QUERY_TENANT, null);
-
- } catch (MsoException me) {
- logger.recordMetricEvent (queryTenantStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with Open Stack", OPENSTACK, QUERY_TENANT, null);
- String error = "Create Tenant " + tenantName + ": " + me;
- logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, "createTenant", MsoLogger.ErrorCode.DataError, "Exception while communicate with Open Stack", me);
- logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new TenantException (me);
- }
- if (newTenant == null) {
- if (backout == null)
- backout = true;
- long createTenantStartTime = System.currentTimeMillis ();
- try {
- newTenantId = tUtils.createTenant (tenantName, cloudSiteId, metadata, backout.booleanValue ());
- logger.recordMetricEvent (createTenantStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", OPENSTACK, CREATE_TENANT, null);
- } catch (MsoException me) {
- logger.recordMetricEvent (createTenantStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, "Exception while communicate with Open Stack", OPENSTACK, CREATE_TENANT, null);
- String error = "Create Tenant " + tenantName + ": " + me;
- logger.error (MessageEnum.RA_CREATE_TENANT_ERR, me.getMessage(), OPENSTACK, "createTenant", MsoLogger.ErrorCode.DataError, "Exception while communicate with Open Stack", me);
- logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new TenantException (me);
- }
- tenantRollback.setTenantId (newTenantId);
- tenantRollback.setTenantCreated (true);
- logger.debug ("Tenant " + tenantName + " successfully created with ID " + newTenantId);
- } else {
- if (failIfExists != null && failIfExists) {
- String error = CREATE_TENANT + ": Tenant " + tenantName + " already exists in " + cloudSiteId;
- logger.error (MessageEnum.RA_TENANT_ALREADY_EXIST, tenantName, cloudSiteId, OPENSTACK, "", MsoLogger.ErrorCode.DataError, CREATE_TENANT + ", Tenant already exists");
- logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.DataError, error);
- throw new TenantAlreadyExists (tenantName, cloudSiteId, newTenant.getTenantId ());
- }
-
- newTenantId = newTenant.getTenantId ();
- tenantRollback.setTenantCreated (false);
- logger.debug ("Tenant " + tenantName + " already exists with ID " + newTenantId);
- }
-
-
- tenantId.value = newTenantId;
- rollback.value = tenantRollback;
- logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully create tenant");
- return;
- }
-
- @Override
- public void queryTenant (String cloudSiteId,
- String tenantNameOrId,
- MsoRequest msoRequest,
- Holder <String> tenantId,
- Holder <String> tenantName,
- Holder <Map <String, String>> metadata) throws TenantException {
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName (QUERY_TENANT);
- logger.debug ("Querying Tenant " + tenantNameOrId + " in " + cloudSiteId);
-
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis ();
-
- MsoTenantUtils tUtils = null;
- MsoTenant qTenant = null;
- long subStartTime = System.currentTimeMillis ();
- try {
- tUtils = tFactory.getTenantUtils (cloudSiteId);
- qTenant = tUtils.queryTenant (tenantNameOrId, cloudSiteId);
- logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully received response from Open Stack", OPENSTACK, QUERY_TENANT, null);
- if (qTenant == null) {
- // Not found by ID, Try by name.
- qTenant = tUtils.queryTenantByName (tenantNameOrId, cloudSiteId);
- }
-
- if (qTenant == null) {
- logger.debug ("QueryTenant: Tenant " + tenantNameOrId + " not found");
- tenantId.value = null;
- tenantName.value = null;
- metadata.value = null;
- } else {
- logger.debug ("QueryTenant: Tenant " + tenantNameOrId + " found with ID " + qTenant.getTenantId ());
- tenantId.value = qTenant.getTenantId ();
- tenantName.value = qTenant.getTenantName ();
- metadata.value = qTenant.getMetadata ();
- }
- } catch (MsoException me) {
- String error = "Query Tenant " + tenantNameOrId + ": " + me;
- logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, OPENSTACK, QUERY_TENANT, null);
- logger.error (MessageEnum.RA_GENERAL_EXCEPTION, me.getMessage(), OPENSTACK, "", MsoLogger.ErrorCode.DataError, "Exception in queryTenant", me);
- logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new TenantException (me);
- }
- logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully query tenant");
- return;
- }
-
- @Override
- public void deleteTenant (String cloudSiteId,
- String tenantId,
- MsoRequest msoRequest,
- Holder <Boolean> tenantDeleted) throws TenantException {
- MsoLogger.setLogContext (msoRequest);
- MsoLogger.setServiceName (DELETE_TENANT);
-
- logger.debug ("Deleting Tenant " + tenantId + " in " + cloudSiteId);
-
- // Will capture execution time for metrics
- long startTime = System.currentTimeMillis ();
-
- // Delete the Tenant.
- long subStartTime = System.currentTimeMillis ();
- try {
-
- MsoTenantUtils tUtils = tFactory.getTenantUtils (cloudSiteId);
- boolean deleted = tUtils.deleteTenant (tenantId, cloudSiteId);
- tenantDeleted.value = deleted;
- logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully communicate with Open Stack", OPENSTACK, DELETE_TENANT, null);
- } catch (MsoException me) {
- String error = "Delete Tenant " + tenantId + ": " + me;
- logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, OPENSTACK, DELETE_TENANT, null);
- logger.error (MessageEnum.RA_DELETE_TEMAMT_ERR, me.getMessage(), OPENSTACK, "", MsoLogger.ErrorCode.DataError, "Exception - DeleteTenant", me);
- logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new TenantException (me);
- }
-
- // On success, nothing is returned.
- logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully delete tenant");
- return;
- }
-
- /**
- * This web service endpoint will rollback a previous Create VNF operation.
- * A rollback object is returned to the client in a successful creation
- * response. The client can pass that object as-is back to the rollbackVnf
- * operation to undo the creation.
- *
- * The rollback includes removing the VNF and deleting the tenant if the
- * tenant did not exist prior to the VNF creation.
- */
- @Override
- public void rollbackTenant (TenantRollback rollback) throws TenantException {
- long startTime = System.currentTimeMillis ();
- MsoLogger.setServiceName (ROLLBACK_TENANT);
- // rollback may be null (e.g. if stack already existed when Create was called)
- if (rollback == null) {
- logger.warn (MessageEnum.RA_ROLLBACK_NULL, OPENSTACK, "rollbackTenant", MsoLogger.ErrorCode.DataError, "rollbackTenant, rollback is null");
- return;
- }
-
- // Get the elements of the VnfRollback object for easier access
- String cloudSiteId = rollback.getCloudId ();
- String tenantId = rollback.getTenantId ();
-
- MsoLogger.setLogContext (rollback.getMsoRequest ());
- logger.debug ("Rolling Back Tenant " + rollback.getTenantId () + " in " + cloudSiteId);
-
- long subStartTime = System.currentTimeMillis ();
- if (rollback.getTenantCreated ()) {
- try {
-
- MsoTenantUtils tUtils = tFactory.getTenantUtils (cloudSiteId);
- tUtils.deleteTenant (tenantId, cloudSiteId);
- logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully communicate with Open Stack", OPENSTACK, ROLLBACK_TENANT, null);
- } catch (MsoException me) {
- me.addContext (ROLLBACK_TENANT);
- // Failed to delete the tenant.
- String error = "Rollback Tenant " + tenantId + ": " + me;
- logger.recordMetricEvent (subStartTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error, OPENSTACK, ROLLBACK_TENANT, null);
- logger.error (MessageEnum.RA_ROLLBACK_TENANT_ERR, me.getMessage(), OPENSTACK, "rollbackTenant", MsoLogger.ErrorCode.DataError, "Exception - rollbackTenant", me);
- logger.recordAuditEvent (startTime, MsoLogger.StatusCode.ERROR, MsoLogger.ResponseCode.CommunicationError, error);
- throw new TenantException (me);
- }
- }
- logger.recordAuditEvent (startTime, MsoLogger.StatusCode.COMPLETE, MsoLogger.ResponseCode.Suc, "Successfully roll back tenant");
- return;
- }
-}
diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/TenantAdapterRest.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/TenantAdapterRest.java
deleted file mode 100644
index 63f65ccd25..0000000000
--- a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/TenantAdapterRest.java
+++ /dev/null
@@ -1,307 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
- * Copyright (C) 2017 Huawei Technologies Co., Ltd. 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.mso.adapters.tenant;
-
-
-import java.util.Map;
-
-import javax.servlet.http.HttpServletResponse;
-import javax.ws.rs.Consumes;
-import javax.ws.rs.DELETE;
-import javax.ws.rs.GET;
-import javax.ws.rs.HEAD;
-import javax.ws.rs.POST;
-import javax.ws.rs.Path;
-import javax.ws.rs.PathParam;
-import javax.ws.rs.Produces;
-import javax.ws.rs.QueryParam;
-import javax.ws.rs.core.MediaType;
-import javax.ws.rs.core.Response;
-import javax.xml.ws.Holder;
-
-import org.openecomp.mso.adapters.tenant.exceptions.TenantAlreadyExists;
-import org.openecomp.mso.adapters.tenant.exceptions.TenantException;
-import org.openecomp.mso.adapters.tenantrest.CreateTenantError;
-import org.openecomp.mso.adapters.tenantrest.CreateTenantRequest;
-import org.openecomp.mso.adapters.tenantrest.CreateTenantResponse;
-import org.openecomp.mso.adapters.tenantrest.DeleteTenantError;
-import org.openecomp.mso.adapters.tenantrest.DeleteTenantRequest;
-import org.openecomp.mso.adapters.tenantrest.DeleteTenantResponse;
-import org.openecomp.mso.adapters.tenantrest.QueryTenantError;
-import org.openecomp.mso.adapters.tenantrest.QueryTenantResponse;
-import org.openecomp.mso.adapters.tenantrest.RollbackTenantError;
-import org.openecomp.mso.adapters.tenantrest.RollbackTenantRequest;
-import org.openecomp.mso.adapters.tenantrest.RollbackTenantResponse;
-import org.openecomp.mso.adapters.tenantrest.TenantRollback;
-import org.openecomp.mso.logger.MsoLogger;
-import org.openecomp.mso.openstack.beans.MsoTenant;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-/**
- * This class services calls to the REST interface for Tenants (http://host:port/vnfs/rest/v1/tenants)
- * Both XML and JSON can be produced/consumed. Set Accept: and Content-Type: headers appropriately. XML is the default.
- */
-@Path("/v1/tenants")
-public class TenantAdapterRest {
- private static MsoLogger LOGGER = MsoLogger.getMsoLogger (MsoLogger.Catalog.RA);
-
- //RAA? No logging in wrappers
-
- @HEAD
- @GET
- @Path("/healthcheck")
- @Produces(MediaType.TEXT_HTML)
- public Response healthcheck () {
- String CHECK_HTML = "<!DOCTYPE html><html><head><meta charset=\"ISO-8859-1\"><title>Health Check</title></head><body>Application ready</body></html>";
- return Response.status (HttpServletResponse.SC_OK).entity (CHECK_HTML).build ();
- }
-
- /*
- URL:
- EP: http://host:8080/tenants/rest
- Resource: v1/tenants
- REQ - metadata?
- {
- "cloudSiteId": "DAN",
- "tenantName": "RAA_1",
- "failIfExists": true,
- "msoRequest": {
- "requestId": "ra1",
- "serviceInstanceId": "sa1"
- }}
- RESP-
- {
- "cloudSiteId": "DAN",
- "tenantId": "128e10b9996d43a7874f19bbc4eb6749",
- "tenantCreated": true,
- "tenantRollback": {
- "tenantId": "128e10b9996d43a7874f19bbc4eb6749",
- "cloudId": "DAN", // RAA? cloudId instead of cloudSiteId
- "tenantCreated": true,
- "msoRequest": {
- "requestId": "ra1",
- "serviceInstanceId": "sa1"
- }
- }
- }
- */
- @POST
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response createTenant(CreateTenantRequest req) {
- LOGGER.debug("createTenant enter: " + req.toJsonString());
-
- String newTenantId = null;
- TenantRollback tenantRollback = new TenantRollback ();
-
- try {
- Holder<String> htenant = new Holder<>();
- Holder<TenantRollback> hrollback = new Holder<>();
- MsoTenantAdapter impl = new MsoTenantAdapterImpl();
- impl.createTenant(
- req.getCloudSiteId(),
- req.getTenantName(),
- req.getMetadata(),
- req.getFailIfExists(),
- req.getBackout(),
- req.getMsoRequest(),
- htenant,
- hrollback);
- newTenantId = htenant.value;
- tenantRollback = hrollback.value;
-// TenantAdapterCore TAImpl = new TenantAdapterCore();
-// newTenantId = TAImpl.createTenant (req.getCloudSiteId(),
-// req.getTenantName(),
-// req.getFailIfExists(),
-// req.getBackout(),
-// req.getMetadata(),
-// req.getMsoRequest(),
-// tenantRollback);
- }
- catch (TenantAlreadyExists tae) {
- LOGGER.debug("Exception :",tae);
- CreateTenantError exc = new CreateTenantError(tae.getMessage(), tae.getFaultInfo().getCategory(), Boolean.TRUE);
- return Response.status(HttpServletResponse.SC_NOT_IMPLEMENTED).entity(exc).build();
- }
- catch (TenantException te) {
- LOGGER.debug("Exception :",te);
- CreateTenantError exc = new CreateTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory(), Boolean.TRUE);
- return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build();
- }
- catch (Exception e) {
- LOGGER.debug("Exception :",e);
- CreateTenantError exc = new CreateTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE);
- return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build();
- }
-
- CreateTenantResponse resp = new CreateTenantResponse (req.getCloudSiteId(), newTenantId, tenantRollback.getTenantCreated(), tenantRollback);
- return Response.status(HttpServletResponse.SC_OK).entity(resp).build();
- }
-
- /*
- URL:
- http://host:8080/tenants/rest
- Resource: v1/tenant/tennatId
- REQ:
- {"cloudSiteId": "DAN",
- "tenantId": "ca84cd3d3df44272845da554656b3ace",
- "msoRequest": {
- "requestId": "ra1",
- "serviceInstanceId": "sa1"
- }
- }
- RESP:
- {"tenantDeleted": true}
- */
- @DELETE
- @Path("{tenantId}")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response deleteTenant(
- @PathParam("tenantId") String tenantId,
- DeleteTenantRequest req)
- {
- boolean tenantDeleted = false;
-
- try {
- Holder<Boolean> deleted = new Holder<>();
- MsoTenantAdapter impl = new MsoTenantAdapterImpl();
- impl.deleteTenant(
- req.getCloudSiteId(),
- req.getTenantId(),
- req.getMsoRequest(),
- deleted);
- tenantDeleted = deleted.value;
- }
- catch (TenantException te) {
- LOGGER.debug("Exception :",te);
- DeleteTenantError exc = new DeleteTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory(), Boolean.TRUE);
- return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build();
- }
- catch (Exception e) {
- LOGGER.debug("Exception :",e);
- DeleteTenantError exc = new DeleteTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE);
- return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build();
- }
- DeleteTenantResponse resp = new DeleteTenantResponse();
- resp.setTenantDeleted(tenantDeleted);
- return Response.status(HttpServletResponse.SC_OK).entity(resp).build();
- }
-
- /*
- URL
- EP://http://host:8080/tenants/rest
- Resource: /v1/tenants
- Params:?tenantNameOrId=RAA_1&cloudSiteId=DAN
- RESP
- {
- "tenantId": "214b428a1f554c02935e66330f6a5409",
- "tenantName": "RAA_1",
- "metadata": {}
- }
- */
- @GET
- @Path("{tenantId}")
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response queryTenant(
- @PathParam("tenantId") String tenantId,
-// @QueryParam("tenantNameOrId") String tenantNameOrId, //RAA? diff from doc
- @QueryParam("cloudSiteId") String cloudSiteId,
- @QueryParam("msoRequest.requestId") String requestId,
- @QueryParam("msoRequest.serviceInstanceId") String serviceInstanceId)
- {
- MsoTenant tenant = null;
- try {
- Holder<String> htenant = new Holder<>();
- Holder<String> tenantName = new Holder<>();
- Holder<Map<String,String>> metadata = new Holder<>();
- MsoTenantAdapter impl = new MsoTenantAdapterImpl();
- impl.queryTenant(
- cloudSiteId,
- tenantId,
- null,
- htenant,
- tenantName,
- metadata
- );
- tenant = new MsoTenant(htenant.value, tenantName.value, metadata.value);
-// TenantAdapterCore TAImpl = new TenantAdapterCore();
-// MsoRequest msoReq = new MsoRequest();
-// tenant = TAImpl.queryTenant (cloudSiteId, tenantId, msoReq);
- }
- catch (TenantException te) {
- LOGGER.debug("Exception :",te);
- QueryTenantError exc = new QueryTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory());
- return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build();
- }
- catch (Exception e) {
- LOGGER.debug("Exception :",e);
- QueryTenantError exc = new QueryTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL);
- return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build();
- }
- QueryTenantResponse resp = new QueryTenantResponse(tenant.getTenantId(), tenant.getTenantName(), tenant.getMetadata());
- return Response.status(HttpServletResponse.SC_OK).entity(resp).build();
- }
-
- /*
- URL
- EP: //http://host:8080/tenants/rest
- Resource: /v1/tenants/rollback
- REQ
- {"cloudSiteId": "DAN",
- "tenantId": "f58abb05041d4ff384d4d22d1ccd2a6c",
- "msoRequest": {
- "requestId": "ra1",
- "serviceInstanceId": "sa1"
- }
- }
- RESP:
- {"tenantDeleted": true}
- */
- @DELETE
- @Path("")
- @Consumes({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- @Produces({ MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON })
- public Response rollbackTenant(
- @QueryParam("rollback") String action, // WTF?
- RollbackTenantRequest req)
- {
- try {
- MsoTenantAdapter impl = new MsoTenantAdapterImpl();
- impl.rollbackTenant(req.getTenantRollback());
- }
- catch (TenantException te) {
- LOGGER.debug("Exception :",te);
- RollbackTenantError exc = new RollbackTenantError(te.getFaultInfo().getMessage(), te.getFaultInfo().getCategory(), Boolean.TRUE);
- return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build();
- }
- catch (Exception e) {
- LOGGER.debug("Exception :",e);
- RollbackTenantError exc = new RollbackTenantError(e.getMessage(), MsoExceptionCategory.INTERNAL, Boolean.TRUE);
- return Response.status(HttpServletResponse.SC_INTERNAL_SERVER_ERROR).entity(exc).build();
- }
-
- RollbackTenantResponse resp = new RollbackTenantResponse ();
- resp.setTenantRolledback(req != null);
- return Response.status(HttpServletResponse.SC_OK).entity(resp).build();
- }
-}
diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantAlreadyExists.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantAlreadyExists.java
deleted file mode 100644
index e232866126..0000000000
--- a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantAlreadyExists.java
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.mso.adapters.tenant.exceptions;
-
-
-
-import javax.xml.ws.WebFault;
-
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-
-/**
- * This class reports an exception when trying to create a VNF when another
- * VNF of the same name already exists in the target cloud/tenant. Note that
- * the createVnf method suppresses this exception by default.
- *
- *
- */
-@WebFault (name="TenantAlreadyExists", faultBean="org.openecomp.mso.adapters.tenant.exceptions.TenantExceptionBean", targetNamespace="http://org.openecomp.mso/tenant")
-public class TenantAlreadyExists extends TenantException {
-
- private static final long serialVersionUID = 1L;
-
- public TenantAlreadyExists (String name, String cloudId, String tenantId) {
- super("Tenant " + name + " already exists in " + cloudId + " with ID " + tenantId, MsoExceptionCategory.USERDATA);
- }
-}
diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantException.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantException.java
deleted file mode 100644
index e868a7e80c..0000000000
--- a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantException.java
+++ /dev/null
@@ -1,76 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.mso.adapters.tenant.exceptions;
-
-
-
-import javax.xml.ws.WebFault;
-
-import org.openecomp.mso.adapters.tenant.exceptions.TenantExceptionBean;
-import org.openecomp.mso.openstack.exceptions.MsoException;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-/**
- * This class simply extends Exception (without addition additional functionality)
- * to provide an identifier for Tenant related exceptions on create, delete, query.
- *
- *
- */
-@WebFault (name="TenantException", faultBean="org.openecomp.mso.adapters.tenant.exceptions.TenantExceptionBean", targetNamespace="http://org.openecomp.mso/tenant")
-public class TenantException extends Exception {
-
- private static final long serialVersionUID = 1L;
-
- private TenantExceptionBean faultInfo;
-
- public TenantException (String msg) {
- super(msg);
- faultInfo = new TenantExceptionBean (msg);
- }
-
- public TenantException (String msg, Throwable e) {
- super (msg, e);
- faultInfo = new TenantExceptionBean (msg);
- }
-
- public TenantException (String msg, MsoExceptionCategory category) {
- super(msg);
- faultInfo = new TenantExceptionBean (msg, category);
- }
-
- public TenantException (String msg, MsoExceptionCategory category, Throwable e) {
- super (msg, e);
- faultInfo = new TenantExceptionBean (msg, category);
- }
-
- public TenantException (MsoException e) {
- super (e);
- faultInfo = new TenantExceptionBean (e.getContextMessage(), e.getCategory());
- }
-
- public TenantExceptionBean getFaultInfo() {
- return faultInfo;
- }
-
- public void setFaultInfo(TenantExceptionBean faultInfo) {
- this.faultInfo = faultInfo;
- }
-}
diff --git a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionBean.java b/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionBean.java
deleted file mode 100644
index 5cd9f2fe3e..0000000000
--- a/adapters/mso-tenant-adapter/src/main/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionBean.java
+++ /dev/null
@@ -1,64 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.mso.adapters.tenant.exceptions;
-
-
-import java.io.Serializable;
-
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-/**
- * Jax-WS Fault Bean for Network Exceptions
- */
-public class TenantExceptionBean implements Serializable {
-
- private static final long serialVersionUID = -9062290006520066109L;
-
- private String message;
- private MsoExceptionCategory category;
-
- public TenantExceptionBean () {}
-
- public TenantExceptionBean (String message) {
- this.message = message;
- }
-
- public TenantExceptionBean (String message, MsoExceptionCategory category) {
- this.message = message;
- this.category = category;
- }
-
- public String getMessage() {
- return message;
- }
-
- public void setMessage(String message) {
- this.message = message;
- }
-
- public MsoExceptionCategory getCategory () {
- return category;
- }
-
- public void setCategory (MsoExceptionCategory category) {
- this.category = category;
- }
-}
diff --git a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImplTest.java b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImplTest.java
deleted file mode 100644
index 821c114351..0000000000
--- a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/MsoTenantAdapterImplTest.java
+++ /dev/null
@@ -1,82 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.mso.adapters.tenant;
-
-import org.junit.BeforeClass;
-import org.junit.Test;
-import org.mockito.Mock;
-import org.mockito.Mockito;
-import org.openecomp.mso.adapters.tenantrest.TenantRollback;
-import org.openecomp.mso.cloud.CloudConfig;
-import org.openecomp.mso.cloud.CloudConfigFactory;
-import org.openecomp.mso.entity.MsoRequest;
-
-import javax.validation.constraints.Null;
-import javax.xml.ws.Holder;
-import java.util.HashMap;
-
-public class MsoTenantAdapterImplTest {
-
- @Mock
- private static MsoTenantAdapterImpl msoTenantAdapter;
-
- @Mock
- private static CloudConfigFactory cloudConfigFactory;
-
- // TODO: following test case is done for coverage
- // later it should be modified for proper test.
-
- @BeforeClass
- public static final void prepare () {
- msoTenantAdapter = Mockito.spy (new MsoTenantAdapterImpl());
- cloudConfigFactory = Mockito.mock(CloudConfigFactory.class);
- CloudConfig cloudConfig = Mockito.mock(CloudConfig.class);
- Mockito.when(cloudConfigFactory.getCloudConfig()).thenReturn(cloudConfig);
- msoTenantAdapter.getTenantUtilsFactory().setCloudConfigFactory(cloudConfigFactory);
- }
-
- @Test
- public void healthCheck() throws Exception {
- msoTenantAdapter.healthCheck();
- }
-
- @Test(expected = NullPointerException.class)
- public void createTenant() throws Exception {
- msoTenantAdapter.createTenant("site", "tenant", new HashMap<>(),
- true, true, new MsoRequest(), new Holder(), new Holder());
- }
-
- @Test(expected = NullPointerException.class)
- public void queryTenant() throws Exception {
- msoTenantAdapter.queryTenant("site", "tenant", new MsoRequest(),
- new Holder<>(), new Holder<>(), new Holder<>());
- }
-
- @Test(expected = NullPointerException.class)
- public void deleteTenant() throws Exception {
- msoTenantAdapter.deleteTenant("cloud", "tenant", new MsoRequest(), new Holder());
- }
-
- @Test
- public void rollbackTenant() throws Exception {
- msoTenantAdapter.rollbackTenant(new TenantRollback());
- }
-
-} \ No newline at end of file
diff --git a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/TenantAdapterRestTest.java b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/TenantAdapterRestTest.java
deleted file mode 100644
index d710e67752..0000000000
--- a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/TenantAdapterRestTest.java
+++ /dev/null
@@ -1,60 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * Copyright (C) 2018 Huawei Technologies Co., Ltd. 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.mso.adapters.tenant;
-
-import org.junit.Test;
-import org.openecomp.mso.adapters.tenantrest.CreateTenantRequest;
-import org.openecomp.mso.adapters.tenantrest.DeleteTenantRequest;
-import org.openecomp.mso.adapters.tenantrest.RollbackTenantRequest;
-
-public class TenantAdapterRestTest {
-
- // TODO: following test case is done for coverage
- // later it should be modified for proper test.
-
- TenantAdapterRest tenantAdapterRest = new TenantAdapterRest();
-/*
-will need to rewrite these.. commenting for now...
- @Test(expected = ClassFormatError.class)
- public void healthcheck() throws Exception {
- tenantAdapterRest.healthcheck();
- }
-
- @Test(expected = ClassFormatError.class)
- public void createTenant() throws Exception {
- tenantAdapterRest.createTenant(new CreateTenantRequest());
- }
-
- @Test(expected = ClassFormatError.class)
- public void deleteTenant() throws Exception {
- tenantAdapterRest.deleteTenant("test", new DeleteTenantRequest());
- }
-
- @Test(expected = ClassFormatError.class)
- public void queryTenant() throws Exception {
- tenantAdapterRest.queryTenant("test", "test", "requestid", "serviceInstanceId");
- }
-
- @Test(expected = ClassFormatError.class)
- public void rollbackTenant() throws Exception {
- tenantAdapterRest.rollbackTenant("action", new RollbackTenantRequest());
- }
-*/
-} \ No newline at end of file
diff --git a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/exceptions/TenantAlreadyExistsTest.java b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/exceptions/TenantAlreadyExistsTest.java
deleted file mode 100644
index 7f30b70742..0000000000
--- a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/exceptions/TenantAlreadyExistsTest.java
+++ /dev/null
@@ -1,32 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.mso.adapters.tenant.exceptions;
-
-import org.junit.Test;
-
-public class TenantAlreadyExistsTest {
-
- @Test
- public void test() {
- TenantAlreadyExists tar= new TenantAlreadyExists("name", "cloudId", "tenantId");
- assert(tar!=null);
- }
-} \ No newline at end of file
diff --git a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionBeanTest.java b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionBeanTest.java
deleted file mode 100644
index c2f1d4e7aa..0000000000
--- a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionBeanTest.java
+++ /dev/null
@@ -1,47 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.mso.adapters.tenant.exceptions;
-
-import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-public class TenantExceptionBeanTest {
-
-@Mock
-private MsoExceptionCategory mec;
-
-@InjectMocks
-private TenantExceptionBean teb;
-
-@Test
- public void test() {
- teb =new TenantExceptionBean("message",mec);
- teb.setMessage("message");
- teb.setCategory(MsoExceptionCategory.INTERNAL);
- teb.setCategory(MsoExceptionCategory.IO);
- teb.setCategory(MsoExceptionCategory.OPENSTACK);
- teb.setCategory(MsoExceptionCategory.USERDATA);
- assert(teb.getMessage().equals("message"));
- assert(teb.getCategory()!=null);
- }
-}
diff --git a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionTest.java b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionTest.java
deleted file mode 100644
index 32e1fd198d..0000000000
--- a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/exceptions/TenantExceptionTest.java
+++ /dev/null
@@ -1,49 +0,0 @@
-/*
-* ============LICENSE_START=======================================================
-* ONAP : SO
-* ================================================================================
-* Copyright 2018 TechMahindra
-*=================================================================================
-* 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.mso.adapters.tenant.exceptions;
-
-import org.junit.Test;
-import org.mockito.InjectMocks;
-import org.mockito.Mock;
-import org.openecomp.mso.openstack.exceptions.MsoExceptionCategory;
-
-public class TenantExceptionTest {
-
- @Mock
- private TenantExceptionBean teb;
-
- @Mock
- private MsoExceptionCategory mec;
-
- @InjectMocks
- private TenantException te;
-
- @Test
- public void test() {
- teb=new TenantExceptionBean("message");
- teb.setMessage("message");
- teb.setCategory(MsoExceptionCategory.INTERNAL);
- te = new TenantException("message", mec);
- te.setFaultInfo(teb);
- assert(te.getFaultInfo()!=null);
- assert(te.getFaultInfo().equals(teb));
- }
-}
diff --git a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java b/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java
deleted file mode 100644
index 2a33ebc50c..0000000000
--- a/adapters/mso-tenant-adapter/src/test/java/org/openecomp/mso/adapters/tenant/test/TenantTest.java
+++ /dev/null
@@ -1,132 +0,0 @@
-/*-
- * ============LICENSE_START=======================================================
- * ONAP - SO
- * ================================================================================
- * 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.mso.adapters.tenant.test;
-
-
-
-import java.util.Map;
-
-import javax.xml.ws.Holder;
-
-import org.openecomp.mso.adapters.tenant.MsoTenantAdapter;
-import org.openecomp.mso.adapters.tenant.MsoTenantAdapterImpl;
-import org.openecomp.mso.adapters.tenant.exceptions.TenantException;
-import org.openecomp.mso.adapters.tenantrest.TenantRollback;
-
-public class TenantTest {
- public static final void main (String args[])
- {
- String cloudId = "MT";
- cloudId = "AIC_GAMMALAB";
-
- MsoTenantAdapter tenantAdapter = new MsoTenantAdapterImpl();
-
- Holder<String> tenantId = new Holder<>();
- Holder<String> tenantName = new Holder<>();
- Holder<Map<String,String>> tenantMetadata = new Holder<>();
- Holder<Boolean> tenantDeleted = new Holder<>();
- Holder<TenantRollback> rollback = new Holder<>();
-
- try {
- tenantAdapter.queryTenant (cloudId, "934a4ac9c4bd4b8d9d8ab3ef900281b0", null, tenantId, tenantName, tenantMetadata);
- System.out.println ("Got Tenant ID=" + tenantId.value + ", name=" + tenantName.value + ", metadata = " + tenantMetadata.value);
- }
- catch (TenantException e) {
- System.out.println ("Got Tenant Exception: " + e);
- System.exit(1);
- }
-/*
- Map<String,String> metadata = new HashMap<String,String>();
- metadata.put("sdn-global-id", "abc");
- metadata.put("service-type", "gamma");
-
- // Create a new tenant
- try {
- tenantAdapter.createTenant(cloudId, "TEST_META6", metadata, true, tenantId, rollback);
- System.out.println ("Created Tenant ID " + tenantId.value);
- }
- catch (TenantAlreadyExists e) {
- System.out.println ("Create: Tenant already exists: " + "TEST_META6");
- }
- catch (TenantException e) {
- System.out.println ("Got Tenant Exception on Create: " + e);
- System.exit(1);
- }
-
- // Query the new tenant
- try {
- tenantAdapter.queryTenant (cloudId, "TEST_META6", tenantId, tenantName, tenantMetadata);
- System.out.println ("Queried Tenant ID=" + tenantId.value + ", name=" + tenantName.value + ", metadata = " + tenantMetadata.value);
- }
- catch (TenantException e) {
- System.out.println ("Got Tenant Exception on Query: " + e);
- System.exit(1);
- }
-
- try {
- Thread.sleep(10000);
- } catch (InterruptedException e1) {}
-
- // Delete the new tenant
- try {
- tenantAdapter.deleteTenant (cloudId, tenantId.value, tenantDeleted);
- if (tenantDeleted.value)
- System.out.println ("Deleted Tenant " + tenantId.value);
- else
- System.out.println ("Delete: Tenant " + tenantId.value + " does not exist");
- }
- catch (TenantException e) {
- System.out.println ("Got Tenant Exception on Delete: " + e);
- }
-/*
- // Create another new tenant
- try {
- tenantAdapter.createTenant(cloudId, "TEST_MSO2", null, false, tenantId, rollback);
- System.out.println ("Created Tenant ID " + tenantId.value);
- }
- catch (TenantException e) {
- System.out.println ("Got Tenant Exception on Create: " + e);
- }
-
- // Query the new tenant
- try {
- tenantAdapter.queryTenant (cloudId, "TEST_MSO2", tenantId, tenantName);
- System.out.println ("Queried Tenant ID=" + tenantId.value + ", name=" + tenantName.value);
- }
- catch (TenantException e) {
- System.out.println ("Got Tenant Exception on Query: " + e);
- }
-
- try {
- Thread.sleep(10000);
- } catch (InterruptedException e1) {}
-
- // Rollback the new tenant
- try {
- tenantAdapter.rollbackTenant(rollback.value);
- System.out.println ("Rolled Back Tenant ID " + tenantId.value);
- }
- catch (TenantException e) {
- System.out.println ("Got Tenant Exception on Rollback: " + e);
- }
-*/
- }
-}
diff --git a/adapters/mso-tenant-adapter/src/test/resources/logback-test.xml b/adapters/mso-tenant-adapter/src/test/resources/logback-test.xml
deleted file mode 100644
index a23395fe1b..0000000000
--- a/adapters/mso-tenant-adapter/src/test/resources/logback-test.xml
+++ /dev/null
@@ -1,47 +0,0 @@
-<!--
- ============LICENSE_START=======================================================
- ECOMP MSO
- ================================================================================
- 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=========================================================
- -->
-
-<configuration >
-
- <appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender">
- <encoder>
- <pattern>%d{MM/dd-HH:mm:ss.SSS}|%X{RequestId}|%X{ServiceInstanceId}|%thread|%X{ServiceName}|%X{InstanceUUID}|%.-5level|%X{AlertSeverity}||%X{ServerIPAddress}|%X{ServerFQDN}|%X{RemoteHost}||%X{Timer}|%msg%n</pattern>
- </encoder>
- </appender>
-
-
- <logger name="com.att.eelf.audit" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="com.att.eelf.metrics" level="info" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <logger name="com.att.eelf.error" level="trace" additivity="false">
- <appender-ref ref="STDOUT" />
- </logger>
-
- <root level="info">
- <appender-ref ref="STDOUT" />
- </root>
-
-
-</configuration>