From 7e28cea706ca5e0ca423fde637a7846eaaa2e1e0 Mon Sep 17 00:00:00 2001 From: Tomasz Golabek Date: Thu, 11 Apr 2019 14:29:49 +0200 Subject: Some unit tests for catalog-be Code coverage for some classes from catalog-be increased. Some refactor made if needed. Change-Id: Ia9348f624984ab7e5f9aa53c0adf33cf5867fa07 Issue-ID: SDC-2220 Signed-off-by: Tomasz Golabek --- .../openecomp/sdc/be/info/DistributionStatus.java | 25 +++++++++++----------- .../openecomp/sdc/be/info/GroupDefinitionInfo.java | 14 +++++------- .../openecomp/sdc/be/info/GroupTemplateInfo.java | 4 +--- .../sdc/be/info/NodeTypeInfoToUpdateArtifacts.java | 22 +++++++++++++++++++ 4 files changed, 40 insertions(+), 25 deletions(-) (limited to 'catalog-be/src/main/java/org') diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/DistributionStatus.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/DistributionStatus.java index 11a42694bf..1aad998e78 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/DistributionStatus.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/DistributionStatus.java @@ -7,19 +7,23 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ */ package org.openecomp.sdc.be.info; +import java.util.Arrays; +import java.util.Optional; import org.openecomp.sdc.common.log.wrappers.Logger; public enum DistributionStatus { @@ -44,18 +48,13 @@ public enum DistributionStatus { } public static DistributionStatus getStatusByAuditingStatusName(String auditingStatus) { - DistributionStatus res = null; - DistributionStatus[] values = values(); - for (DistributionStatus value : values) { - if (value.getAuditingStatus().equals(auditingStatus)) { - res = value; - break; - } - } - if (res == null) { - log.debug("No DistributionStatus is mapped to name {}", auditingStatus); + Optional distributionStatus = Arrays.stream(values()) + .filter(value -> value.getAuditingStatus().equals(auditingStatus)).findAny(); + if (!distributionStatus.isPresent()){ + log.debug("No DistributionStatus is mapped to name {}", auditingStatus); } - return res; + // it should be replaced by some exception handling. Keeping it only for the purpose of backward compatibility + return distributionStatus.orElse(null); } } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupDefinitionInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupDefinitionInfo.java index e7a0706b31..621485c7a1 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupDefinitionInfo.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupDefinitionInfo.java @@ -7,17 +7,18 @@ * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at - * + * * http://www.apache.org/licenses/LICENSE-2.0 - * + * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ============LICENSE_END========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ */ - package org.openecomp.sdc.be.info; import org.openecomp.sdc.be.model.GroupDefinition; @@ -62,9 +63,7 @@ public class GroupDefinitionInfo { private List properties; - public GroupDefinitionInfo() { - super(); - } + public GroupDefinitionInfo() {} public GroupDefinitionInfo(GroupDefinition other) { this.setName(other.getName()); @@ -139,7 +138,6 @@ public class GroupDefinitionInfo { this.version = version; } - public String getCustomizationUUID() { return customizationUUID; } @@ -172,8 +170,6 @@ public class GroupDefinitionInfo { this.properties = (properties==null) ? null : new ArrayList<>(properties); } - - public String getGroupInstanceUniqueId() { return groupInstanceUniqueId; } diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupTemplateInfo.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupTemplateInfo.java index 301cffafdc..3ae0dcdf62 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupTemplateInfo.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/GroupTemplateInfo.java @@ -25,9 +25,7 @@ public class GroupTemplateInfo { boolean isBase; ArtifactTemplateInfo artifactTemplateInfo; - public GroupTemplateInfo() { - super(); - } + public GroupTemplateInfo() {} public String getGroupName() { return groupName; diff --git a/catalog-be/src/main/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifacts.java b/catalog-be/src/main/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifacts.java index 766581bd62..9ab0bd7f27 100644 --- a/catalog-be/src/main/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifacts.java +++ b/catalog-be/src/main/java/org/openecomp/sdc/be/info/NodeTypeInfoToUpdateArtifacts.java @@ -1,3 +1,24 @@ +/*- + * ============LICENSE_START======================================================= + * SDC + * ================================================================================ + * Copyright (C) 2018 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========================================================= + * Modifications copyright (c) 2019 Nokia + * ================================================================================ + */ package org.openecomp.sdc.be.info; import org.openecomp.sdc.be.components.impl.ArtifactsBusinessLogic.ArtifactOperationEnum; @@ -12,6 +33,7 @@ public class NodeTypeInfoToUpdateArtifacts { private String nodeName; private Map>> nodeTypesArtifactsToHandle; + NodeTypeInfoToUpdateArtifacts() {} public NodeTypeInfoToUpdateArtifacts(String nodeName, Map>> nodeTypesArtifactsToHandle) { -- cgit 1.2.3-korg