summaryrefslogtreecommitdiffstats
path: root/common-be/src
diff options
context:
space:
mode:
authorvasraz <vasyl.razinkov@est.tech>2023-05-24 17:30:41 +0100
committerMichael Morris <michael.morris@est.tech>2023-06-08 19:44:38 +0000
commit98f08c1f9b617e670cd4c71321c9152e8f63b18c (patch)
tree5823c85f9c16dd24918438e251238ba770532a91 /common-be/src
parent1c4fe946f65fb4e7db5cc5d4225b14ec6cc22306 (diff)
Update external query api with new query params
Signed-off-by: Vasyl Razinkov <vasyl.razinkov@est.tech> Change-Id: Ib4970d4f57f9e236f520ca1925915d288c9c5236 Issue-ID: SDC-4409
Diffstat (limited to 'common-be/src')
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnum.java9
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/FilterKeyEnum.java33
-rw-r--r--common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java3
-rw-r--r--common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/FilterKeyEnumTest.java73
4 files changed, 63 insertions, 55 deletions
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnum.java
index 44956ceb17..e549466c45 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnum.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ComponentTypeEnum.java
@@ -20,10 +20,13 @@ import lombok.Getter;
@Getter
@AllArgsConstructor
public enum ComponentTypeEnum {
- RESOURCE("Resource"), SERVICE("Service"), RESOURCE_INSTANCE("Resource Instance"), PRODUCT("Product"), SERVICE_INSTANCE("Service Instance");
- // Those values cannot be another field in enum, because they are needed
+ RESOURCE("Resource"),
+ SERVICE("Service"),
+ RESOURCE_INSTANCE("Resource Instance"),
+ PRODUCT("Product"),
+ SERVICE_INSTANCE("Service Instance");
- // as constants for Swagger allowedValues param
+ // Those values cannot be another field in enum, because they are needed as constants for Swagger allowedValues param
public static final String RESOURCE_PARAM_NAME = "resources";
public static final String SERVICE_PARAM_NAME = "services";
public static final String PRODUCT_PARAM_NAME = "products";
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/FilterKeyEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/FilterKeyEnum.java
index a4dc0084cc..3ba4ca62cd 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/FilterKeyEnum.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/FilterKeyEnum.java
@@ -15,35 +15,44 @@
package org.openecomp.sdc.be.datatypes.enums;
import java.util.Arrays;
+import java.util.Collections;
import java.util.List;
-import java.util.stream.Collectors;
import lombok.AllArgsConstructor;
import lombok.Getter;
@Getter
@AllArgsConstructor
public enum FilterKeyEnum {
- RESOURCE_TYPE("resourceType"), SUB_CATEGORY("subCategory"), CATEGORY("category"), DISTRIBUTION_STATUS("distributionStatus"), NAME_FRAGMENT(
- "nameFragment");
- private static final int NUMBER_OF_RESOURCES_FILTERED = 3;
- private static final int NUMBER_OF_SERVICES_FILTERED = 4;
+ RESOURCE_TYPE("resourceType"),
+ SUB_CATEGORY("subCategory"),
+ CATEGORY("category"),
+ VERSION("version"),
+ METADATA("metadata"),
+ DISTRIBUTION_STATUS("distributionStatus"),
+ NAME_FRAGMENT("nameFragment");
private final String name;
- public static List<String> getAllFilters() {
- return Arrays.stream(FilterKeyEnum.values()).map(FilterKeyEnum::getName).collect(Collectors.toList());
- }
+ private static final List<String> RESOURCES_FILTERED = Arrays.asList(
+ RESOURCE_TYPE.getName(),
+ SUB_CATEGORY.getName(),
+ CATEGORY.getName());
+ private static final List<String> SERVICES_FILTERED = Arrays.asList(
+ CATEGORY.getName(),
+ DISTRIBUTION_STATUS.getName(),
+ VERSION.getName(),
+ METADATA.getName());
public static List<String> getValidFiltersByAssetType(ComponentTypeEnum assetType) {
if (assetType == null) {
- return null;
+ return Collections.emptyList();
}
switch (assetType) {
case RESOURCE:
- return getAllFilters().subList(0, NUMBER_OF_RESOURCES_FILTERED);
+ return RESOURCES_FILTERED;
case SERVICE:
- return getAllFilters().subList(2, NUMBER_OF_SERVICES_FILTERED);
+ return SERVICES_FILTERED;
default:
- return null;
+ return Collections.emptyList();
}
}
}
diff --git a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java
index 88ff61b6d1..e65fb1bdce 100644
--- a/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java
+++ b/common-be/src/main/java/org/openecomp/sdc/be/datatypes/enums/ResourceTypeEnum.java
@@ -38,7 +38,8 @@ public enum ResourceTypeEnum {
VL("VL"/* (Virtual Link)"*/, true),
VFCMT("VFCMT"/* (VFC Monitoring Template)"*/, true),
- Configuration("Configuration", true), ServiceProxy("ServiceProxy", true),
+ Configuration("Configuration", true),
+ ServiceProxy("ServiceProxy", true),
//Generic VFC/VF/PNF/Service Type
ABSTRACT("Abstract", true),
SERVICE("Service"/*(Network Service)"*/, false);
diff --git a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/FilterKeyEnumTest.java b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/FilterKeyEnumTest.java
index 54f90e65b3..b08a32fc05 100644
--- a/common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/FilterKeyEnumTest.java
+++ b/common-be/src/test/java/org/openecomp/sdc/be/datatypes/enums/FilterKeyEnumTest.java
@@ -7,9 +7,9 @@
* 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.
@@ -20,43 +20,38 @@
package org.openecomp.sdc.be.datatypes.enums;
-import org.junit.Test;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum.CATEGORY;
+import static org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum.RESOURCE_TYPE;
+import static org.openecomp.sdc.be.datatypes.enums.FilterKeyEnum.VERSION;
import java.util.List;
-
-public class FilterKeyEnumTest {
-
- private FilterKeyEnum createTestSubject() {
- return FilterKeyEnum.CATEGORY;
- }
-
- @Test
- public void testGetName() throws Exception {
- FilterKeyEnum testSubject;
- String result;
-
- // default test
- testSubject = createTestSubject();
- result = testSubject.getName();
- }
-
- @Test
- public void testGetAllFilters() throws Exception {
- List<String> result;
-
- // default test
- result = FilterKeyEnum.getAllFilters();
- }
-
- @Test
- public void testGetValidFiltersByAssetType() throws Exception {
- ComponentTypeEnum assetType = null;
- List<String> result;
-
- // default test
- result = FilterKeyEnum.getValidFiltersByAssetType(ComponentTypeEnum.RESOURCE);
- result = FilterKeyEnum.getValidFiltersByAssetType(ComponentTypeEnum.SERVICE);
- result = FilterKeyEnum.getValidFiltersByAssetType(ComponentTypeEnum.SERVICE_INSTANCE);
- result = FilterKeyEnum.getValidFiltersByAssetType(assetType);
- }
+import org.junit.jupiter.api.Test;
+
+class FilterKeyEnumTest {
+
+ @Test
+ void testGetValidFiltersByAssetType() {
+ List<String> result;
+
+ result = FilterKeyEnum.getValidFiltersByAssetType(ComponentTypeEnum.RESOURCE);
+ assertNotNull(result);
+ assertEquals(3, result.size());
+ assertTrue(result.contains(CATEGORY.getName()));
+ assertFalse(result.contains(VERSION.getName()));
+ result = FilterKeyEnum.getValidFiltersByAssetType(ComponentTypeEnum.SERVICE);
+ assertNotNull(result);
+ assertEquals(4, result.size());
+ assertTrue(result.contains(CATEGORY.getName()));
+ assertFalse(result.contains(RESOURCE_TYPE.getName()));
+ result = FilterKeyEnum.getValidFiltersByAssetType(ComponentTypeEnum.SERVICE_INSTANCE);
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ result = FilterKeyEnum.getValidFiltersByAssetType(null);
+ assertNotNull(result);
+ assertEquals(0, result.size());
+ }
}