Improve test coverage
[sdc.git] / common-be / src / main / java / org / openecomp / sdc / be / datatypes / enums / FilterKeyEnum.java
1 /*-
2  * Copyright (C) 2017 AT&T Intellectual Property. All rights reserved.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *      http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15
16 package org.openecomp.sdc.be.datatypes.enums;
17
18 import java.util.Arrays;
19 import java.util.List;
20 import java.util.stream.Collectors;
21 import lombok.AllArgsConstructor;
22 import lombok.Getter;
23
24 @Getter
25 @AllArgsConstructor
26 public enum FilterKeyEnum {
27     RESOURCE_TYPE("resourceType"), SUB_CATEGORY("subCategory"), CATEGORY("category"), DISTRIBUTION_STATUS("distributionStatus"), NAME_FRAGMENT(
28         "nameFragment");
29
30     private static final int NUMBER_OF_RESOURCES_FILTERED = 3;
31     private static final int NUMBER_OF_SERVICES_FILTERED = 4;
32     private final String name;
33
34     public static List<String> getAllFilters() {
35         return Arrays.stream(FilterKeyEnum.values()).map(FilterKeyEnum::getName).collect(Collectors.toList());
36     }
37
38     public static List<String> getValidFiltersByAssetType(ComponentTypeEnum assetType) {
39         if (assetType == null) {
40             return null;
41         }
42         switch (assetType) {
43             case RESOURCE:
44                 return getAllFilters().subList(0, NUMBER_OF_RESOURCES_FILTERED);
45             case SERVICE:
46                 return getAllFilters().subList(2, NUMBER_OF_SERVICES_FILTERED);
47             default:
48                 return null;
49         }
50
51     }
52 }