From 05dd5d2fd893f526eb6a807afb5725c8e426dd52 Mon Sep 17 00:00:00 2001 From: kurczews Date: Tue, 14 Aug 2018 11:23:35 +0200 Subject: Renaming vid-automation #6 Change-Id: I0971c966ddcd76927bdf1a4c4d47afc900987ddf Issue-ID: VID-205 Signed-off-by: kurczews --- .../java/org/onap/vid/model/aai/AaiResponse.java | 34 ++++ .../model/asyncInstantiation/JobAuditStatus.java | 121 ++++++++++++++ .../vid/model/asyncInstantiation/ServiceInfo.java | 75 +++++++++ .../model/category/AddCategoryOptionResponse.java | 15 ++ .../model/category/AddCategoryOptionsRequest.java | 13 ++ .../model/category/CategoryParameterOption.java | 34 ++++ .../model/category/CategoryParameterOptionRep.java | 31 ++++ .../model/category/CategoryParametersResponse.java | 27 +++ .../vid/model/probe/ExternalComponentStatus.java | 28 ++++ .../onap/vid/model/probe/HttpRequestMetadata.java | 49 ++++++ .../workflow/GetVnfWorkflowRelationRequest.java | 28 ++++ .../vid/model/workflow/GetWorkflowsResponse.java | 24 +++ .../vid/model/workflow/ListOfErrorsResponse.java | 24 +++ .../org/onap/vid/model/workflow/VnfDetails.java | 66 ++++++++ .../model/workflow/VnfDetailsWithWorkflows.java | 27 +++ .../workflow/VnfWorkflowRelationAllResponse.java | 23 +++ .../model/workflow/VnfWorkflowRelationRequest.java | 31 ++++ .../workflow/VnfWorkflowRelationResponse.java | 14 ++ .../onap/vid/model/workflow/WorkflowsDetail.java | 43 +++++ .../java/org/onap/vid/more/LoggerFormatTest.java | 91 ++++++++++ .../onap/vid/more/RequestIdFilterInstalled.java | 184 +++++++++++++++++++++ .../org/onap/vid/more/SimulatorLoaderTest.java | 133 +++++++++++++++ .../org/opencomp/vid/model/aai/AaiResponse.java | 34 ---- .../model/asyncInstantiation/JobAuditStatus.java | 124 -------------- .../vid/model/asyncInstantiation/ServiceInfo.java | 75 --------- .../model/category/AddCategoryOptionResponse.java | 15 -- .../model/category/AddCategoryOptionsRequest.java | 13 -- .../model/category/CategoryParameterOption.java | 34 ---- .../model/category/CategoryParameterOptionRep.java | 31 ---- .../model/category/CategoryParametersResponse.java | 27 --- .../vid/model/probe/ExternalComponentStatus.java | 28 ---- .../vid/model/probe/HttpRequestMetadata.java | 49 ------ .../workflow/GetVnfWorkflowRelationRequest.java | 28 ---- .../vid/model/workflow/GetWorkflowsResponse.java | 24 --- .../vid/model/workflow/ListOfErrorsResponse.java | 24 --- .../opencomp/vid/model/workflow/VnfDetails.java | 66 -------- .../model/workflow/VnfDetailsWithWorkflows.java | 27 --- .../workflow/VnfWorkflowRelationAllResponse.java | 23 --- .../model/workflow/VnfWorkflowRelationRequest.java | 31 ---- .../workflow/VnfWorkflowRelationResponse.java | 14 -- .../vid/model/workflow/WorkflowsDetail.java | 43 ----- .../org/opencomp/vid/more/LoggerFormatTest.java | 97 ----------- .../vid/more/RequestIdFilterInstalled.java | 184 --------------------- .../org/opencomp/vid/more/SimulatorLoaderTest.java | 127 -------------- 44 files changed, 1115 insertions(+), 1118 deletions(-) create mode 100644 vid-automation/src/test/java/org/onap/vid/model/aai/AaiResponse.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/category/AddCategoryOptionResponse.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/category/AddCategoryOptionsRequest.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/category/CategoryParameterOption.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/category/CategoryParameterOptionRep.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/category/CategoryParametersResponse.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/probe/ExternalComponentStatus.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/probe/HttpRequestMetadata.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/workflow/GetVnfWorkflowRelationRequest.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/workflow/GetWorkflowsResponse.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/workflow/ListOfErrorsResponse.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/workflow/VnfDetails.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/workflow/VnfDetailsWithWorkflows.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/workflow/VnfWorkflowRelationAllResponse.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/workflow/VnfWorkflowRelationRequest.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/workflow/VnfWorkflowRelationResponse.java create mode 100644 vid-automation/src/test/java/org/onap/vid/model/workflow/WorkflowsDetail.java create mode 100644 vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java create mode 100644 vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java create mode 100644 vid-automation/src/test/java/org/onap/vid/more/SimulatorLoaderTest.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/aai/AaiResponse.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/asyncInstantiation/JobAuditStatus.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/asyncInstantiation/ServiceInfo.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/category/AddCategoryOptionResponse.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/category/AddCategoryOptionsRequest.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/category/CategoryParameterOption.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/category/CategoryParameterOptionRep.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/category/CategoryParametersResponse.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/probe/ExternalComponentStatus.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/probe/HttpRequestMetadata.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/workflow/GetVnfWorkflowRelationRequest.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/workflow/GetWorkflowsResponse.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/workflow/ListOfErrorsResponse.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfDetails.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfDetailsWithWorkflows.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfWorkflowRelationAllResponse.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfWorkflowRelationRequest.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfWorkflowRelationResponse.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/model/workflow/WorkflowsDetail.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/more/LoggerFormatTest.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/more/RequestIdFilterInstalled.java delete mode 100644 vid-automation/src/test/java/org/opencomp/vid/more/SimulatorLoaderTest.java (limited to 'vid-automation/src/test/java') diff --git a/vid-automation/src/test/java/org/onap/vid/model/aai/AaiResponse.java b/vid-automation/src/test/java/org/onap/vid/model/aai/AaiResponse.java new file mode 100644 index 000000000..389cdd88e --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/aai/AaiResponse.java @@ -0,0 +1,34 @@ +package org.onap.vid.model.aai; + +import com.google.common.base.MoreObjects; +import org.onap.vid.model.mso.ProxyResponse; + +/** + * Created by Oren on 7/10/17. + */ +public class AaiResponse extends ProxyResponse { + + T t; + + public AaiResponse() { + } + + public AaiResponse(T t, String errorMessage, int aaiHttpCode) { + this.t = t; + this.errorMessage = errorMessage; + this.httpCode = aaiHttpCode; + } + + public T getT() { + return t; + } + + @Override + public String toString() { + return MoreObjects.toStringHelper(this) + .add("httpCode", httpCode) + .add("errorMessage", errorMessage) + .add("t", t) + .toString(); + } +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java b/vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java new file mode 100644 index 000000000..7c1481562 --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/JobAuditStatus.java @@ -0,0 +1,121 @@ +package org.onap.vid.model.asyncInstantiation; + +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +import java.util.UUID; + + +public class JobAuditStatus { + + public JobAuditStatus(){} + + + public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source){ + this.jobId = jobId; + this.jobStatus = jobStatus; + this.source = source; + this.isFinal = isFinal(); + } + + public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, UUID requestId, String additionalInfo, Boolean isFinal) { + this(jobId, jobStatus, source); + this.requestId = requestId; + this.additionalInfo = additionalInfo; + this.isFinal = isFinal; + } + + + + public enum SourceStatus { + MSO, + VID + } + + private UUID jobId; + private String jobStatus; + private SourceStatus source; + private UUID requestId; + private String additionalInfo; + + + + private Boolean isFinal; + + public String getJobStatus() { + return jobStatus; + } + + public UUID getJobId() { + return jobId; + } + + public SourceStatus getSource() { + return source; + } + + public String getAdditionalInfo() { + return additionalInfo; + } + + public UUID getRequestId() { + return requestId; + } + + + + public Boolean isFinal(){ + return isFinal; + } + + public void setFinal(Boolean aFinal) { + isFinal = aFinal; + } + + @Override + public String toString() { + return "JobAuditStatus{" + + "jobId=" + jobId + + ", jobStatus='" + jobStatus + '\'' + + ", source=" + source + + ", requestId=" + requestId + + ", additionalInfo='" + additionalInfo + '\'' + + ", isFinal=" + isFinal + + '}'; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (o == null || getClass() != o.getClass()) return false; + + JobAuditStatus that = (JobAuditStatus) o; + + return new EqualsBuilder() + .append(jobId, that.jobId) + .append(jobStatus, that.jobStatus) + .append(source, that.source) + .append(requestId, that.requestId) + .append(additionalInfo, that.additionalInfo) + .append(isFinal, that.isFinal) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(jobId) + .append(jobStatus) + .append(source) + .append(requestId) + .append(additionalInfo) + .append(isFinal) + .toHashCode(); + } + + + + + +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java b/vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java new file mode 100644 index 000000000..371aaf81e --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/asyncInstantiation/ServiceInfo.java @@ -0,0 +1,75 @@ +package org.onap.vid.model.asyncInstantiation; + + +import vid.automation.test.model.JobStatus; + +import java.util.Date; + +public class ServiceInfo { + + public String jobId; + public String templateId; + public String userId; + public JobStatus jobStatus; + public Date statusModifiedDate; + public boolean hidden; + public boolean pause; + public String owningEntityId; + public String owningEntityName; + public String project; + public String aicZoneId; + public String aicZoneName; + public String tenantId; + public String tenantName; + public String regionId; + public String regionName; + public String serviceType; + public String subscriberName; + public String serviceInstanceId; + public String serviceInstanceName; + public String serviceModelId; + public String serviceModelName; + public String serviceModelVersion; + public Date createdBulkDate; + + public ServiceInfo(){ + + } + + public ServiceInfo(String userId, JobStatus jobStatus, boolean pause, String owningEntityId, String owningEntityName, String project, String aicZoneId, String aicZoneName, String tenantId, String tenantName, String regionId, String regionName, String serviceType, String subscriberName, String serviceInstanceId, String serviceInstanceName, String serviceModelId, String serviceModelName, String serviceModelVersion, String jobId, String templateId) { + this.userId = userId; + this.jobStatus = jobStatus; + this.pause = pause; + this.owningEntityId = owningEntityId; + this.owningEntityName = owningEntityName; + this.project = project; + this.aicZoneId = aicZoneId; + this.aicZoneName = aicZoneName; + this.tenantId = tenantId; + this.tenantName = tenantName; + this.regionId = regionId; + this.regionName = regionName; + this.serviceType = serviceType; + this.subscriberName = subscriberName; + this.serviceInstanceId = serviceInstanceId; + this.serviceInstanceName = serviceInstanceName; + this.serviceModelId = serviceModelId; + this.serviceModelName = serviceModelName; + this.serviceModelVersion = serviceModelVersion; + this.jobId = jobId; + this.templateId = templateId; + } + + public JobStatus getJobStatus() { + return jobStatus; + } + + public String getServiceInstanceName() { + return serviceInstanceName; + } + + public String getJobId() { + return jobId; + } + +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/category/AddCategoryOptionResponse.java b/vid-automation/src/test/java/org/onap/vid/model/category/AddCategoryOptionResponse.java new file mode 100644 index 000000000..eb60b85f0 --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/category/AddCategoryOptionResponse.java @@ -0,0 +1,15 @@ +package org.onap.vid.model.category; + +import org.onap.vid.model.workflow.ListOfErrorsResponse; + +import java.util.List; + +public class AddCategoryOptionResponse extends ListOfErrorsResponse { + + public AddCategoryOptionResponse() { + } + + public AddCategoryOptionResponse(List errors) { + super(errors); + } +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/category/AddCategoryOptionsRequest.java b/vid-automation/src/test/java/org/onap/vid/model/category/AddCategoryOptionsRequest.java new file mode 100644 index 000000000..dc12a79a2 --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/category/AddCategoryOptionsRequest.java @@ -0,0 +1,13 @@ +package org.onap.vid.model.category; + +import java.util.ArrayList; +import java.util.List; + +public class AddCategoryOptionsRequest { + + public List options; + + public AddCategoryOptionsRequest() { + options = new ArrayList<>(); + } +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/category/CategoryParameterOption.java b/vid-automation/src/test/java/org/onap/vid/model/category/CategoryParameterOption.java new file mode 100644 index 000000000..39e7eb76f --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/category/CategoryParameterOption.java @@ -0,0 +1,34 @@ +package org.onap.vid.model.category; + +public class CategoryParameterOption { + + private String appId; + private String name; + + + public CategoryParameterOption() { + } + + public CategoryParameterOption(String appId, String name) { + setAppId(appId); + setName(name); + } + + public String getAppId() { + return appId; + } + + public void setAppId(String appId) { + this.appId = appId; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/category/CategoryParameterOptionRep.java b/vid-automation/src/test/java/org/onap/vid/model/category/CategoryParameterOptionRep.java new file mode 100644 index 000000000..fd554ef6a --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/category/CategoryParameterOptionRep.java @@ -0,0 +1,31 @@ +package org.onap.vid.model.category; + +public class CategoryParameterOptionRep { + + private String id; + private String name; + + public CategoryParameterOptionRep() { + } + + public CategoryParameterOptionRep(String id, String name) { + this.id = id; + this.name = name; + } + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/category/CategoryParametersResponse.java b/vid-automation/src/test/java/org/onap/vid/model/category/CategoryParametersResponse.java new file mode 100644 index 000000000..721c01e5b --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/category/CategoryParametersResponse.java @@ -0,0 +1,27 @@ +package org.onap.vid.model.category; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; +import java.util.Map; + +public class CategoryParametersResponse { + + private Map> categoryParameters; + + public CategoryParametersResponse() { + } + + public CategoryParametersResponse(Map> categoryParameters) { + this.categoryParameters = categoryParameters; + } + + @JsonProperty("categoryParameters") + public Map> getCategoryParameters() { + return categoryParameters; + } + + public void setCategoryParameters(Map> categoryParameters) { + this.categoryParameters = categoryParameters; + } +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/probe/ExternalComponentStatus.java b/vid-automation/src/test/java/org/onap/vid/model/probe/ExternalComponentStatus.java new file mode 100644 index 000000000..439764945 --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/probe/ExternalComponentStatus.java @@ -0,0 +1,28 @@ +package org.onap.vid.model.probe; + +public class ExternalComponentStatus { + public enum Component {AAI, MSO} + private Component component; + private boolean available; + private HttpRequestMetadata metadata; + + public ExternalComponentStatus(){} + + public ExternalComponentStatus(Component component, boolean isAvailable, HttpRequestMetadata metadata) { + this.component = component; + this.available = isAvailable; + this.metadata = metadata; + } + + public Component getComponent() { + return component; + } + + public boolean isAvailable() { + return available; + } + + public HttpRequestMetadata getMetadata() { + return metadata; + } +} \ No newline at end of file diff --git a/vid-automation/src/test/java/org/onap/vid/model/probe/HttpRequestMetadata.java b/vid-automation/src/test/java/org/onap/vid/model/probe/HttpRequestMetadata.java new file mode 100644 index 000000000..1443c4660 --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/probe/HttpRequestMetadata.java @@ -0,0 +1,49 @@ +package org.onap.vid.model.probe; + +import org.springframework.http.HttpMethod; + +public class HttpRequestMetadata { + + + public HttpMethod getHttpMethod() { + return httpMethod; + } + + public int getHttpCode() { + return httpCode; + } + + public String getUrl() { + return url; + } + + public String getRawData() { + return rawData; + } + + public float getDuration() { + return duration; + } + + public String getDescription() { + return description; + } + + private HttpMethod httpMethod; + private int httpCode; + private String url; + private String rawData; + private String description; + private float duration; + + public HttpRequestMetadata(){ + } + + public HttpRequestMetadata(HttpMethod httpMethod,int httpCode, String url, String rawData, String description) { + this.httpMethod = httpMethod; + this.httpCode = httpCode; + this.url = url; + this.rawData = rawData; + this.description = description; + } +} \ No newline at end of file diff --git a/vid-automation/src/test/java/org/onap/vid/model/workflow/GetVnfWorkflowRelationRequest.java b/vid-automation/src/test/java/org/onap/vid/model/workflow/GetVnfWorkflowRelationRequest.java new file mode 100644 index 000000000..3e831747f --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/workflow/GetVnfWorkflowRelationRequest.java @@ -0,0 +1,28 @@ +package org.onap.vid.model.workflow; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class GetVnfWorkflowRelationRequest { + + public GetVnfWorkflowRelationRequest() { + } + + public GetVnfWorkflowRelationRequest(List vnfsDetails) { + this.vnfsDetails = vnfsDetails; + } + + @JsonProperty("vnfsDetails") + private List vnfsDetails; + + @JsonProperty("vnfsDetails") + public List getVnfDetails() { + return vnfsDetails; + } + + @JsonProperty("vnfsDetails") + public void setVnfDetails(List vnfDetails) { + this.vnfsDetails = vnfDetails; + } +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/workflow/GetWorkflowsResponse.java b/vid-automation/src/test/java/org/onap/vid/model/workflow/GetWorkflowsResponse.java new file mode 100644 index 000000000..cc52017e4 --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/workflow/GetWorkflowsResponse.java @@ -0,0 +1,24 @@ +package org.onap.vid.model.workflow; + +import java.util.List; + +public class GetWorkflowsResponse { + private List workflows; + + public GetWorkflowsResponse() { + } + + public GetWorkflowsResponse(List workflows) { + this.workflows = workflows; + } + + public List getWorkflows() { + return workflows; + } + + public void setWorkflows(List workflows) { + this.workflows = workflows; + } + + +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/workflow/ListOfErrorsResponse.java b/vid-automation/src/test/java/org/onap/vid/model/workflow/ListOfErrorsResponse.java new file mode 100644 index 000000000..0f38c2f4f --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/workflow/ListOfErrorsResponse.java @@ -0,0 +1,24 @@ +package org.onap.vid.model.workflow; + +import java.util.ArrayList; +import java.util.List; + +public class ListOfErrorsResponse { + protected List errors; + + public ListOfErrorsResponse() { + this.errors = new ArrayList<>(); + } + + public ListOfErrorsResponse(List errors) { + this.errors = errors; + } + + public List getErrors() { + return errors; + } + + public void setErrors(List errors) { + this.errors = errors; + } +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfDetails.java b/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfDetails.java new file mode 100644 index 000000000..7e04dc0d1 --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfDetails.java @@ -0,0 +1,66 @@ +package org.onap.vid.model.workflow; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class VnfDetails { + + public VnfDetails() { + } + + public VnfDetails(String UUID, String invariantUUID) { + this.UUID = UUID; + this.invariantUUID = invariantUUID; + } + + @JsonProperty("UUID") + private String UUID; + + @JsonProperty("invariantUUID") + private String invariantUUID; + + @JsonProperty("UUID") + public String getUUID() { + return UUID; + } + + @JsonProperty("UUID") + public void setUUID(String uUID) { + UUID = uUID; + } + + @JsonProperty("invariantUUID") + public String getInvariantUUID() { + return invariantUUID; + } + + @JsonProperty("invariantUUID") + public void setInvariantUUID(String invariantUUID) { + this.invariantUUID = invariantUUID; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + + VnfDetails that = (VnfDetails) o; + + if (getUUID() != null ? !getUUID().equals(that.getUUID()) : that.getUUID() != null) return false; + return getInvariantUUID() != null ? getInvariantUUID().equals(that.getInvariantUUID()) : that.getInvariantUUID() == null; + } + + @Override + public int hashCode() { + int result = getUUID() != null ? getUUID().hashCode() : 0; + result = 31 * result + (getInvariantUUID() != null ? getInvariantUUID().hashCode() : 0); + return result; + } + + @Override + public String toString() { + return "VnfDetails{" + + "UUID='" + UUID + '\'' + + ", invariantUUID='" + invariantUUID + '\'' + + '}'; + } +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfDetailsWithWorkflows.java b/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfDetailsWithWorkflows.java new file mode 100644 index 000000000..92d227de9 --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfDetailsWithWorkflows.java @@ -0,0 +1,27 @@ +package org.onap.vid.model.workflow; + + +import java.util.List; + +public class VnfDetailsWithWorkflows extends VnfDetails { + + private List workflows; + + public VnfDetailsWithWorkflows() { + } + + + @SuppressWarnings("WeakerAccess") + public VnfDetailsWithWorkflows(String UUID, String invariantUUID, List workflows) { + super(UUID, invariantUUID); + this.workflows = workflows; + } + + public List getWorkflows() { + return workflows; + } + + public void setWorkflows(List workflows) { + this.workflows = workflows; + } +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfWorkflowRelationAllResponse.java b/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfWorkflowRelationAllResponse.java new file mode 100644 index 000000000..2a4f0aa37 --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfWorkflowRelationAllResponse.java @@ -0,0 +1,23 @@ +package org.onap.vid.model.workflow; + +import java.util.List; + +public class VnfWorkflowRelationAllResponse { + + private List vnfs; + + public VnfWorkflowRelationAllResponse() { + } + + public VnfWorkflowRelationAllResponse(List vnfs) { + this.vnfs = vnfs; + } + + public List getVnfs() { + return vnfs; + } + + public void setVnfs(List vnfs) { + this.vnfs = vnfs; + } +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfWorkflowRelationRequest.java b/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfWorkflowRelationRequest.java new file mode 100644 index 000000000..b9553bcc5 --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfWorkflowRelationRequest.java @@ -0,0 +1,31 @@ +package org.onap.vid.model.workflow; + +import com.fasterxml.jackson.annotation.JsonProperty; + +import java.util.List; + +public class VnfWorkflowRelationRequest { + + public VnfWorkflowRelationRequest() { + } + + public VnfWorkflowRelationRequest(List workflowsDetails) { + this.workflowsDetails = workflowsDetails; + } + + @JsonProperty("workflowsDetails") + private List workflowsDetails; + + @JsonProperty("workflowsDetails") + public List getWorkflowsDetails() { + return workflowsDetails; + } + + @JsonProperty("workflowsDetails") + public void setWorkflowsDetails(List workflowsDetails) { + this.workflowsDetails = workflowsDetails; + } + + + +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfWorkflowRelationResponse.java b/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfWorkflowRelationResponse.java new file mode 100644 index 000000000..1badf169a --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/workflow/VnfWorkflowRelationResponse.java @@ -0,0 +1,14 @@ +package org.onap.vid.model.workflow; + + +import java.util.List; + +public class VnfWorkflowRelationResponse extends ListOfErrorsResponse { + + public VnfWorkflowRelationResponse() { + } + + public VnfWorkflowRelationResponse(List errors) { + super(errors); + } +} diff --git a/vid-automation/src/test/java/org/onap/vid/model/workflow/WorkflowsDetail.java b/vid-automation/src/test/java/org/onap/vid/model/workflow/WorkflowsDetail.java new file mode 100644 index 000000000..609804c68 --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/model/workflow/WorkflowsDetail.java @@ -0,0 +1,43 @@ +package org.onap.vid.model.workflow; + +import com.fasterxml.jackson.annotation.JsonProperty; + +public class WorkflowsDetail { + + public WorkflowsDetail() { + } + + public WorkflowsDetail(VnfDetails vnfDetails, String workflowName) { + this.vnfDetails = vnfDetails; + this.workflowName = workflowName; + } + + @JsonProperty("vnfDetails") + private VnfDetails vnfDetails; + + @JsonProperty("workflowName") + private String workflowName; + + @JsonProperty("vnfDetails") + public VnfDetails getVnfDetails() { + return vnfDetails; + } + @JsonProperty("vnfDetails") + public void setVnfDetails(VnfDetails vnfDetails) { + this.vnfDetails = vnfDetails; + } + @JsonProperty("workflowName") + public String getWorkflowName() { + return workflowName; + } + @JsonProperty("workflowName") + public void setWorkflowName(String workflowName) { + this.workflowName = workflowName; + } + + @Override + public String toString() { + return vnfDetails + + ", workflowName='" + workflowName; + } +} diff --git a/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java new file mode 100644 index 000000000..6656a6c6b --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/more/LoggerFormatTest.java @@ -0,0 +1,91 @@ +package org.onap.vid.more; + +import com.fasterxml.jackson.databind.JsonNode; +import org.apache.commons.lang3.StringUtils; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; +import org.onap.vid.api.BaseApiTest; +import org.springframework.web.client.RestTemplate; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import vid.automation.test.services.SimulatorApi; + +import java.net.URI; +import java.util.HashMap; +import java.util.Map; + +import static org.hamcrest.CoreMatchers.is; +import static org.hamcrest.Matchers.greaterThan; +import static org.hamcrest.Matchers.greaterThanOrEqualTo; +import static org.junit.Assert.assertThat; + +public class LoggerFormatTest extends BaseApiTest { + + + // See: https://wiki.web.att.com/display/KSAT/REST-based+Log+Checker + private final static String logChecker = "http://eelflogcheck.it.att.com:31820/validate"; + + @BeforeClass + public void login() { + super.login(); + } + + @BeforeClass + public void setAaiSubscribers() { + SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); + } + + @Test + public void validateAuditLogsFormat() { + validateLogsFormat("audit"); + } + + @Test(enabled = false) // no total-score is returned for error-log + public void validateErrorLogsFormat() { + validateLogsFormat("error"); + } + + @Test + public void validateMetricsLogsFormat() { + validateLogsFormat("metrics", "metric"); + } + + private void validateLogsFormat(String logName) { + validateLogsFormat(logName, logName); + } + + private void validateLogsFormat(String logName, String logType) { + + String logLines = getLogLines(logName); + JsonNode response = getCheckerResults(logType, logLines); + + System.out.println(response); + double fieldscore = response.path("summary").path("score").path("fieldscore").asDouble(); + double overall = response.path("summary").path("score").path("overallscore").asDouble(); + + assertThat(fieldscore, is(greaterThan(0.95))); + assertThat(overall, is(greaterThan(0.95))); + + } + + private String getLogLines(String logname) { + return getLogLines(logname, 5000, 30, restTemplate, uri); + } + + public static String getLogLines(String logname, int maxRows, int minRows, RestTemplate restTemplate, URI uri) { + String logLines = restTemplate.getForObject(uri + "/logger/" + logname + "?limit={maxRows}", String.class, maxRows); + assertThat("expecting at least " + minRows + " rows in " + logname, + StringUtils.countMatches(logLines, '\n') + 1, + is(greaterThanOrEqualTo(minRows))); + return logLines; + } + + private JsonNode getCheckerResults(String logtype, String logLines) { + Map params = new HashMap<>(); + params.put("format", "raw"); + params.put("type", logtype); + params.put("component", "vid"); + params.put("data", logLines); + + return restTemplate.postForObject(logChecker, params, JsonNode.class); + } +} diff --git a/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java b/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java new file mode 100644 index 000000000..5a0a0f845 --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/more/RequestIdFilterInstalled.java @@ -0,0 +1,184 @@ +package org.onap.vid.more; + +import com.google.common.collect.ImmutableList; +import com.google.common.collect.ImmutableMap; +import org.apache.commons.lang3.StringUtils; +import org.apache.commons.lang3.tuple.Pair; +import org.onap.vid.api.OperationalEnvironmentControllerApiTest; +import org.onap.vid.api.BaseApiTest; +import org.onap.vid.api.ServiceInstanceMsoApiTest; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.ResponseEntity; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.Test; +import vid.automation.test.services.SimulatorApi; + +import java.util.UUID; + +import static org.hamcrest.CoreMatchers.*; +import static org.hamcrest.Matchers.containsInAnyOrder; +import static org.hamcrest.Matchers.nullValue; +import static org.junit.Assert.assertThat; +import static org.onap.vid.api.CategoryParametersApiTest.GET_CATEGORY_PARAMETER_PROPERTIES; +import static org.onap.vid.api.pProbeMsoApiTest.MSO_CREATE_CONFIGURATION; +import static org.springframework.http.HttpHeaders.AUTHORIZATION; +import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; + +public class RequestIdFilterInstalled extends BaseApiTest { + + /* + Tests whether every incoming request to VID goes through + the requestId filter. This happens by checking the log + AND by checking the echoed header. + + The correctness of the Filter itself is done by unit- + tests. + + The outgoing (outgress) headers are checked by the REST + Clients unit-tests. + */ + + private static final String ECOMP_REQUEST_ID = "x-ecomp-requestid"; + private final String ECOMP_REQUEST_ID_ECHO = ECOMP_REQUEST_ID + "-echo"; + + @BeforeClass + public void login() { + super.login(); + } + + @Test + public void frontendApi_doGET_RequestIdReceived() { + + final Pair responseAndUuid = makeRequest( + HttpMethod.GET, + "/operationalEnvironment/requestStatus?requestId=" + OperationalEnvironmentControllerApiTest.GET_STATUS_REQUEST_UUID, + null, + OperationalEnvironmentControllerApiTest.GET_CLOUD_RESOURCES_REQUEST_STATUS + ); + assertThatUuidInResponseAndUuidIsInARecentLog(responseAndUuid); + + } + + @Test + public void frontendApi_doPOST_RequestIdReceived() { + + final Pair responseAndUuid = makeRequest( + HttpMethod.POST, + "/" + ServiceInstanceMsoApiTest.MSO_DEACTIVATE_SERVICE_INSTANCE, + "{}", + ServiceInstanceMsoApiTest.DEACTIVATE_OK_JSON + ); + assertThatUuidInResponseAndUuidIsInARecentLog(responseAndUuid); + } + + @Test + public void frontendApi_doPOSTWithClientError_RequestIdReceived() { + + final Pair responseAndUuid = makeRequest( + HttpMethod.POST, + "/" + MSO_CREATE_CONFIGURATION, + "i'm not a json" + ); + assertThatUuidInResponseAndUuidIsInARecentLog(responseAndUuid); + + } + + + @Test(groups = { "worksOnlyWithLocalhostVID" }) + public void mopOwningEntityApi_doGET_RequestIdReceived() { + + final Pair responseAndUuid = makeRequest( + HttpMethod.GET, + "/" + GET_CATEGORY_PARAMETER_PROPERTIES + "?familyName=PARAMETER_STANDARDIZATION", + null + ); + + assertThatUuidInResponseAndUuidIsInARecentLog(responseAndUuid); + + /* + test should be for: + x few FE requests; + x few FE errors requests; + - few UI elements requests; + x scheduler callback; + - MOP of workflows; + x MOP of OE; + - health-check + */ + } + + @Test + public void schedulerApi_doPOST_RequestIdReceived() { + + final String anyInstanceId = "any instance id"; + SimulatorApi.registerExpectation( + "mso_in_place_software_update_ok.json", + ImmutableMap.of("SERVICE_INSTANCE_ID", anyInstanceId, "VNF_INSTANCE_ID", anyInstanceId), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); + final Pair responseAndUuid = makeRequest( + HttpMethod.POST, + "/change-management/workflow/" + anyInstanceId, + "{}" + ); + assertThatUuidInResponseAndUuidIsInARecentLog(responseAndUuid); + + } + + @Test + public void healthcheck_doGET_RequestIdReceived(){ + final Pair responseAndUuid = makeRequest( + HttpMethod.GET, "/healthCheck", null + ); + assertThatUuidInResponseAndUuidIsInARecentLog(responseAndUuid); + } + + private void assertThatUuidInResponseAndUuidIsInARecentLog(Pair responseAndUuid) { + assertThatResponseHasUuid(responseAndUuid.getLeft(), responseAndUuid.getRight()); + assertThatTermIsInARecentLog(responseAndUuid.getRight()); + } + + private void assertThatResponseHasUuid(HttpEntity response, String uuid) { + // THIS TEST IS NOT JUST NICE TO HAVE, it also lets us know + // that the request/response ran through our "promise request + // id" filter, which is great! + assertThat(response, not(nullValue())); + assertThat(response.getHeaders().get(ECOMP_REQUEST_ID_ECHO), containsInAnyOrder(uuid)); + } + + private void assertThatTermIsInARecentLog(String uuid) { + final ImmutableList logLines = ImmutableList.of( + LoggerFormatTest.getLogLines("audit", 5, 0, restTemplate, uri), + LoggerFormatTest.getLogLines("error", 5, 0, restTemplate, uri) + ); + + // Assert that audit *OR* error has the uuid + assertThat("uuid not found in any log", logLines, hasItem(containsString(uuid))); + } + + private Pair makeRequest(HttpMethod httpMethod, String url, String body) { + return makeRequest(httpMethod, url, body, null); + } + + private Pair makeRequest(HttpMethod httpMethod, String url, String body, String expectationFilename) { + final String uuid = UUID.randomUUID().toString(); + final HttpHeaders headers = new HttpHeaders(); + headers.add(ECOMP_REQUEST_ID, uuid); + headers.add(AUTHORIZATION, "Basic 123=="); + + SimulatorApi.clearExpectations(); + if (!StringUtils.isEmpty(expectationFilename)) { + SimulatorApi.registerExpectation(expectationFilename, APPEND); + } + SimulatorApi.registerExpectation("aai_get_full_subscribers.json", APPEND); + SimulatorApi.registerExpectation("ecompportal_getSessionSlotCheckInterval.json", APPEND); + + HttpEntity entity = new HttpEntity<>(body, headers); + ResponseEntity response = null; + response = restTemplateErrorAgnostic.exchange(uri + url, + httpMethod, entity, String.class); + + return Pair.of(response, uuid); + } + +} diff --git a/vid-automation/src/test/java/org/onap/vid/more/SimulatorLoaderTest.java b/vid-automation/src/test/java/org/onap/vid/more/SimulatorLoaderTest.java new file mode 100644 index 000000000..bc550ae19 --- /dev/null +++ b/vid-automation/src/test/java/org/onap/vid/more/SimulatorLoaderTest.java @@ -0,0 +1,133 @@ +package org.onap.vid.more; + +import org.onap.simulator.presetGenerator.presets.BasePresets.BasePreset; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIBadBodyForGetServicesGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetNetworkZones; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetPNFByRegionErrorPut; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetServicesGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAISearchNodeQueryEmptyResult; +import org.onap.simulator.presetGenerator.presets.aai.PresetAAIServiceDesignAndCreationPut; +import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet; +import org.onap.simulator.presetGenerator.presets.ecompportal_att.PresetGetUserGet; +import org.onap.simulator.presetGenerator.presets.mso.PresetActivateServiceInstancePost; +import org.onap.simulator.presetGenerator.presets.mso.PresetDeactivateServiceInstancePost; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstancePost; +import org.onap.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet; +import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet; +import org.onap.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet; +import org.onap.vid.api.BaseApiTest; +import org.springframework.http.HttpMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; +import vid.automation.test.services.SimulatorApi; +import vid.automation.test.services.SimulatorApi.RegistrationStrategy; + +import javax.ws.rs.client.Entity; +import javax.ws.rs.client.Invocation; +import javax.ws.rs.client.WebTarget; +import javax.ws.rs.core.MediaType; +import javax.ws.rs.core.Response; +import java.lang.reflect.Method; +import java.util.Collections; +import java.util.List; +import java.util.Map; + +import static org.testng.Assert.assertEquals; +import static vid.automation.test.services.SimulatorApi.registerExpectationFromPreset; +import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets; + +public class SimulatorLoaderTest extends BaseApiTest { + + + protected Invocation.Builder createSimulatorRequestBuilder(BasePreset preset) { + WebTarget webTarget = client.target(SimulatorApi.getSimulationUri() + preset.getReqPath()); + webTarget = addQueryParamsToWebTarget(preset, webTarget); + return webTarget.request() + .accept("application/json"); + } + + private WebTarget addQueryParamsToWebTarget(BasePreset preset, WebTarget webTarget) { + if (preset.getQueryParams() != null) { + for (Map.Entry entry : preset.getQueryParams().entrySet()) { + webTarget = webTarget.queryParam(entry.getKey(), entry.getValue().toArray()); + } + } + return webTarget; + } + + @DataProvider + public static Object[][] presetClassesWithPutPost(Method test) { + return new Object[][]{ + {new PresetAAIGetPNFByRegionErrorPut()}, + {new PresetAAIServiceDesignAndCreationPut("a","b")}, + {new PresetDeactivateServiceInstancePost()}, + {new PresetActivateServiceInstancePost()}, + {new PresetMSOCreateServiceInstancePost()} + }; + } + + @Test(dataProvider = "presetClassesWithPutPost") + public void presetPutPost_WhenLoaded_SimulatorReturnsFakeValues(C preset) { + registerExpectationFromPreset(preset, RegistrationStrategy.CLEAR_THEN_SET); + + Response cres = createSimulatorRequestBuilder(preset) + .method(preset.getReqMethod().name(), + Entity.entity(preset.getRequestBody(), MediaType.APPLICATION_JSON)); + + int status = cres.getStatus(); + + assertEquals(status, preset.getResponseCode()); + } + + @DataProvider + public static Object[][] presetWithGetInstances(Method test) { + return new Object[][]{ + {new PresetAAIGetSubscribersGet()}, + {new PresetGetSessionSlotCheckIntervalGet()}, + {new PresetGetUserGet()}, + {new PresetAAIGetServicesGet()}, + {new PresetSDCGetServiceMetadataGet("a" , "b", "serviceCreationTest.zip")}, + {new PresetSDCGetServiceToscaModelGet( "a", "serviceCreationTest.zip")}, + {new PresetMSOOrchestrationRequestGet()}, + {new PresetAAIGetNetworkZones()}, + {new PresetAAISearchNodeQueryEmptyResult()}, + {new PresetAAIBadBodyForGetServicesGet("not a json")}, + }; + } + + @Test(dataProvider = "presetWithGetInstances") + public void assertPresetWithGetMethod(C preset) { + registerExpectationFromPreset(preset, RegistrationStrategy.CLEAR_THEN_SET); + + Response cres = createSimulatorRequestBuilder(preset).get(); + + int status = cres.getStatus(); + + assertEquals(status, preset.getResponseCode()); + } + + @Test(expectedExceptions = { RuntimeException.class }, expectedExceptionsMessageRegExp = ".*SimulatorLoaderTest.*") + public void assertPresetThatThrowException() { + + registerExpectationFromPresets(Collections.singletonList( + new BasePreset() { + + @Override + public HttpMethod getReqMethod() { + throw new RuntimeException(); + } + + @Override + public String getReqPath() { + return null; + } + + @Override + protected String getRootPath() { + return null; + } + }), RegistrationStrategy.CLEAR_THEN_SET); + } + +} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/aai/AaiResponse.java b/vid-automation/src/test/java/org/opencomp/vid/model/aai/AaiResponse.java deleted file mode 100644 index 3124ca407..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/aai/AaiResponse.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.opencomp.vid.model.aai; - -import com.google.common.base.MoreObjects; -import org.opencomp.vid.model.mso.ProxyResponse; - -/** - * Created by Oren on 7/10/17. - */ -public class AaiResponse extends ProxyResponse { - - T t; - - public AaiResponse() { - } - - public AaiResponse(T t, String errorMessage, int aaiHttpCode) { - this.t = t; - this.errorMessage = errorMessage; - this.httpCode = aaiHttpCode; - } - - public T getT() { - return t; - } - - @Override - public String toString() { - return MoreObjects.toStringHelper(this) - .add("httpCode", httpCode) - .add("errorMessage", errorMessage) - .add("t", t) - .toString(); - } -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/asyncInstantiation/JobAuditStatus.java b/vid-automation/src/test/java/org/opencomp/vid/model/asyncInstantiation/JobAuditStatus.java deleted file mode 100644 index 254eb9c00..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/asyncInstantiation/JobAuditStatus.java +++ /dev/null @@ -1,124 +0,0 @@ -package org.opencomp.vid.model.asyncInstantiation; - -import com.google.common.collect.ImmutableList; -import org.apache.commons.lang3.builder.EqualsBuilder; -import org.apache.commons.lang3.builder.HashCodeBuilder; -import vid.automation.test.model.JobStatus; - -import java.util.Date; -import java.util.UUID; - - -public class JobAuditStatus { - - public JobAuditStatus(){} - - - public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source){ - this.jobId = jobId; - this.jobStatus = jobStatus; - this.source = source; - this.isFinal = isFinal(); - } - - public JobAuditStatus(UUID jobId, String jobStatus, SourceStatus source, UUID requestId, String additionalInfo, Boolean isFinal) { - this(jobId, jobStatus, source); - this.requestId = requestId; - this.additionalInfo = additionalInfo; - this.isFinal = isFinal; - } - - - - public enum SourceStatus { - MSO, - VID - } - - private UUID jobId; - private String jobStatus; - private SourceStatus source; - private UUID requestId; - private String additionalInfo; - - - - private Boolean isFinal; - - public String getJobStatus() { - return jobStatus; - } - - public UUID getJobId() { - return jobId; - } - - public SourceStatus getSource() { - return source; - } - - public String getAdditionalInfo() { - return additionalInfo; - } - - public UUID getRequestId() { - return requestId; - } - - - - public Boolean isFinal(){ - return isFinal; - } - - public void setFinal(Boolean aFinal) { - isFinal = aFinal; - } - - @Override - public String toString() { - return "JobAuditStatus{" + - "jobId=" + jobId + - ", jobStatus='" + jobStatus + '\'' + - ", source=" + source + - ", requestId=" + requestId + - ", additionalInfo='" + additionalInfo + '\'' + - ", isFinal=" + isFinal + - '}'; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - - if (o == null || getClass() != o.getClass()) return false; - - JobAuditStatus that = (JobAuditStatus) o; - - return new EqualsBuilder() - .append(jobId, that.jobId) - .append(jobStatus, that.jobStatus) - .append(source, that.source) - .append(requestId, that.requestId) - .append(additionalInfo, that.additionalInfo) - .append(isFinal, that.isFinal) - .isEquals(); - } - - @Override - public int hashCode() { - return new HashCodeBuilder(17, 37) - .append(jobId) - .append(jobStatus) - .append(source) - .append(requestId) - .append(additionalInfo) - .append(isFinal) - .toHashCode(); - } - - - - - -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/asyncInstantiation/ServiceInfo.java b/vid-automation/src/test/java/org/opencomp/vid/model/asyncInstantiation/ServiceInfo.java deleted file mode 100644 index ee3cd7a77..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/asyncInstantiation/ServiceInfo.java +++ /dev/null @@ -1,75 +0,0 @@ -package org.opencomp.vid.model.asyncInstantiation; - - -import vid.automation.test.model.JobStatus; - -import java.util.Date; - -public class ServiceInfo { - - public String jobId; - public String templateId; - public String userId; - public JobStatus jobStatus; - public Date statusModifiedDate; - public boolean hidden; - public boolean pause; - public String owningEntityId; - public String owningEntityName; - public String project; - public String aicZoneId; - public String aicZoneName; - public String tenantId; - public String tenantName; - public String regionId; - public String regionName; - public String serviceType; - public String subscriberName; - public String serviceInstanceId; - public String serviceInstanceName; - public String serviceModelId; - public String serviceModelName; - public String serviceModelVersion; - public Date createdBulkDate; - - public ServiceInfo(){ - - } - - public ServiceInfo(String userId, JobStatus jobStatus, boolean pause, String owningEntityId, String owningEntityName, String project, String aicZoneId, String aicZoneName, String tenantId, String tenantName, String regionId, String regionName, String serviceType, String subscriberName, String serviceInstanceId, String serviceInstanceName, String serviceModelId, String serviceModelName, String serviceModelVersion, String jobId, String templateId) { - this.userId = userId; - this.jobStatus = jobStatus; - this.pause = pause; - this.owningEntityId = owningEntityId; - this.owningEntityName = owningEntityName; - this.project = project; - this.aicZoneId = aicZoneId; - this.aicZoneName = aicZoneName; - this.tenantId = tenantId; - this.tenantName = tenantName; - this.regionId = regionId; - this.regionName = regionName; - this.serviceType = serviceType; - this.subscriberName = subscriberName; - this.serviceInstanceId = serviceInstanceId; - this.serviceInstanceName = serviceInstanceName; - this.serviceModelId = serviceModelId; - this.serviceModelName = serviceModelName; - this.serviceModelVersion = serviceModelVersion; - this.jobId = jobId; - this.templateId = templateId; - } - - public JobStatus getJobStatus() { - return jobStatus; - } - - public String getServiceInstanceName() { - return serviceInstanceName; - } - - public String getJobId() { - return jobId; - } - -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/category/AddCategoryOptionResponse.java b/vid-automation/src/test/java/org/opencomp/vid/model/category/AddCategoryOptionResponse.java deleted file mode 100644 index 9cfaec954..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/category/AddCategoryOptionResponse.java +++ /dev/null @@ -1,15 +0,0 @@ -package org.opencomp.vid.model.category; - -import org.opencomp.vid.model.workflow.ListOfErrorsResponse; - -import java.util.List; - -public class AddCategoryOptionResponse extends ListOfErrorsResponse { - - public AddCategoryOptionResponse() { - } - - public AddCategoryOptionResponse(List errors) { - super(errors); - } -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/category/AddCategoryOptionsRequest.java b/vid-automation/src/test/java/org/opencomp/vid/model/category/AddCategoryOptionsRequest.java deleted file mode 100644 index 2c3edfde5..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/category/AddCategoryOptionsRequest.java +++ /dev/null @@ -1,13 +0,0 @@ -package org.opencomp.vid.model.category; - -import java.util.ArrayList; -import java.util.List; - -public class AddCategoryOptionsRequest { - - public List options; - - public AddCategoryOptionsRequest() { - options = new ArrayList<>(); - } -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/category/CategoryParameterOption.java b/vid-automation/src/test/java/org/opencomp/vid/model/category/CategoryParameterOption.java deleted file mode 100644 index 2aa839247..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/category/CategoryParameterOption.java +++ /dev/null @@ -1,34 +0,0 @@ -package org.opencomp.vid.model.category; - -public class CategoryParameterOption { - - private String appId; - private String name; - - - public CategoryParameterOption() { - } - - public CategoryParameterOption(String appId, String name) { - setAppId(appId); - setName(name); - } - - public String getAppId() { - return appId; - } - - public void setAppId(String appId) { - this.appId = appId; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/category/CategoryParameterOptionRep.java b/vid-automation/src/test/java/org/opencomp/vid/model/category/CategoryParameterOptionRep.java deleted file mode 100644 index 27b42e66f..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/category/CategoryParameterOptionRep.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.opencomp.vid.model.category; - -public class CategoryParameterOptionRep { - - private String id; - private String name; - - public CategoryParameterOptionRep() { - } - - public CategoryParameterOptionRep(String id, String name) { - this.id = id; - this.name = name; - } - - public String getId() { - return id; - } - - public void setId(String id) { - this.id = id; - } - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/category/CategoryParametersResponse.java b/vid-automation/src/test/java/org/opencomp/vid/model/category/CategoryParametersResponse.java deleted file mode 100644 index 9b9cc8408..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/category/CategoryParametersResponse.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.opencomp.vid.model.category; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; -import java.util.Map; - -public class CategoryParametersResponse { - - private Map> categoryParameters; - - public CategoryParametersResponse() { - } - - public CategoryParametersResponse(Map> categoryParameters) { - this.categoryParameters = categoryParameters; - } - - @JsonProperty("categoryParameters") - public Map> getCategoryParameters() { - return categoryParameters; - } - - public void setCategoryParameters(Map> categoryParameters) { - this.categoryParameters = categoryParameters; - } -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/probe/ExternalComponentStatus.java b/vid-automation/src/test/java/org/opencomp/vid/model/probe/ExternalComponentStatus.java deleted file mode 100644 index 8d548842f..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/probe/ExternalComponentStatus.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.opencomp.vid.model.probe; - -public class ExternalComponentStatus { - public enum Component {AAI, MSO} - private Component component; - private boolean available; - private HttpRequestMetadata metadata; - - public ExternalComponentStatus(){} - - public ExternalComponentStatus(Component component, boolean isAvailable, HttpRequestMetadata metadata) { - this.component = component; - this.available = isAvailable; - this.metadata = metadata; - } - - public Component getComponent() { - return component; - } - - public boolean isAvailable() { - return available; - } - - public HttpRequestMetadata getMetadata() { - return metadata; - } -} \ No newline at end of file diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/probe/HttpRequestMetadata.java b/vid-automation/src/test/java/org/opencomp/vid/model/probe/HttpRequestMetadata.java deleted file mode 100644 index 4ab5ae4a8..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/probe/HttpRequestMetadata.java +++ /dev/null @@ -1,49 +0,0 @@ -package org.opencomp.vid.model.probe; - -import org.springframework.http.HttpMethod; - -public class HttpRequestMetadata { - - - public HttpMethod getHttpMethod() { - return httpMethod; - } - - public int getHttpCode() { - return httpCode; - } - - public String getUrl() { - return url; - } - - public String getRawData() { - return rawData; - } - - public float getDuration() { - return duration; - } - - public String getDescription() { - return description; - } - - private HttpMethod httpMethod; - private int httpCode; - private String url; - private String rawData; - private String description; - private float duration; - - public HttpRequestMetadata(){ - } - - public HttpRequestMetadata(HttpMethod httpMethod,int httpCode, String url, String rawData, String description) { - this.httpMethod = httpMethod; - this.httpCode = httpCode; - this.url = url; - this.rawData = rawData; - this.description = description; - } -} \ No newline at end of file diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/GetVnfWorkflowRelationRequest.java b/vid-automation/src/test/java/org/opencomp/vid/model/workflow/GetVnfWorkflowRelationRequest.java deleted file mode 100644 index e2f15ba95..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/GetVnfWorkflowRelationRequest.java +++ /dev/null @@ -1,28 +0,0 @@ -package org.opencomp.vid.model.workflow; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class GetVnfWorkflowRelationRequest { - - public GetVnfWorkflowRelationRequest() { - } - - public GetVnfWorkflowRelationRequest(List vnfsDetails) { - this.vnfsDetails = vnfsDetails; - } - - @JsonProperty("vnfsDetails") - private List vnfsDetails; - - @JsonProperty("vnfsDetails") - public List getVnfDetails() { - return vnfsDetails; - } - - @JsonProperty("vnfsDetails") - public void setVnfDetails(List vnfDetails) { - this.vnfsDetails = vnfDetails; - } -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/GetWorkflowsResponse.java b/vid-automation/src/test/java/org/opencomp/vid/model/workflow/GetWorkflowsResponse.java deleted file mode 100644 index f1005b2aa..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/GetWorkflowsResponse.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.opencomp.vid.model.workflow; - -import java.util.List; - -public class GetWorkflowsResponse { - private List workflows; - - public GetWorkflowsResponse() { - } - - public GetWorkflowsResponse(List workflows) { - this.workflows = workflows; - } - - public List getWorkflows() { - return workflows; - } - - public void setWorkflows(List workflows) { - this.workflows = workflows; - } - - -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/ListOfErrorsResponse.java b/vid-automation/src/test/java/org/opencomp/vid/model/workflow/ListOfErrorsResponse.java deleted file mode 100644 index 60b733fe4..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/ListOfErrorsResponse.java +++ /dev/null @@ -1,24 +0,0 @@ -package org.opencomp.vid.model.workflow; - -import java.util.ArrayList; -import java.util.List; - -public class ListOfErrorsResponse { - protected List errors; - - public ListOfErrorsResponse() { - this.errors = new ArrayList<>(); - } - - public ListOfErrorsResponse(List errors) { - this.errors = errors; - } - - public List getErrors() { - return errors; - } - - public void setErrors(List errors) { - this.errors = errors; - } -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfDetails.java b/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfDetails.java deleted file mode 100644 index a7b27356c..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfDetails.java +++ /dev/null @@ -1,66 +0,0 @@ -package org.opencomp.vid.model.workflow; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class VnfDetails { - - public VnfDetails() { - } - - public VnfDetails(String UUID, String invariantUUID) { - this.UUID = UUID; - this.invariantUUID = invariantUUID; - } - - @JsonProperty("UUID") - private String UUID; - - @JsonProperty("invariantUUID") - private String invariantUUID; - - @JsonProperty("UUID") - public String getUUID() { - return UUID; - } - - @JsonProperty("UUID") - public void setUUID(String uUID) { - UUID = uUID; - } - - @JsonProperty("invariantUUID") - public String getInvariantUUID() { - return invariantUUID; - } - - @JsonProperty("invariantUUID") - public void setInvariantUUID(String invariantUUID) { - this.invariantUUID = invariantUUID; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || getClass() != o.getClass()) return false; - - VnfDetails that = (VnfDetails) o; - - if (getUUID() != null ? !getUUID().equals(that.getUUID()) : that.getUUID() != null) return false; - return getInvariantUUID() != null ? getInvariantUUID().equals(that.getInvariantUUID()) : that.getInvariantUUID() == null; - } - - @Override - public int hashCode() { - int result = getUUID() != null ? getUUID().hashCode() : 0; - result = 31 * result + (getInvariantUUID() != null ? getInvariantUUID().hashCode() : 0); - return result; - } - - @Override - public String toString() { - return "VnfDetails{" + - "UUID='" + UUID + '\'' + - ", invariantUUID='" + invariantUUID + '\'' + - '}'; - } -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfDetailsWithWorkflows.java b/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfDetailsWithWorkflows.java deleted file mode 100644 index 953e25b77..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfDetailsWithWorkflows.java +++ /dev/null @@ -1,27 +0,0 @@ -package org.opencomp.vid.model.workflow; - - -import java.util.List; - -public class VnfDetailsWithWorkflows extends VnfDetails { - - private List workflows; - - public VnfDetailsWithWorkflows() { - } - - - @SuppressWarnings("WeakerAccess") - public VnfDetailsWithWorkflows(String UUID, String invariantUUID, List workflows) { - super(UUID, invariantUUID); - this.workflows = workflows; - } - - public List getWorkflows() { - return workflows; - } - - public void setWorkflows(List workflows) { - this.workflows = workflows; - } -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfWorkflowRelationAllResponse.java b/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfWorkflowRelationAllResponse.java deleted file mode 100644 index 3f0cc3ef9..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfWorkflowRelationAllResponse.java +++ /dev/null @@ -1,23 +0,0 @@ -package org.opencomp.vid.model.workflow; - -import java.util.List; - -public class VnfWorkflowRelationAllResponse { - - private List vnfs; - - public VnfWorkflowRelationAllResponse() { - } - - public VnfWorkflowRelationAllResponse(List vnfs) { - this.vnfs = vnfs; - } - - public List getVnfs() { - return vnfs; - } - - public void setVnfs(List vnfs) { - this.vnfs = vnfs; - } -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfWorkflowRelationRequest.java b/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfWorkflowRelationRequest.java deleted file mode 100644 index 86ac2b40c..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfWorkflowRelationRequest.java +++ /dev/null @@ -1,31 +0,0 @@ -package org.opencomp.vid.model.workflow; - -import com.fasterxml.jackson.annotation.JsonProperty; - -import java.util.List; - -public class VnfWorkflowRelationRequest { - - public VnfWorkflowRelationRequest() { - } - - public VnfWorkflowRelationRequest(List workflowsDetails) { - this.workflowsDetails = workflowsDetails; - } - - @JsonProperty("workflowsDetails") - private List workflowsDetails; - - @JsonProperty("workflowsDetails") - public List getWorkflowsDetails() { - return workflowsDetails; - } - - @JsonProperty("workflowsDetails") - public void setWorkflowsDetails(List workflowsDetails) { - this.workflowsDetails = workflowsDetails; - } - - - -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfWorkflowRelationResponse.java b/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfWorkflowRelationResponse.java deleted file mode 100644 index fdc57ad17..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/VnfWorkflowRelationResponse.java +++ /dev/null @@ -1,14 +0,0 @@ -package org.opencomp.vid.model.workflow; - - -import java.util.List; - -public class VnfWorkflowRelationResponse extends ListOfErrorsResponse { - - public VnfWorkflowRelationResponse() { - } - - public VnfWorkflowRelationResponse(List errors) { - super(errors); - } -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/WorkflowsDetail.java b/vid-automation/src/test/java/org/opencomp/vid/model/workflow/WorkflowsDetail.java deleted file mode 100644 index a67f724c8..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/model/workflow/WorkflowsDetail.java +++ /dev/null @@ -1,43 +0,0 @@ -package org.opencomp.vid.model.workflow; - -import com.fasterxml.jackson.annotation.JsonProperty; - -public class WorkflowsDetail { - - public WorkflowsDetail() { - } - - public WorkflowsDetail(VnfDetails vnfDetails, String workflowName) { - this.vnfDetails = vnfDetails; - this.workflowName = workflowName; - } - - @JsonProperty("vnfDetails") - private VnfDetails vnfDetails; - - @JsonProperty("workflowName") - private String workflowName; - - @JsonProperty("vnfDetails") - public VnfDetails getVnfDetails() { - return vnfDetails; - } - @JsonProperty("vnfDetails") - public void setVnfDetails(VnfDetails vnfDetails) { - this.vnfDetails = vnfDetails; - } - @JsonProperty("workflowName") - public String getWorkflowName() { - return workflowName; - } - @JsonProperty("workflowName") - public void setWorkflowName(String workflowName) { - this.workflowName = workflowName; - } - - @Override - public String toString() { - return vnfDetails + - ", workflowName='" + workflowName; - } -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/more/LoggerFormatTest.java b/vid-automation/src/test/java/org/opencomp/vid/more/LoggerFormatTest.java deleted file mode 100644 index 8b3d244b5..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/more/LoggerFormatTest.java +++ /dev/null @@ -1,97 +0,0 @@ -package org.opencomp.vid.more; - -import com.fasterxml.jackson.databind.JsonNode; -import org.apache.commons.lang3.StringUtils; -import org.opencomp.simulator.presetGenerator.presets.aai.PresetAAIGetSubscribersGet; -import org.opencomp.vid.api.BaseApiTest; -import org.springframework.http.client.ClientHttpRequestInterceptor; -import org.springframework.web.client.RestTemplate; -import org.testng.SkipException; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.BeforeMethod; -import org.testng.annotations.Test; -import vid.automation.test.services.SimulatorApi; - -import java.net.URI; -import java.time.LocalDate; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import static java.util.Collections.singletonList; -import static org.hamcrest.CoreMatchers.is; -import static org.hamcrest.Matchers.greaterThan; -import static org.hamcrest.Matchers.greaterThanOrEqualTo; -import static org.junit.Assert.assertThat; - -public class LoggerFormatTest extends BaseApiTest { - - - // See: https://wiki.web.att.com/display/KSAT/REST-based+Log+Checker - private final static String logChecker = "http://eelflogcheck.it.att.com:31820/validate"; - - @BeforeClass - public void login() { - super.login(); - } - - @BeforeClass - public void setAaiSubscribers() { - SimulatorApi.registerExpectationFromPreset(new PresetAAIGetSubscribersGet(), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); - } - - @Test - public void validateAuditLogsFormat() { - validateLogsFormat("audit"); - } - - @Test(enabled = false) // no total-score is returned for error-log - public void validateErrorLogsFormat() { - validateLogsFormat("error"); - } - - @Test - public void validateMetricsLogsFormat() { - validateLogsFormat("metrics", "metric"); - } - - private void validateLogsFormat(String logName) { - validateLogsFormat(logName, logName); - } - - private void validateLogsFormat(String logName, String logType) { - - String logLines = getLogLines(logName); - JsonNode response = getCheckerResults(logType, logLines); - - System.out.println(response); - double fieldscore = response.path("summary").path("score").path("fieldscore").asDouble(); - double overall = response.path("summary").path("score").path("overallscore").asDouble(); - - assertThat(fieldscore, is(greaterThan(0.95))); - assertThat(overall, is(greaterThan(0.95))); - - } - - private String getLogLines(String logname) { - return getLogLines(logname, 5000, 30, restTemplate, uri); - } - - public static String getLogLines(String logname, int maxRows, int minRows, RestTemplate restTemplate, URI uri) { - String logLines = restTemplate.getForObject(uri + "/logger/" + logname + "?limit={maxRows}", String.class, maxRows); - assertThat("expecting at least " + minRows + " rows in " + logname, - StringUtils.countMatches(logLines, '\n') + 1, - is(greaterThanOrEqualTo(minRows))); - return logLines; - } - - private JsonNode getCheckerResults(String logtype, String logLines) { - Map params = new HashMap<>(); - params.put("format", "raw"); - params.put("type", logtype); - params.put("component", "vid"); - params.put("data", logLines); - - return restTemplate.postForObject(logChecker, params, JsonNode.class); - } -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/more/RequestIdFilterInstalled.java b/vid-automation/src/test/java/org/opencomp/vid/more/RequestIdFilterInstalled.java deleted file mode 100644 index 637904766..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/more/RequestIdFilterInstalled.java +++ /dev/null @@ -1,184 +0,0 @@ -package org.opencomp.vid.more; - -import com.google.common.collect.ImmutableList; -import com.google.common.collect.ImmutableMap; -import org.apache.commons.lang3.StringUtils; -import org.apache.commons.lang3.tuple.Pair; -import org.opencomp.vid.api.BaseApiTest; -import org.opencomp.vid.api.OperationalEnvironmentControllerApiTest; -import org.opencomp.vid.api.ServiceInstanceMsoApiTest; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpHeaders; -import org.springframework.http.HttpMethod; -import org.springframework.http.ResponseEntity; -import org.testng.annotations.BeforeClass; -import org.testng.annotations.Test; -import vid.automation.test.services.SimulatorApi; - -import java.util.UUID; - -import static org.hamcrest.CoreMatchers.*; -import static org.hamcrest.Matchers.containsInAnyOrder; -import static org.hamcrest.Matchers.nullValue; -import static org.junit.Assert.assertThat; -import static org.opencomp.vid.api.CategoryParametersApiTest.GET_CATEGORY_PARAMETER_PROPERTIES; -import static org.opencomp.vid.api.pProbeMsoApiTest.MSO_CREATE_CONFIGURATION; -import static org.springframework.http.HttpHeaders.AUTHORIZATION; -import static vid.automation.test.services.SimulatorApi.RegistrationStrategy.APPEND; - -public class RequestIdFilterInstalled extends BaseApiTest { - - /* - Tests whether every incoming request to VID goes through - the requestId filter. This happens by checking the log - AND by checking the echoed header. - - The correctness of the Filter itself is done by unit- - tests. - - The outgoing (outgress) headers are checked by the REST - Clients unit-tests. - */ - - private static final String ECOMP_REQUEST_ID = "x-ecomp-requestid"; - private final String ECOMP_REQUEST_ID_ECHO = ECOMP_REQUEST_ID + "-echo"; - - @BeforeClass - public void login() { - super.login(); - } - - @Test - public void frontendApi_doGET_RequestIdReceived() { - - final Pair responseAndUuid = makeRequest( - HttpMethod.GET, - "/operationalEnvironment/requestStatus?requestId=" + OperationalEnvironmentControllerApiTest.GET_STATUS_REQUEST_UUID, - null, - OperationalEnvironmentControllerApiTest.GET_CLOUD_RESOURCES_REQUEST_STATUS - ); - assertThatUuidInResponseAndUuidIsInARecentLog(responseAndUuid); - - } - - @Test - public void frontendApi_doPOST_RequestIdReceived() { - - final Pair responseAndUuid = makeRequest( - HttpMethod.POST, - "/" + ServiceInstanceMsoApiTest.MSO_DEACTIVATE_SERVICE_INSTANCE, - "{}", - ServiceInstanceMsoApiTest.DEACTIVATE_OK_JSON - ); - assertThatUuidInResponseAndUuidIsInARecentLog(responseAndUuid); - } - - @Test - public void frontendApi_doPOSTWithClientError_RequestIdReceived() { - - final Pair responseAndUuid = makeRequest( - HttpMethod.POST, - "/" + MSO_CREATE_CONFIGURATION, - "i'm not a json" - ); - assertThatUuidInResponseAndUuidIsInARecentLog(responseAndUuid); - - } - - - @Test(groups = { "worksOnlyWithLocalhostVID" }) - public void mopOwningEntityApi_doGET_RequestIdReceived() { - - final Pair responseAndUuid = makeRequest( - HttpMethod.GET, - "/" + GET_CATEGORY_PARAMETER_PROPERTIES + "?familyName=PARAMETER_STANDARDIZATION", - null - ); - - assertThatUuidInResponseAndUuidIsInARecentLog(responseAndUuid); - - /* - test should be for: - x few FE requests; - x few FE errors requests; - - few UI elements requests; - x scheduler callback; - - MOP of workflows; - x MOP of OE; - - health-check - */ - } - - @Test - public void schedulerApi_doPOST_RequestIdReceived() { - - final String anyInstanceId = "any instance id"; - SimulatorApi.registerExpectation( - "mso_in_place_software_update_ok.json", - ImmutableMap.of("SERVICE_INSTANCE_ID", anyInstanceId, "VNF_INSTANCE_ID", anyInstanceId), SimulatorApi.RegistrationStrategy.CLEAR_THEN_SET); - final Pair responseAndUuid = makeRequest( - HttpMethod.POST, - "/change-management/workflow/" + anyInstanceId, - "{}" - ); - assertThatUuidInResponseAndUuidIsInARecentLog(responseAndUuid); - - } - - @Test - public void healthcheck_doGET_RequestIdReceived(){ - final Pair responseAndUuid = makeRequest( - HttpMethod.GET, "/healthCheck", null - ); - assertThatUuidInResponseAndUuidIsInARecentLog(responseAndUuid); - } - - private void assertThatUuidInResponseAndUuidIsInARecentLog(Pair responseAndUuid) { - assertThatResponseHasUuid(responseAndUuid.getLeft(), responseAndUuid.getRight()); - assertThatTermIsInARecentLog(responseAndUuid.getRight()); - } - - private void assertThatResponseHasUuid(HttpEntity response, String uuid) { - // THIS TEST IS NOT JUST NICE TO HAVE, it also lets us know - // that the request/response ran through our "promise request - // id" filter, which is great! - assertThat(response, not(nullValue())); - assertThat(response.getHeaders().get(ECOMP_REQUEST_ID_ECHO), containsInAnyOrder(uuid)); - } - - private void assertThatTermIsInARecentLog(String uuid) { - final ImmutableList logLines = ImmutableList.of( - LoggerFormatTest.getLogLines("audit", 5, 0, restTemplate, uri), - LoggerFormatTest.getLogLines("error", 5, 0, restTemplate, uri) - ); - - // Assert that audit *OR* error has the uuid - assertThat("uuid not found in any log", logLines, hasItem(containsString(uuid))); - } - - private Pair makeRequest(HttpMethod httpMethod, String url, String body) { - return makeRequest(httpMethod, url, body, null); - } - - private Pair makeRequest(HttpMethod httpMethod, String url, String body, String expectationFilename) { - final String uuid = UUID.randomUUID().toString(); - final HttpHeaders headers = new HttpHeaders(); - headers.add(ECOMP_REQUEST_ID, uuid); - headers.add(AUTHORIZATION, "Basic 123=="); - - SimulatorApi.clearExpectations(); - if (!StringUtils.isEmpty(expectationFilename)) { - SimulatorApi.registerExpectation(expectationFilename, APPEND); - } - SimulatorApi.registerExpectation("aai_get_full_subscribers.json", APPEND); - SimulatorApi.registerExpectation("ecompportal_getSessionSlotCheckInterval.json", APPEND); - - HttpEntity entity = new HttpEntity<>(body, headers); - ResponseEntity response = null; - response = restTemplateErrorAgnostic.exchange(uri + url, - httpMethod, entity, String.class); - - return Pair.of(response, uuid); - } - -} diff --git a/vid-automation/src/test/java/org/opencomp/vid/more/SimulatorLoaderTest.java b/vid-automation/src/test/java/org/opencomp/vid/more/SimulatorLoaderTest.java deleted file mode 100644 index 2bcf0698f..000000000 --- a/vid-automation/src/test/java/org/opencomp/vid/more/SimulatorLoaderTest.java +++ /dev/null @@ -1,127 +0,0 @@ -package org.opencomp.vid.more; - -import org.opencomp.simulator.presetGenerator.presets.BasePresets.BasePreset; -import org.opencomp.simulator.presetGenerator.presets.aai.*; -import org.opencomp.simulator.presetGenerator.presets.ecompportal_att.PresetGetSessionSlotCheckIntervalGet; -import org.opencomp.simulator.presetGenerator.presets.ecompportal_att.PresetGetUserGet; -import org.opencomp.simulator.presetGenerator.presets.mso.PresetActivateServiceInstancePost; -import org.opencomp.simulator.presetGenerator.presets.mso.PresetDeactivateServiceInstancePost; -import org.opencomp.simulator.presetGenerator.presets.mso.PresetMSOCreateServiceInstancePost; -import org.opencomp.simulator.presetGenerator.presets.mso.PresetMSOOrchestrationRequestGet; -import org.opencomp.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceMetadataGet; -import org.opencomp.simulator.presetGenerator.presets.sdc.PresetSDCGetServiceToscaModelGet; -import org.opencomp.vid.api.BaseApiTest; -import org.springframework.http.HttpMethod; -import org.testng.annotations.DataProvider; -import org.testng.annotations.Test; -import vid.automation.test.services.SimulatorApi; -import vid.automation.test.services.SimulatorApi.RegistrationStrategy; - -import javax.ws.rs.client.Entity; -import javax.ws.rs.client.Invocation; -import javax.ws.rs.client.WebTarget; -import javax.ws.rs.core.MediaType; -import javax.ws.rs.core.Response; -import java.lang.reflect.Method; -import java.util.Collections; -import java.util.List; -import java.util.Map; - -import static org.testng.Assert.assertEquals; -import static vid.automation.test.services.SimulatorApi.registerExpectationFromPreset; -import static vid.automation.test.services.SimulatorApi.registerExpectationFromPresets; - -public class SimulatorLoaderTest extends BaseApiTest { - - - protected Invocation.Builder createSimulatorRequestBuilder(BasePreset preset) { - WebTarget webTarget = client.target(SimulatorApi.getSimulationUri() + preset.getReqPath()); - webTarget = addQueryParamsToWebTarget(preset, webTarget); - return webTarget.request() - .accept("application/json"); - } - - private WebTarget addQueryParamsToWebTarget(BasePreset preset, WebTarget webTarget) { - if (preset.getQueryParams() != null) { - for (Map.Entry entry : preset.getQueryParams().entrySet()) { - webTarget = webTarget.queryParam(entry.getKey(), entry.getValue().toArray()); - } - } - return webTarget; - } - - @DataProvider - public static Object[][] presetClassesWithPutPost(Method test) { - return new Object[][]{ - {new PresetAAIGetPNFByRegionErrorPut()}, - {new PresetAAIServiceDesignAndCreationPut("a","b")}, - {new PresetDeactivateServiceInstancePost()}, - {new PresetActivateServiceInstancePost()}, - {new PresetMSOCreateServiceInstancePost()} - }; - } - - @Test(dataProvider = "presetClassesWithPutPost") - public void presetPutPost_WhenLoaded_SimulatorReturnsFakeValues(C preset) { - registerExpectationFromPreset(preset, RegistrationStrategy.CLEAR_THEN_SET); - - Response cres = createSimulatorRequestBuilder(preset) - .method(preset.getReqMethod().name(), - Entity.entity(preset.getRequestBody(), MediaType.APPLICATION_JSON)); - - int status = cres.getStatus(); - - assertEquals(status, preset.getResponseCode()); - } - - @DataProvider - public static Object[][] presetWithGetInstances(Method test) { - return new Object[][]{ - {new PresetAAIGetSubscribersGet()}, - {new PresetGetSessionSlotCheckIntervalGet()}, - {new PresetGetUserGet()}, - {new PresetAAIGetServicesGet()}, - {new PresetSDCGetServiceMetadataGet("a" , "b", "serviceCreationTest.zip")}, - {new PresetSDCGetServiceToscaModelGet( "a", "serviceCreationTest.zip")}, - {new PresetMSOOrchestrationRequestGet()}, - {new PresetAAIGetNetworkZones()}, - {new PresetAAISearchNodeQueryEmptyResult()}, - {new PresetAAIBadBodyForGetServicesGet("not a json")}, - }; - } - - @Test(dataProvider = "presetWithGetInstances") - public void assertPresetWithGetMethod(C preset) { - registerExpectationFromPreset(preset, RegistrationStrategy.CLEAR_THEN_SET); - - Response cres = createSimulatorRequestBuilder(preset).get(); - - int status = cres.getStatus(); - - assertEquals(status, preset.getResponseCode()); - } - - @Test(expectedExceptions = { RuntimeException.class }, expectedExceptionsMessageRegExp = ".*SimulatorLoaderTest.*") - public void assertPresetThatThrowException() { - - registerExpectationFromPresets(Collections.singletonList( - new BasePreset() { - - @Override - public HttpMethod getReqMethod() { - throw new RuntimeException(); - } - - @Override - public String getReqPath() { - return null; - } - - @Override - protected String getRootPath() { - return null; - } - }), RegistrationStrategy.CLEAR_THEN_SET); - } - -} -- cgit 1.2.3-korg