summaryrefslogtreecommitdiffstats
path: root/common-be/src/main
diff options
context:
space:
mode:
authorMichaelMorris <michael.morris@est.tech>2020-06-23 09:15:48 +0100
committerSébastien Determe <sebastien.determe@intl.att.com>2020-09-04 14:42:04 +0000
commit032525a375681fb18cc498d8daed9d73faa21ec3 (patch)
tree20cf4c17f406b8d30c29ce904fe1f19ea4a2c989 /common-be/src/main
parentc16117e08b97da93da61be841c22f5759cdadd37 (diff)
Support for Nested/Hierarchical Services
Change-Id: I478cf2e1f9cf96443a3e35bf22ac2c9d72bca8f1 Issue-ID: SDC-3145 Signed-off-by: MichaelMorris <michael.morris@est.tech>
Diffstat (limited to 'common-be/src/main')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/category/CategoryDataDefinition.java106
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java2
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/OriginTypeEnum.java3
3 files changed, 15 insertions, 96 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/category/CategoryDataDefinition.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/category/CategoryDataDefinition.java
index 27d6ae56fa..cf0117f74a 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/category/CategoryDataDefinition.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/category/CategoryDataDefinition.java
@@ -21,114 +21,32 @@
package org.openecomp.sdc.be.datatypes.category;
import org.openecomp.sdc.be.datatypes.tosca.ToscaDataDefinition;
-
+import lombok.EqualsAndHashCode;
+import lombok.Getter;
+import lombok.Setter;
+import lombok.ToString;
+import lombok.NoArgsConstructor;
import java.util.List;
+@Getter
+@Setter
+@EqualsAndHashCode(callSuper = false)
+@ToString
+@NoArgsConstructor
public class CategoryDataDefinition extends ToscaDataDefinition {
private String name;
private String normalizedName;
private String uniqueId;
private List<String> icons;
-
- public CategoryDataDefinition() {
-
- }
+ private boolean useServiceSubstitutionForNestedServices = false;
public CategoryDataDefinition(CategoryDataDefinition c) {
this.name = c.name;
this.normalizedName = c.normalizedName;
this.uniqueId = c.uniqueId;
this.icons = c.icons;
- }
-
- public String getName() {
- return name;
- }
-
- public void setName(String name) {
- this.name = name;
- }
-
- public String getNormalizedName() {
- return normalizedName;
- }
-
- public void setNormalizedName(String normalizedName) {
- this.normalizedName = normalizedName;
- }
-
- public String getUniqueId() {
- return uniqueId;
- }
-
- public void setUniqueId(String uniqueId) {
- this.uniqueId = uniqueId;
- }
-
- public List<String> getIcons() {
- return icons;
- }
-
- public void setIcons(List<String> icons) {
- this.icons = icons;
- }
-
- @Override
- public int hashCode() {
- final int prime = 31;
- int result = 1;
- result = prime * result + ((name == null) ? 0 : name.hashCode());
- result = prime * result + ((normalizedName == null) ? 0 : normalizedName.hashCode());
- result = prime * result + ((uniqueId == null) ? 0 : uniqueId.hashCode());
- result = prime * result + ((icons == null) ? 0 : icons.hashCode());
- return result;
- }
-
- @Override
- public boolean equals(Object obj) {
- if (this == obj) {
- return true;
- }
- if (obj == null) {
- return false;
- }
- if (getClass() != obj.getClass()) {
- return false;
- }
- CategoryDataDefinition other = (CategoryDataDefinition) obj;
- if (name == null) {
- if (other.name != null) {
- return false;
- }
- } else if (!name.equals(other.name)) {
- return false;
- }
- if (normalizedName == null) {
- if (other.normalizedName != null) {
- return false;
- }
- } else if (!normalizedName.equals(other.normalizedName)) {
- return false;
- }
- if (uniqueId == null) {
- if (other.uniqueId != null) {
- return false;
- }
- } else if (!uniqueId.equals(other.uniqueId)) {
- return false;
- }
- if (icons == null) {
- return other.icons == null;
- } else {
- return icons.equals(other.icons);
- }
- }
-
- @Override
- public String toString() {
- return "CategoryDataDefinition [name=" + name + ", normalizedName=" + normalizedName + ", uniqueId=" + uniqueId
- + ", icons=" + icons + "]";
+ this.useServiceSubstitutionForNestedServices = c.useServiceSubstitutionForNestedServices;
}
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java
index 09e1de6c7b..296b0067b8 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/GraphPropertyEnum.java
@@ -50,7 +50,7 @@ public enum GraphPropertyEnum {
LAST_LOGIN_TIME("lastLoginTime", Long.class, false, false),
//used for category (old format, no json for categories)
ICONS("icons", String.class, false, false),
-
+ USE_SUBSTITUTION_FOR_NESTED_SERVICES("useServiceSubstitutionForNestedServices", Boolean.class, false, false),
//Archive/Restore
IS_ARCHIVED("isArchived", Boolean.class, false, true),
IS_VSP_ARCHIVED("isVspArchived", Boolean.class, false, true),
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/OriginTypeEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/OriginTypeEnum.java
index 48394013de..5e709054a4 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/OriginTypeEnum.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/OriginTypeEnum.java
@@ -27,7 +27,8 @@ public enum OriginTypeEnum {
CVFC("CVFC", "CVFC (Complex Virtual Function Component)", "resource instance", ComponentTypeEnum.RESOURCE, false),
PNF("PNF", "PNF (Physical Network Function)", "resource instance", ComponentTypeEnum.RESOURCE, false),
CR("CR", "CR (Complex Resource)", "resource instance", ComponentTypeEnum.RESOURCE, false),
- ServiceProxy("Service Proxy", "Service Proxy", "service proxy", ComponentTypeEnum.RESOURCE, false);
+ ServiceProxy("Service Proxy", "Service Proxy", "service proxy", ComponentTypeEnum.RESOURCE, false),
+ ServiceSubstitution("Service Substitution", "Service Substitution", "service substitution", ComponentTypeEnum.RESOURCE, false);
private String value;
private String displayValue;
#008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
/*
 * Copyright © 2019 iconectiv
 *
 * 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=========================================================
 * Modifications copyright (c) 2019 Nokia
 * ================================================================================
 */

package org.openecomp.sdcrests.externaltesting.rest.services;


import org.openecomp.core.externaltesting.api.*;
import org.openecomp.core.externaltesting.errors.ExternalTestingException;
import org.openecomp.sdc.logging.api.Logger;
import org.openecomp.sdc.logging.api.LoggerFactory;
import org.openecomp.sdcrests.externaltesting.rest.ExternalTesting;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.http.HttpStatus;
import org.springframework.stereotype.Service;

import javax.inject.Named;
import javax.ws.rs.core.Response;
import java.util.List;
import java.util.Optional;
import java.util.stream.Collectors;

@SuppressWarnings("unused")
@Named
@Service("externaltesting")
@Scope(value = "prototype")
public class ExternalTestingImpl implements ExternalTesting {

  private final ExternalTestingManager testingManager;

  private static final Logger logger =
      LoggerFactory.getLogger(ExternalTestingImpl.class);

  public ExternalTestingImpl(@Autowired ExternalTestingManager testingManager) {
    this.testingManager = testingManager;
  }

  /**
   * Return the configuration of the feature to the client.
   * @return JSON response content.
   */
  @Override
  public Response getConfig() {
    try {
      return Response.ok(testingManager.getConfig()).build();
    }
    catch (ExternalTestingException e) {
      return convertTestingException(e);
    }
  }

  /**
   * To enable automated functional testing, allow
   * a put for the client configuration.
   * @return JSON response content.
   */
  @Override
  public Response setConfig(ClientConfiguration config) {
    try {
      return Response.ok(testingManager.setConfig(config)).build();
    }
    catch (ExternalTestingException e) {
      return convertTestingException(e);
    }
  }


  /**
   * Return the test tree structure created by the testing manager.
   * @return JSON response content.
   */
  @Override
  public Response getTestCasesAsTree() {
    try {
      return Response.ok(testingManager.getTestCasesAsTree()).build();
    }
    catch (ExternalTestingException e) {
      return convertTestingException(e);
    }
  }

  @Override
  public Response getEndpoints() {
    try {
      return Response.ok(testingManager.getEndpoints()).build();
    }
    catch (ExternalTestingException e) {
      return convertTestingException(e);
    }
  }

  /**
   * To enable automated functional testing, allow a put of the endpoints.
   * @return JSON response content.
   */
  @Override
  public Response setEndpoints(List<RemoteTestingEndpointDefinition> endpoints) {
    try {
      return Response.ok(testingManager.setEndpoints(endpoints)).build();
    }
    catch (ExternalTestingException e) {
      return convertTestingException(e);
    }
  }

  @Override
  public Response getScenarios(String endpoint) {
    try {
      return Response.ok(testingManager.getScenarios(endpoint)).build();
    }
    catch (ExternalTestingException e) {
      return convertTestingException(e);
    }

  }

  @Override
  public Response getTestsuites(String endpoint, String scenario) {
    try {
      return Response.ok(testingManager.getTestSuites(endpoint, scenario)).build();
    }
    catch (ExternalTestingException e) {
      return convertTestingException(e);
    }
  }

  @Override
  public Response getTestcases(String endpoint, String scenario) {
    try {
      return Response.ok(testingManager.getTestCases(endpoint, scenario)).build();
    }
    catch (ExternalTestingException e) {
      return convertTestingException(e);
    }
  }

  @Override
  public Response getTestcase(String endpoint, String scenario, String testsuite, String testcase) {
    try {
      return Response.ok(testingManager.getTestCase(endpoint, scenario, testsuite, testcase)).build();
    }
    catch (ExternalTestingException e) {
      return convertTestingException(e);
    }
  }

  @Override
  public Response execute(List<VtpTestExecutionRequest> req, String requestId) {
    try {
      List<VtpTestExecutionResponse> responses = testingManager.execute(req, requestId);
      List<Integer> statuses = responses.stream().map(r-> Optional.ofNullable(r.getHttpStatus()).orElse(HttpStatus.OK.value())).distinct().collect(Collectors.toList());
      if (statuses.size() == 1) {
        return Response.status(HttpStatus.OK.value()).entity(responses).build();
      }
      else {
        return Response.status(HttpStatus.MULTI_STATUS.value()).entity(responses).build();
      }
    }
    catch (ExternalTestingException e) {
      return convertTestingException(e);
    }
  }

  @Override
  public Response getExecution(String endpoint, String executionId) {
    try {
      return Response.ok(testingManager.getExecution(endpoint, executionId)).build();
    }
    catch (ExternalTestingException e) {
      return convertTestingException(e);
    }
  }

  private Response convertTestingException(ExternalTestingException e) {
    if (logger.isErrorEnabled()) {
      logger.error("testing exception {} {} {}", e.getMessageCode(), e.getHttpStatus(), e.getDetail(), e);
    }
    TestErrorBody body = new TestErrorBody(e.getMessageCode(), e.getHttpStatus(), e.getDetail());
    return Response.status(e.getHttpStatus()).entity(body).build();
  }
}