diff options
42 files changed, 558 insertions, 415 deletions
diff --git a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java index 468b771c07..47ba076e0e 100644 --- a/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java +++ b/adapters/mso-adapter-utils/src/main/java/org/onap/so/openstack/utils/MsoHeatEnvironmentEntry.java @@ -246,22 +246,4 @@ public class MsoHeatEnvironmentEntry { sb.append(this.rawEntry.substring(indexOf)); return sb; } - - public void setHPAParameters(StringBuilder hpasb) { - try { - MsoYamlEditorWithEnvt yaml = new MsoYamlEditorWithEnvt(hpasb.toString().getBytes()); - Set<MsoHeatEnvironmentParameter> hpaParams = yaml.getParameterListFromEnvt(); - for (MsoHeatEnvironmentParameter hpaparam : hpaParams) { - for (MsoHeatEnvironmentParameter param : this.parameters) { - if (param.getName() == hpaparam.getName()) { - param.setValue(hpaparam.getValue()); - } - } - } - } catch (Exception e) { - logger.debug("Exception:", e); - this.errorString = e.getMessage(); - // e.printStackTrace(); - } - } } diff --git a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java index 4c115271f0..c0e065c298 100644 --- a/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java +++ b/adapters/mso-openstack-adapters/src/main/java/org/onap/so/adapters/network/MsoNetworkAdapterImpl.java @@ -842,8 +842,8 @@ public class MsoNetworkAdapterImpl implements MsoNetworkAdapter { } else { String error = String.format( "Network Type:%s Version_Min:%s Version_Max:%s not supported on Cloud:%s with AIC_Version:%s", - networkType, networkType, networkResource.getAicVersionMin(), networkResource.getAicVersionMax(), - cloudSiteId, cloudSite.getCloudVersion()); + networkType, networkResource.getAicVersionMin(), networkResource.getAicVersionMax(), cloudSiteId, + cloudSite.getCloudVersion()); logger.error(LoggingAnchor.THREE, MessageEnum.RA_CONFIG_EXC, ErrorCode.DataError.getValue(), error); throw new NetworkException(error, MsoExceptionCategory.USERDATA); } diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java index 8be3d6ba06..f2c6b2f16a 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/ResourceStructure.java @@ -61,7 +61,7 @@ public abstract class ResourceStructure { /** * Number of resources provided by the resource structure. */ - protected int NumberOfResources; + protected int numberOfResources; /** * The list of artifacts existing in this resource hashed by UUID. @@ -142,11 +142,11 @@ public abstract class ResourceStructure { } public int getNumberOfResources() { - return NumberOfResources; + return numberOfResources; } public void setNumberOfResources(int numberOfResources) { - NumberOfResources = numberOfResources; + this.numberOfResources = numberOfResources; } public Map<String, VfModuleArtifact> getArtifactsMapByUUID() { diff --git a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java index a68d98e0b0..ef4dfa24aa 100644 --- a/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java +++ b/asdc-controller/src/main/java/org/onap/so/asdc/installer/bpmn/WorkflowResource.java @@ -52,7 +52,7 @@ import org.springframework.stereotype.Component; public class WorkflowResource { protected static final Logger logger = LoggerFactory.getLogger(WorkflowResource.class); - private static final String pattern = ".*\\\"activity:(.*)\\\" .*"; + private static final String PATTERN = ".*\\\"activity:(.*)\\\" .*"; private static final String TARGET_RESOURCE_VNF = "vnf"; private static final String SOURCE_SDC = "sdc"; private static final String BPMN_SUFFIX = ".bpmn"; @@ -176,7 +176,7 @@ public class WorkflowResource { protected List<String> getActivityNameList(String bpmnContent) { List<String> activityNameList = new ArrayList<>(); - Pattern p = Pattern.compile(pattern); + Pattern p = Pattern.compile(PATTERN); Matcher m = p.matcher(bpmnContent); while (m.find()) { activityNameList.add(m.group(1)); diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java index cc3ec52c7a..3a4df68f02 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/common/resource/InstanceResourceList.java @@ -68,7 +68,7 @@ public class InstanceResourceList { public static List<Resource> getInstanceResourceList(final VnfResource vnfResource, final String uuiRequest) { - List<Resource> sequencedResourceList = new ArrayList<Resource>(); + List<Resource> sequencedResourceList = new ArrayList<>(); Gson gson = new Gson(); JsonObject servJsonObject = gson.fromJson(uuiRequest, JsonObject.class); JsonObject reqInputJsonObj = servJsonObject.getAsJsonObject("service").getAsJsonObject("parameters") @@ -117,7 +117,7 @@ public class InstanceResourceList { } private static List<Resource> getGroupResourceInstanceList(VnfResource vnfResource, JsonObject vfObj) { - List<Resource> sequencedResourceList = new ArrayList<Resource>(); + List<Resource> sequencedResourceList = new ArrayList<>(); if (vnfResource.getGroupOrder() != null && !StringUtils.isEmpty(vnfResource.getGroupOrder())) { String[] grpSequence = vnfResource.getGroupOrder().split(","); for (String grpType : grpSequence) { diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/Metadata.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/Metadata.java index f56fad3bcf..84b162e1a2 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/Metadata.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/Metadata.java @@ -31,7 +31,7 @@ public class Metadata implements Serializable { private static final long serialVersionUID = 4981393122007858950L; @JsonProperty("metadatum") - private List<Metadatum> metadatum = new ArrayList<Metadatum>(); + private List<Metadatum> metadatum = new ArrayList<>(); public List<Metadatum> getMetadatum() { return metadatum; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/AggregateRoute.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/AggregateRoute.java index a5eb9d86a7..96a6ab7bd2 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/AggregateRoute.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/AggregateRoute.java @@ -36,8 +36,6 @@ public class AggregateRoute implements Serializable, ShallowCopy<AggregateRoute> @Id @JsonProperty("route-id") private String routeId; - @JsonProperty("route-name") - private String routeName; @JsonProperty("network-start-address") private String networkStartAddress; @JsonProperty("cidr-mask") @@ -54,14 +52,6 @@ public class AggregateRoute implements Serializable, ShallowCopy<AggregateRoute> this.routeId = routeId; } - public String getRouteName() { - return routeName; - } - - public void setRouteName(String routeName) { - this.routeName = routeName; - } - public String getNetworkStartAddress() { return networkStartAddress; } diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java index 841546b3b1..ebf722ef74 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/GenericVnf.java @@ -133,7 +133,7 @@ public class GenericVnf implements Serializable, ShallowCopy<GenericVnf> { @JsonProperty("model-info-generic-vnf") private ModelInfoGenericVnf modelInfoGenericVnf; @JsonProperty("instance-groups") - private List<InstanceGroup> instanceGroups = new ArrayList<InstanceGroup>(); + private List<InstanceGroup> instanceGroups = new ArrayList<>(); @JsonProperty("call-homing") private Boolean callHoming; @JsonProperty("nf-function") diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/LInterface.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/LInterface.java index 387d191409..db2785902a 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/LInterface.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/LInterface.java @@ -65,15 +65,15 @@ public class LInterface implements Serializable, ShallowCopy<LInterface> { @JsonProperty("allowed-address-pairs") private String allowedAddressPairs; @JsonProperty("vlans") - private List<Vlan> vlans = new ArrayList<Vlan>(); + private List<Vlan> vlans = new ArrayList<>(); @JsonProperty("sriov-vfs") - private List<SriovVf> sriovVfs = new ArrayList<SriovVf>(); + private List<SriovVf> sriovVfs = new ArrayList<>(); @JsonProperty("l-interfaces") - private List<LInterface> lInterfaces = new ArrayList<LInterface>(); + private List<LInterface> lInterfaces = new ArrayList<>(); @JsonProperty("l3-interface-ipv4-address-list") - private List<L3InterfaceIpv4AddressList> l3InterfaceIpv4AddressList = new ArrayList<L3InterfaceIpv4AddressList>(); + private List<L3InterfaceIpv4AddressList> l3InterfaceIpv4AddressList = new ArrayList<>(); @JsonProperty("l3-interface-ipv6-address-list") - private List<L3InterfaceIpv6AddressList> l3InterfaceIpv6AddressList = new ArrayList<L3InterfaceIpv6AddressList>(); + private List<L3InterfaceIpv6AddressList> l3InterfaceIpv6AddressList = new ArrayList<>(); public String getInterfaceName() { return interfaceName; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/PServer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/PServer.java index d0bf1f588b..f3e28faf44 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/PServer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/PServer.java @@ -41,9 +41,9 @@ public class PServer implements Serializable, ShallowCopy<PServer> { @JsonProperty("hostname") private String hostname; @JsonProperty("physical-links") - private List<PhysicalLink> physicalLinks = new ArrayList<PhysicalLink>(); // TODO techincally there is a pInterface - // between (pserver <--> physical-link) - // but dont really need that pojo + private List<PhysicalLink> physicalLinks = new ArrayList<>(); // TODO techincally there is a pInterface + // between (pserver <--> physical-link) + // but dont really need that pojo public String getPserverId() { return pserverId; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java index 0803bed574..6cc8aa368c 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceInstance.java @@ -79,7 +79,7 @@ public class ServiceInstance implements Serializable, ShallowCopy<ServiceInstanc @JsonProperty("instance-groups") private List<InstanceGroup> instanceGroups = new ArrayList<>(); @JsonProperty("service-proxies") - private List<ServiceProxy> serviceProxies = new ArrayList<ServiceProxy>(); + private List<ServiceProxy> serviceProxies = new ArrayList<>(); public void setServiceProxies(List<ServiceProxy> serviceProxies) { this.serviceProxies = serviceProxies; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceSubscription.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceSubscription.java index 05199b7f37..b677b1efd0 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceSubscription.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/ServiceSubscription.java @@ -41,7 +41,7 @@ public class ServiceSubscription implements Serializable, ShallowCopy<ServiceSub @JsonProperty("temp-ub-sub-account-id") private String tempUbSubAccountId; @JsonProperty("service-instances") - private List<ServiceInstance> serviceInstances = new ArrayList<ServiceInstance>(); + private List<ServiceInstance> serviceInstances = new ArrayList<>(); public String getServiceType() { return serviceType; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vlan.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vlan.java index 6951a23630..8c0db18d80 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vlan.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/bbobjects/Vlan.java @@ -62,9 +62,9 @@ public class Vlan implements Serializable, ShallowCopy<Vlan> { @JsonProperty("is-ip-unnumbered") private Boolean isIpUnnumbered; @JsonProperty("l3-interface-ipv4-address-list") - private List<L3InterfaceIpv4AddressList> l3InterfaceIpv4AddressList = new ArrayList<L3InterfaceIpv4AddressList>(); + private List<L3InterfaceIpv4AddressList> l3InterfaceIpv4AddressList = new ArrayList<>(); @JsonProperty("l3-interface-ipv6-address-list") - private List<L3InterfaceIpv6AddressList> l3InterfaceIpv6AddressList = new ArrayList<L3InterfaceIpv6AddressList>(); + private List<L3InterfaceIpv6AddressList> l3InterfaceIpv6AddressList = new ArrayList<>(); public String getVlanInterface() { return vlanInterface; diff --git a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java index 573925ff3f..ea48c78dc0 100644 --- a/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java +++ b/bpmn/MSOCommonBPMN/src/main/java/org/onap/so/bpmn/servicedecomposition/tasks/BBInputSetupMapperLayer.java @@ -30,6 +30,7 @@ import java.util.Map; import java.util.Optional; import org.modelmapper.ModelMapper; import org.modelmapper.convention.MatchingStrategies; +import org.onap.so.bpmn.servicedecomposition.bbobjects.AggregateRoute; import org.onap.so.bpmn.servicedecomposition.bbobjects.AllottedResource; import org.onap.so.bpmn.servicedecomposition.bbobjects.CloudRegion; import org.onap.so.bpmn.servicedecomposition.bbobjects.Collection; @@ -131,6 +132,10 @@ public class BBInputSetupMapperLayer { return modelMapper.map(aaiSegmentationAssignment, SegmentationAssignment.class); } + protected AggregateRoute mapAAIAggregateRoute(org.onap.aai.domain.yang.AggregateRoute aaiAggregateRoute) { + return modelMapper.map(aaiAggregateRoute, AggregateRoute.class); + } + protected CtagAssignment mapAAICtagAssignment(org.onap.aai.domain.yang.CtagAssignment aaiCtagAssignment) { return modelMapper.map(aaiCtagAssignment, CtagAssignment.class); } @@ -262,10 +267,21 @@ public class BBInputSetupMapperLayer { mapAllSubnetsIntoL3Network(aaiL3Network, network); mapAllCtagAssignmentsIntoL3Network(aaiL3Network, network); mapAllSegmentationAssignmentsIntoL3Network(aaiL3Network, network); + mapAllAggregateRoutesIntoL3Network(aaiL3Network, network); network.setOrchestrationStatus(this.mapOrchestrationStatusFromAAI(aaiL3Network.getOrchestrationStatus())); return network; } + protected void mapAllAggregateRoutesIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network, + L3Network network) { + if (aaiL3Network.getAggregateRoutes() != null) { + for (org.onap.aai.domain.yang.AggregateRoute aaiAggregateRoute : aaiL3Network.getAggregateRoutes() + .getAggregateRoute()) { + network.getAggregateRoutes().add(mapAAIAggregateRoute(aaiAggregateRoute)); + } + } + } + protected void mapAllSegmentationAssignmentsIntoL3Network(org.onap.aai.domain.yang.L3Network aaiL3Network, L3Network network) { if (aaiL3Network.getSegmentationAssignments() != null) { diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json index 418396f290..9b32a4c446 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/aaiL3NetworkInputWithSubnets.json @@ -69,5 +69,15 @@ } ] }, + "aggregateRoutes": { + "aggregateRoute": [ + { + "routeId": "routeId", + "networkStartAddress": "10.80.12.0", + "cidrMask": "23", + "ipVersion": "4" + } + ] + }, "relationshipList": null }
\ No newline at end of file diff --git a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json index ccefe195c9..f65fe17a2e 100644 --- a/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json +++ b/bpmn/MSOCommonBPMN/src/test/resources/__files/ExecuteBuildingBlock/l3NetworkExpectedWithSubnet.json @@ -52,5 +52,13 @@ "segmentation-id": "segmentationId" } ], + "aggregate-routes": [ + { + "route-id": "routeId", + "network-start-address": "10.80.12.0", + "cidr-mask": "23", + "ip-version": "4" + } + ], "model-info-network": null } diff --git a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java index 21847e1c4e..7d5bb0dcf1 100644 --- a/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java +++ b/bpmn/MSOCoreBPMN/src/main/java/org/onap/so/bpmn/core/WorkflowException.java @@ -33,7 +33,7 @@ public class WorkflowException implements Serializable { private final int errorCode; private final String errorMessage; private final String workStep; - private transient TargetEntities extSystemErrorSource; + private TargetEntities extSystemErrorSource; /** * Constructor diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java index d67e6ef0db..a011346756 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/pnf/delegate/ConfigCheckerDelegate.java @@ -45,7 +45,7 @@ public class ConfigCheckerDelegate implements JavaDelegate { private Logger logger = LoggerFactory.getLogger(ConfigCheckerDelegate.class); // ERROR CODE for variable not found in the delegation Context - private static int ERROR_CODE = 601; + private static final int ERROR_CODE = 601; @Autowired protected ExceptionBuilder exceptionUtil; diff --git a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java index 579e7b72df..2f05eb5f2d 100644 --- a/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java +++ b/bpmn/so-bpmn-infrastructure-common/src/main/java/org/onap/so/bpmn/infrastructure/workflow/service/ServicePluginFactory.java @@ -863,23 +863,23 @@ public class ServicePluginFactory { HttpClient client = HttpClientBuilder.create().build(); - if ("POST".equals(methodType.toUpperCase())) { + if ("POST".equalsIgnoreCase(methodType)) { HttpPost httpPost = new HttpPost(msbUrl); httpPost.setConfig(requestConfig); httpPost.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); method = httpPost; - } else if ("PUT".equals(methodType.toUpperCase())) { + } else if ("PUT".equalsIgnoreCase(methodType)) { HttpPut httpPut = new HttpPut(msbUrl); httpPut.setConfig(requestConfig); httpPut.setEntity(new StringEntity(content, ContentType.APPLICATION_JSON)); method = httpPut; - } else if ("GET".equals(methodType.toUpperCase())) { + } else if ("GET".equalsIgnoreCase(methodType)) { HttpGet httpGet = new HttpGet(msbUrl); httpGet.setConfig(requestConfig); httpGet.addHeader("X-FromAppId", "MSO"); httpGet.addHeader("Accept", "application/json"); method = httpGet; - } else if ("DELETE".equals(methodType.toUpperCase())) { + } else if ("DELETE".equalsIgnoreCase(methodType)) { HttpDelete httpDelete = new HttpDelete(msbUrl); httpDelete.setConfig(requestConfig); method = httpDelete; diff --git a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java index 12d1b0be95..b8146b5504 100644 --- a/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java +++ b/bpmn/so-bpmn-tasks/src/main/java/org/onap/so/client/sdnc/beans/SDNCRequest.java @@ -36,7 +36,7 @@ public class SDNCRequest implements Serializable { private SDNCTopology topology; private String correlationValue = UUID.randomUUID().toString(); private String correlationName = "SDNCCallback"; - private Object SDNCPayload; + private Object sdncPayload; public String getTimeOut() { @@ -72,11 +72,11 @@ public class SDNCRequest implements Serializable { } public Object getSDNCPayload() { - return SDNCPayload; + return sdncPayload; } public void setSDNCPayload(Object sDNCPayload) { - SDNCPayload = sDNCPayload; + this.sdncPayload = sDNCPayload; } @Override diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLNodeKey.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLNodeKey.java index f7f5d78604..e301edb0fd 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLNodeKey.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/DSLNodeKey.java @@ -32,9 +32,9 @@ public class DSLNodeKey implements QueryStep { private boolean not = false; private final StringBuilder query = new StringBuilder(); private final String keyName; - private final List<String> values; + private final List<Object> values; - public DSLNodeKey(String keyName, String... value) { + public DSLNodeKey(String keyName, Object... value) { this.keyName = keyName; this.values = Arrays.asList(value); @@ -54,14 +54,18 @@ public class DSLNodeKey implements QueryStep { result.append(" !"); } result.append("('").append(keyName).append("', "); - List<String> temp = new ArrayList<>(); - for (String item : values) { + List<Object> temp = new ArrayList<>(); + for (Object item : values) { if ("null".equals(item)) { temp.add(String.format("' %s '", item)); } else if ("".equals(item)) { temp.add("' '"); } else { - temp.add(String.format("'%s'", item)); + if (item instanceof String) { + temp.add(String.format("'%s'", item)); + } else { + temp.add(item); + } } } result.append(Joiner.on(", ").join(temp)).append(")"); diff --git a/common/src/main/java/org/onap/so/client/graphinventory/entities/__.java b/common/src/main/java/org/onap/so/client/graphinventory/entities/__.java index 2fdd6574e5..87d4d84cac 100644 --- a/common/src/main/java/org/onap/so/client/graphinventory/entities/__.java +++ b/common/src/main/java/org/onap/so/client/graphinventory/entities/__.java @@ -45,7 +45,7 @@ public class __ { return __.<DSLNode>start(new DSLNode(name, key)); } - public static DSLNodeKey key(String keyName, String... value) { + public static DSLNodeKey key(String keyName, Object... value) { return new DSLNodeKey(keyName, value); } diff --git a/common/src/main/java/org/onap/so/utils/TargetEntities.java b/common/src/main/java/org/onap/so/utils/TargetEntities.java index 94385ec8ea..67016a1fa9 100644 --- a/common/src/main/java/org/onap/so/utils/TargetEntities.java +++ b/common/src/main/java/org/onap/so/utils/TargetEntities.java @@ -20,6 +20,8 @@ package org.onap.so.utils; -public interface TargetEntities { +import java.io.Serializable; + +public interface TargetEntities extends Serializable { } diff --git a/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java b/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java index 6e55fe17fa..590e83827b 100644 --- a/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java +++ b/common/src/test/java/org/onap/so/client/aai/DSLQueryBuilderTest.java @@ -108,4 +108,14 @@ public class DSLQueryBuilderTest { builder.equals("pserver*('hostname', 'my-hostname') > p-interface > sriov-pf('pf-pci-id', 'my-id')")); assertTrue(builder.equals(builder)); } + + + @Test + public void mixedTypeTest() { + DSLQueryBuilder<DSLNode, DSLNode> builder = new DSLQueryBuilder<>(new DSLNode(AAIObjectType.CLOUD_REGION, + __.key("cloud-owner", "owner"), __.key("cloud-region-id", "id"))); + builder.to(__.node(AAIObjectType.VLAN_TAG, __.key("vlan-id-outer", 167), __.key("my-boolean", true)).output()); + assertTrue(builder.equals( + "cloud-region('cloud-owner', 'owner')('cloud-region-id', 'id') > vlan-tag*('vlan-id-outer', 167)('my-boolean', true)")); + } } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Actions.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Actions.java index 5dbe44f58b..5ae0cea549 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Actions.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/Actions.java @@ -20,6 +20,8 @@ package org.onap.so.apihandlerinfra; -public interface Actions { +import java.io.Serializable; + +public interface Actions extends Serializable { } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/DuplicateRequestException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/DuplicateRequestException.java index 42198e2d0c..cbbfa16eaa 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/DuplicateRequestException.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/DuplicateRequestException.java @@ -22,7 +22,7 @@ package org.onap.so.apihandlerinfra.exceptions; public class DuplicateRequestException extends ApiException { - private static final String duplicateFailMessage = "Error: Locked instance - This %s (%s) " + private static final String DUPLICATE_FAIL_MESSAGE = "Error: Locked instance - This %s (%s) " + "already has a request being worked with a status of %s (RequestId - %s). The existing request must finish or be cleaned up before proceeding."; private DuplicateRequestException(Builder builder) { @@ -36,7 +36,7 @@ public class DuplicateRequestException extends ApiException { public Builder(String requestScope, String instance, String requestStatus, String requestID, int httpResponseCode, String messageID) { - super(String.format(duplicateFailMessage, requestScope, instance, requestStatus, requestID), + super(String.format(DUPLICATE_FAIL_MESSAGE, requestScope, instance, requestStatus, requestID), httpResponseCode, messageID); } diff --git a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RequestDbFailureException.java b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RequestDbFailureException.java index 577a14674b..a8f868da05 100644 --- a/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RequestDbFailureException.java +++ b/mso-api-handlers/mso-api-handler-common/src/main/java/org/onap/so/apihandlerinfra/exceptions/RequestDbFailureException.java @@ -22,7 +22,7 @@ package org.onap.so.apihandlerinfra.exceptions; public class RequestDbFailureException extends ApiException { - private static final String requestDbFailMessage = "Unable to %s due to error contacting requestDb: %s"; + private static final String REQUEST_DB_FAIL_MESSAGE = "Unable to %s due to error contacting requestDb: %s"; private RequestDbFailureException(Builder builder) { super(builder); @@ -32,7 +32,7 @@ public class RequestDbFailureException extends ApiException { public Builder(String action, String error, int httpResponseCode, String messageID) { - super(requestDbFailMessage.format(requestDbFailMessage, action, error), httpResponseCode, messageID); + super(REQUEST_DB_FAIL_MESSAGE.format(REQUEST_DB_FAIL_MESSAGE, action, error), httpResponseCode, messageID); } public RequestDbFailureException build() { diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GenericStringConverter.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GenericStringConverter.java new file mode 100644 index 0000000000..80144d8ca1 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GenericStringConverter.java @@ -0,0 +1,33 @@ +package org.onap.so.apihandlerinfra; + +import java.net.URI; +import java.util.Set; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.context.properties.ConfigurationPropertiesBinding; +import org.springframework.core.convert.TypeDescriptor; +import org.springframework.core.convert.converter.GenericConverter; +import org.springframework.stereotype.Component; +import com.google.common.collect.ImmutableSet; + +@Component +@ConfigurationPropertiesBinding +public class GenericStringConverter implements GenericConverter { + + @Autowired + private HealthCheckConverter converter; + + @Override + public Set<ConvertiblePair> getConvertibleTypes() { + + ConvertiblePair[] pairs = new ConvertiblePair[] {new ConvertiblePair(String.class, Subsystem.class), + new ConvertiblePair(String.class, URI.class)}; + return ImmutableSet.copyOf(pairs); + } + + @Override + public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { + + return converter.convert(source, sourceType, targetType); + + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java index 3d4b2c76fb..0379ae3578 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandler.java @@ -25,11 +25,8 @@ package org.onap.so.apihandlerinfra; import java.net.URI; import java.util.Collections; -import org.onap.so.logger.LoggingAnchor; -import org.slf4j.Logger; -import org.slf4j.LoggerFactory; -import org.springframework.http.MediaType; -import org.springframework.http.ResponseEntity; +import java.util.List; +import java.util.stream.Collectors; import javax.annotation.PostConstruct; import javax.transaction.Transactional; import javax.ws.rs.DefaultValue; @@ -42,14 +39,20 @@ import javax.ws.rs.core.Context; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; import org.apache.http.HttpStatus; +import org.onap.so.apihandlerinfra.HealthCheckConfig.Endpoint; +import org.onap.so.logger.LoggingAnchor; import org.onap.so.logger.MessageEnum; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.core.env.Environment; import org.springframework.http.HttpEntity; import org.springframework.http.HttpHeaders; +import org.springframework.http.HttpMethod; +import org.springframework.http.MediaType; +import org.springframework.http.ResponseEntity; import org.springframework.stereotype.Component; import org.springframework.web.client.RestTemplate; -import org.springframework.http.HttpMethod; import io.swagger.annotations.Api; import io.swagger.annotations.ApiOperation; @@ -59,45 +62,38 @@ import io.swagger.annotations.ApiOperation; @Api(value = "/globalhealthcheck", description = "APIH Infra Global Health Check") public class GlobalHealthcheckHandler { private static Logger logger = LoggerFactory.getLogger(GlobalHealthcheckHandler.class); - private static final String CONTEXTPATH_PROPERTY = "management.context-path"; - private static final String PROPERTY_DOMAIN = "mso.health.endpoints"; - private static final String CATALOGDB_PROPERTY = PROPERTY_DOMAIN + ".catalogdb"; - private static final String REQUESTDB_PROPERTY = PROPERTY_DOMAIN + ".requestdb"; - private static final String SDNC_PROPERTY = PROPERTY_DOMAIN + ".sdnc"; - private static final String OPENSTACK_PROPERTY = PROPERTY_DOMAIN + ".openstack"; - private static final String BPMN_PROPERTY = PROPERTY_DOMAIN + ".bpmn"; - private static final String ASDC_PROPERTY = PROPERTY_DOMAIN + ".asdc"; - private static final String REQUESTDBATTSVC_PROPERTY = PROPERTY_DOMAIN + ".requestdbattsvc"; - private static final String DEFAULT_PROPERTY_VALUE = ""; + protected static final String CONTEXTPATH_PROPERTY = "management.endpoints.web.base-path"; + protected static final String PROPERTY_DOMAIN = "mso.health"; + protected static final String CATALOGDB_PROPERTY = PROPERTY_DOMAIN + ".endpoints.catalogdb"; + protected static final String REQUESTDB_PROPERTY = PROPERTY_DOMAIN + ".endpoints.requestdb"; + protected static final String SDNC_PROPERTY = PROPERTY_DOMAIN + ".endpoints.sdnc"; + protected static final String OPENSTACK_PROPERTY = PROPERTY_DOMAIN + ".endpoints.openstack"; + protected static final String BPMN_PROPERTY = PROPERTY_DOMAIN + ".endpoints.bpmn"; + protected static final String ASDC_PROPERTY = PROPERTY_DOMAIN + ".endpoints.asdc"; + protected static final String REQUESTDBATTSVC_PROPERTY = PROPERTY_DOMAIN + ".endpoints.requestdbattsvc"; + protected static final String MSO_AUTH_PROPERTY = PROPERTY_DOMAIN + ".auth"; + protected static final String DEFAULT_PROPERTY_VALUE = ""; // e.g. /manage private String actuatorContextPath; - private String endpointCatalogdb; - private String endpointRequestdb; - private String endpointSdnc; - private String endpointOpenstack; - private String endpointBpmn; - private String endpointAsdc; - private String endpointRequestdbAttsvc; @Autowired private Environment env; @Autowired private RestTemplate restTemplate; - private final String health = "/health"; + @Autowired + private HealthCheckConfig config; + + private static final String HEALTH = "/health"; + + private String msoAuth; @PostConstruct protected void init() { actuatorContextPath = env.getProperty(CONTEXTPATH_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointCatalogdb = env.getProperty(CATALOGDB_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointRequestdb = env.getProperty(REQUESTDB_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointSdnc = env.getProperty(SDNC_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointOpenstack = env.getProperty(OPENSTACK_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointBpmn = env.getProperty(BPMN_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointAsdc = env.getProperty(ASDC_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); - endpointRequestdbAttsvc = env.getProperty(REQUESTDBATTSVC_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); + msoAuth = env.getProperty(MSO_AUTH_PROPERTY, String.class, DEFAULT_PROPERTY_VALUE); } @GET @@ -108,29 +104,25 @@ public class GlobalHealthcheckHandler { @Context ContainerRequestContext requestContext) { Response HEALTH_CHECK_RESPONSE = null; // Build internal response object - HealthcheckResponse rsp = new HealthcheckResponse(); + HealthCheckResponse rsp = new HealthCheckResponse(); try { // Generated RequestId String requestId = requestContext.getProperty("requestId").toString(); logger.info(LoggingAnchor.TWO, MessageEnum.APIH_GENERATED_REQUEST_ID.toString(), requestId); - // set APIH status, this is the main entry point - rsp.setApih(HealthcheckStatus.UP.toString()); - // set BPMN - rsp.setBpmn(querySubsystemHealth(MsoSubsystems.BPMN)); - // set SDNCAdapter - rsp.setSdncAdapter(querySubsystemHealth(MsoSubsystems.SDNC)); - // set ASDCController - rsp.setAsdcController(querySubsystemHealth(MsoSubsystems.ASDC)); - // set CatalogDbAdapter - rsp.setCatalogdbAdapter(querySubsystemHealth(MsoSubsystems.CATALOGDB)); - // set RequestDbAdapter - rsp.setRequestdbAdapter(querySubsystemHealth(MsoSubsystems.REQUESTDB)); - // set OpenStackAdapter - rsp.setOpenstackAdapter(querySubsystemHealth(MsoSubsystems.OPENSTACK)); - // set RequestDbAdapterAttSvc - rsp.setRequestdbAdapterAttsvc(querySubsystemHealth(MsoSubsystems.REQUESTDBATT)); + List<Endpoint> endpoints = config.getEndpoints().stream().filter(item -> { + if (!enableBpmn && SoSubsystems.BPMN.equals(item.getSubsystem())) { + return false; + } else { + return true; + } + }).collect(Collectors.toList()); + + for (Endpoint endpoint : endpoints) { + rsp.getSubsystems().add(querySubsystemHealth(endpoint)); + } + // set Message rsp.setMessage(String.format("HttpStatus: %s", HttpStatus.SC_OK)); logger.info(rsp.toString()); @@ -149,70 +141,51 @@ public class GlobalHealthcheckHandler { protected HttpEntity<String> buildHttpEntityForRequest() { HttpHeaders headers = new HttpHeaders(); headers.setAccept(Collections.singletonList(MediaType.APPLICATION_JSON)); - headers.set("Content-Type", "application/json"); + headers.set(HttpHeaders.CONTENT_TYPE, "application/json"); + headers.set(HttpHeaders.AUTHORIZATION, msoAuth); HttpEntity<String> entity = new HttpEntity<>("parameters", headers); return entity; } - protected String querySubsystemHealth(MsoSubsystems subsystem) { + protected HealthCheckSubsystem querySubsystemHealth(Endpoint subsystem) { + HealthCheckStatus status = HealthCheckStatus.DOWN; + URI uri = subsystem.getUri(); try { // get port number for the subsystem - String ept = getEndpointUrlForSubsystemEnum(subsystem); - // build final endpoint url - UriBuilder builder = UriBuilder.fromPath(ept).path(actuatorContextPath).path(health); - URI uri = builder.build(); - logger.info("Calculated URL: {}", uri.toString()); + uri = UriBuilder.fromUri(subsystem.getUri()).path(actuatorContextPath).path(HEALTH).build(); + logger.info("Calculated URL: {}", uri); ResponseEntity<SubsystemHealthcheckResponse> result = restTemplate.exchange(uri, HttpMethod.GET, buildHttpEntityForRequest(), SubsystemHealthcheckResponse.class); - return processResponseFromSubsystem(result, subsystem); + status = processResponseFromSubsystem(result, subsystem); + } catch (Exception ex) { logger.error("Exception occured in GlobalHealthcheckHandler.querySubsystemHealth() ", ex); - return HealthcheckStatus.DOWN.toString(); } + + return new HealthCheckSubsystem(subsystem.getSubsystem(), uri, status); } - protected String processResponseFromSubsystem(ResponseEntity<SubsystemHealthcheckResponse> result, - MsoSubsystems subsystem) { + protected HealthCheckStatus processResponseFromSubsystem(ResponseEntity<SubsystemHealthcheckResponse> result, + Endpoint endpoint) { if (result == null || result.getStatusCodeValue() != HttpStatus.SC_OK) { logger.error(String.format("Globalhealthcheck: checking subsystem: %s failed ! result object is: %s", - subsystem, result == null ? "NULL" : result)); - return HealthcheckStatus.DOWN.toString(); + endpoint.getSubsystem(), result == null ? "NULL" : result)); + return HealthCheckStatus.DOWN; } SubsystemHealthcheckResponse body = result.getBody(); String status = body.getStatus(); if ("UP".equalsIgnoreCase(status)) { - return HealthcheckStatus.UP.toString(); + return HealthCheckStatus.UP; } else { - logger.error("{}, query health endpoint did not return UP status!", subsystem); - return HealthcheckStatus.DOWN.toString(); + logger.error("{}, query health endpoint did not return UP status!", endpoint.getSubsystem()); + return HealthCheckStatus.DOWN; } } - - protected String getEndpointUrlForSubsystemEnum(MsoSubsystems subsystem) { - switch (subsystem) { - case SDNC: - return this.endpointSdnc; - case ASDC: - return this.endpointAsdc; - case BPMN: - return this.endpointBpmn; - case CATALOGDB: - return this.endpointCatalogdb; - case OPENSTACK: - return this.endpointOpenstack; - case REQUESTDB: - return this.endpointRequestdb; - case REQUESTDBATT: - return this.endpointRequestdbAttsvc; - default: - return ""; - } - } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheck.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheck.java new file mode 100644 index 0000000000..1899cdd765 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheck.java @@ -0,0 +1,84 @@ +package org.onap.so.apihandlerinfra; + +import java.net.URI; +import javax.ws.rs.core.UriBuilder; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; + +@Configuration +@ConfigurationProperties(prefix = "mso.health.enpoints") +public class HealthCheck { + + private Subsystem subsystem; + private URI uri; + private HealthCheckStatus status = HealthCheckStatus.DOWN; + + public HealthCheck() { + + } + + public HealthCheck(String subsystem, String uri) { + this.subsystem = SoSubsystems.valueOf(subsystem.toUpperCase()); + this.uri = UriBuilder.fromUri(uri).build(); + } + + public HealthCheck(Subsystem subsystem, URI uri) { + this.subsystem = subsystem; + this.uri = uri; + } + + public HealthCheck(Subsystem subsystem, URI uri, HealthCheckStatus status) { + this.subsystem = subsystem; + this.uri = uri; + this.status = status; + } + + public Subsystem getSubsystem() { + return subsystem; + } + + public void setSubsystem(Subsystem component) { + this.subsystem = component; + } + + public URI getUri() { + return uri; + } + + public void setUri(URI uri) { + this.uri = uri; + } + + public HealthCheckStatus getStatus() { + return status; + } + + public void setStatus(HealthCheckStatus status) { + this.status = status; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("subsystem", subsystem).append("uri", uri).append("status", status) + .toString(); + } + + @Override + public boolean equals(final Object other) { + if (!(other instanceof HealthCheck)) { + return false; + } + HealthCheck castOther = (HealthCheck) other; + return new EqualsBuilder().append(subsystem, castOther.subsystem).append(uri, castOther.uri) + .append(status, castOther.status).isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder().append(subsystem).append(uri).append(status).toHashCode(); + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckConfig.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckConfig.java new file mode 100644 index 0000000000..11fd94bc91 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckConfig.java @@ -0,0 +1,83 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.apihandlerinfra; + +import java.net.URI; +import java.util.List; +import javax.validation.constraints.NotNull; +import org.apache.commons.lang3.builder.ToStringBuilder; +import org.springframework.boot.context.properties.ConfigurationProperties; +import org.springframework.context.annotation.Configuration; +import org.springframework.validation.annotation.Validated; + +@Configuration +@ConfigurationProperties(prefix = "mso.health") +@Validated +public class HealthCheckConfig { + + @NotNull + private List<Endpoint> endpoints; + + public List<Endpoint> getEndpoints() { + return endpoints; + } + + public void setEndpoints(List<Endpoint> endpoints) { + this.endpoints = endpoints; + } + + @Override + public String toString() { + return new ToStringBuilder(this).append("endpoints", this.endpoints).toString(); + } + + @Validated + public static class Endpoint { + @NotNull + private Subsystem subsystem; + @NotNull + private URI uri; + + public Endpoint() { + + } + + public Endpoint(Subsystem subsystem, URI uri) { + this.subsystem = subsystem; + this.uri = uri; + } + + public Subsystem getSubsystem() { + return subsystem; + } + + public void setSubsystem(Subsystem subsystem) { + this.subsystem = subsystem; + } + + public URI getUri() { + return uri; + } + + public void setUri(URI uri) { + this.uri = uri; + } + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckConverter.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckConverter.java new file mode 100644 index 0000000000..ed06018e7b --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckConverter.java @@ -0,0 +1,22 @@ +package org.onap.so.apihandlerinfra; + +import java.net.URI; +import javax.ws.rs.core.UriBuilder; +import org.springframework.core.convert.TypeDescriptor; +import org.springframework.stereotype.Component; + +@Component +public class HealthCheckConverter { + + + public Object convert(Object source, TypeDescriptor sourceType, TypeDescriptor targetType) { + if (sourceType.getType() == String.class && targetType.getType() == Subsystem.class) { + return SoSubsystems.valueOf(((String) source).toUpperCase()); + } else if (sourceType.getType() == String.class && targetType.getType() == URI.class) { + return UriBuilder.fromUri((String) source).build(); + } else { + return source; + } + } + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckResponse.java new file mode 100644 index 0000000000..5400249c65 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckResponse.java @@ -0,0 +1,49 @@ +/*- + * ============LICENSE_START======================================================= + * ONAP - SO + * ================================================================================ + * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. + * ================================================================================ + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * ============LICENSE_END========================================================= + */ +package org.onap.so.apihandlerinfra; + +import java.util.ArrayList; +import java.util.List; + +public class HealthCheckResponse { + + + private List<HealthCheckSubsystem> subsystems = new ArrayList<>(); + private String message; + + + public List<HealthCheckSubsystem> getSubsystems() { + return subsystems; + } + + public void setSubsystems(List<HealthCheckSubsystem> subsystems) { + this.subsystems = subsystems; + } + + public String getMessage() { + return message; + } + + public void setMessage(String message) { + this.message = message; + } + + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthcheckStatus.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckStatus.java index 077a3c2d60..6b31c1f1ed 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthcheckStatus.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckStatus.java @@ -19,12 +19,12 @@ */ package org.onap.so.apihandlerinfra; -public enum HealthcheckStatus { +public enum HealthCheckStatus { UP("UP"), DOWN("DOWN"); private String status; - private HealthcheckStatus(String status) { + private HealthCheckStatus(String status) { this.status = status; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckSubsystem.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckSubsystem.java new file mode 100644 index 0000000000..e1335b952c --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthCheckSubsystem.java @@ -0,0 +1,40 @@ +package org.onap.so.apihandlerinfra; + +import java.net.URI; + +public class HealthCheckSubsystem { + + private Subsystem subsystem; + private URI uri; + private HealthCheckStatus status; + + public HealthCheckSubsystem(Subsystem subsystem, URI uri, HealthCheckStatus status) { + this.subsystem = subsystem; + this.uri = uri; + this.status = status; + } + + public Subsystem getSubsystem() { + return subsystem; + } + + public void setSubsystem(Subsystem subsystem) { + this.subsystem = subsystem; + } + + public URI getUri() { + return uri; + } + + public void setUri(URI uri) { + this.uri = uri; + } + + public HealthCheckStatus getStatus() { + return status; + } + + public void setStatus(HealthCheckStatus status) { + this.status = status; + } +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthcheckResponse.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthcheckResponse.java deleted file mode 100644 index fad3dd4055..0000000000 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/HealthcheckResponse.java +++ /dev/null @@ -1,116 +0,0 @@ -/*- - * ============LICENSE_START======================================================= - * ONAP - SO - * ================================================================================ - * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved. - * ================================================================================ - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - * ============LICENSE_END========================================================= - */ -package org.onap.so.apihandlerinfra; - -import org.apache.commons.lang3.builder.ToStringBuilder; - -public class HealthcheckResponse { - private String apih; - private String bpmn; - private String sdncAdapter; - private String asdcController; - private String catalogdbAdapter; - private String requestdbAdapter; - private String openstackAdapter; - private String requestdbAdapterAttsvc; - private String message = ""; - - public String getApih() { - return apih; - } - - public void setApih(String apih) { - this.apih = apih; - } - - public String getBpmn() { - return bpmn; - } - - public void setBpmn(String bpmn) { - this.bpmn = bpmn; - } - - public String getSdncAdapter() { - return sdncAdapter; - } - - public void setSdncAdapter(String sdncAdapter) { - this.sdncAdapter = sdncAdapter; - } - - public String getAsdcController() { - return asdcController; - } - - public void setAsdcController(String asdcController) { - this.asdcController = asdcController; - } - - public String getCatalogdbAdapter() { - return catalogdbAdapter; - } - - public void setCatalogdbAdapter(String catalogdbAdapter) { - this.catalogdbAdapter = catalogdbAdapter; - } - - public String getRequestdbAdapter() { - return requestdbAdapter; - } - - public void setRequestdbAdapter(String requestdbAdapter) { - this.requestdbAdapter = requestdbAdapter; - } - - public String getOpenstackAdapter() { - return openstackAdapter; - } - - public void setOpenstackAdapter(String openstackAdapter) { - this.openstackAdapter = openstackAdapter; - } - - public String getRequestdbAdapterAttsvc() { - return requestdbAdapterAttsvc; - } - - public void setRequestdbAdapterAttsvc(String requestdbAdapterAttsvc) { - this.requestdbAdapterAttsvc = requestdbAdapterAttsvc; - } - - public String getMessage() { - return message; - } - - public void setMessage(String message) { - this.message = message; - } - - @Override - public String toString() { - return new ToStringBuilder(this).append("apih", this.apih).append("pbmn", this.bpmn) - .append("sdncAdapter", this.sdncAdapter).append("asdcController", this.asdcController) - .append("catalogdbAdapter", this.catalogdbAdapter).append("requestdbAdapter", this.requestdbAdapter) - .append("openstackAdapter", this.openstackAdapter) - .append("requestdbAdapterAttsvc", this.requestdbAdapterAttsvc).append("message", this.message) - .toString(); - } -} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoSubsystems.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SoSubsystems.java index 13f1e52068..5842531dc3 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/MsoSubsystems.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/SoSubsystems.java @@ -19,18 +19,18 @@ */ package org.onap.so.apihandlerinfra; -public enum MsoSubsystems { +public enum SoSubsystems implements Subsystem { APIH("API Handler"), ASDC("ASDC Controller"), BPMN("BPMN Infra"), CATALOGDB("CatalogDb Adapter"), OPENSTACK("Openstack Adapter"), REQUESTDB("RequestDB Adapter"), - REQUESTDBATT("RequestDB Adapter ATT Svc"), SDNC("SDNC Adapter"); + private String subsystem; - private MsoSubsystems(String subsystem) { + private SoSubsystems(String subsystem) { this.subsystem = subsystem; } diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Subsystem.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Subsystem.java new file mode 100644 index 0000000000..88626f3168 --- /dev/null +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/Subsystem.java @@ -0,0 +1,5 @@ +package org.onap.so.apihandlerinfra; + +public interface Subsystem { + +} diff --git a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java index 216588432b..ef5abe9f74 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/main/java/org/onap/so/apihandlerinfra/tenantisolation/ModelDistributionRequest.java @@ -137,10 +137,8 @@ public class ModelDistributionRequest { se.setMessageId(messageId); se.setText(text); if (variables != null) { - if (variables != null) { - for (String variable : variables) { - se.getVariables().add(variable); - } + for (String variable : variables) { + se.getVariables().add(variable); } } re.setServiceException(se); diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java index 928b488f6a..0291cfd2ea 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java +++ b/mso-api-handlers/mso-api-handler-infra/src/test/java/org/onap/so/apihandlerinfra/GlobalHealthcheckHandlerTest.java @@ -20,70 +20,67 @@ package org.onap.so.apihandlerinfra; -import static org.junit.Assert.assertArrayEquals; +import static com.shazam.shazamcrest.matcher.Matchers.sameBeanAs; import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertTrue; -import static org.mockito.ArgumentMatchers.any; -import static org.mockito.ArgumentMatchers.anyObject; +import static org.junit.Assert.assertThat; import static org.mockito.ArgumentMatchers.anyString; import java.net.URI; -import java.util.Collections; -import java.util.List; -import org.springframework.test.util.ReflectionTestUtils; import javax.ws.rs.container.ContainerRequestContext; import javax.ws.rs.core.Response; import javax.ws.rs.core.UriBuilder; -import org.springframework.core.ParameterizedTypeReference; -import org.springframework.http.HttpEntity; -import org.springframework.http.HttpMethod; -import org.springframework.http.HttpStatus; -import org.springframework.http.MediaType; import org.json.JSONException; -import org.junit.Rule; import org.junit.Test; -import org.mockito.InjectMocks; +import org.junit.runner.RunWith; import org.mockito.ArgumentMatchers; -import org.mockito.Mock; import org.mockito.Mockito; -import org.mockito.Spy; -import org.mockito.junit.MockitoJUnit; -import org.mockito.junit.MockitoRule; +import org.onap.so.apihandlerinfra.HealthCheckConfig.Endpoint; +import org.springframework.boot.context.properties.EnableConfigurationProperties; +import org.springframework.boot.test.context.ConfigFileApplicationContextInitializer; +import org.springframework.boot.test.mock.mockito.MockBean; +import org.springframework.boot.test.mock.mockito.SpyBean; +import org.springframework.http.HttpEntity; +import org.springframework.http.HttpMethod; +import org.springframework.http.HttpStatus; +import org.springframework.http.MediaType; import org.springframework.http.ResponseEntity; +import org.springframework.test.context.ActiveProfiles; +import org.springframework.test.context.ContextConfiguration; +import org.springframework.test.context.junit4.SpringRunner; +import org.springframework.test.util.ReflectionTestUtils; import org.springframework.web.client.RestTemplate; +import com.fasterxml.jackson.core.JsonProcessingException; +@RunWith(SpringRunner.class) +@ContextConfiguration(classes = {GenericStringConverter.class, HealthCheckConverter.class}, + initializers = {ConfigFileApplicationContextInitializer.class}) +@ActiveProfiles("test") +@EnableConfigurationProperties({HealthCheckConfig.class}) public class GlobalHealthcheckHandlerTest { - @Mock - RestTemplate restTemplate; + @MockBean + private RestTemplate restTemplate; - @Mock - ContainerRequestContext requestContext; + @MockBean + private ContainerRequestContext requestContext; - @InjectMocks - @Spy - GlobalHealthcheckHandler globalhealth; - - @Rule - public MockitoRule mockitoRule = MockitoJUnit.rule(); + @SpyBean + private GlobalHealthcheckHandler globalhealth; @Test public void testQuerySubsystemHealthNullResult() { ReflectionTestUtils.setField(globalhealth, "actuatorContextPath", "/manage"); - ReflectionTestUtils.setField(globalhealth, "endpointBpmn", "http://localhost:8080"); Mockito.when(restTemplate.exchange(ArgumentMatchers.any(URI.class), ArgumentMatchers.any(HttpMethod.class), ArgumentMatchers.<HttpEntity<?>>any(), ArgumentMatchers.<Class<Object>>any())).thenReturn(null); - String result = globalhealth.querySubsystemHealth(MsoSubsystems.BPMN); - System.out.println(result); - assertEquals(HealthcheckStatus.DOWN.toString(), result); + HealthCheckSubsystem result = globalhealth + .querySubsystemHealth(new Endpoint(SoSubsystems.BPMN, UriBuilder.fromPath("http://localhost").build())); + assertEquals(HealthCheckStatus.DOWN, result.getStatus()); } @Test public void testQuerySubsystemHealthNotNullResult() { ReflectionTestUtils.setField(globalhealth, "actuatorContextPath", "/manage"); - ReflectionTestUtils.setField(globalhealth, "endpointAsdc", "http://localhost:8080"); SubsystemHealthcheckResponse subSystemResponse = new SubsystemHealthcheckResponse(); subSystemResponse.setStatus("UP"); @@ -92,20 +89,13 @@ public class GlobalHealthcheckHandlerTest { Mockito.when(restTemplate.exchange(ArgumentMatchers.any(URI.class), ArgumentMatchers.any(HttpMethod.class), ArgumentMatchers.<HttpEntity<?>>any(), ArgumentMatchers.<Class<Object>>any())).thenReturn(r); - String result = globalhealth.querySubsystemHealth(MsoSubsystems.ASDC); - System.out.println(result); - assertEquals(HealthcheckStatus.UP.toString(), result); + HealthCheckSubsystem result = globalhealth + .querySubsystemHealth(new Endpoint(SoSubsystems.ASDC, UriBuilder.fromPath("http://localhost").build())); + assertEquals(HealthCheckStatus.UP, result.getStatus()); } private Response globalHealthcheck(String status) { ReflectionTestUtils.setField(globalhealth, "actuatorContextPath", "/manage"); - ReflectionTestUtils.setField(globalhealth, "endpointAsdc", "http://localhost:8080"); - ReflectionTestUtils.setField(globalhealth, "endpointSdnc", "http://localhost:8081"); - ReflectionTestUtils.setField(globalhealth, "endpointBpmn", "http://localhost:8082"); - ReflectionTestUtils.setField(globalhealth, "endpointCatalogdb", "http://localhost:8083"); - ReflectionTestUtils.setField(globalhealth, "endpointOpenstack", "http://localhost:8084"); - ReflectionTestUtils.setField(globalhealth, "endpointRequestdb", "http://localhost:8085"); - ReflectionTestUtils.setField(globalhealth, "endpointRequestdbAttsvc", "http://localhost:8086"); SubsystemHealthcheckResponse subSystemResponse = new SubsystemHealthcheckResponse(); @@ -116,70 +106,41 @@ public class GlobalHealthcheckHandlerTest { Mockito.when(requestContext.getProperty(anyString())).thenReturn("1234567890"); Response response = globalhealth.globalHealthcheck(true, requestContext); - return response; } @Test - public void globalHealthcheckAllUPTest() throws JSONException { - Response response = globalHealthcheck("UP"); - assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); - HealthcheckResponse root; - root = (HealthcheckResponse) response.getEntity(); - String apistatus = root.getApih(); - assertTrue(apistatus.equalsIgnoreCase(HealthcheckStatus.UP.toString())); - - String bpmnstatus = root.getBpmn(); - assertTrue(bpmnstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString())); - - String sdncstatus = root.getSdncAdapter(); - assertTrue(sdncstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString())); + public void globalHealthcheckAllUPTest() throws JSONException, JsonProcessingException { - String asdcstatus = root.getAsdcController(); - assertTrue(asdcstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString())); + HealthCheckResponse expected = new HealthCheckResponse(); - String catastatus = root.getCatalogdbAdapter(); - assertTrue(catastatus.equalsIgnoreCase(HealthcheckStatus.UP.toString())); - - String reqdbstatus = root.getRequestdbAdapter(); - assertTrue(reqdbstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString())); - - String openstatus = root.getOpenstackAdapter(); - assertTrue(openstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString())); + for (Subsystem system : SoSubsystems.values()) { + expected.getSubsystems().add(new HealthCheckSubsystem(system, + UriBuilder.fromUri("http://localhost").build(), HealthCheckStatus.UP)); + } + expected.setMessage("HttpStatus: 200"); + Response response = globalHealthcheck("UP"); + assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); + HealthCheckResponse root; + root = (HealthCheckResponse) response.getEntity(); + assertThat(root, sameBeanAs(expected).ignoring("subsystems.uri").ignoring("subsystems.subsystem")); - String reqdbattstatus = root.getRequestdbAdapterAttsvc(); - assertTrue(reqdbattstatus.equalsIgnoreCase(HealthcheckStatus.UP.toString())); } @Test public void globalHealthcheckAllDOWNTest() throws JSONException { + HealthCheckResponse expected = new HealthCheckResponse(); + + for (Subsystem system : SoSubsystems.values()) { + expected.getSubsystems().add(new HealthCheckSubsystem(system, + UriBuilder.fromUri("http://localhost").build(), HealthCheckStatus.DOWN)); + } + expected.setMessage("HttpStatus: 200"); Response response = globalHealthcheck("DOWN"); assertEquals(Response.Status.OK.getStatusCode(), response.getStatus()); - HealthcheckResponse root; - root = (HealthcheckResponse) response.getEntity(); - String apistatus = root.getApih(); - assertTrue(apistatus.equalsIgnoreCase(HealthcheckStatus.UP.toString())); - - String bpmnstatus = root.getBpmn(); - assertTrue(bpmnstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString())); - - String sdncstatus = root.getSdncAdapter(); - assertTrue(sdncstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString())); - - String asdcstatus = root.getAsdcController(); - assertTrue(asdcstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString())); - - String catastatus = root.getCatalogdbAdapter(); - assertTrue(catastatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString())); - - String reqdbstatus = root.getRequestdbAdapter(); - assertTrue(reqdbstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString())); - - String openstatus = root.getOpenstackAdapter(); - assertTrue(openstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString())); - - String reqdbattstatus = root.getRequestdbAdapterAttsvc(); - assertTrue(reqdbattstatus.equalsIgnoreCase(HealthcheckStatus.DOWN.toString())); + HealthCheckResponse root; + root = (HealthCheckResponse) response.getEntity(); + assertThat(root, sameBeanAs(expected).ignoring("subsystems.uri").ignoring("subsystems.subsystem")); } @Test @@ -189,40 +150,15 @@ public class GlobalHealthcheckHandlerTest { assertEquals(MediaType.APPLICATION_JSON, he.getHeaders().getContentType()); } - @Test - public void getEndpointUrlForSubsystemEnumTest() { - ReflectionTestUtils.setField(globalhealth, "actuatorContextPath", "/manage"); - ReflectionTestUtils.setField(globalhealth, "endpointAsdc", "http://localhost:8080"); - ReflectionTestUtils.setField(globalhealth, "endpointSdnc", "http://localhost:8081"); - ReflectionTestUtils.setField(globalhealth, "endpointBpmn", "http://localhost:8082"); - ReflectionTestUtils.setField(globalhealth, "endpointCatalogdb", "http://localhost:8083"); - ReflectionTestUtils.setField(globalhealth, "endpointOpenstack", "http://localhost:8084"); - ReflectionTestUtils.setField(globalhealth, "endpointRequestdb", "http://localhost:8085"); - ReflectionTestUtils.setField(globalhealth, "endpointRequestdbAttsvc", "http://localhost:8086"); - - String result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.ASDC); - assertEquals("http://localhost:8080", result); - result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.SDNC); - assertEquals("http://localhost:8081", result); - result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.BPMN); - assertEquals("http://localhost:8082", result); - result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.CATALOGDB); - assertEquals("http://localhost:8083", result); - result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.OPENSTACK); - assertEquals("http://localhost:8084", result); - result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.REQUESTDB); - assertEquals("http://localhost:8085", result); - result = globalhealth.getEndpointUrlForSubsystemEnum(MsoSubsystems.REQUESTDBATT); - assertEquals("http://localhost:8086", result); - } @Test public void processResponseFromSubsystemTest() { SubsystemHealthcheckResponse subSystemResponse = new SubsystemHealthcheckResponse(); subSystemResponse.setStatus("UP"); ResponseEntity<SubsystemHealthcheckResponse> r = new ResponseEntity<>(subSystemResponse, HttpStatus.OK); - String result = globalhealth.processResponseFromSubsystem(r, MsoSubsystems.BPMN); - assertEquals("UP", result); + Endpoint endpoint = new Endpoint(SoSubsystems.BPMN, UriBuilder.fromUri("http://localhost").build()); + HealthCheckStatus result = globalhealth.processResponseFromSubsystem(r, endpoint); + assertEquals(HealthCheckStatus.UP, result); } } diff --git a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml index 2e1c6a9bdc..27e1ae90d2 100644 --- a/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml +++ b/mso-api-handlers/mso-api-handler-infra/src/test/resources/application-test.yaml @@ -9,14 +9,20 @@ server: mso: health: endpoints: - catalogdb: http://localhost:${wiremock.server.port} - requestdb: http://localhost:${wiremock.server.port} - sdnc: http://localhost:${wiremock.server.port} - openstack: http://localhost:${wiremock.server.port} - bpmn: http://localhost:${wiremock.server.port} - asdc: http://localhost:${wiremock.server.port} - requestdbattsvc: http://localhost:${wiremock.server.port} - + - subsystem: apih + uri: http://localhost:${wiremock.server.port} + - subsystem: asdc + uri: http://localhost:${wiremock.server.port} + - subsystem: bpmn + uri: http://localhost:${wiremock.server.port} + - subsystem: catalogdb + uri: http://localhost:${wiremock.server.port} + - subsystem: openstack + uri: http://localhost:${wiremock.server.port} + - subsystem: requestdb + uri: http://localhost:${wiremock.server.port} + - subsystem: sdnc + uri: http://localhost:${wiremock.server.port} infra-requests: archived: period: 180 @@ -118,7 +124,13 @@ mariaDB4j: port: 3307 databaseName: catalogdb databaseName2: requestdb - +#Actuator +management: + endpoints: + web: + base-path: /manage + exposure: + include: "*" org: onap: diff --git a/version.properties b/version.properties index 99af34261b..f78f30b18d 100644 --- a/version.properties +++ b/version.properties @@ -4,7 +4,7 @@ major=1 minor=5 -patch=0 +patch=1 base_version=${major}.${minor}.${patch} |