From 2c7babf2999eb56229a1ed2a32da8bdac096ea5d Mon Sep 17 00:00:00 2001 From: "Georgios P. Katsikas" Date: Wed, 18 Feb 2026 12:57:48 +0000 Subject: [PATCH 1/4] refactor: bring policy to its new form --- proto/policy.proto | 14 +- proto/policy_action.proto | 5 - proto/policy_condition.proto | 43 - .../java/org/etsi/tfs/policy/Serializer.java | 636 +------- .../policy/monitoring/MonitoringGateway.java | 51 - .../monitoring/MonitoringGatewayImpl.java | 147 -- .../policy/monitoring/MonitoringService.java | 51 - .../monitoring/MonitoringServiceImpl.java | 91 -- .../monitoring/model/AlarmDescriptor.java | 78 - .../monitoring/model/AlarmResponse.java | 46 - .../monitoring/model/AlarmSubscription.java | 51 - .../monitoring/model/BooleanKpiValue.java | 36 - .../monitoring/model/FloatKpiValue.java | 36 - .../monitoring/model/IntegerKpiValue.java | 36 - .../etsi/tfs/policy/monitoring/model/Kpi.java | 49 - .../monitoring/model/KpiDescriptor.java | 84 -- .../tfs/policy/monitoring/model/KpiValue.java | 22 - .../monitoring/model/KpiValueRange.java | 84 -- .../policy/monitoring/model/LongKpiValue.java | 36 - .../monitoring/model/MonitorKpiRequest.java | 48 - .../monitoring/model/StringKpiValue.java | 36 - .../monitoring/model/SubsDescriptor.java | 78 - .../policy/monitoring/model/SubsResponse.java | 46 - .../policy/policy/AddPolicyDeviceImpl.java | 1 - .../policy/policy/AddPolicyServiceImpl.java | 3 - .../tfs/policy/policy/CommonAlarmService.java | 129 -- .../policy/CommonPolicyServiceImpl.java | 113 -- .../policy/policy/model/BooleanOperator.java | 23 - .../policy/model/NumericalOperator.java | 27 - .../policy/model/PolicyRuleActionEnum.java | 1 - .../policy/policy/model/PolicyRuleBasic.java | 57 +- .../policy/model/PolicyRuleCondition.java | 83 -- .../policy/model/PolicyRuleService.java | 6 +- .../PolicyRuleConditionFieldsGetter.java | 47 - .../etsi/tfs/policy/PolicyAddDeviceTest.java | 56 +- .../etsi/tfs/policy/PolicyAddServiceTest.java | 18 +- .../tfs/policy/PolicyDeleteServiceTest.java | 13 - .../tfs/policy/PolicyGrpcServiceTest.java | 36 - .../policy/PolicyRuleBasicValidationTest.java | 143 +- .../PolicyRuleConditionValidationTest.java | 139 -- .../PolicyRuleDeviceValidationTest.java | 87 +- .../PolicyRuleServiceValidationTest.java | 97 +- .../tfs/policy/PolicyUpdateDeviceTest.java | 26 +- .../tfs/policy/PolicyUpdateServiceTest.java | 17 +- .../org/etsi/tfs/policy/SerializerTest.java | 995 +------------ .../generated-sources/grpc/policy/Policy.java | 581 ++------ .../grpc/policy/PolicyCondition.java | 1318 ----------------- src/policy/target/kubernetes/kubernetes.yml | 37 +- src/ztp/target/kubernetes/kubernetes.yml | 34 +- 49 files changed, 229 insertions(+), 5662 deletions(-) delete mode 100644 proto/policy_condition.proto delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringGateway.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringGatewayImpl.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringService.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringServiceImpl.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/AlarmDescriptor.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/AlarmResponse.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/AlarmSubscription.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/BooleanKpiValue.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/FloatKpiValue.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/IntegerKpiValue.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/Kpi.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/KpiDescriptor.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/KpiValue.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/KpiValueRange.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/LongKpiValue.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/MonitorKpiRequest.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/StringKpiValue.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/SubsDescriptor.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/SubsResponse.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/policy/CommonAlarmService.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/policy/model/BooleanOperator.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/policy/model/NumericalOperator.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleCondition.java delete mode 100644 src/policy/src/main/java/org/etsi/tfs/policy/policy/service/PolicyRuleConditionFieldsGetter.java delete mode 100644 src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleConditionValidationTest.java delete mode 100644 src/policy/target/generated-sources/grpc/policy/PolicyCondition.java diff --git a/proto/policy.proto b/proto/policy.proto index 51ea63b7f..1991e35d2 100644 --- a/proto/policy.proto +++ b/proto/policy.proto @@ -16,9 +16,7 @@ syntax = "proto3"; package policy; import "context.proto"; -import "policy_condition.proto"; import "policy_action.proto"; -import "monitoring.proto"; // to be migrated to: "kpi_manager.proto" service PolicyService { rpc PolicyAddService (PolicyRuleService) returns (PolicyRuleState) {} @@ -36,8 +34,8 @@ enum PolicyRuleStateEnum { POLICY_FAILED = 1; // Rule failed POLICY_INSERTED = 2; // Rule is just inserted POLICY_VALIDATED = 3; // Rule content is correct - POLICY_PROVISIONED = 4; // Rule subscribed to Monitoring - POLICY_ACTIVE = 5; // Rule is currently active (alarm is just thrown by Monitoring) + POLICY_PROVISIONED = 4; // Rule subscribed to Analyzer + POLICY_ACTIVE = 5; // Rule is currently active (alarm is just thrown by Analyzer) POLICY_ENFORCED = 6; // Rule action is successfully enforced POLICY_INEFFECTIVE = 7; // The applied rule action did not work as expected POLICY_EFFECTIVE = 8; // The applied rule action did work as expected @@ -57,12 +55,10 @@ message PolicyRuleState { // Basic policy rule attributes message PolicyRuleBasic { PolicyRuleId policyRuleId = 1; - PolicyRuleState policyRuleState = 2; //policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default. - uint32 priority = 3; - monitoring.KpiId kpiId = 4; // to be migrated to: "kpi_manager.KpiId" + PolicyRuleState policyRuleState = 2; + uint32 policyRulePriority = 3; - // Event-Condition-Action (ECA) model - repeated PolicyRuleAction actionList = 5; // One or more actions should be applied + repeated PolicyRuleAction actionList = 4; // One or more actions should be applied } // Service-oriented policy rule diff --git a/proto/policy_action.proto b/proto/policy_action.proto index 0724c33dd..15db58c3f 100644 --- a/proto/policy_action.proto +++ b/proto/policy_action.proto @@ -35,8 +35,3 @@ message PolicyRuleActionConfig { string action_key = 1; string action_value = 2; } - -// message PolicyRuleAction { -// PolicyRuleActionEnum action = 1; -// repeated string parameters = 2; -// } diff --git a/proto/policy_condition.proto b/proto/policy_condition.proto deleted file mode 100644 index a5904eeb0..000000000 --- a/proto/policy_condition.proto +++ /dev/null @@ -1,43 +0,0 @@ -// Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) -// -// 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. - -syntax = "proto3"; -package policy; - -import "monitoring.proto"; // to be migrated to: "kpi_manager.proto" - -// Condition -message PolicyRuleCondition { - monitoring.KpiId kpiId = 1; // to be migrated to: "kpi_manager.KpiId" - NumericalOperator numericalOperator = 2; - monitoring.KpiValue kpiValue = 3; -} - -// Operator to be used when comparing Kpis with condition values -enum NumericalOperator { - POLICYRULE_CONDITION_NUMERICAL_UNDEFINED = 0; // Kpi numerical operator undefined - POLICYRULE_CONDITION_NUMERICAL_EQUAL = 1; // Kpi is equal with value - POLICYRULE_CONDITION_NUMERICAL_NOT_EQUAL = 2; // Kpi is not equal with value - POLICYRULE_CONDITION_NUMERICAL_LESS_THAN = 3; // Kpi is less than value - POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL = 4; // Kpi is less than or equal with value - POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN = 5; // Kpi is greater than value - POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL = 6; // Kpi is less than or equal with value -} - -// Operator to be used when evaluating each condition -enum BooleanOperator { - POLICYRULE_CONDITION_BOOLEAN_UNDEFINED = 0; // Boolean operator undefined - POLICYRULE_CONDITION_BOOLEAN_AND = 1; // Boolean AND operator - POLICYRULE_CONDITION_BOOLEAN_OR = 2; // Boolean OR operator -} \ No newline at end of file diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/Serializer.java b/src/policy/src/main/java/org/etsi/tfs/policy/Serializer.java index 20dcd2bd3..327afbe01 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/Serializer.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/Serializer.java @@ -27,13 +27,8 @@ import context.ContextOuterClass.Location.LocationCase; import context.ContextOuterClass.Uuid; import jakarta.inject.Singleton; import java.util.ArrayList; -import java.util.List; import java.util.stream.Collectors; import kpi_sample_types.KpiSampleTypes; -import monitoring.Monitoring; -import monitoring.Monitoring.AlarmID; -import monitoring.Monitoring.KpiId; -import monitoring.Monitoring.SubscriptionID; import org.etsi.tfs.policy.acl.AclAction; import org.etsi.tfs.policy.acl.AclEntry; import org.etsi.tfs.policy.acl.AclForwardActionEnum; @@ -43,30 +38,12 @@ import org.etsi.tfs.policy.acl.AclRuleSet; import org.etsi.tfs.policy.acl.AclRuleTypeEnum; import org.etsi.tfs.policy.context.model.*; import org.etsi.tfs.policy.kpi_sample_types.model.KpiSampleType; -import org.etsi.tfs.policy.monitoring.model.AlarmDescriptor; -import org.etsi.tfs.policy.monitoring.model.AlarmResponse; -import org.etsi.tfs.policy.monitoring.model.AlarmSubscription; -import org.etsi.tfs.policy.monitoring.model.BooleanKpiValue; -import org.etsi.tfs.policy.monitoring.model.FloatKpiValue; -import org.etsi.tfs.policy.monitoring.model.IntegerKpiValue; -import org.etsi.tfs.policy.monitoring.model.Kpi; -import org.etsi.tfs.policy.monitoring.model.KpiDescriptor; -import org.etsi.tfs.policy.monitoring.model.KpiValue; -import org.etsi.tfs.policy.monitoring.model.KpiValueRange; -import org.etsi.tfs.policy.monitoring.model.LongKpiValue; -import org.etsi.tfs.policy.monitoring.model.MonitorKpiRequest; -import org.etsi.tfs.policy.monitoring.model.StringKpiValue; -import org.etsi.tfs.policy.monitoring.model.SubsDescriptor; -import org.etsi.tfs.policy.monitoring.model.SubsResponse; import org.etsi.tfs.policy.policy.model.*; -import org.etsi.tfs.policy.policy.model.BooleanOperator; -import org.etsi.tfs.policy.policy.model.NumericalOperator; import org.etsi.tfs.policy.policy.model.PolicyRule; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum; import org.etsi.tfs.policy.policy.model.PolicyRuleBasic; -import org.etsi.tfs.policy.policy.model.PolicyRuleCondition; import org.etsi.tfs.policy.policy.model.PolicyRuleDevice; import org.etsi.tfs.policy.policy.model.PolicyRuleService; import org.etsi.tfs.policy.policy.model.PolicyRuleState; @@ -76,7 +53,6 @@ import org.etsi.tfs.policy.policy.model.PolicyRuleTypeService; import policy.Policy; import policy.Policy.PolicyRuleId; import policy.PolicyAction; -import policy.PolicyCondition; @Singleton public class Serializer { @@ -1450,434 +1426,6 @@ public class Serializer { return new PolicyRuleState(ruleState, serializedRuleStateMessage); } - public PolicyCondition.NumericalOperator serialize(NumericalOperator numericalOperator) { - switch (numericalOperator) { - case POLICY_RULE_CONDITION_NUMERICAL_EQUAL: - return PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_EQUAL; - case POLICY_RULE_CONDITION_NUMERICAL_NOT_EQUAL: - return PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_NOT_EQUAL; - case POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN: - return PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_LESS_THAN; - case POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL: - return PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL; - case POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN: - return PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN; - case POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL: - return PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL; - case POLICY_RULE_CONDITION_NUMERICAL_UNDEFINED: - return PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_UNDEFINED; - default: - return PolicyCondition.NumericalOperator.UNRECOGNIZED; - } - } - - public NumericalOperator deserialize( - PolicyCondition.NumericalOperator serializedNumericalOperator) { - switch (serializedNumericalOperator) { - case POLICYRULE_CONDITION_NUMERICAL_EQUAL: - return NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_EQUAL; - case POLICYRULE_CONDITION_NUMERICAL_NOT_EQUAL: - return NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_NOT_EQUAL; - case POLICYRULE_CONDITION_NUMERICAL_LESS_THAN: - return NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN; - case POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL: - return NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL; - case POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN: - return NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN; - case POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL: - return NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL; - case POLICYRULE_CONDITION_NUMERICAL_UNDEFINED: - case UNRECOGNIZED: - default: - return NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_UNDEFINED; - } - } - - public Monitoring.KpiValue serializeStringKpiValue(KpiValue kpiValue) { - final var builder = Monitoring.KpiValue.newBuilder(); - - return builder.setStringVal(kpiValue.getValue()).build(); - } - - public String deserializeStringKpiValue(Monitoring.KpiValue serializedKpiValue) { - - return serializedKpiValue.getStringVal(); - } - - public Monitoring.KpiValue serializeBooleanKpiValue(KpiValue kpiValue) { - final var builder = Monitoring.KpiValue.newBuilder(); - - return builder.setBoolVal(kpiValue.getValue()).build(); - } - - public boolean deserializeBooleanKpiValue(Monitoring.KpiValue serializedKpiValue) { - - return serializedKpiValue.getBoolVal(); - } - - public Monitoring.KpiValue serializeFloatKpiValue(KpiValue kpiValue) { - final var builder = Monitoring.KpiValue.newBuilder(); - - return builder.setFloatVal(kpiValue.getValue()).build(); - } - - public float deserializeFloatKpiValue(Monitoring.KpiValue serializedKpiValue) { - - return serializedKpiValue.getFloatVal(); - } - - public Monitoring.KpiValue serializeIntegerKpiValue(KpiValue kpiValue) { - final var builder = Monitoring.KpiValue.newBuilder(); - - return builder.setInt32Val(kpiValue.getValue()).build(); - } - - public Monitoring.KpiValue serializeLongKpiValue(KpiValue kpiValue) { - final var builder = Monitoring.KpiValue.newBuilder(); - - return builder.setInt64Val(kpiValue.getValue()).build(); - } - - public int deserializeIntegerKpiValue(Monitoring.KpiValue serializedKpiValue) { - - return serializedKpiValue.getInt32Val(); - } - - public Monitoring.KpiValue serialize(KpiValue kpiValue) { - final var builder = Monitoring.KpiValue.newBuilder(); - - if (kpiValue.getValue() instanceof Integer) { - final var serializedIntegerKpiValue = serializeIntegerKpiValue((KpiValue) kpiValue); - builder.setInt32Val(serializedIntegerKpiValue.getInt32Val()); - } - if (kpiValue.getValue() instanceof Long) { - final var serializedIntegerKpiValue = serializeLongKpiValue((KpiValue) kpiValue); - builder.setInt64Val(serializedIntegerKpiValue.getInt64Val()); - } - if (kpiValue.getValue() instanceof Float) { - final var serializedFloatKpiValue = serializeFloatKpiValue((KpiValue) kpiValue); - builder.setFloatVal(serializedFloatKpiValue.getFloatVal()); - } - if (kpiValue.getValue() instanceof String) { - final var serializedStringKpiValue = serializeStringKpiValue((KpiValue) kpiValue); - builder.setStringVal(serializedStringKpiValue.getStringVal()); - } - if (kpiValue.getValue() instanceof Boolean) { - final var serializedBooleanKpiValue = serializeBooleanKpiValue((KpiValue) kpiValue); - builder.setBoolVal(serializedBooleanKpiValue.getBoolVal()); - } - - return builder.build(); - } - - public KpiValue deserialize(Monitoring.KpiValue serializedKpiValue) { - - final var typeOfKpiValue = serializedKpiValue.getValueCase(); - - switch (typeOfKpiValue) { - case INT32VAL: - final var intValue = deserializeIntegerKpiValue(serializedKpiValue); - return new IntegerKpiValue(intValue); - case UINT32VAL: - final var uintValue = deserializeIntegerKpiValue(serializedKpiValue); - return new IntegerKpiValue(uintValue); - case INT64VAL: - final var longValue = deserializeIntegerKpiValue(serializedKpiValue); - return new LongKpiValue(longValue); - case UINT64VAL: - final var ulongValue = deserializeIntegerKpiValue(serializedKpiValue); - return new LongKpiValue(ulongValue); - case BOOLVAL: - final var booleanValue = deserializeBooleanKpiValue(serializedKpiValue); - return new BooleanKpiValue(booleanValue); - case FLOATVAL: - final var floatValue = deserializeFloatKpiValue(serializedKpiValue); - return new FloatKpiValue(floatValue); - case STRINGVAL: - final var stringValue = deserializeStringKpiValue(serializedKpiValue); - return new StringKpiValue(stringValue); - default: - case VALUE_NOT_SET: - throw new IllegalStateException("Kpi value not set"); - } - } - - public Monitoring.KpiValueRange serialize(KpiValueRange kpiValueRange) { - final var builder = Monitoring.KpiValueRange.newBuilder(); - - final var kpiValueMin = kpiValueRange.getKpiMinValue(); - final var kpiValueMax = kpiValueRange.getKpiMaxValue(); - - Monitoring.KpiValue serializedKpiValueMin; - Monitoring.KpiValue serializedKpiValueMax; - - if (kpiValueMin == null && kpiValueMax == null) { - throw new IllegalStateException("KPI value max and min cannot be both null"); - } else if (kpiValueMax == null) { - serializedKpiValueMin = serialize(kpiValueMin); - serializedKpiValueMax = serialize(new StringKpiValue("NaN")); - } else if (kpiValueMin == null) { - serializedKpiValueMin = serialize(new StringKpiValue("NaN")); - serializedKpiValueMax = serialize(kpiValueMax); - } else { - serializedKpiValueMin = serialize(kpiValueMin); - serializedKpiValueMax = serialize(kpiValueMax); - } - - builder.setKpiMinValue(serializedKpiValueMin); - builder.setKpiMaxValue(serializedKpiValueMax); - - return builder.build(); - } - - public KpiValueRange deserialize(Monitoring.KpiValueRange serializedKpiValueRange) { - final var serializedMinKpiValue = serializedKpiValueRange.getKpiMinValue(); - final var serializedMaxKpiValue = serializedKpiValueRange.getKpiMaxValue(); - final var serializedInRange = serializedKpiValueRange.getInRange(); - final var serializedMaxValue = serializedKpiValueRange.getIncludeMaxValue(); - final var serializedMinValue = serializedKpiValueRange.getIncludeMinValue(); - - final var minKpiValue = deserialize(serializedMinKpiValue); - final var maxKpiValue = deserialize(serializedMaxKpiValue); - - return new KpiValueRange( - minKpiValue, maxKpiValue, serializedInRange, serializedMaxValue, serializedMinValue); - } - - public AlarmID serializeAlarmId(String alarmId) { - final var builder = Monitoring.AlarmID.newBuilder(); - - final var serializedAlarmIdUuid = serializeUuid(alarmId); - builder.setAlarmId(serializedAlarmIdUuid); - - return builder.build(); - } - - public String deserialize(AlarmID serializedAlarmId) { - final var serializedAlarmIdUuid = serializedAlarmId.getAlarmId(); - - return deserialize(serializedAlarmIdUuid); - } - - public Monitoring.AlarmDescriptor serialize(AlarmDescriptor alarmDescriptor) { - final var builder = Monitoring.AlarmDescriptor.newBuilder(); - - final var alarmId = alarmDescriptor.getAlarmId(); - final var alarmDescription = alarmDescriptor.getAlarmDescription(); - final var name = alarmDescriptor.getName(); - final var kpiId = alarmDescriptor.getKpiId(); - final var kpiValueRange = alarmDescriptor.getKpiValueRange(); - final var timestamp = alarmDescriptor.getTimestamp(); - - final var serializedAlarmId = serializeAlarmId(alarmId); - final var serializedKpiId = serializeKpiId(kpiId); - final var serializedKpiValueRange = serialize(kpiValueRange); - final var serializedTimestamp = serialize(timestamp); - - builder.setAlarmId(serializedAlarmId); - builder.setAlarmDescription(alarmDescription); - builder.setName(name); - builder.setKpiId(serializedKpiId); - builder.setKpiValueRange(serializedKpiValueRange); - builder.setTimestamp(serializedTimestamp); - - return builder.build(); - } - - public AlarmDescriptor deserialize(Monitoring.AlarmDescriptor serializedAlarmDescriptor) { - - final var serializedAlarmId = serializedAlarmDescriptor.getAlarmId(); - final var alarmDescription = serializedAlarmDescriptor.getAlarmDescription(); - final var name = serializedAlarmDescriptor.getName(); - final var serializedKpiId = serializedAlarmDescriptor.getKpiId(); - final var serializedKpiValueRange = serializedAlarmDescriptor.getKpiValueRange(); - final var serializeTimestamp = serializedAlarmDescriptor.getTimestamp(); - - final var alarmId = deserialize(serializedAlarmId); - final var kpiId = deserialize(serializedKpiId); - final var kpiValueRange = deserialize(serializedKpiValueRange); - final var timestamp = deserialize(serializeTimestamp); - - return new AlarmDescriptor(alarmId, alarmDescription, name, kpiId, kpiValueRange, timestamp); - } - - public Monitoring.AlarmResponse serialize(AlarmResponse alarmResponse) { - final var builder = Monitoring.AlarmResponse.newBuilder(); - - final var alarmId = alarmResponse.getAlarmId(); - final var kpiList = alarmResponse.getKpiList(); - - final var serializedAlarmIdUuid = serializeUuid(alarmId); - final var serializedAlarmId = - Monitoring.AlarmID.newBuilder().setAlarmId(serializedAlarmIdUuid).build(); - final var serializedKpis = kpiList.stream().map(this::serialize).collect(Collectors.toList()); - final var serializedKpisList = Monitoring.KpiList.newBuilder().addAllKpi(serializedKpis); - - builder.setAlarmId(serializedAlarmId); - builder.setKpiList(serializedKpisList); - - return builder.build(); - } - - public Monitoring.SubsResponse serialize(SubsResponse subsResponse) { - final var builder = Monitoring.SubsResponse.newBuilder(); - - final var subscriptionId = subsResponse.getSubscriptionId(); - final var kpiList = subsResponse.getKpiList(); - - final var serializedSubscriptionIdUuid = serializeSubscriptionIdId(subscriptionId); - final var serializedKpis = kpiList.stream().map(this::serialize).collect(Collectors.toList()); - final var serializedKpisList = Monitoring.KpiList.newBuilder().addAllKpi(serializedKpis); - - builder.setSubsId(serializedSubscriptionIdUuid); - builder.setKpiList(serializedKpisList); - - return builder.build(); - } - - public AlarmResponse deserialize(Monitoring.AlarmResponse serializedAlarmResponse) { - final var serializedAlarmId = serializedAlarmResponse.getAlarmId().getAlarmId(); - final var serializedKpiList = serializedAlarmResponse.getKpiList(); - final var listSerializedKpis = serializedKpiList.getKpiList(); - - final var alarmId = deserialize(serializedAlarmId); - final var kpisList = - listSerializedKpis.stream().map(this::deserialize).collect(Collectors.toList()); - - return new AlarmResponse(alarmId, kpisList); - } - - public Monitoring.MonitorKpiRequest serialize(MonitorKpiRequest monitorKpiRequest) { - final var builder = Monitoring.MonitorKpiRequest.newBuilder(); - - final var kpiId = monitorKpiRequest.getKpiId(); - final var monitoringWindow = monitorKpiRequest.getMonitoringWindow(); - final var samplingRate = monitorKpiRequest.getSamplingRate(); - - final var serializedKpiId = serializeKpiId(kpiId); - - builder.setKpiId(serializedKpiId); - builder.setMonitoringWindowS(monitoringWindow); - builder.setSamplingRateS(samplingRate); - - return builder.build(); - } - - public MonitorKpiRequest deserialize(Monitoring.MonitorKpiRequest serializedMonitorKpiRequest) { - - final var serializedKpiId = serializedMonitorKpiRequest.getKpiId(); - final var kpiId = deserialize(serializedKpiId); - final var monitoringWindow = serializedMonitorKpiRequest.getMonitoringWindowS(); - final var samplingRate = serializedMonitorKpiRequest.getSamplingRateS(); - - return new MonitorKpiRequest(kpiId, monitoringWindow, samplingRate); - } - - public SubsResponse deserialize(Monitoring.SubsResponse serializedSubsResponse) { - final var serializedSubsId = serializedSubsResponse.getSubsId(); - final var serializedKpiList = serializedSubsResponse.getKpiList(); - final var listSerializedKpis = serializedKpiList.getKpiList(); - - final var subsId = deserialize(serializedSubsId); - final var kpiList = - listSerializedKpis.stream().map(this::deserialize).collect(Collectors.toList()); - - return new SubsResponse(subsId, kpiList); - } - - public Monitoring.SubsDescriptor serialize(SubsDescriptor subDescriptor) { - final var builder = Monitoring.SubsDescriptor.newBuilder(); - - final var subscriptionId = subDescriptor.getSubscriptionId(); - final var kpiId = subDescriptor.getKpiId(); - final var samplingDurationS = subDescriptor.getSamplingDurationS(); - final var samplingIntervalS = subDescriptor.getSamplingIntervalS(); - final var startTimestamp = subDescriptor.getStartTimestamp(); - final var endTimestamp = subDescriptor.getEndTimestamp(); - - final var serializedSubscriptionIdUuid = serializeSubscriptionIdId(subscriptionId); - final var serializedKpiIdUuid = serializeUuid(kpiId); - final var serializedKpiId = Monitoring.KpiId.newBuilder().setKpiId(serializedKpiIdUuid).build(); - final var serializedStartTimestamp = serialize(startTimestamp); - final var serializedEndTimestamp = serialize(endTimestamp); - - builder.setSubsId(serializedSubscriptionIdUuid); - builder.setKpiId(serializedKpiId); - builder.setSamplingDurationS(samplingDurationS); - builder.setSamplingIntervalS(samplingIntervalS); - builder.setStartTimestamp(serializedStartTimestamp); - builder.setEndTimestamp(serializedEndTimestamp); - - return builder.build(); - } - - public SubsDescriptor deserialize(Monitoring.SubsDescriptor serializedSubDescriptor) { - final var serializedSubscriptionId = serializedSubDescriptor.getSubsId(); - final var serializedKpiId = serializedSubDescriptor.getKpiId(); - final var samplingDurationS = serializedSubDescriptor.getSamplingDurationS(); - final var samplingIntervalS = serializedSubDescriptor.getSamplingIntervalS(); - final var serializedStartTimestamp = serializedSubDescriptor.getStartTimestamp(); - final var serializedEndTimestamp = serializedSubDescriptor.getEndTimestamp(); - - final var subscriptionId = deserialize(serializedSubscriptionId); - final var kpiId = deserialize(serializedKpiId); - final var startTimestamp = deserialize(serializedStartTimestamp); - final var endTimestamp = deserialize(serializedEndTimestamp); - - return new SubsDescriptor( - subscriptionId, kpiId, samplingDurationS, samplingIntervalS, startTimestamp, endTimestamp); - } - - public SubscriptionID serializeSubscriptionIdId(String subscriptionId) { - final var builder = Monitoring.SubscriptionID.newBuilder(); - - final var serializedSubscriptionIdUuid = serializeUuid(subscriptionId); - builder.setSubsId(serializedSubscriptionIdUuid); - - return builder.build(); - } - - public String deserialize(SubscriptionID serializedSubscriptionId) { - final var serializedSubscriptionIdUuid = serializedSubscriptionId.getSubsId(); - - return deserialize(serializedSubscriptionIdUuid); - } - - public PolicyCondition.PolicyRuleCondition serialize(PolicyRuleCondition policyRuleCondition) { - final var builder = PolicyCondition.PolicyRuleCondition.newBuilder(); - - final var policyRuleConditionKpiId = policyRuleCondition.getKpiId(); - final var numericalOperator = policyRuleCondition.getNumericalOperator(); - final var policyRuleConditionKpiValue = policyRuleCondition.getKpiValue(); - - final var serializedKpiIdUuid = serializeUuid(policyRuleConditionKpiId); - final var serializedKpiId = KpiId.newBuilder().setKpiId(serializedKpiIdUuid).build(); - final var serializedNumericalOperator = serialize(numericalOperator); - final var serializedPolicyRuleConditionKpiValue = serialize(policyRuleConditionKpiValue); - - builder.setKpiId(serializedKpiId); - builder.setNumericalOperator(serializedNumericalOperator); - builder.setKpiValue(serializedPolicyRuleConditionKpiValue); - - return builder.build(); - } - - public PolicyRuleCondition deserialize( - PolicyCondition.PolicyRuleCondition serializedPolicyRuleCondition) { - - final var serializedPolicyRuleConditionKpiId = - serializedPolicyRuleCondition.getKpiId().getKpiId(); - final var serializedNumericalOperator = serializedPolicyRuleCondition.getNumericalOperator(); - final var serializedPolicyRuleConditionKpiValue = serializedPolicyRuleCondition.getKpiValue(); - - final var policyRuleConditionKpiId = deserialize(serializedPolicyRuleConditionKpiId); - final var numericalOperator = deserialize(serializedNumericalOperator); - final var policyRuleConditionKpiValue = deserialize(serializedPolicyRuleConditionKpiValue); - - return new PolicyRuleCondition( - policyRuleConditionKpiId, numericalOperator, policyRuleConditionKpiValue); - } - public PolicyAction.PolicyRuleActionEnum serialize(PolicyRuleActionEnum policyRuleActionEnum) { switch (policyRuleActionEnum) { case POLICY_RULE_ACTION_SET_DEVICE_STATUS: @@ -1968,39 +1516,12 @@ public class Serializer { return new PolicyRuleAction(policyRuleActionEnum, policyRuleActionActionConfigs); } - public PolicyCondition.BooleanOperator serialize(BooleanOperator booleanOperator) { - switch (booleanOperator) { - case POLICYRULE_CONDITION_BOOLEAN_AND: - return PolicyCondition.BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_AND; - case POLICYRULE_CONDITION_BOOLEAN_OR: - return PolicyCondition.BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_OR; - case POLICYRULE_CONDITION_BOOLEAN_UNDEFINED: - return PolicyCondition.BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_UNDEFINED; - default: - return PolicyCondition.BooleanOperator.UNRECOGNIZED; - } - } - - public BooleanOperator deserialize(PolicyCondition.BooleanOperator serializedBooleanOperator) { - switch (serializedBooleanOperator) { - case POLICYRULE_CONDITION_BOOLEAN_OR: - return BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_OR; - case POLICYRULE_CONDITION_BOOLEAN_AND: - return BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_AND; - case POLICYRULE_CONDITION_BOOLEAN_UNDEFINED: - case UNRECOGNIZED: - default: - return BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_UNDEFINED; - } - } - public Policy.PolicyRuleBasic serialize(PolicyRuleBasic policyRuleBasic) { final var builder = Policy.PolicyRuleBasic.newBuilder(); final var policyRuleId = policyRuleBasic.getPolicyRuleId(); final var policyRuleState = policyRuleBasic.getPolicyRuleState(); - final var priority = policyRuleBasic.getPriority(); - final var kpiId = policyRuleBasic.getKpiId(); + final var policyRulePriority = policyRuleBasic.getPolicyRulePriority(); final var policyRuleActions = policyRuleBasic.getPolicyRuleActions(); final var serializedPolicyRuleId = serializePolicyRuleId(policyRuleId); @@ -2010,8 +1531,7 @@ public class Serializer { builder.setPolicyRuleId(serializedPolicyRuleId); builder.setPolicyRuleState(serializedPolicyRuleState); - builder.setPriority(priority); - builder.setKpiId(KpiId.newBuilder().setKpiId(Uuid.newBuilder().setUuid("kpiId").build())); + builder.setPolicyRulePriority(policyRulePriority); builder.addAllActionList(serializedPolicyRuleActions); return builder.build(); @@ -2020,17 +1540,16 @@ public class Serializer { public PolicyRuleBasic deserialize(Policy.PolicyRuleBasic serializedPolicyRuleBasic) { final var serializedPolicyRuleId = serializedPolicyRuleBasic.getPolicyRuleId(); final var serializedPolicyRuleState = serializedPolicyRuleBasic.getPolicyRuleState(); - final var priority = serializedPolicyRuleBasic.getPriority(); + final var policyRulePriority = serializedPolicyRuleBasic.getPolicyRulePriority(); final var serializedPolicyRuleActions = serializedPolicyRuleBasic.getActionListList(); - final var serializedKpiId = serializedPolicyRuleBasic.getKpiId(); final var policyRuleId = deserialize(serializedPolicyRuleId); - final var kpiId = deserialize(serializedKpiId); final var policyRuleState = deserialize(serializedPolicyRuleState); final var policyRuleActions = serializedPolicyRuleActions.stream().map(this::deserialize).collect(Collectors.toList()); - return new PolicyRuleBasic(policyRuleId, kpiId, policyRuleState, priority, policyRuleActions); + return new PolicyRuleBasic( + policyRuleId, policyRuleState, policyRulePriority, policyRuleActions); } public Policy.PolicyRuleService serialize(PolicyRuleService policyRuleService) { @@ -2134,124 +1653,6 @@ public class Serializer { return new PolicyRuleDevice(policyRuleBasic, policyRuleDeviceIds); } - public KpiId serializeKpiId(String kpiId) { - final var builder = Monitoring.KpiId.newBuilder(); - - final var serializedKpiIdUuid = serializeUuid(kpiId); - builder.setKpiId(serializedKpiIdUuid); - - return builder.build(); - } - - public String deserialize(KpiId serializedKpiId) { - final var serializedKpiIdUuid = serializedKpiId.getKpiId(); - - return deserialize(serializedKpiIdUuid); - } - - public Monitoring.Kpi serialize(Kpi kpi) { - final var builder = Monitoring.Kpi.newBuilder(); - - final var kpiId = kpi.getKpiId(); - final var timestamp = kpi.getTimestamp(); - final var kpiValue = kpi.getKpiValue(); - - final var serializedKpiId = serializeKpiId(kpiId); - final var serializedTimestamp = serialize(timestamp); - final var serializedKpiValue = serialize(kpiValue); - - builder.setKpiId(serializedKpiId); - builder.setTimestamp(serializedTimestamp); - builder.setKpiValue(serializedKpiValue); - - return builder.build(); - } - - public Kpi deserialize(Monitoring.Kpi serializedKpi) { - - final var serializedKpiId = serializedKpi.getKpiId(); - final var serializedTimestamp = serializedKpi.getTimestamp(); - final var serializedKpiValue = serializedKpi.getKpiValue(); - - final var kpiId = deserialize(serializedKpiId); - final var timestamp = deserialize(serializedTimestamp); - final var kpiValue = deserialize(serializedKpiValue); - - return new Kpi(kpiId, timestamp, kpiValue); - } - - public List serialize(List kpis) { - List serializedKpis = new ArrayList<>(); - - for (Kpi kpi : kpis) { - final var serializedKpi = serialize(kpi); - - serializedKpis.add(serializedKpi); - } - return serializedKpis; - } - - public List deserialize(List serializedKpis) { - List kpis = new ArrayList<>(); - - for (Monitoring.Kpi serializedKpi : serializedKpis) { - final var kpi = deserialize(serializedKpi); - - kpis.add(kpi); - } - return kpis; - } - - public Monitoring.KpiDescriptor serialize(KpiDescriptor kpiDescriptor) { - final var builder = Monitoring.KpiDescriptor.newBuilder(); - - final var kpiDescriptorDescription = kpiDescriptor.getKpiDescription(); - final var kpiDescriptorKpiSampleType = kpiDescriptor.getKpiSampleType(); - final var kpiDescriptorDeviceId = kpiDescriptor.getDeviceId(); - final var kpiDescriptorEndPointId = kpiDescriptor.getEndPointId(); - final var kpiDescriptorServiceId = kpiDescriptor.getServiceId(); - final var kpiDescriptorSliceId = kpiDescriptor.getSliceId(); - - final var serializedKpiDescriptorKpiSampleType = serialize(kpiDescriptorKpiSampleType); - final var serializedKpiDescriptorDeviceId = serializeDeviceId(kpiDescriptorDeviceId); - final var serializedKpiDescriptorEndPointId = serialize(kpiDescriptorEndPointId); - final var serializedKpiDescriptorServiceId = serialize(kpiDescriptorServiceId); - final var serializedKpiDescriptorSliceId = serialize(kpiDescriptorSliceId); - - builder.setKpiDescription(kpiDescriptorDescription); - builder.setKpiSampleType(serializedKpiDescriptorKpiSampleType); - builder.setDeviceId(serializedKpiDescriptorDeviceId); - builder.setEndpointId(serializedKpiDescriptorEndPointId); - builder.setServiceId(serializedKpiDescriptorServiceId); - builder.setSliceId(serializedKpiDescriptorSliceId); - - return builder.build(); - } - - public KpiDescriptor deserialize(Monitoring.KpiDescriptor serializedKpiDescriptor) { - - final var serializedKpiDescriptorDescription = serializedKpiDescriptor.getKpiDescription(); - final var serializedKpiDescriptorKpiSampleType = serializedKpiDescriptor.getKpiSampleType(); - final var serializedKpiDescriptorDeviceId = serializedKpiDescriptor.getDeviceId(); - final var serializedKpiDescriptorEndPointId = serializedKpiDescriptor.getEndpointId(); - final var serializedKpiDescriptorServiceId = serializedKpiDescriptor.getServiceId(); - final var serializedKpiDescriptorSLiceId = serializedKpiDescriptor.getSliceId(); - - final var kpiSampleType = deserialize(serializedKpiDescriptorKpiSampleType); - final var deviceId = deserialize(serializedKpiDescriptorDeviceId); - final var endPointId = deserialize(serializedKpiDescriptorEndPointId); - final var serviceId = deserialize(serializedKpiDescriptorServiceId); - final var sliceId = deserialize(serializedKpiDescriptorSLiceId); - - return new KpiDescriptor( - serializedKpiDescriptorDescription, - kpiSampleType, - deviceId, - endPointId, - serviceId, - sliceId); - } - public ContextOuterClass.DeviceConfig serialize(DeviceConfig deviceConfig) { final var builder = ContextOuterClass.DeviceConfig.newBuilder(); @@ -2442,33 +1843,6 @@ public class Serializer { return new EndPoint.EndPointBuilder(endPointId, endPointType, kpiSampleTypes).build(); } - public Monitoring.AlarmSubscription serialize(AlarmSubscription alarmSubscription) { - final var builder = Monitoring.AlarmSubscription.newBuilder(); - - final var alarmId = alarmSubscription.getAlarmId(); - final var subscriptionTimeoutS = alarmSubscription.getSubscriptionTimeoutS(); - final var subscriptionFrequencyMs = alarmSubscription.getSubscriptionFrequencyMs(); - - final var serializedAlarmId = serializeAlarmId(alarmId); - - builder.setAlarmId(serializedAlarmId); - builder.setSubscriptionTimeoutS(subscriptionTimeoutS); - builder.setSubscriptionFrequencyMs(subscriptionFrequencyMs); - - return builder.build(); - } - - public AlarmSubscription deserialize(Monitoring.AlarmSubscription serializedAlarmSubscription) { - - final var serializedAlarmId = serializedAlarmSubscription.getAlarmId(); - final var subscriptionTimeoutS = serializedAlarmSubscription.getSubscriptionTimeoutS(); - final var subscriptionFrequencyMs = serializedAlarmSubscription.getSubscriptionFrequencyMs(); - - final var alarmId = deserialize(serializedAlarmId); - - return new AlarmSubscription(alarmId, subscriptionTimeoutS, subscriptionFrequencyMs); - } - public ContextOuterClass.Device serialize(Device device) { final var builder = ContextOuterClass.Device.newBuilder(); diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringGateway.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringGateway.java deleted file mode 100644 index 0f6c6a5fa..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringGateway.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring; - -import io.smallrye.mutiny.Multi; -import io.smallrye.mutiny.Uni; -import org.etsi.tfs.policy.context.model.Empty; -import org.etsi.tfs.policy.monitoring.model.AlarmDescriptor; -import org.etsi.tfs.policy.monitoring.model.AlarmResponse; -import org.etsi.tfs.policy.monitoring.model.AlarmSubscription; -import org.etsi.tfs.policy.monitoring.model.KpiDescriptor; -import org.etsi.tfs.policy.monitoring.model.MonitorKpiRequest; -import org.etsi.tfs.policy.monitoring.model.SubsDescriptor; -import org.etsi.tfs.policy.monitoring.model.SubsResponse; - -public interface MonitoringGateway { - - Uni setKpi(KpiDescriptor kpiDescriptor); - - Uni getKpiDescriptor(String kpiId); - - Uni monitorKpi(MonitorKpiRequest monitorKpiRequest); - - Multi setKpiSubscription(SubsDescriptor subsDescriptor); - - Uni getSubsDescriptor(String subscriptionId); - - Uni setKpiAlarm(AlarmDescriptor alarmDescriptor); - - Uni getAlarmDescriptor(String alarmId); - - Multi getAlarmResponseStream(AlarmSubscription alarmSubscription); - - Uni deleteAlarm(String deviceId); - - Uni deleteKpi(String kpiId); -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringGatewayImpl.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringGatewayImpl.java deleted file mode 100644 index ccc12944f..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringGatewayImpl.java +++ /dev/null @@ -1,147 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring; - -import io.quarkus.grpc.GrpcClient; -import io.smallrye.mutiny.Multi; -import io.smallrye.mutiny.Uni; -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; -import monitoring.MutinyMonitoringServiceGrpc.MutinyMonitoringServiceStub; -import org.etsi.tfs.policy.Serializer; -import org.etsi.tfs.policy.context.model.Empty; -import org.etsi.tfs.policy.monitoring.model.AlarmDescriptor; -import org.etsi.tfs.policy.monitoring.model.AlarmResponse; -import org.etsi.tfs.policy.monitoring.model.AlarmSubscription; -import org.etsi.tfs.policy.monitoring.model.KpiDescriptor; -import org.etsi.tfs.policy.monitoring.model.MonitorKpiRequest; -import org.etsi.tfs.policy.monitoring.model.SubsDescriptor; -import org.etsi.tfs.policy.monitoring.model.SubsResponse; - -@ApplicationScoped -public class MonitoringGatewayImpl implements MonitoringGateway { - - @GrpcClient("monitoring") - MutinyMonitoringServiceStub streamingDelegateMonitoring; - - private final Serializer serializer; - - @Inject - public MonitoringGatewayImpl(Serializer serializer) { - this.serializer = serializer; - } - - @Override - public Uni setKpi(KpiDescriptor kpiDescriptor) { - final var serializedKpiDescriptor = serializer.serialize(kpiDescriptor); - - return streamingDelegateMonitoring - .setKpi(serializedKpiDescriptor) - .onItem() - .transform(serializer::deserialize); - } - - @Override - public Uni getKpiDescriptor(String kpiId) { - final var serializedKpiId = serializer.serializeKpiId(kpiId); - - return streamingDelegateMonitoring - .getKpiDescriptor(serializedKpiId) - .onItem() - .transform(serializer::deserialize); - } - - @Override - public Uni monitorKpi(MonitorKpiRequest monitorKpiRequest) { - final var serializedKpiId = serializer.serialize(monitorKpiRequest); - - return streamingDelegateMonitoring - .monitorKpi(serializedKpiId) - .onItem() - .transform(serializer::deserializeEmpty); - } - - @Override - public Multi setKpiSubscription(SubsDescriptor subsDescriptor) { - final var serializedSubsDescriptor = serializer.serialize(subsDescriptor); - - return streamingDelegateMonitoring - .setKpiSubscription(serializedSubsDescriptor) - .onItem() - .transform(serializer::deserialize); - } - - @Override - public Uni getSubsDescriptor(String subscriptionId) { - final var serializedSubscriptionId = serializer.serializeSubscriptionIdId(subscriptionId); - - return streamingDelegateMonitoring - .getSubsDescriptor(serializedSubscriptionId) - .onItem() - .transform(serializer::deserialize); - } - - @Override - public Uni setKpiAlarm(AlarmDescriptor alarmDescriptor) { - final var serializedAlarmDescriptor = serializer.serialize(alarmDescriptor); - - return streamingDelegateMonitoring - .setKpiAlarm(serializedAlarmDescriptor) - .onItem() - .transform(serializer::deserialize); - } - - @Override - public Uni getAlarmDescriptor(String alarmId) { - final var serializedAlarmId = serializer.serializeAlarmId(alarmId); - - return streamingDelegateMonitoring - .getAlarmDescriptor(serializedAlarmId) - .onItem() - .transform(serializer::deserialize); - } - - @Override - public Multi getAlarmResponseStream(AlarmSubscription alarmSubscription) { - final var serializedAlarmSubscription = serializer.serialize(alarmSubscription); - - return streamingDelegateMonitoring - .getAlarmResponseStream(serializedAlarmSubscription) - .onItem() - .transform(serializer::deserialize); - } - - @Override - public Uni deleteAlarm(String alarmId) { - final var serializedAlarmId = serializer.serializeAlarmId(alarmId); - - return streamingDelegateMonitoring - .deleteAlarm(serializedAlarmId) - .onItem() - .transform(serializer::deserializeEmpty); - } - - @Override - public Uni deleteKpi(String kpiId) { - final var serializedKpiId = serializer.serializeKpiId(kpiId); - - return streamingDelegateMonitoring - .deleteKpi(serializedKpiId) - .onItem() - .transform(serializer::deserializeEmpty); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringService.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringService.java deleted file mode 100644 index 5d95457ea..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringService.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring; - -import io.smallrye.mutiny.Multi; -import io.smallrye.mutiny.Uni; -import org.etsi.tfs.policy.context.model.Empty; -import org.etsi.tfs.policy.monitoring.model.AlarmDescriptor; -import org.etsi.tfs.policy.monitoring.model.AlarmResponse; -import org.etsi.tfs.policy.monitoring.model.AlarmSubscription; -import org.etsi.tfs.policy.monitoring.model.KpiDescriptor; -import org.etsi.tfs.policy.monitoring.model.MonitorKpiRequest; -import org.etsi.tfs.policy.monitoring.model.SubsDescriptor; -import org.etsi.tfs.policy.monitoring.model.SubsResponse; - -public interface MonitoringService { - - Uni setKpi(KpiDescriptor kpiDescriptor); - - Uni getKpiDescriptor(String kpiId); - - Uni monitorKpi(MonitorKpiRequest monitorKpiRequest); - - Multi setKpiSubscription(SubsDescriptor subsDescriptor); - - Uni getSubsDescriptor(String subscriptionId); - - Uni setKpiAlarm(AlarmDescriptor alarmDescriptor); - - Uni getAlarmDescriptor(String alarmId); - - Multi getAlarmResponseStream(AlarmSubscription alarmSubscription); - - Uni deleteAlarm(String deviceId); - - Uni deleteKpi(String kpiId); -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringServiceImpl.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringServiceImpl.java deleted file mode 100644 index 80a81f8f5..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/MonitoringServiceImpl.java +++ /dev/null @@ -1,91 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring; - -import io.smallrye.mutiny.Multi; -import io.smallrye.mutiny.Uni; -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; -import org.etsi.tfs.policy.context.model.Empty; -import org.etsi.tfs.policy.monitoring.model.AlarmDescriptor; -import org.etsi.tfs.policy.monitoring.model.AlarmResponse; -import org.etsi.tfs.policy.monitoring.model.AlarmSubscription; -import org.etsi.tfs.policy.monitoring.model.KpiDescriptor; -import org.etsi.tfs.policy.monitoring.model.MonitorKpiRequest; -import org.etsi.tfs.policy.monitoring.model.SubsDescriptor; -import org.etsi.tfs.policy.monitoring.model.SubsResponse; - -@ApplicationScoped -public class MonitoringServiceImpl implements MonitoringService { - - private final MonitoringGateway monitoringGateway; - - @Inject - public MonitoringServiceImpl(MonitoringGateway monitoringGateway) { - this.monitoringGateway = monitoringGateway; - } - - @Override - public Uni setKpi(KpiDescriptor kpiDescriptor) { - return monitoringGateway.setKpi(kpiDescriptor); - } - - @Override - public Uni getKpiDescriptor(String kpiId) { - return monitoringGateway.getKpiDescriptor(kpiId); - } - - @Override - public Uni monitorKpi(MonitorKpiRequest monitorKpiRequest) { - return monitoringGateway.monitorKpi(monitorKpiRequest); - } - - @Override - public Multi setKpiSubscription(SubsDescriptor subsDescriptor) { - return monitoringGateway.setKpiSubscription(subsDescriptor); - } - - @Override - public Uni getSubsDescriptor(String subscriptionId) { - return monitoringGateway.getSubsDescriptor(subscriptionId); - } - - @Override - public Uni setKpiAlarm(AlarmDescriptor alarmDescriptor) { - return monitoringGateway.setKpiAlarm(alarmDescriptor); - } - - @Override - public Uni getAlarmDescriptor(String alarmId) { - return monitoringGateway.getAlarmDescriptor(alarmId); - } - - @Override - public Multi getAlarmResponseStream(AlarmSubscription alarmSubscription) { - return monitoringGateway.getAlarmResponseStream(alarmSubscription); - } - - @Override - public Uni deleteAlarm(String alarmId) { - return monitoringGateway.deleteAlarm(alarmId); - } - - @Override - public Uni deleteKpi(String kpiId) { - return monitoringGateway.deleteKpi(kpiId); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/AlarmDescriptor.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/AlarmDescriptor.java deleted file mode 100644 index 41473a352..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/AlarmDescriptor.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -public class AlarmDescriptor { - private final String alarmId; - private final String alarmDescription; - private final String name; - private final String kpiId; - private final KpiValueRange kpiValueRange; - private final double timestamp; - - public AlarmDescriptor( - String alarmId, - String alarmDescription, - String name, - String kpiId, - KpiValueRange kpiValueRange, - double timestamp) { - this.alarmId = alarmId; - this.alarmDescription = alarmDescription; - this.name = name; - this.kpiId = kpiId; - this.kpiValueRange = kpiValueRange; - this.timestamp = timestamp; - } - - public String getAlarmId() { - return alarmId; - } - - public String getAlarmDescription() { - return alarmDescription; - } - - public String getName() { - return name; - } - - public String getKpiId() { - return kpiId; - } - - public KpiValueRange getKpiValueRange() { - return kpiValueRange; - } - - public double getTimestamp() { - return timestamp; - } - - @Override - public String toString() { - return String.format( - "%s:{alarmId:\"%s\", alarmDescription:\"%s\", name:\"%s\", [%s], [%s], timestamp:\"%f\"}", - getClass().getSimpleName(), - alarmId, - alarmDescription, - name, - kpiId, - kpiValueRange, - timestamp); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/AlarmResponse.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/AlarmResponse.java deleted file mode 100644 index 091f9e1c3..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/AlarmResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -import java.util.List; -import org.etsi.tfs.policy.common.Util; - -public class AlarmResponse { - - private final String alarmId; - - private final List kpiList; - - public AlarmResponse(String alarmId, List kpiList) { - this.alarmId = alarmId; - this.kpiList = kpiList; - } - - public String getAlarmId() { - return alarmId; - } - - public List getKpiList() { - return kpiList; - } - - @Override - public String toString() { - return String.format( - "%s:{alarmId:\"%s\", %s}", getClass().getSimpleName(), alarmId, Util.toString(kpiList)); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/AlarmSubscription.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/AlarmSubscription.java deleted file mode 100644 index 01a85fdc5..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/AlarmSubscription.java +++ /dev/null @@ -1,51 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -public class AlarmSubscription { - - private final String alarmId; - private final float subscriptionTimeoutS; - private final float subscriptionFrequencyMs; - - // TODO: Refactor the AlarmSubscription constructor to allow infinite subscriptionTimeoutS - public AlarmSubscription( - String alarmId, float subscriptionTimeoutS, float subscriptionFrequencyMs) { - this.alarmId = alarmId; - this.subscriptionTimeoutS = subscriptionTimeoutS; - this.subscriptionFrequencyMs = subscriptionFrequencyMs; - } - - public String getAlarmId() { - return alarmId; - } - - public float getSubscriptionTimeoutS() { - return subscriptionTimeoutS; - } - - public float getSubscriptionFrequencyMs() { - return subscriptionFrequencyMs; - } - - @Override - public String toString() { - return String.format( - "%s:{alarmId:\"%s\", subscriptionTimeoutS:\"%f\", subscriptionFrequencyMs:\"%f\"}", - getClass().getSimpleName(), alarmId, subscriptionTimeoutS, subscriptionFrequencyMs); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/BooleanKpiValue.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/BooleanKpiValue.java deleted file mode 100644 index 0354413c3..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/BooleanKpiValue.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -public class BooleanKpiValue implements KpiValue { - - private final boolean value; - - public BooleanKpiValue(boolean value) { - this.value = value; - } - - @Override - public Boolean getValue() { - return this.value; - } - - @Override - public String toString() { - return String.format("%s:{value:\"%b\"}", getClass().getSimpleName(), value); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/FloatKpiValue.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/FloatKpiValue.java deleted file mode 100644 index afb1ffff9..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/FloatKpiValue.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -public class FloatKpiValue implements KpiValue { - - private final float value; - - public FloatKpiValue(float value) { - this.value = value; - } - - @Override - public Float getValue() { - return this.value; - } - - @Override - public String toString() { - return String.format("%s:{value:\"%f\"}", getClass().getSimpleName(), value); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/IntegerKpiValue.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/IntegerKpiValue.java deleted file mode 100644 index cdd86163a..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/IntegerKpiValue.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -public class IntegerKpiValue implements KpiValue { - - private final int value; - - public IntegerKpiValue(int value) { - this.value = value; - } - - @Override - public Integer getValue() { - return this.value; - } - - @Override - public String toString() { - return String.format("%s:{value:\"%d\"}", getClass().getSimpleName(), value); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/Kpi.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/Kpi.java deleted file mode 100644 index 2af26df2d..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/Kpi.java +++ /dev/null @@ -1,49 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -public class Kpi { - - private final String kpiId; - private final double timestamp; - private final KpiValue kpiValue; - - public Kpi(String kpiId, double timestamp, KpiValue kpiValue) { - this.kpiId = kpiId; - this.timestamp = timestamp; - this.kpiValue = kpiValue; - } - - public String getKpiId() { - return kpiId; - } - - public double getTimestamp() { - return timestamp; - } - - public KpiValue getKpiValue() { - return kpiValue; - } - - @Override - public String toString() { - return String.format( - "%s:{kpiId:\"%s\", timeStamp:\"%f\", %s}", - getClass().getSimpleName(), kpiId, timestamp, kpiValue); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/KpiDescriptor.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/KpiDescriptor.java deleted file mode 100644 index 95eeddb56..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/KpiDescriptor.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -import org.etsi.tfs.policy.context.model.EndPointId; -import org.etsi.tfs.policy.context.model.ServiceId; -import org.etsi.tfs.policy.context.model.SliceId; -import org.etsi.tfs.policy.kpi_sample_types.model.KpiSampleType; - -public class KpiDescriptor { - - private final String kpiDescription; - private final KpiSampleType kpiSampleType; - private final String deviceId; - private final EndPointId endPointId; - private final ServiceId serviceId; - private final SliceId sliceId; - - public KpiDescriptor( - String kpiDescription, - KpiSampleType kpiSampleType, - String deviceId, - EndPointId endPointId, - ServiceId serviceId, - SliceId sliceId) { - this.kpiDescription = kpiDescription; - this.kpiSampleType = kpiSampleType; - this.deviceId = deviceId; - this.endPointId = endPointId; - this.serviceId = serviceId; - this.sliceId = sliceId; - } - - public String getKpiDescription() { - return kpiDescription; - } - - public KpiSampleType getKpiSampleType() { - return kpiSampleType; - } - - public String getDeviceId() { - return deviceId; - } - - public EndPointId getEndPointId() { - return endPointId; - } - - public ServiceId getServiceId() { - return serviceId; - } - - public SliceId getSliceId() { - return sliceId; - } - - @Override - public String toString() { - return String.format( - "%s:{kpiDescription:\"%s\", kpiSampleType:\"%s\", deviceId:\"%s\", %s, %s, %s}", - getClass().getSimpleName(), - kpiDescription, - kpiSampleType.toString(), - deviceId, - endPointId, - serviceId, - sliceId); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/KpiValue.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/KpiValue.java deleted file mode 100644 index 713a25ec7..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/KpiValue.java +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -public interface KpiValue { - - public T getValue(); -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/KpiValueRange.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/KpiValueRange.java deleted file mode 100644 index 5a92810d0..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/KpiValueRange.java +++ /dev/null @@ -1,84 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -public class KpiValueRange { - - private KpiValue kpiMinValue; - private KpiValue kpiMaxValue; - private boolean inRange; - private boolean includeMinValue; - private boolean includeMaxValue; - - public KpiValueRange( - KpiValue kpiMinValue, - KpiValue kpiMaxValue, - boolean inRange, - boolean includeMinValue, - boolean includeMaxValue) { - this.kpiMinValue = kpiMinValue; - this.kpiMaxValue = kpiMaxValue; - this.inRange = inRange; - this.includeMinValue = includeMinValue; - this.includeMaxValue = includeMaxValue; - } - - public KpiValue getKpiMinValue() { - return kpiMinValue; - } - - public KpiValue getKpiMaxValue() { - return kpiMaxValue; - } - - public boolean getInRange() { - return inRange; - } - - public boolean getIncludeMinValue() { - return includeMinValue; - } - - public boolean getIncludeMaxValue() { - return includeMaxValue; - } - - public void setKpiMinValue(KpiValue kpiMinValue) { - this.kpiMinValue = kpiMinValue; - } - - public void setKpiMaxValue(KpiValue kpiMaxValue) { - this.kpiMaxValue = kpiMaxValue; - } - - public void setInRange(boolean inRange) { - this.inRange = inRange; - } - - public void setIncludeMinValue(boolean includeMinValue) { - this.includeMinValue = includeMinValue; - } - - public void setIncludeMaxValue(boolean includeMaxValue) { - this.includeMaxValue = includeMaxValue; - } - - @Override - public String toString() { - return String.format("%s:{%s, %s}", getClass().getSimpleName(), kpiMinValue, kpiMaxValue); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/LongKpiValue.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/LongKpiValue.java deleted file mode 100644 index 3d732432a..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/LongKpiValue.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -public class LongKpiValue implements KpiValue { - - private final long value; - - public LongKpiValue(int value) { - this.value = value; - } - - @Override - public Long getValue() { - return this.value; - } - - @Override - public String toString() { - return String.format("%s:{value:\"%d\"}", getClass().getSimpleName(), value); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/MonitorKpiRequest.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/MonitorKpiRequest.java deleted file mode 100644 index c8b890a73..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/MonitorKpiRequest.java +++ /dev/null @@ -1,48 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -public class MonitorKpiRequest { - private final String kpiId; - private final float monitoringWindow; - private final float samplingRate; - - public MonitorKpiRequest(String kpiId, float monitoringWindow, float samplingRate) { - this.kpiId = kpiId; - this.monitoringWindow = monitoringWindow; - this.samplingRate = samplingRate; - } - - public String getKpiId() { - return kpiId; - } - - public float getMonitoringWindow() { - return monitoringWindow; - } - - public float getSamplingRate() { - return samplingRate; - } - - @Override - public String toString() { - return String.format( - "%s:{KpiId:\"%s\", [%s], [%s]}", - getClass().getSimpleName(), kpiId, monitoringWindow, samplingRate); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/StringKpiValue.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/StringKpiValue.java deleted file mode 100644 index 2d9bd9946..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/StringKpiValue.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -public class StringKpiValue implements KpiValue { - - private final String value; - - public StringKpiValue(String value) { - this.value = value; - } - - @Override - public String getValue() { - return this.value; - } - - @Override - public String toString() { - return String.format("%s:{value:\"%s\"}", getClass().getSimpleName(), value); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/SubsDescriptor.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/SubsDescriptor.java deleted file mode 100644 index 760d58ad1..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/SubsDescriptor.java +++ /dev/null @@ -1,78 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -public class SubsDescriptor { - private final String subscriptionId; - private final String kpiId; - private final float samplingDurationS; - private final float samplingIntervalS; - private final double startTimestamp; - private final double endTimestamp; - - public SubsDescriptor( - String subscriptionId, - String kpiId, - float samplingDurationS, - float samplingIntervalS, - double startTimestamp, - double endTimestamp) { - this.subscriptionId = subscriptionId; - this.kpiId = kpiId; - this.samplingDurationS = samplingDurationS; - this.samplingIntervalS = samplingIntervalS; - this.startTimestamp = startTimestamp; - this.endTimestamp = endTimestamp; - } - - public String getSubscriptionId() { - return subscriptionId; - } - - public String getKpiId() { - return kpiId; - } - - public float getSamplingDurationS() { - return samplingDurationS; - } - - public float getSamplingIntervalS() { - return samplingIntervalS; - } - - public double getStartTimestamp() { - return startTimestamp; - } - - public double getEndTimestamp() { - return endTimestamp; - } - - @Override - public String toString() { - return String.format( - "%s:{subscriptionId:\"%s\", kpiId:\"%s\", samplingDurationS:\"%f\", samplingIntervalS:\"%f\", startTimestamp:\"%f\", endTimestamp:\"%f\"}", - getClass().getSimpleName(), - subscriptionId, - kpiId, - samplingDurationS, - samplingIntervalS, - startTimestamp, - endTimestamp); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/SubsResponse.java b/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/SubsResponse.java deleted file mode 100644 index 6e70e4be4..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/monitoring/model/SubsResponse.java +++ /dev/null @@ -1,46 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.monitoring.model; - -import java.util.List; -import org.etsi.tfs.policy.common.Util; - -public class SubsResponse { - - private final String subscriptionId; - private final List kpiList; - - public SubsResponse(String subscriptionId, List kpiList) { - this.subscriptionId = subscriptionId; - this.kpiList = kpiList; - } - - public String getSubscriptionId() { - return subscriptionId; - } - - public List getKpiList() { - return kpiList; - } - - @Override - public String toString() { - return String.format( - "%s:{subscriptionId:\"%s\", %s}", - getClass().getSimpleName(), subscriptionId, Util.toString(kpiList)); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyDeviceImpl.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyDeviceImpl.java index 29113ca0f..694340a7c 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyDeviceImpl.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyDeviceImpl.java @@ -40,7 +40,6 @@ public class AddPolicyDeviceImpl { @Inject private PolicyRuleConditionValidator policyRuleConditionValidator; @Inject private CommonPolicyServiceImpl commonPolicyServiceImpl; - @Inject private CommonAlarmService commonAlarmService; @Inject private ContextService contextService; diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyServiceImpl.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyServiceImpl.java index 01b0f96d6..a396d5c02 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyServiceImpl.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyServiceImpl.java @@ -53,9 +53,6 @@ public class AddPolicyServiceImpl { final var policyRuleTypeService = new PolicyRuleTypeService(policyRuleService); final var policyRule = new PolicyRule(policyRuleTypeService); - final String kpiId = policyRuleService.getPolicyRuleBasic().getKpiId(); - commonPolicyService.getKpiPolicyRuleServiceMap().put(kpiId, policyRuleService); - return setPolicyRuleOnContextAndReturnState(policyRule); } diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/CommonAlarmService.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/CommonAlarmService.java deleted file mode 100644 index c46704368..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/CommonAlarmService.java +++ /dev/null @@ -1,129 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.policy; - -import io.smallrye.mutiny.Multi; -import io.smallrye.mutiny.Uni; -import io.smallrye.mutiny.subscription.Cancellable; -import jakarta.enterprise.context.ApplicationScoped; -import jakarta.inject.Inject; -import java.util.ArrayList; -import java.util.List; -import org.etsi.tfs.policy.monitoring.MonitoringService; -import org.etsi.tfs.policy.monitoring.model.AlarmDescriptor; -import org.etsi.tfs.policy.monitoring.model.AlarmResponse; -import org.etsi.tfs.policy.monitoring.model.AlarmSubscription; -import org.etsi.tfs.policy.policy.model.PolicyRuleDevice; -import org.etsi.tfs.policy.policy.model.PolicyRuleService; -import org.jboss.logging.Logger; - -@ApplicationScoped -public class CommonAlarmService { - private static final Logger LOGGER = Logger.getLogger(CommonAlarmService.class); - - @Inject private CommonPolicyServiceImpl commonPolicyServiceImpl; - @Inject private MonitoringService monitoringService; - - /** - * Transform the alarmIds into promised alarms returned from the getAlarmResponseStream - * - * @param alarmIds the list of alarm ids - * @param policyRuleService the policy rule service - * @return - */ - private List> transformAlarmIds( - List> alarmIds, PolicyRuleService policyRuleService) { - List> alarmResponseStreamList = new ArrayList<>(); - for (Uni alarmId : alarmIds) { - Multi alarmResponseStream = - alarmId.onItem().transformToMulti(id -> setPolicyMonitor(policyRuleService, id)); - - alarmResponseStreamList.add(alarmResponseStream); - } - return alarmResponseStreamList; - } - - private List> transformAlarmIds( - List> alarmIds, PolicyRuleDevice policyRuleDevice) { - // Transform the alarmIds into promised alarms returned from the - // getAlarmResponseStream - List> alarmResponseStreamList = new ArrayList<>(); - for (Uni alarmId : alarmIds) { - alarmResponseStreamList.add( - alarmId.onItem().transformToMulti(id -> setPolicyMonitor(policyRuleDevice, id))); - } - return alarmResponseStreamList; - } - - private Multi setPolicyMonitor(PolicyRuleService policyRuleService, String id) { - commonPolicyServiceImpl.getAlarmPolicyRuleServiceMap().put(id, policyRuleService); - - // TODO: Create infinite subscription - var alarmSubscription = new AlarmSubscription(id, 259200, 5000); - return monitoringService.getAlarmResponseStream(alarmSubscription); - } - - private Multi setPolicyMonitor(PolicyRuleDevice policyRuleDevice, String id) { - commonPolicyServiceImpl.getAlarmPolicyRuleDeviceMap().put(id, policyRuleDevice); - - // TODO: Create infinite subscription - var alarmSubscription = new AlarmSubscription(id, 259200, 5000); - return monitoringService.getAlarmResponseStream(alarmSubscription); - } - - /** - * Create an alarmIds list that contains the promised ids returned from setKpiAlarm - * - * @param alarmDescriptorList the list of alarm descriptors - * @return the list of alarm descriptors - */ - public List> createAlarmList(List alarmDescriptorList) { - List> alarmIds = new ArrayList>(); - for (AlarmDescriptor alarmDescriptor : alarmDescriptorList) { - LOGGER.infof("alarmDescriptor:"); - LOGGER.infof(alarmDescriptor.toString()); - alarmIds.add(monitoringService.setKpiAlarm(alarmDescriptor)); - } - return alarmIds; - } - - private Cancellable monitorAlarmResponseForService(Multi multi) { - return multi - .subscribe() - .with( - alarmResponse -> { - LOGGER.infof("**************************Received Alarm!**************************"); - LOGGER.infof("alarmResponse:"); - LOGGER.info(alarmResponse); - LOGGER.info(alarmResponse.getAlarmId()); - commonPolicyServiceImpl.applyActionService(alarmResponse.getAlarmId()); - }); - } - - private Cancellable monitorAlarmResponseForDevice(Multi multi) { - return multi - .subscribe() - .with( - alarmResponse -> { - LOGGER.infof("**************************Received Alarm!**************************"); - LOGGER.infof("alarmResponse:"); - LOGGER.info(alarmResponse); - LOGGER.info(alarmResponse.getAlarmId()); - commonPolicyServiceImpl.applyActionDevice(alarmResponse.getAlarmId()); - }); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/CommonPolicyServiceImpl.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/CommonPolicyServiceImpl.java index c85cdd928..b8b243600 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/CommonPolicyServiceImpl.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/CommonPolicyServiceImpl.java @@ -39,14 +39,10 @@ import org.etsi.tfs.policy.context.model.ConstraintCustom; import org.etsi.tfs.policy.context.model.ConstraintTypeCustom; import org.etsi.tfs.policy.context.model.ServiceConfig; import org.etsi.tfs.policy.device.DeviceService; -import org.etsi.tfs.policy.monitoring.MonitoringService; -import org.etsi.tfs.policy.monitoring.model.AlarmDescriptor; -import org.etsi.tfs.policy.monitoring.model.KpiValueRange; import org.etsi.tfs.policy.policy.model.PolicyRule; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum; -import org.etsi.tfs.policy.policy.model.PolicyRuleCondition; import org.etsi.tfs.policy.policy.model.PolicyRuleDevice; import org.etsi.tfs.policy.policy.model.PolicyRuleService; import org.etsi.tfs.policy.policy.model.PolicyRuleState; @@ -61,7 +57,6 @@ public class CommonPolicyServiceImpl { private static final Logger LOGGER = Logger.getLogger(CommonPolicyServiceImpl.class); - @Inject private MonitoringService monitoringService; @Inject private ContextService contextService; @Inject private ServiceService serviceService; @Inject private DeviceService deviceService; @@ -158,114 +153,6 @@ public class CommonPolicyServiceImpl { } } - private KpiValueRange convertPolicyRuleConditionToKpiValueRange( - PolicyRuleCondition policyRuleCondition) { - - switch (policyRuleCondition.getNumericalOperator()) { - case POLICY_RULE_CONDITION_NUMERICAL_EQUAL: - return new KpiValueRange( - policyRuleCondition.getKpiValue(), policyRuleCondition.getKpiValue(), true, true, true); - case POLICY_RULE_CONDITION_NUMERICAL_NOT_EQUAL: - return new KpiValueRange( - policyRuleCondition.getKpiValue(), - policyRuleCondition.getKpiValue(), - true, - false, - false); - - case POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN: - return new KpiValueRange(null, policyRuleCondition.getKpiValue(), true, false, false); - - case POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL: - return new KpiValueRange(null, policyRuleCondition.getKpiValue(), true, true, false); - - case POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN: - return new KpiValueRange(policyRuleCondition.getKpiValue(), null, true, false, false); - - case POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL: - return new KpiValueRange(policyRuleCondition.getKpiValue(), null, true, false, true); - default: - return null; - } - } - - private KpiValueRange combineKpiValueRanges( - String kpiId, KpiValueRange firstKpiValueRange, KpiValueRange secondKpiValueRange) { - if (secondKpiValueRange.getInRange() == true) { - LOGGER.errorf("KpiId: %s, has already range values", kpiId); - return null; - } - - if ((firstKpiValueRange.getKpiMinValue() != null) - && (secondKpiValueRange.getKpiMinValue() != null)) { - LOGGER.errorf("KpiId: %s, has already min value", kpiId); - return null; - } - - if ((firstKpiValueRange.getKpiMaxValue() != null) - && (secondKpiValueRange.getKpiMinValue() != null)) { - LOGGER.errorf("KpiId: %s, has already max value", kpiId); - return null; - } - - // Objects.nonNull(secondKpiValueRange); - - var kpiMinValue = - firstKpiValueRange.getKpiMinValue() != null - ? firstKpiValueRange.getKpiMinValue() - : secondKpiValueRange.getKpiMinValue(); - var kpiMaxValue = - firstKpiValueRange.getKpiMaxValue() != null - ? firstKpiValueRange.getKpiMaxValue() - : secondKpiValueRange.getKpiMaxValue(); - boolean includeMinValue = - firstKpiValueRange.getIncludeMinValue() || secondKpiValueRange.getIncludeMinValue(); - boolean includeMaxValue = - firstKpiValueRange.getIncludeMaxValue() || secondKpiValueRange.getIncludeMaxValue(); - - return new KpiValueRange(kpiMinValue, kpiMaxValue, true, includeMinValue, includeMaxValue); - } - - private AlarmDescriptor createAlarmDescriptorWithoutRange( - PolicyRuleCondition policyRuleCondition) { - - final var kpiId = policyRuleCondition.getKpiId(); - final var kpiValueRange = convertPolicyRuleConditionToKpiValueRange(policyRuleCondition); - - return new AlarmDescriptor( - "", "alarmDescription", "alarmName-" + gen(), kpiId, kpiValueRange, getTimeStamp()); - } - - // TODO: To be refactored or deprecated - // private void evaluateAction( - // PolicyRule policyRule, - // List alarmDescriptorList, - // Multi multi) { - // - // Long count = - // multi - // .collect() - // .with(Collectors.counting()) - // .await() - // .atMost(Duration.ofMinutes(POLICY_EVALUATION_TIMEOUT)); - // - // if (count > ACCEPTABLE_NUMBER_OF_ALARMS) { - // for (AlarmDescriptor alarmDescriptor : alarmDescriptorList) { - // monitoringService - // .deleteAlarm(alarmDescriptor.getAlarmId()) - // .subscribe() - // .with( - // emptyMessage -> - // LOGGER.infof( - // "Alarm [%s] has been deleted as ineffective.\n", - // alarmDescriptor.getAlarmId())); - // } - // setPolicyRuleToContext(policyRule, INEFFECTIVE_POLICYRULE_STATE); - // } else { - // setPolicyRuleToContext(policyRule, EFFECTIVE_POLICYRULE_STATE); - // } - // } - public void applyActionDevice(String alarmId) { PolicyRuleDevice policyRuleDevice = alarmPolicyRuleDeviceMap.get(alarmId); diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/BooleanOperator.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/BooleanOperator.java deleted file mode 100644 index 7c62621c8..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/BooleanOperator.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.policy.model; - -public enum BooleanOperator { - POLICYRULE_CONDITION_BOOLEAN_UNDEFINED, - POLICYRULE_CONDITION_BOOLEAN_AND, - POLICYRULE_CONDITION_BOOLEAN_OR -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/NumericalOperator.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/NumericalOperator.java deleted file mode 100644 index decd5071f..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/NumericalOperator.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.policy.model; - -public enum NumericalOperator { - POLICY_RULE_CONDITION_NUMERICAL_UNDEFINED, - POLICY_RULE_CONDITION_NUMERICAL_EQUAL, - POLICY_RULE_CONDITION_NUMERICAL_NOT_EQUAL, - POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN, - POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL, - POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, - POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleActionEnum.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleActionEnum.java index e2da581a2..638f915c2 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleActionEnum.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleActionEnum.java @@ -22,6 +22,5 @@ public enum PolicyRuleActionEnum { POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE, POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT, POLICY_RULE_ACTION_CALL_SERVICE_RPC, - // This is temporary POLICY_RULE_ACTION_RECALCULATE_PATH } diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleBasic.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleBasic.java index cfc88a08e..aa6b82adc 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleBasic.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleBasic.java @@ -19,47 +19,34 @@ package org.etsi.tfs.policy.policy.model; import static com.google.common.base.Preconditions.checkArgument; import static com.google.common.base.Preconditions.checkNotNull; -import java.util.ArrayList; import java.util.List; import org.etsi.tfs.policy.common.Util; public class PolicyRuleBasic { - private String kpiId; private String policyRuleId; private PolicyRuleState policyRuleState; - private int priority; + private int policyRulePriority; private List policyRuleActions; private Boolean isValid; private String exceptionMessage; public PolicyRuleBasic( String policyRuleId, - String kpiId, PolicyRuleState policyRuleState, - int priority, + int policyRulePriority, List policyRuleActions) { - try { - checkArgument(!policyRuleId.isBlank(), "Policy rule ID must not be empty."); - this.policyRuleId = policyRuleId; - this.policyRuleState = policyRuleState; - this.priority = priority; - checkArgument(priority >= 0, "Priority value must be greater or equal than zero."); - checkNotNull(kpiId, "Kpi ID must not be null."); - checkArgument(!kpiId.isBlank(), "Kpi ID must not be empty."); - this.kpiId = kpiId; - checkArgument(!policyRuleActions.isEmpty(), "Policy Rule actions cannot be empty."); - this.policyRuleActions = policyRuleActions; - this.isValid = true; - - } catch (Exception e) { - this.policyRuleId = ""; - this.priority = 0; - this.policyRuleActions = new ArrayList(); - this.isValid = false; - this.exceptionMessage = e.getMessage(); - } + checkNotNull(policyRuleId, "Policy rule ID must not be NULL."); + checkArgument(!policyRuleId.isBlank(), "Policy rule ID must not be empty."); + this.policyRuleId = policyRuleId; + this.policyRuleState = policyRuleState; + checkArgument(policyRulePriority >= 0, "Priority value must be greater than or equal to zero."); + this.policyRulePriority = policyRulePriority; + checkNotNull(policyRuleActions, "Policy rule actions cannot be NULL."); + checkArgument(!policyRuleActions.isEmpty(), "Policy rule actions cannot be empty."); + this.policyRuleActions = policyRuleActions; + this.isValid = true; } public boolean areArgumentsValid() { @@ -74,14 +61,6 @@ public class PolicyRuleBasic { return policyRuleActions; } - public String getKpiId() { - return kpiId; - } - - public void setKpiId(String kpiId) { - this.kpiId = kpiId; - } - public String getPolicyRuleId() { return policyRuleId; } @@ -98,22 +77,22 @@ public class PolicyRuleBasic { this.policyRuleState = policyRuleState; } - public int getPriority() { - return priority; + public int getPolicyRulePriority() { + return policyRulePriority; } - public void setPriority(int priority) { - this.priority = priority; + public void setPolicyRulePriority(int policyRulePriority) { + this.policyRulePriority = policyRulePriority; } @Override public String toString() { return String.format( - "%s:{policyRuleId:\"%s\", %s, priority:%d, [%s]}", + "%s:{policyRuleId:\"%s\", %s, policyRulePriority:%d, [%s]}", getClass().getSimpleName(), policyRuleId, policyRuleState, - priority, + policyRulePriority, Util.toString(policyRuleActions)); } } diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleCondition.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleCondition.java deleted file mode 100644 index 84e9ebb60..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleCondition.java +++ /dev/null @@ -1,83 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.policy.model; - -import static com.google.common.base.Preconditions.checkArgument; -import static com.google.common.base.Preconditions.checkNotNull; - -import org.etsi.tfs.policy.monitoring.model.KpiValue; - -public class PolicyRuleCondition { - - private final String kpiId; - private final NumericalOperator numericalOperator; - private final KpiValue kpiValue; - - public PolicyRuleCondition( - String kpiId, NumericalOperator numericalOperator, KpiValue kpiValue) { - checkNotNull(kpiId, "Kpi ID must not be null."); - checkArgument(!kpiId.isBlank(), "Kpi ID must not be empty."); - this.kpiId = kpiId; - checkArgument( - numericalOperator != NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_UNDEFINED, - "Numerical operator cannot be undefined"); - this.numericalOperator = numericalOperator; - checkNotNull(kpiValue, "Kpi value must not be null."); - checkArgument( - isKpiValueValid(kpiValue), - "Kpi value must be: String, Float, Boolean or Integer but it was [%s].", - kpiValue.getValue().getClass().getName()); - this.kpiValue = kpiValue; - } - - public String getKpiId() { - return kpiId; - } - - public NumericalOperator getNumericalOperator() { - return numericalOperator; - } - - public KpiValue getKpiValue() { - return kpiValue; - } - - private boolean isKpiValueValid(KpiValue kpiValue) { - final var kpiValueType = kpiValue.getValue(); - - if (kpiValueType instanceof String) { - return true; - } - - if (kpiValueType instanceof Boolean) { - return true; - } - - if (kpiValueType instanceof Integer) { - return true; - } - - return kpiValueType instanceof Float; - } - - @Override - public String toString() { - return String.format( - "%s:{kpiId:\"%s\", numericalOperator:\"%s\", %s}", - getClass().getSimpleName(), kpiId, numericalOperator.toString(), kpiValue); - } -} diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleService.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleService.java index 7859b9b25..607ea65e2 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleService.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleService.java @@ -35,11 +35,11 @@ public class PolicyRuleService extends PolicyRuleBase { try { this.policyRuleBasic = policyRuleBasic; checkArgument( - !serviceId.getContextId().isBlank(), "Context Id of Service Id must not be empty."); - checkArgument(!serviceId.getId().isBlank(), "Service Id must not be empty."); + !serviceId.getContextId().isBlank(), "Context ID of Service ID must not be empty."); + checkArgument(!serviceId.getId().isBlank(), "Service ID must not be empty."); this.serviceId = serviceId; // TODO If device list not empty - // checkArgument(!deviceIds.isEmpty(), "Device Ids must not be empty."); + // checkArgument(!deviceIds.isEmpty(), "Device IDs must not be empty."); this.deviceIds = deviceIds; this.isValid = true; this.exceptionMessage = ""; diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/service/PolicyRuleConditionFieldsGetter.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/service/PolicyRuleConditionFieldsGetter.java deleted file mode 100644 index 0e955e43e..000000000 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/service/PolicyRuleConditionFieldsGetter.java +++ /dev/null @@ -1,47 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy.policy.service; - -import jakarta.inject.Singleton; -import java.util.List; -import java.util.stream.Collectors; -import org.etsi.tfs.policy.monitoring.model.KpiValue; -import org.etsi.tfs.policy.policy.model.NumericalOperator; -import org.etsi.tfs.policy.policy.model.PolicyRuleCondition; - -@Singleton -public class PolicyRuleConditionFieldsGetter { - - public List getKpiIds(List policyRuleConditions) { - return policyRuleConditions.stream() - .map(PolicyRuleCondition::getKpiId) - .collect(Collectors.toList()); - } - - public List getKpiValues(List policyRuleConditions) { - return policyRuleConditions.stream() - .map(PolicyRuleCondition::getKpiValue) - .collect(Collectors.toList()); - } - - public List getNumericalOperators( - List policyRuleConditions) { - return policyRuleConditions.stream() - .map(PolicyRuleCondition::getNumericalOperator) - .collect(Collectors.toList()); - } -} diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddDeviceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddDeviceTest.java index 3e0837449..a9545f338 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddDeviceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddDeviceTest.java @@ -32,16 +32,11 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.etsi.tfs.policy.context.ContextService; -import org.etsi.tfs.policy.monitoring.MonitoringService; -import org.etsi.tfs.policy.monitoring.model.IntegerKpiValue; -import org.etsi.tfs.policy.monitoring.model.KpiValue; import org.etsi.tfs.policy.policy.PolicyServiceImpl; -import org.etsi.tfs.policy.policy.model.NumericalOperator; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum; import org.etsi.tfs.policy.policy.model.PolicyRuleBasic; -import org.etsi.tfs.policy.policy.model.PolicyRuleCondition; import org.etsi.tfs.policy.policy.model.PolicyRuleDevice; import org.etsi.tfs.policy.policy.model.PolicyRuleState; import org.etsi.tfs.policy.policy.model.PolicyRuleStateEnum; @@ -59,7 +54,6 @@ class PolicyAddDeviceTest { @InjectMock ContextService contextService; - @InjectMock MonitoringService monitoringService; static PolicyRuleBasic policyRuleBasic; static PolicyRuleDevice policyRuleDevice; @@ -67,11 +61,6 @@ class PolicyAddDeviceTest { static void init() { String policyId = "policyRuleId"; - KpiValue kpiValue = new IntegerKpiValue(100); - - PolicyRuleCondition policyRuleCondition = - new PolicyRuleCondition( - "kpiId", NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, kpiValue); PolicyRuleActionConfig policyRuleActionConfig = new PolicyRuleActionConfig("key", "value"); @@ -83,7 +72,6 @@ class PolicyAddDeviceTest { policyRuleBasic = new PolicyRuleBasic( policyId, - "kpiId", new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), 1, Arrays.asList(policyRuleAction)); @@ -122,7 +110,6 @@ class PolicyAddDeviceTest { PolicyRuleBasic policyRuleBasic = new PolicyRuleBasic( "policyId", - "kpiId", new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), 0, new ArrayList<>()); @@ -132,7 +119,7 @@ class PolicyAddDeviceTest { PolicyRuleState expectedResult = new PolicyRuleState( - PolicyRuleStateEnum.POLICY_FAILED, "Policy Rule actions cannot be empty."); + PolicyRuleStateEnum.POLICY_FAILED, "Policy rule actions cannot be empty."); policyService .addPolicyDevice(policyRuleDevice) @@ -203,45 +190,4 @@ class PolicyAddDeviceTest { assertThat(message.get(5, TimeUnit.SECONDS).getPolicyRuleStateMessage()) .isEqualTo(expectedResult.getPolicyRuleStateMessage().toString()); } - - // @Test - // void failurePolicyDevice() throws ExecutionException, InterruptedException, TimeoutException - // { - // CompletableFuture message = new CompletableFuture<>(); - // - // PolicyRuleDevice policyRuleDevice = - // new PolicyRuleDevice(policyRuleBasic, Arrays.asList("device1", "device2")); - // - // // String expectedResult = "Failed1 to set policy rule for testing purposes."; - // - // PolicyRuleState expectedResult = - // new PolicyRuleState( - // PolicyRuleStateEnum.POLICY_VALIDATED, - // "Failed1 to set policy rule for testing purposes."); - // - // Mockito.when(policyRuleConditionValidator.isDeviceIdValid(Mockito.anyString())) - // .thenReturn(Uni.createFrom().item(Boolean.TRUE)); - // - // Mockito.when(contextService.setPolicyRule(Mockito.any())) - // .thenReturn( - // Uni.createFrom() - // .failure( - // new ExternalServiceFailureException( - // "Failed to set policy rule for testing - // purposes."))); - // - // policyService - // .addPolicyDevice(policyRuleDevice) - // .subscribe() - // .with( - // item -> {}, - // error -> { - // - // assertThat(error.getMessage()).isEqualTo(expectedResult.getPolicyRuleStateMessage()); - // message.completeExceptionally(error); - // }); - // - // assertThat(message.get(5, TimeUnit.SECONDS).getMessage()) - // .isEqualTo(expectedResult.getPolicyRuleStateMessage().toString()); - // } } diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddServiceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddServiceTest.java index f14b51735..95b8655c4 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddServiceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddServiceTest.java @@ -35,17 +35,12 @@ import org.etsi.tfs.policy.context.ContextService; import org.etsi.tfs.policy.context.model.Service; import org.etsi.tfs.policy.context.model.ServiceId; import org.etsi.tfs.policy.context.model.ServiceTypeEnum; -import org.etsi.tfs.policy.monitoring.MonitoringService; -import org.etsi.tfs.policy.monitoring.model.IntegerKpiValue; -import org.etsi.tfs.policy.monitoring.model.KpiValue; import org.etsi.tfs.policy.policy.PolicyServiceImpl; -import org.etsi.tfs.policy.policy.model.NumericalOperator; import org.etsi.tfs.policy.policy.model.PolicyRule; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum; import org.etsi.tfs.policy.policy.model.PolicyRuleBasic; -import org.etsi.tfs.policy.policy.model.PolicyRuleCondition; import org.etsi.tfs.policy.policy.model.PolicyRuleService; import org.etsi.tfs.policy.policy.model.PolicyRuleState; import org.etsi.tfs.policy.policy.model.PolicyRuleStateEnum; @@ -63,8 +58,6 @@ public class PolicyAddServiceTest { @InjectMock ContextService contextService; - @InjectMock MonitoringService monitoringService; - static PolicyRuleBasic policyRuleBasic; static PolicyRuleService policyRuleService; @@ -72,11 +65,6 @@ public class PolicyAddServiceTest { static void init() { String policyId = "policyRuleId"; - KpiValue kpiValue = new IntegerKpiValue(100); - - PolicyRuleCondition policyRuleCondition = - new PolicyRuleCondition( - "kpiId", NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, kpiValue); PolicyRuleActionConfig policyRuleActionConfig = new PolicyRuleActionConfig("key", "value"); @@ -88,7 +76,6 @@ public class PolicyAddServiceTest { policyRuleBasic = new PolicyRuleBasic( policyId, - "kpiId", new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), 1, Arrays.asList(policyRuleAction)); @@ -115,7 +102,7 @@ public class PolicyAddServiceTest { PolicyRuleState expectedResult = new PolicyRuleState( - PolicyRuleStateEnum.POLICY_FAILED, "Context Id of Service Id must not be empty."); + PolicyRuleStateEnum.POLICY_FAILED, "Context ID of Service ID must not be empty."); policyService .addPolicyService(policyRuleService) @@ -140,7 +127,7 @@ public class PolicyAddServiceTest { new PolicyRuleService(policyRuleBasic, serviceId, deviceIds); PolicyRuleState expectedResult = - new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED, "Service Id must not be empty."); + new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED, "Service ID must not be empty."); policyService .addPolicyService(policyRuleService) @@ -161,7 +148,6 @@ public class PolicyAddServiceTest { PolicyRuleBasic policyRuleBasic = new PolicyRuleBasic( policyId, - "kpiId", new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), 1, new ArrayList<>()); diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyDeleteServiceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyDeleteServiceTest.java index 47d1c0b81..1d3444e14 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyDeleteServiceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyDeleteServiceTest.java @@ -33,17 +33,12 @@ import org.etsi.tfs.policy.context.ContextService; import org.etsi.tfs.policy.context.model.Service; import org.etsi.tfs.policy.context.model.ServiceId; import org.etsi.tfs.policy.context.model.ServiceTypeEnum; -import org.etsi.tfs.policy.monitoring.MonitoringService; -import org.etsi.tfs.policy.monitoring.model.IntegerKpiValue; -import org.etsi.tfs.policy.monitoring.model.KpiValue; import org.etsi.tfs.policy.policy.PolicyServiceImpl; -import org.etsi.tfs.policy.policy.model.NumericalOperator; import org.etsi.tfs.policy.policy.model.PolicyRule; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum; import org.etsi.tfs.policy.policy.model.PolicyRuleBasic; -import org.etsi.tfs.policy.policy.model.PolicyRuleCondition; import org.etsi.tfs.policy.policy.model.PolicyRuleService; import org.etsi.tfs.policy.policy.model.PolicyRuleState; import org.etsi.tfs.policy.policy.model.PolicyRuleStateEnum; @@ -59,8 +54,6 @@ class PolicyDeleteServiceTest { @Inject PolicyServiceImpl policyService; @InjectMock ContextService contextService; - @InjectMock MonitoringService monitoringService; - static PolicyRuleBasic policyRuleBasic; static PolicyRuleService policyRuleService; @@ -68,11 +61,6 @@ class PolicyDeleteServiceTest { static void init() { String policyId = "policyRuleId"; - KpiValue kpiValue = new IntegerKpiValue(100); - - PolicyRuleCondition policyRuleCondition = - new PolicyRuleCondition( - "kpiId", NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, kpiValue); PolicyRuleActionConfig policyRuleActionConfig = new PolicyRuleActionConfig("key", "value"); @@ -84,7 +72,6 @@ class PolicyDeleteServiceTest { policyRuleBasic = new PolicyRuleBasic( policyId, - "kpiId", new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors1"), 1, Arrays.asList(policyRuleAction)); diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyGrpcServiceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyGrpcServiceTest.java index 084841499..577fbea02 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyGrpcServiceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyGrpcServiceTest.java @@ -19,7 +19,6 @@ package org.etsi.tfs.policy; import static org.assertj.core.api.Assertions.assertThat; import context.ContextOuterClass; -import context.ContextOuterClass.Uuid; import io.quarkus.grpc.GrpcClient; import io.quarkus.test.junit.QuarkusTest; import jakarta.inject.Inject; @@ -29,9 +28,6 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import monitoring.Monitoring.KpiId; -import org.etsi.tfs.policy.monitoring.model.FloatKpiValue; -import org.etsi.tfs.policy.monitoring.model.IntegerKpiValue; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; import org.jboss.logging.Logger; import org.junit.jupiter.api.Test; @@ -40,9 +36,6 @@ import policy.Policy.PolicyRuleBasic; import policy.Policy.PolicyRuleStateEnum; import policy.PolicyAction; import policy.PolicyAction.PolicyRuleActionEnum; -import policy.PolicyCondition; -import policy.PolicyCondition.NumericalOperator; -import policy.PolicyCondition.PolicyRuleCondition; import policy.PolicyService; @QuarkusTest @@ -83,35 +76,6 @@ class PolicyGrpcServiceTest { .setPolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED) .build(); - final var expectedFirstKpiValue = new IntegerKpiValue(22); - final var expectedSecondKpiValue = new FloatKpiValue(69.1f); - - final var serializedExpectedFirstKpiValue = serializer.serialize(expectedFirstKpiValue); - final var serializedExpectedSecondKpiValue = serializer.serialize(expectedSecondKpiValue); - - final var firstExpectedPolicyRuleCondition = - PolicyRuleCondition.newBuilder() - .setKpiId( - KpiId.newBuilder() - .setKpiId( - Uuid.newBuilder().setUuid("79e49ba3-a7b4-4b4b-8aaa-28b05c6f888e").build())) - .setNumericalOperator(NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_EQUAL) - .setKpiValue(serializedExpectedFirstKpiValue) - .build(); - - final var secondExpectedPolicyRuleCondition = - PolicyCondition.PolicyRuleCondition.newBuilder() - .setKpiId( - KpiId.newBuilder() - .setKpiId( - Uuid.newBuilder().setUuid("eae900e5-2703-467d-82f2-97aae8b55c15").build())) - .setNumericalOperator(NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN) - .setKpiValue(serializedExpectedSecondKpiValue) - .build(); - - final var expectedPolicyRuleConditions = - List.of(firstExpectedPolicyRuleCondition, secondExpectedPolicyRuleCondition); - PolicyRuleActionConfig policyRuleActionConfig_1 = new PolicyRuleActionConfig("paramater1", "parameter2"); final var serializedPolicyRuleActionConfigList_1 = diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleBasicValidationTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleBasicValidationTest.java index b2bebd343..c4d01d6b8 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleBasicValidationTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleBasicValidationTest.java @@ -23,39 +23,25 @@ import io.quarkus.test.junit.QuarkusTest; import java.util.Collections; import java.util.List; import java.util.UUID; -import org.etsi.tfs.policy.monitoring.model.IntegerKpiValue; -import org.etsi.tfs.policy.monitoring.model.KpiValue; -import org.etsi.tfs.policy.policy.model.BooleanOperator; -import org.etsi.tfs.policy.policy.model.NumericalOperator; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum; import org.etsi.tfs.policy.policy.model.PolicyRuleBasic; -import org.etsi.tfs.policy.policy.model.PolicyRuleCondition; import org.etsi.tfs.policy.policy.model.PolicyRuleState; import org.etsi.tfs.policy.policy.model.PolicyRuleStateEnum; import org.junit.jupiter.api.Test; -// TODO: Revisit PolicyRuleBasicValidationTest cases after handling exceptions in PolicyRuleBasic -// constructor @QuarkusTest class PolicyRuleBasicValidationTestHelper { private PolicyRuleBasic createPolicyRuleBasic( String policyRuleId, - String kpiId, PolicyRuleState policyRuleState, - int priority, + int policyRulePriority, List policyRuleActions) { - return new PolicyRuleBasic(policyRuleId, kpiId, policyRuleState, priority, policyRuleActions); - } - - private List createPolicyRuleConditions( - String kpiId, NumericalOperator numericalOperator, KpiValue kpiValue) { - final var policyRuleCondition = new PolicyRuleCondition(kpiId, numericalOperator, kpiValue); - - return List.of(policyRuleCondition); + return new PolicyRuleBasic( + policyRuleId, policyRuleState, policyRulePriority, policyRuleActions); } private List createPolicyRuleActions( @@ -67,11 +53,6 @@ class PolicyRuleBasicValidationTestHelper { @Test void shouldThrowNullPointerExceptionGivenNullPolicyRuleId() { - final var policyRuleConditions = - createPolicyRuleConditions( - UUID.randomUUID().toString(), - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN, - new IntegerKpiValue(3)); final var policyRuleActions = createPolicyRuleActions( PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT, @@ -82,16 +63,11 @@ class PolicyRuleBasicValidationTestHelper { final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1"); assertThatExceptionOfType(NullPointerException.class) - .isThrownBy(() -> createPolicyRuleBasic(null, "", policyRuleState, 3, policyRuleActions)); + .isThrownBy(() -> createPolicyRuleBasic(null, policyRuleState, 3, policyRuleActions)); } @Test void shouldThrowIllegalArgumentExceptionGivenEmptyPolicyRuleId() { - final var policyRuleConditions = - createPolicyRuleConditions( - UUID.randomUUID().toString(), - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, - new IntegerKpiValue(3)); final var policyRuleActions = createPolicyRuleActions( PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE, @@ -102,16 +78,11 @@ class PolicyRuleBasicValidationTestHelper { final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_ENFORCED, "1"); assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> createPolicyRuleBasic("", "", policyRuleState, 3, policyRuleActions)); + .isThrownBy(() -> createPolicyRuleBasic("", policyRuleState, 3, policyRuleActions)); } @Test void shouldThrowIllegalArgumentExceptionGivenWhiteSpacedPolicyRuleId() { - final var policyRuleConditions = - createPolicyRuleConditions( - UUID.randomUUID().toString(), - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_NOT_EQUAL, - new IntegerKpiValue(3)); final var policyRuleActions = createPolicyRuleActions( PolicyRuleActionEnum.POLICY_RULE_ACTION_NO_ACTION, @@ -122,16 +93,11 @@ class PolicyRuleBasicValidationTestHelper { final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_ENFORCED, "1"); assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> createPolicyRuleBasic(" ", "", policyRuleState, 3, policyRuleActions)); + .isThrownBy(() -> createPolicyRuleBasic(" ", policyRuleState, 3, policyRuleActions)); } @Test void shouldThrowIllegalArgumentExceptionGivenNegativePriority() { - final var policyRuleConditions = - createPolicyRuleConditions( - UUID.randomUUID().toString(), - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL, - new IntegerKpiValue(3)); final var policyRuleActions = createPolicyRuleActions( PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS, @@ -145,89 +111,21 @@ class PolicyRuleBasicValidationTestHelper { assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( - () -> createPolicyRuleBasic(policyRuleId, "", policyRuleState, 3, policyRuleActions)); - } - - @Test - void shouldThrowNullPointerExceptionGivenNullPolicyRuleConditions() { - final var policyRuleActions = - createPolicyRuleActions( - PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE, - List.of( - new PolicyRuleActionConfig( - UUID.randomUUID().toString(), UUID.randomUUID().toString()))); - - final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_ENFORCED, "1"); - - final var policyRuleId = UUID.randomUUID().toString(); - - assertThatExceptionOfType(NullPointerException.class) - .isThrownBy(() -> createPolicyRuleBasic(null, "", policyRuleState, 3, policyRuleActions)); - } - - @Test - void shouldThrowIllegalArgumentExceptionGivenEmptyPolicyRuleConditions() { - final var policyRuleConditions = Collections.emptyList(); - final var policyRuleActions = - createPolicyRuleActions( - PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE, - List.of( - new PolicyRuleActionConfig( - UUID.randomUUID().toString(), UUID.randomUUID().toString()))); - - final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_REMOVED, "1"); - - final var policyRuleId = UUID.randomUUID().toString(); - - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> createPolicyRuleBasic(null, "", policyRuleState, 3, policyRuleActions)); - } - - @Test - void shouldThrowIllegalArgumentExceptionGivenUndefinedBooleanOperator() { - final var policyRuleConditions = - createPolicyRuleConditions( - UUID.randomUUID().toString(), - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, - new IntegerKpiValue(3)); - final var policyRuleActions = - createPolicyRuleActions( - PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE, - List.of( - new PolicyRuleActionConfig( - UUID.randomUUID().toString(), UUID.randomUUID().toString()))); - - final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_VALIDATED, "1"); - - final var policyRuleId = UUID.randomUUID().toString(); - - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> createPolicyRuleBasic(null, "", policyRuleState, 3, policyRuleActions)); + () -> createPolicyRuleBasic(policyRuleId, policyRuleState, -1, policyRuleActions)); } @Test void shouldThrowNullPointerExceptionGivenNullPolicyRuleActions() { - final var policyRuleConditions = - createPolicyRuleConditions( - UUID.randomUUID().toString(), - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, - new IntegerKpiValue(3)); - final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_PROVISIONED, "1"); final var policyRuleId = UUID.randomUUID().toString(); assertThatExceptionOfType(NullPointerException.class) - .isThrownBy(() -> createPolicyRuleBasic(null, "", policyRuleState, 3, null)); + .isThrownBy(() -> createPolicyRuleBasic(policyRuleId, policyRuleState, 3, null)); } @Test - void shouldThrowIllegalArgumentExceptionGivenEmptyPolicyPolicyRuleActions() { - final var policyRuleConditions = - createPolicyRuleConditions( - UUID.randomUUID().toString(), - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, - new IntegerKpiValue(3)); + void shouldThrowIllegalArgumentExceptionGivenEmptyPolicyRuleActions() { final var policyRuleActions = Collections.emptyList(); final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED, "1"); @@ -235,7 +133,8 @@ class PolicyRuleBasicValidationTestHelper { final var policyRuleId = UUID.randomUUID().toString(); assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> createPolicyRuleBasic(null, "", policyRuleState, 3, policyRuleActions)); + .isThrownBy( + () -> createPolicyRuleBasic(policyRuleId, policyRuleState, 3, policyRuleActions)); } @Test @@ -245,18 +144,6 @@ class PolicyRuleBasicValidationTestHelper { new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1"); final var expectedPriority = 3; - final var firstKpiValue = new IntegerKpiValue(22); - - final var firstExpectedPolicyRuleCondition = - new PolicyRuleCondition( - "firstExpectedPolicyRuleConditionVariable", - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, - firstKpiValue); - - final var expectedPolicyRuleConditions = List.of(firstExpectedPolicyRuleCondition); - - final var expectedBooleanOperator = BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_OR; - final var firstExpectedPolicyRuleAction = new PolicyRuleAction( PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS, @@ -267,16 +154,10 @@ class PolicyRuleBasicValidationTestHelper { final var expectedPolicyRuleBasic = new PolicyRuleBasic( expectedPolicyRuleId, - "kpiId", expectedPolicyRuleState, expectedPriority, expectedPolicyRuleActions); - final var policyRuleConditions = - createPolicyRuleConditions( - "firstExpectedPolicyRuleConditionVariable", - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, - new IntegerKpiValue(22)); final var policyRuleActions = createPolicyRuleActions( PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS, @@ -285,7 +166,7 @@ class PolicyRuleBasicValidationTestHelper { final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1"); final var policyRuleBasic = - createPolicyRuleBasic(null, "kpiId", policyRuleState, 3, policyRuleActions); + createPolicyRuleBasic(expectedPolicyRuleId, policyRuleState, 3, policyRuleActions); assertThat(policyRuleBasic).usingRecursiveComparison().isEqualTo(expectedPolicyRuleBasic); } diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleConditionValidationTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleConditionValidationTest.java deleted file mode 100644 index 1d523c9a2..000000000 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleConditionValidationTest.java +++ /dev/null @@ -1,139 +0,0 @@ -/* - * Copyright 2022-2025 ETSI SDG TeraFlowSDN (TFS) (https://tfs.etsi.org/) - * - * 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. - */ - -package org.etsi.tfs.policy; - -import static org.assertj.core.api.Assertions.assertThat; -import static org.assertj.core.api.Assertions.assertThatExceptionOfType; - -import io.quarkus.test.junit.QuarkusTest; -import java.util.stream.Stream; -import org.etsi.tfs.policy.monitoring.model.BooleanKpiValue; -import org.etsi.tfs.policy.monitoring.model.FloatKpiValue; -import org.etsi.tfs.policy.monitoring.model.IntegerKpiValue; -import org.etsi.tfs.policy.monitoring.model.KpiValue; -import org.etsi.tfs.policy.monitoring.model.StringKpiValue; -import org.etsi.tfs.policy.policy.model.NumericalOperator; -import org.etsi.tfs.policy.policy.model.PolicyRuleCondition; -import org.junit.jupiter.api.Test; -import org.junit.jupiter.params.ParameterizedTest; -import org.junit.jupiter.params.provider.Arguments; -import org.junit.jupiter.params.provider.MethodSource; -import org.mockito.Mockito; - -@QuarkusTest -class PolicyRuleConditionValidationTest { - - private PolicyRuleCondition createPolicyRuleCondition( - String kpiId, NumericalOperator numericalOperator, KpiValue kpiValue) { - - return new PolicyRuleCondition(kpiId, numericalOperator, kpiValue); - } - - private static Stream provideKpiValues() { - return Stream.of( - Arguments.of(new StringKpiValue("stringKpiValue")), - Arguments.of(new BooleanKpiValue(true)), - Arguments.of(new IntegerKpiValue(44)), - Arguments.of(new FloatKpiValue(12.3f))); - } - - @ParameterizedTest - @MethodSource("provideKpiValues") - void shouldThrowNullPointerExceptionGivenNullKpiId(KpiValue kpiValue) { - assertThatExceptionOfType(NullPointerException.class) - .isThrownBy( - () -> - createPolicyRuleCondition( - null, - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, - kpiValue)); - } - - @ParameterizedTest - @MethodSource("provideKpiValues") - void shouldThrowIllegalArgumentExceptionGivenEmptyKpiId(KpiValue kpiValue) { - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy( - () -> - createPolicyRuleCondition( - "", NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_NOT_EQUAL, kpiValue)); - } - - @ParameterizedTest - @MethodSource("provideKpiValues") - void shouldThrowIllegalArgumentExceptionGivenWhiteSpacedKpiId(KpiValue kpiValue) { - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy( - () -> - createPolicyRuleCondition( - " ", NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_NOT_EQUAL, kpiValue)); - } - - @ParameterizedTest - @MethodSource("provideKpiValues") - void shouldThrowIllegalArgumentExceptionGivenUndefinedNumericalOperator(KpiValue kpiValue) { - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy( - () -> - createPolicyRuleCondition( - "kpiId", - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_UNDEFINED, - kpiValue)); - } - - @Test - void shouldThrowNullPointerExceptionGivenNullKpiValue() { - assertThatExceptionOfType(NullPointerException.class) - .isThrownBy( - () -> - createPolicyRuleCondition( - "kpiId", NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, null)); - } - - @Test - void shouldThrowIllegalArgumentExceptionIfIsKpiValueIsOfInvalidType() { - final var kpiValue = Mockito.mock(KpiValue.class); - Mockito.when(kpiValue.getValue()).thenReturn(1_2L); - - assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy( - () -> - createPolicyRuleCondition( - "kpiId", - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, - kpiValue)); - } - - @ParameterizedTest - @MethodSource("provideKpiValues") - void shouldCreatePolicyRuleConditionObject(KpiValue kpiValue) { - final var expectedKpiId = "expectedKpiId"; - final var expectedNumericalOperator = - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN; - - final var expectedPolicyRuleCondition = - new PolicyRuleCondition(expectedKpiId, expectedNumericalOperator, kpiValue); - - final var policyRuleCondition = - createPolicyRuleCondition( - "expectedKpiId", NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN, kpiValue); - - assertThat(policyRuleCondition) - .usingRecursiveComparison() - .isEqualTo(expectedPolicyRuleCondition); - } -} diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleDeviceValidationTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleDeviceValidationTest.java index 1a4720e3a..a2bdfbb73 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleDeviceValidationTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleDeviceValidationTest.java @@ -21,14 +21,10 @@ import static org.assertj.core.api.Assertions.assertThat; import io.quarkus.test.junit.QuarkusTest; import java.util.List; import java.util.UUID; -import org.etsi.tfs.policy.monitoring.model.IntegerKpiValue; -import org.etsi.tfs.policy.monitoring.model.KpiValue; -import org.etsi.tfs.policy.policy.model.NumericalOperator; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum; import org.etsi.tfs.policy.policy.model.PolicyRuleBasic; -import org.etsi.tfs.policy.policy.model.PolicyRuleCondition; import org.etsi.tfs.policy.policy.model.PolicyRuleDevice; import org.etsi.tfs.policy.policy.model.PolicyRuleState; import org.etsi.tfs.policy.policy.model.PolicyRuleStateEnum; @@ -39,19 +35,11 @@ class PolicyRuleDeviceValidationTest { private PolicyRuleBasic createPolicyRuleBasic( String policyRuleId, - String kpiId, PolicyRuleState policyRuleState, int priority, List policyRuleActions) { - return new PolicyRuleBasic(policyRuleId, kpiId, policyRuleState, priority, policyRuleActions); - } - - private List createPolicyRuleConditions( - String kpiId, NumericalOperator numericalOperator, KpiValue kpiValue) { - final var policyRuleCondition = new PolicyRuleCondition(kpiId, numericalOperator, kpiValue); - - return List.of(policyRuleCondition); + return new PolicyRuleBasic(policyRuleId, policyRuleState, priority, policyRuleActions); } private List createPolicyRuleActions( @@ -71,79 +59,8 @@ class PolicyRuleDeviceValidationTest { return List.of("deviceId1", "deviceId2"); } - // @Test - // void shouldThrowNullPointerExceptionGivenNullPolicyRuleBasic() { - // final var deviceIds = createDeviceIds(); - - // assertThatExceptionOfType(NullPointerException.class) - // .isThrownBy(() -> createPolicyRuleDevice(null, deviceIds)); - // } - - // @Test - // void shouldThrowNullPointerExceptionGivenNullDeviceIds() { - // final var policyRuleConditions = - // createPolicyRuleConditions( - // UUID.randomUUID().toString(), - // NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN, - // new IntegerKpiValue(3)); - // final var policyRuleActions = - // createPolicyRuleActions( - // PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT, - // List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); - - // final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, - // "1"); - - // final var policyRuleBasic = - // createPolicyRuleBasic( - // "policyRuleId", - // 3, - // policyRuleState, - // BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_OR, - // policyRuleConditions, - // policyRuleActions); - - // assertThatExceptionOfType(NullPointerException.class) - // .isThrownBy(() -> createPolicyRuleDevice(policyRuleBasic, null)); - // } - - // @Test - // void shouldThrowIllegalArgumentExceptionGivenEmptyDeviceIds() { - // final var policyRuleConditions = - // createPolicyRuleConditions( - // UUID.randomUUID().toString(), - // NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL, - // new IntegerKpiValue(3)); - // final var policyRuleActions = - // createPolicyRuleActions( - // PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE, - // List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); - - // final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, - // "1"); - - // final var policyRuleBasic = - // createPolicyRuleBasic( - // "policyRuleId1", - // 213, - // policyRuleState, - // BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_AND, - // policyRuleConditions, - // policyRuleActions); - - // final var deviceIds = Collections.emptyList(); - - // assertThatExceptionOfType(IllegalArgumentException.class) - // .isThrownBy(() -> createPolicyRuleDevice(policyRuleBasic, deviceIds)); - // } - @Test void shouldCreatePolicyRuleDeviceObject() { - final var policyRuleConditions = - createPolicyRuleConditions( - UUID.randomUUID().toString(), - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_NOT_EQUAL, - new IntegerKpiValue(3)); final var policyRuleActions = createPolicyRuleActions( PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS, @@ -154,7 +71,7 @@ class PolicyRuleDeviceValidationTest { final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1"); final var policyRuleBasic = - createPolicyRuleBasic("policyRuleId", "", policyRuleState, 3, policyRuleActions); + createPolicyRuleBasic("policyRuleId", policyRuleState, 3, policyRuleActions); final var deviceIds = createDeviceIds(); diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleServiceValidationTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleServiceValidationTest.java index 05bd3e847..0294304f3 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleServiceValidationTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleServiceValidationTest.java @@ -42,14 +42,10 @@ import org.etsi.tfs.policy.context.model.LocationTypeRegion; import org.etsi.tfs.policy.context.model.ServiceId; import org.etsi.tfs.policy.context.model.TopologyId; import org.etsi.tfs.policy.kpi_sample_types.model.KpiSampleType; -import org.etsi.tfs.policy.monitoring.model.IntegerKpiValue; -import org.etsi.tfs.policy.monitoring.model.KpiValue; -import org.etsi.tfs.policy.policy.model.NumericalOperator; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum; import org.etsi.tfs.policy.policy.model.PolicyRuleBasic; -import org.etsi.tfs.policy.policy.model.PolicyRuleCondition; import org.etsi.tfs.policy.policy.model.PolicyRuleService; import org.etsi.tfs.policy.policy.model.PolicyRuleState; import org.etsi.tfs.policy.policy.model.PolicyRuleStateEnum; @@ -128,13 +124,6 @@ class PolicyRuleServiceValidationTest { endPoints); } - private List createPolicyRuleConditions( - String kpiId, NumericalOperator numericalOperator, KpiValue kpiValue) { - final var policyRuleCondition = new PolicyRuleCondition(kpiId, numericalOperator, kpiValue); - - return List.of(policyRuleCondition); - } - private List createPolicyRuleActions( PolicyRuleActionEnum policyRuleActionEnum, List parameters) { final var policyRuleAction = new PolicyRuleAction(policyRuleActionEnum, parameters); @@ -144,12 +133,11 @@ class PolicyRuleServiceValidationTest { private PolicyRuleBasic createPolicyRuleBasic( String policyRuleId, - String kpiId, PolicyRuleState policyRuleState, int priority, List policyRuleActions) { - return new PolicyRuleBasic(policyRuleId, kpiId, policyRuleState, priority, policyRuleActions); + return new PolicyRuleBasic(policyRuleId, policyRuleState, priority, policyRuleActions); } private ServiceId createServiceId(String contextId, String id) { @@ -166,85 +154,11 @@ class PolicyRuleServiceValidationTest { return new PolicyRuleService(policyRuleBasic, serviceId, deviceIds); } - // @Test - // void shouldThrowNullPointerExceptionGivenNullPolicyRuleBasic() { - // final var serviceId = createServiceId("CONTEXT_ID", "id"); - // final var deviceIds = createDeviceIds(); - - // assertThatExceptionOfType(NullPointerException.class) - // .isThrownBy(() -> createPolicyRuleService(null, serviceId, deviceIds)); - // } - - // @Test - // void shouldThrowNullPointerExceptionGivenNullServiceId() { - // final var policyRuleConditions = - // createPolicyRuleConditions( - // UUID.randomUUID().toString(), - // NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL, - // new IntegerKpiValue(3)); - // final var policyRuleActions = - // createPolicyRuleActions( - // PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT, - // List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); - - // final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, - // "1"); - - // final var deviceIds = createDeviceIds(); - - // final var policyRuleBasic = - // createPolicyRuleBasic( - // "policyRuleId1", - // 3, - // policyRuleState, - // BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_OR, - // policyRuleConditions, - // policyRuleActions); - - // assertThatExceptionOfType(NullPointerException.class) - // .isThrownBy(() -> createPolicyRuleService(policyRuleBasic, null, deviceIds)); - // } - - // @Test - // void shouldThrowNullPointerExceptionGivenNullDeviceIds() { - // final var serviceId = createServiceId("contextId", "ID"); - - // final var policyRuleConditions = - // createPolicyRuleConditions( - // UUID.randomUUID().toString(), - // NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN, - // new IntegerKpiValue(3)); - // final var policyRuleActions = - // createPolicyRuleActions( - // PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE, - // List.of(UUID.randomUUID().toString(), UUID.randomUUID().toString())); - - // final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, - // "1"); - - // final var policyRuleBasic = - // createPolicyRuleBasic( - // "policyRuleId2", - // 2, - // policyRuleState, - // BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_AND, - // policyRuleConditions, - // policyRuleActions); - - // assertThatExceptionOfType(NullPointerException.class) - // .isThrownBy(() -> createPolicyRuleService(policyRuleBasic, serviceId, null)); - // } - @Test void shouldCreatePolicyRuleServiceObjectGivenEmptyDeviceIds() { final var serviceId = createServiceId("contextId", "id"); final var deviceIds = Collections.emptyList(); - final var policyRuleConditions = - createPolicyRuleConditions( - UUID.randomUUID().toString(), - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, - new IntegerKpiValue(3)); final var policyRuleActions = createPolicyRuleActions( PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS, @@ -255,7 +169,7 @@ class PolicyRuleServiceValidationTest { final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1"); final var policyRuleBasic = - createPolicyRuleBasic("policyRuleId", "kpiId", policyRuleState, 0, policyRuleActions); + createPolicyRuleBasic("policyRuleId", policyRuleState, 0, policyRuleActions); final var expectedPolicyRuleService = new PolicyRuleService(policyRuleBasic, serviceId, deviceIds); @@ -270,11 +184,6 @@ class PolicyRuleServiceValidationTest { final var serviceId = createServiceId("contextId", "id"); final var deviceIds = List.of("deviceIdA", "deviceIdB"); - final var policyRuleConditions = - createPolicyRuleConditions( - UUID.randomUUID().toString(), - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN, - new IntegerKpiValue(3)); final var policyRuleActions = createPolicyRuleActions( PolicyRuleActionEnum.POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT, @@ -285,7 +194,7 @@ class PolicyRuleServiceValidationTest { final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1"); final var policyRuleBasic = - createPolicyRuleBasic("policyRuleId", "kpiId", policyRuleState, 0, policyRuleActions); + createPolicyRuleBasic("policyRuleId", policyRuleState, 0, policyRuleActions); final var expectedPolicyRuleService = new PolicyRuleService(policyRuleBasic, serviceId, deviceIds); diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateDeviceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateDeviceTest.java index ddc8c7b05..5daafd8dc 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateDeviceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateDeviceTest.java @@ -31,16 +31,11 @@ import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.etsi.tfs.policy.monitoring.MonitoringService; -import org.etsi.tfs.policy.monitoring.model.IntegerKpiValue; -import org.etsi.tfs.policy.monitoring.model.KpiValue; import org.etsi.tfs.policy.policy.PolicyServiceImpl; -import org.etsi.tfs.policy.policy.model.NumericalOperator; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum; import org.etsi.tfs.policy.policy.model.PolicyRuleBasic; -import org.etsi.tfs.policy.policy.model.PolicyRuleCondition; import org.etsi.tfs.policy.policy.model.PolicyRuleDevice; import org.etsi.tfs.policy.policy.model.PolicyRuleState; import org.etsi.tfs.policy.policy.model.PolicyRuleStateEnum; @@ -56,8 +51,6 @@ class PolicyUpdateDeviceTest { @InjectMock PolicyRuleConditionValidator policyRuleConditionValidator; - @InjectMock MonitoringService monitoringService; - static PolicyRuleBasic policyRuleBasic; static PolicyRuleDevice policyRuleDevice; @@ -65,11 +58,6 @@ class PolicyUpdateDeviceTest { static void init() { String policyId = "policyRuleId"; - KpiValue kpiValue = new IntegerKpiValue(100); - - PolicyRuleCondition policyRuleCondition = - new PolicyRuleCondition( - "kpiId", NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, kpiValue); PolicyRuleActionConfig policyRuleActionConfig = new PolicyRuleActionConfig("key", "value"); @@ -81,7 +69,6 @@ class PolicyUpdateDeviceTest { policyRuleBasic = new PolicyRuleBasic( policyId, - "kpiId", new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), 1, Arrays.asList(policyRuleAction)); @@ -117,20 +104,25 @@ class PolicyUpdateDeviceTest { void isPolicyRuleBasicValid() throws ExecutionException, InterruptedException, TimeoutException { CompletableFuture message = new CompletableFuture<>(); + PolicyRuleActionConfig policyRuleActionConfig = new PolicyRuleActionConfig("key", "value"); + + PolicyRuleAction policyRuleAction = + new PolicyRuleAction( + PolicyRuleActionEnum.POLICY_RULE_ACTION_NO_ACTION, + Arrays.asList(policyRuleActionConfig)); + PolicyRuleBasic policyRuleBasic = new PolicyRuleBasic( "policyId", - "kpiId", new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), 0, - new ArrayList<>()); + Arrays.asList(policyRuleAction)); PolicyRuleDevice policyRuleDevice = new PolicyRuleDevice(policyRuleBasic, Arrays.asList("device1", "device2")); PolicyRuleState expectedResult = - new PolicyRuleState( - PolicyRuleStateEnum.POLICY_FAILED, "Policy Rule actions cannot be empty."); + new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED, "policyId is invalid."); policyService .updatePolicyDevice(policyRuleDevice) diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateServiceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateServiceTest.java index 8c8bcf47e..15610f263 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateServiceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateServiceTest.java @@ -35,16 +35,11 @@ import org.etsi.tfs.policy.context.ContextService; import org.etsi.tfs.policy.context.model.Service; import org.etsi.tfs.policy.context.model.ServiceId; import org.etsi.tfs.policy.context.model.ServiceTypeEnum; -import org.etsi.tfs.policy.monitoring.MonitoringService; -import org.etsi.tfs.policy.monitoring.model.IntegerKpiValue; -import org.etsi.tfs.policy.monitoring.model.KpiValue; import org.etsi.tfs.policy.policy.PolicyServiceImpl; -import org.etsi.tfs.policy.policy.model.NumericalOperator; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum; import org.etsi.tfs.policy.policy.model.PolicyRuleBasic; -import org.etsi.tfs.policy.policy.model.PolicyRuleCondition; import org.etsi.tfs.policy.policy.model.PolicyRuleService; import org.etsi.tfs.policy.policy.model.PolicyRuleState; import org.etsi.tfs.policy.policy.model.PolicyRuleStateEnum; @@ -62,8 +57,6 @@ class PolicyUpdateServiceTest { @InjectMock ContextService contextService; - @InjectMock MonitoringService monitoringService; - static PolicyRuleBasic policyRuleBasic; static PolicyRuleService policyRuleService; @@ -71,11 +64,6 @@ class PolicyUpdateServiceTest { static void init() { String policyId = "policyRuleId"; - KpiValue kpiValue = new IntegerKpiValue(100); - - PolicyRuleCondition policyRuleCondition = - new PolicyRuleCondition( - "kpiId", NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, kpiValue); PolicyRuleActionConfig policyRuleActionConfig = new PolicyRuleActionConfig("key", "value"); @@ -87,7 +75,6 @@ class PolicyUpdateServiceTest { policyRuleBasic = new PolicyRuleBasic( policyId, - "kpiId", new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), 1, Arrays.asList(policyRuleAction)); @@ -114,7 +101,7 @@ class PolicyUpdateServiceTest { PolicyRuleState expectedResult = new PolicyRuleState( - PolicyRuleStateEnum.POLICY_FAILED, "Context Id of Service Id must not be empty."); + PolicyRuleStateEnum.POLICY_FAILED, "Context ID of Service ID must not be empty."); policyService .updatePolicyService(policyRuleService) @@ -139,7 +126,7 @@ class PolicyUpdateServiceTest { new PolicyRuleService(policyRuleBasic, serviceId, deviceIds); PolicyRuleState expectedResult = - new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED, "Service Id must not be empty."); + new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED, "Service ID must not be empty."); policyService .updatePolicyService(policyRuleService) diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/SerializerTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/SerializerTest.java index 19a7179a7..7811affd6 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/SerializerTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/SerializerTest.java @@ -30,10 +30,6 @@ import jakarta.inject.Inject; import java.util.List; import java.util.stream.Collectors; import java.util.stream.Stream; -import kpi_sample_types.KpiSampleTypes; -import monitoring.Monitoring; -import monitoring.Monitoring.AlarmID; -import monitoring.Monitoring.KpiId; import org.etsi.tfs.policy.acl.AclAction; import org.etsi.tfs.policy.acl.AclEntry; import org.etsi.tfs.policy.acl.AclForwardActionEnum; @@ -82,27 +78,12 @@ import org.etsi.tfs.policy.context.model.ServiceId; import org.etsi.tfs.policy.context.model.ServiceStatus; import org.etsi.tfs.policy.context.model.ServiceStatusEnum; import org.etsi.tfs.policy.context.model.ServiceTypeEnum; -import org.etsi.tfs.policy.context.model.SliceId; import org.etsi.tfs.policy.context.model.TopologyId; import org.etsi.tfs.policy.kpi_sample_types.model.KpiSampleType; -import org.etsi.tfs.policy.monitoring.model.AlarmDescriptor; -import org.etsi.tfs.policy.monitoring.model.AlarmResponse; -import org.etsi.tfs.policy.monitoring.model.BooleanKpiValue; -import org.etsi.tfs.policy.monitoring.model.FloatKpiValue; -import org.etsi.tfs.policy.monitoring.model.IntegerKpiValue; -import org.etsi.tfs.policy.monitoring.model.Kpi; -import org.etsi.tfs.policy.monitoring.model.KpiDescriptor; -import org.etsi.tfs.policy.monitoring.model.KpiValue; -import org.etsi.tfs.policy.monitoring.model.KpiValueRange; -import org.etsi.tfs.policy.monitoring.model.StringKpiValue; -import org.etsi.tfs.policy.monitoring.model.SubsDescriptor; -import org.etsi.tfs.policy.policy.model.BooleanOperator; -import org.etsi.tfs.policy.policy.model.NumericalOperator; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum; import org.etsi.tfs.policy.policy.model.PolicyRuleBasic; -import org.etsi.tfs.policy.policy.model.PolicyRuleCondition; import org.etsi.tfs.policy.policy.model.PolicyRuleDevice; import org.etsi.tfs.policy.policy.model.PolicyRuleService; import org.etsi.tfs.policy.policy.model.PolicyRuleState; @@ -114,7 +95,6 @@ import org.junit.jupiter.params.provider.MethodSource; import policy.Policy; import policy.Policy.PolicyRuleId; import policy.PolicyAction; -import policy.PolicyCondition; @QuarkusTest class SerializerTest { @@ -151,20 +131,6 @@ class SerializerTest { new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "Policy was effective"); final var expectedPriority = 3; - final var firstKpiValue = new IntegerKpiValue(22); - final var secondKpiValue = new FloatKpiValue(69.1f); - - final var firstExpectedPolicyRuleCondition = - new PolicyRuleCondition( - "firstExpectedPolicyRuleConditionVariable", - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, - firstKpiValue); - final var secondExpectedPolicyRuleCondition = - new PolicyRuleCondition( - "secondExpectedPolicyRuleConditionVariable", - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_EQUAL, - secondKpiValue); - final var firstExpectedPolicyRuleAction = new PolicyRuleAction( PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS, @@ -179,11 +145,7 @@ class SerializerTest { List.of(firstExpectedPolicyRuleAction, secondExpectedPolicyRuleAction); return new PolicyRuleBasic( - expectedPolicyRuleId, - "kpiId", - expectedPolicyRuleState, - expectedPriority, - expectedPolicyRuleActions); + expectedPolicyRuleId, expectedPolicyRuleState, expectedPriority, expectedPolicyRuleActions); } private ConfigRule createConfigRule() { @@ -1758,14 +1720,6 @@ class SerializerTest { assertThat(constraint).usingRecursiveComparison().isEqualTo(expectedConstraint); } - @Test - void shouldThrowIllegalStateExceptionDuringDeserializationOfNonSpecifiedConstraint() { - final var serializedKpiValue = ContextOuterClass.Constraint.newBuilder().build(); - - assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> serializer.deserialize(serializedKpiValue)); - } - @Test void shouldSerializeEndPointId() { final var expectedTopologyId = new TopologyId("contextId", "id"); @@ -2198,47 +2152,6 @@ class SerializerTest { assertThat(service).usingRecursiveComparison().isEqualTo(expectedService); } - private static Stream provideKpiSampleType() { - return Stream.of( - Arguments.of( - KpiSampleType.PACKETS_TRANSMITTED, - KpiSampleTypes.KpiSampleType.KPISAMPLETYPE_PACKETS_TRANSMITTED), - Arguments.of( - KpiSampleType.PACKETS_RECEIVED, - KpiSampleTypes.KpiSampleType.KPISAMPLETYPE_PACKETS_RECEIVED), - Arguments.of( - KpiSampleType.BYTES_TRANSMITTED, - KpiSampleTypes.KpiSampleType.KPISAMPLETYPE_BYTES_TRANSMITTED), - Arguments.of( - KpiSampleType.BYTES_RECEIVED, - KpiSampleTypes.KpiSampleType.KPISAMPLETYPE_BYTES_RECEIVED), - Arguments.of( - KpiSampleType.LINK_TOTAL_CAPACITY_GBPS, - KpiSampleTypes.KpiSampleType.KPISAMPLETYPE_LINK_TOTAL_CAPACITY_GBPS), - Arguments.of( - KpiSampleType.LINK_USED_CAPACITY_GBPS, - KpiSampleTypes.KpiSampleType.KPISAMPLETYPE_LINK_USED_CAPACITY_GBPS), - Arguments.of(KpiSampleType.UNKNOWN, KpiSampleTypes.KpiSampleType.KPISAMPLETYPE_UNKNOWN)); - } - - @ParameterizedTest - @MethodSource("provideKpiSampleType") - void shouldSerializeKpiSampleType( - KpiSampleType kpiSampleType, KpiSampleTypes.KpiSampleType expectedSerializedType) { - final var serializedKpiSampleType = serializer.serialize(kpiSampleType); - - assertThat(serializedKpiSampleType.getNumber()).isEqualTo(expectedSerializedType.getNumber()); - } - - @ParameterizedTest - @MethodSource("provideKpiSampleType") - void shouldDeserializeKpiSampleType( - KpiSampleType expectedKpiSampleType, KpiSampleTypes.KpiSampleType serializedKpiSampleType) { - final var kpiSampleType = serializer.deserialize(serializedKpiSampleType); - - assertThat(kpiSampleType).isEqualTo(expectedKpiSampleType); - } - private static Stream provideRuleState() { return Stream.of( Arguments.of( @@ -2309,666 +2222,6 @@ class SerializerTest { assertThat(policyRuleState).usingRecursiveComparison().isEqualTo(expectedPolicyRuleState); } - private static Stream provideNumericalOperator() { - return Stream.of( - Arguments.of( - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_EQUAL, - PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_EQUAL), - Arguments.of( - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_NOT_EQUAL, - PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_NOT_EQUAL), - Arguments.of( - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN, - PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_LESS_THAN), - Arguments.of( - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL, - PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL), - Arguments.of( - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, - PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN), - Arguments.of( - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL, - PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL), - Arguments.of( - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_UNDEFINED, - PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_UNDEFINED)); - } - - @ParameterizedTest - @MethodSource("provideNumericalOperator") - void shouldSerializeNumericalOperator( - NumericalOperator numericalOperator, - PolicyCondition.NumericalOperator expectedNumericalOperator) { - final var serializedNumericalOperator = serializer.serialize(numericalOperator); - - assertThat(serializedNumericalOperator).isEqualTo(expectedNumericalOperator); - } - - @ParameterizedTest - @MethodSource("provideNumericalOperator") - void shouldDeserializeNumericalOperator( - NumericalOperator expectedNumericalOperator, - PolicyCondition.NumericalOperator serializedNumericalOperator) { - final var numericalOperator = serializer.deserialize(serializedNumericalOperator); - - assertThat(numericalOperator).isEqualTo(expectedNumericalOperator); - } - - @Test - void shouldSerializeSubscriptionId() { - final var subscriptionId = "subscriptionId"; - - final var subscriptionIdUuid = serializer.serializeUuid(subscriptionId); - - final var expectedSubscriptionId = - Monitoring.SubscriptionID.newBuilder().setSubsId(subscriptionIdUuid).build(); - - final var serializedSubscriptionId = serializer.serializeSubscriptionIdId(subscriptionId); - - assertThat(serializedSubscriptionId) - .usingRecursiveComparison() - .isEqualTo(expectedSubscriptionId); - } - - @Test - void shouldDeserializeSubscriptionId() { - final var expectedSubscriptionId = "expectedSubscriptionId"; - - final var serializedSubscriptionIdUuid = serializer.serializeUuid(expectedSubscriptionId); - final var serializedSubscriptionId = - Monitoring.SubscriptionID.newBuilder().setSubsId(serializedSubscriptionIdUuid).build(); - - final var subscriptionId = serializer.deserialize(serializedSubscriptionId); - - assertThat(subscriptionId).isEqualTo(expectedSubscriptionId); - } - - private static Stream provideNumericalOperators() { - return Stream.of( - Arguments.of( - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_EQUAL, - PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_EQUAL), - Arguments.of( - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_NOT_EQUAL, - PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_NOT_EQUAL), - Arguments.of( - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN, - PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_LESS_THAN), - Arguments.of( - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL, - PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL), - Arguments.of( - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN, - PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN), - Arguments.of( - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL, - PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL)); - } - - @ParameterizedTest - @MethodSource("provideNumericalOperators") - void shouldSerializePolicyRuleConditionGivenMultipleNumericalOperators( - NumericalOperator expectedNumericalOperator) { - final var expectedPolicyRuleConditionKpiId = "expectedPolicyRuleConditionKpiId"; - final var expectedPolicyRuleConditionKpiValue = new IntegerKpiValue(34); - - final var policyRuleCondition = - new PolicyRuleCondition( - expectedPolicyRuleConditionKpiId, - expectedNumericalOperator, - expectedPolicyRuleConditionKpiValue); - - final var serializedPolicyRuleConditionKpiIdUuid = - serializer.serializeUuid(expectedPolicyRuleConditionKpiId); - final var serializedPolicyRuleConditionKpiId = - KpiId.newBuilder().setKpiId(serializedPolicyRuleConditionKpiIdUuid).build(); - final var serializedNumericalOperator = serializer.serialize(expectedNumericalOperator); - final var serializedPolicyRuleConditionKpiValue = - serializer.serializeIntegerKpiValue(expectedPolicyRuleConditionKpiValue); - - final var expectedPolicyRuleCondition = - PolicyCondition.PolicyRuleCondition.newBuilder() - .setKpiId(serializedPolicyRuleConditionKpiId) - .setNumericalOperator(serializedNumericalOperator) - .setKpiValue(serializedPolicyRuleConditionKpiValue) - .build(); - - final var serializedPolicyRuleCondition = serializer.serialize(policyRuleCondition); - - assertThat(serializedPolicyRuleCondition) - .usingRecursiveComparison() - .isEqualTo(expectedPolicyRuleCondition); - } - - private static Stream provideKpiValues() { - return Stream.of( - Arguments.of( - new StringKpiValue("stringKpiValue"), - Monitoring.KpiValue.newBuilder().setStringVal("stringKpiValue").build()), - Arguments.of( - new BooleanKpiValue(true), Monitoring.KpiValue.newBuilder().setBoolVal(true).build()), - Arguments.of( - new IntegerKpiValue(44), Monitoring.KpiValue.newBuilder().setInt32Val(44).build()), - Arguments.of( - new FloatKpiValue(12.3f), Monitoring.KpiValue.newBuilder().setFloatVal(12.3f).build())); - } - - @ParameterizedTest - @MethodSource("provideKpiValues") - void shouldSerializeKpiValues(KpiValue kpiValue, Monitoring.KpiValue expectedKpiValue) { - final var serializedKpiValue = serializer.serialize(kpiValue); - - assertThat(serializedKpiValue).isEqualTo(expectedKpiValue); - } - - @ParameterizedTest - @MethodSource("provideKpiValues") - void shouldDeserializeKpiValues( - KpiValue expectedKpiValue, Monitoring.KpiValue serializedKpiValue) { - final var kpiValue = serializer.deserialize(serializedKpiValue); - - assertThat(kpiValue).usingRecursiveComparison().isEqualTo(expectedKpiValue); - } - - @Test - void shouldThrowIllegalStateExceptionDuringDeserializationOfNonSpecifiedKpiValue() { - final var serializedKpiValue = Monitoring.KpiValue.newBuilder().build(); - - assertThatExceptionOfType(IllegalStateException.class) - .isThrownBy(() -> serializer.deserialize(serializedKpiValue)); - } - - @Test - void shouldDeserializeIntegerKpiValue() { - final var expectedKpiValue = new IntegerKpiValue(66); - - final var intValue = serializer.serializeIntegerKpiValue(expectedKpiValue); - final var deserializedKpiValue = serializer.deserializeIntegerKpiValue(intValue); - - assertThat(deserializedKpiValue).isEqualTo(expectedKpiValue.getValue()); - } - - @Test - void shouldDeserializeStringKpiValue() { - final var expectedKpiValue = new StringKpiValue("StringKpiValue"); - - final var stringValue = serializer.serializeStringKpiValue(expectedKpiValue); - final var deserializedKpiValue = serializer.deserializeStringKpiValue(stringValue); - - assertThat(deserializedKpiValue).isEqualTo(expectedKpiValue.getValue()); - } - - @Test - void shouldDeserializeFloatKpiValue() { - final var expectedKpiValue = new FloatKpiValue(2.2f); - - final var floatValue = serializer.serializeFloatKpiValue(expectedKpiValue); - final var deserializedKpiValue = serializer.deserializeFloatKpiValue(floatValue); - - assertThat(deserializedKpiValue).isEqualTo(expectedKpiValue.getValue()); - } - - @Test - void shouldDeserializeBooleanKpiValue() { - final var expectedKpiValue = new BooleanKpiValue(true); - - final var booleanValue = serializer.serializeBooleanKpiValue(expectedKpiValue); - final var deserializedKpiValue = serializer.deserializeBooleanKpiValue(booleanValue); - - assertThat(deserializedKpiValue).isEqualTo(expectedKpiValue.getValue()); - } - - private static Stream provideKpiValueRanges() { - return Stream.of( - Arguments.of( - new KpiValueRange( - new IntegerKpiValue(32), new IntegerKpiValue(42), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setInt32Val(32).build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setInt32Val(42).build()) - .build()), - Arguments.of( - new KpiValueRange( - new IntegerKpiValue(32), new FloatKpiValue(42.2f), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setInt32Val(32).build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setFloatVal(42.2f).build()) - .build()), - Arguments.of( - new KpiValueRange( - new IntegerKpiValue(32), new BooleanKpiValue(true), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setInt32Val(32).build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setBoolVal(true).build()) - .build()), - Arguments.of( - new KpiValueRange( - new IntegerKpiValue(32), new StringKpiValue("string"), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setInt32Val(32).build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setStringVal("string").build()) - .build()), - Arguments.of( - new KpiValueRange( - new FloatKpiValue(56.2f), new IntegerKpiValue(42), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setFloatVal(56.2f).build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setInt32Val(42).build()) - .build()), - Arguments.of( - new KpiValueRange( - new FloatKpiValue(56.2f), new FloatKpiValue(42.2f), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setFloatVal(56.2f).build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setFloatVal(42.2f).build()) - .build()), - Arguments.of( - new KpiValueRange( - new FloatKpiValue(56.2f), new BooleanKpiValue(true), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setFloatVal(56.2f).build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setBoolVal(true).build()) - .build()), - Arguments.of( - new KpiValueRange( - new FloatKpiValue(56.2f), new StringKpiValue("string"), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setFloatVal(56.2f).build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setStringVal("string").build()) - .build()), - Arguments.of( - new KpiValueRange( - new BooleanKpiValue(true), new IntegerKpiValue(42), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setBoolVal(true).build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setInt32Val(42).build()) - .build()), - Arguments.of( - new KpiValueRange( - new BooleanKpiValue(false), new FloatKpiValue(42.2f), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setBoolVal(false).build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setFloatVal(42.2f).build()) - .build()), - Arguments.of( - new KpiValueRange( - new BooleanKpiValue(true), new BooleanKpiValue(true), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setBoolVal(true).build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setBoolVal(true).build()) - .build()), - Arguments.of( - new KpiValueRange( - new BooleanKpiValue(false), new StringKpiValue("string"), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setBoolVal(false).build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setStringVal("string").build()) - .build()), - Arguments.of( - new KpiValueRange( - new StringKpiValue("string"), new IntegerKpiValue(42), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setStringVal("string").build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setInt32Val(42).build()) - .build()), - Arguments.of( - new KpiValueRange( - new StringKpiValue("string"), new FloatKpiValue(42.2f), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setStringVal("string").build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setFloatVal(42.2f).build()) - .build()), - Arguments.of( - new KpiValueRange( - new StringKpiValue("string"), new BooleanKpiValue(true), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setStringVal("string").build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setBoolVal(true).build()) - .build()), - Arguments.of( - new KpiValueRange( - new StringKpiValue("string"), new StringKpiValue("string"), false, false, false), - Monitoring.KpiValueRange.newBuilder() - .setKpiMinValue(Monitoring.KpiValue.newBuilder().setStringVal("string").build()) - .setKpiMaxValue(Monitoring.KpiValue.newBuilder().setStringVal("string").build()) - .build())); - } - - @ParameterizedTest - @MethodSource("provideKpiValueRanges") - void shouldSerializeKpiValueRange( - KpiValueRange kpiValueRange, Monitoring.KpiValueRange expectedKpiValueRange) { - final var serializedKpiValueRange = serializer.serialize(kpiValueRange); - - assertThat(serializedKpiValueRange.getKpiMinValue()) - .isEqualTo(expectedKpiValueRange.getKpiMinValue()); - assertThat(serializedKpiValueRange.getKpiMaxValue()) - .isEqualTo(expectedKpiValueRange.getKpiMaxValue()); - } - - @ParameterizedTest - @MethodSource("provideKpiValueRanges") - void shouldDeserializeKpiValueRange( - KpiValueRange expectedKpiValueRange, Monitoring.KpiValueRange serializedKpiValueRange) { - final var kpiValueRange = serializer.deserialize(serializedKpiValueRange); - - assertThat(kpiValueRange.getKpiMinValue()) - .usingRecursiveComparison() - .isEqualTo(expectedKpiValueRange.getKpiMinValue()); - assertThat(kpiValueRange.getKpiMaxValue()) - .usingRecursiveComparison() - .isEqualTo(expectedKpiValueRange.getKpiMaxValue()); - } - - @Test - void shouldSerializeAlarmId() { - final var alarmId = "alarmId"; - - final var alarmIdUuid = serializer.serializeUuid(alarmId); - - final var expectedAlarmId = Monitoring.AlarmID.newBuilder().setAlarmId(alarmIdUuid).build(); - - final var serializedAlarmId = serializer.serializeAlarmId(alarmId); - - assertThat(serializedAlarmId).usingRecursiveComparison().isEqualTo(expectedAlarmId); - } - - @Test - void shouldDeserializeAlarmId() { - final var expectedAlarmId = "expectedAlarmId"; - - final var serializedAlarmIdUuid = serializer.serializeUuid(expectedAlarmId); - final var serializedAlarmId = - Monitoring.KpiId.newBuilder().setKpiId(serializedAlarmIdUuid).build(); - - final var alarmId = serializer.deserialize(serializedAlarmId); - - assertThat(alarmId).isEqualTo(expectedAlarmId); - } - - @Test - void shouldSerializeAlarmDescriptor() { - final var alarmId = "alarmId"; - final var alarmDescription = "alarmDescription"; - final var name = "name"; - final var kpiId = "kpiId"; - final double timestamp = 100.0; - final var kpiIds = List.of("kpiId1", "kpiId2"); - - final var kpiValueRange = - new KpiValueRange(new IntegerKpiValue(23), new IntegerKpiValue(1800), false, false, false); - final var kpiValueRanges = List.of(kpiValueRange); - - final var alarmDescriptor = - new AlarmDescriptor( - alarmId, alarmDescription, name, kpiIds.get(0), kpiValueRanges.get(0), timestamp); - - final var serializedalarmIdUuid = serializer.serializeUuid(alarmId); - final var serializedalarmId = AlarmID.newBuilder().setAlarmId(serializedalarmIdUuid).build(); - - final var serializedKpiIdUuid = serializer.serializeUuid("kpiId1"); - final var serializedKpiId1 = KpiId.newBuilder().setKpiId(serializedKpiIdUuid).build(); - // final var serializedKpiId2 = KpiId.newBuilder().setKpiId(serializer.serializeUuid("kpiId2")); - final var serializedKpiValueRange = serializer.serialize(kpiValueRange); - final var serializedTimeStamp = - context.ContextOuterClass.Timestamp.newBuilder().setTimestamp(timestamp); - - final var expectedAlarmDescriptor = - Monitoring.AlarmDescriptor.newBuilder() - .setAlarmId(serializedalarmId) - .setAlarmDescription(alarmDescription) - .setName(name) - .setKpiId(serializedKpiId1) - .setKpiValueRange(serializedKpiValueRange) - .setTimestamp(serializedTimeStamp) - .build(); - - final var serializedAlarmDescriptor = serializer.serialize(alarmDescriptor); - - assertThat(serializedAlarmDescriptor).isEqualTo(expectedAlarmDescriptor); - } - - @Test - void shouldDeserializeAlarmDescriptor() { - final var alarmId = "alarmId"; - final var alarmDescription = "alarmDescription"; - final var name = "name"; - final var kpiId = "kpiId"; - final double timestamp = 100.0; - final var kpiIds = List.of("kpiId1", "kpiId2"); - - final var kpiValueRange = - new KpiValueRange(new IntegerKpiValue(23), new IntegerKpiValue(1800), false, false, false); - final var kpiValueRanges = List.of(kpiValueRange); - - final var expectedAlarmDescriptor = - new AlarmDescriptor( - alarmId, alarmDescription, name, kpiIds.get(0), kpiValueRanges.get(0), timestamp); - - final var serializedalarmIdUuid = serializer.serializeUuid(alarmId); - final var serializedalarmId = AlarmID.newBuilder().setAlarmId(serializedalarmIdUuid).build(); - - final var serializedKpiIdUuid = serializer.serializeUuid("kpiId1"); - final var serializedKpiId1 = KpiId.newBuilder().setKpiId(serializedKpiIdUuid).build(); - final var serializedKpiId2 = KpiId.newBuilder().setKpiId(serializer.serializeUuid("kpiId2")); - - final var serializedKpiValueRange = serializer.serialize(kpiValueRange); - final var serializedTimeStamp = - context.ContextOuterClass.Timestamp.newBuilder().setTimestamp(timestamp); - - final var serializedAlarmDescriptor = - Monitoring.AlarmDescriptor.newBuilder() - .setAlarmId(serializedalarmId) - .setAlarmDescription(alarmDescription) - .setName(name) - .setKpiId(serializedKpiId1) - .setKpiValueRange(serializedKpiValueRange) - .setTimestamp(serializedTimeStamp) - .build(); - - final var alarmDescriptor = serializer.deserialize(serializedAlarmDescriptor); - - assertThat(alarmDescriptor).usingRecursiveComparison().isEqualTo(expectedAlarmDescriptor); - } - - @Test - void shouldSerializeAlarmResponse() { - final var alarmId = "alarmId"; - final var kpiValue = new IntegerKpiValue(12); - final var kpiId = "expectedKpiId"; - final var timestamp = 100.0; - final var kpi = new Kpi(kpiId, timestamp, kpiValue); - final var kpiList = List.of(kpi); - - final var alarmResponse = new AlarmResponse(alarmId, kpiList); - - final var serializedAlarmIdUuid = serializer.serializeUuid(alarmId); - final var serializedAlarmId = AlarmID.newBuilder().setAlarmId(serializedAlarmIdUuid).build(); - final var serializedListKpis = serializer.serialize(List.of(kpi)); - final var serializedKpiList = Monitoring.KpiList.newBuilder().addAllKpi(serializedListKpis); - - final var expectedAlarmResponse = - Monitoring.AlarmResponse.newBuilder() - .setAlarmId(serializedAlarmId) - .setKpiList(serializedKpiList) - .build(); - - final var serializedAlarmResponse = serializer.serialize(alarmResponse); - - assertThat(serializedAlarmResponse).isEqualTo(expectedAlarmResponse); - } - - @Test - void shouldDeserializeAlarmResponse() { - final var alarmId = "alarmId"; - final var kpiValue = new IntegerKpiValue(12); - final var kpiId = "expectedKpiId"; - final var timestamp = 100.0; - final var kpi = new Kpi(kpiId, timestamp, kpiValue); - final var kpiList = List.of(kpi); - - final var expectedAlarmResponse = new AlarmResponse(alarmId, kpiList); - - final var serializedAlarmIdUuid = serializer.serializeUuid(alarmId); - final var serializedAlarmId = AlarmID.newBuilder().setAlarmId(serializedAlarmIdUuid).build(); - final var serializedListKpis = serializer.serialize(List.of(kpi)); - final var serializedKpiList = Monitoring.KpiList.newBuilder().addAllKpi(serializedListKpis); - - final var serializedAlarmResponse = - Monitoring.AlarmResponse.newBuilder() - .setAlarmId(serializedAlarmId) - .setKpiList(serializedKpiList) - .build(); - - final var alarmResponse = serializer.deserialize(serializedAlarmResponse); - - assertThat(alarmResponse).usingRecursiveComparison().isEqualTo(expectedAlarmResponse); - } - - @Test - void shouldSerializeSubDescriptor() { - final var subscriptionId = "subscriptionId"; - final var kpiId = "kpiId"; - final var samplingDurationS = 10f; - final var samplingIntervalS = 45f; - final var startTimestamp = 1.0; - final var endTimestamp = 100.0; - - final var subDescriptor = - new SubsDescriptor( - subscriptionId, - kpiId, - samplingDurationS, - samplingIntervalS, - startTimestamp, - endTimestamp); - - final var serializedSubscriptionIdUuid = serializer.serializeUuid(subscriptionId); - final var serializedSubscriptionId = - monitoring.Monitoring.SubscriptionID.newBuilder() - .setSubsId(serializedSubscriptionIdUuid) - .build(); - final var serializedKpiIdUuid = serializer.serializeUuid(kpiId); - final var serializedKpiId = KpiId.newBuilder().setKpiId(serializedKpiIdUuid).build(); - final var serializedStartTimestamp = - ContextOuterClass.Timestamp.newBuilder().setTimestamp(startTimestamp); - final var serializedEndTimestamp = - ContextOuterClass.Timestamp.newBuilder().setTimestamp(endTimestamp); - - final var expectedSubDescriptor = - Monitoring.SubsDescriptor.newBuilder() - .setSubsId(serializedSubscriptionId) - .setKpiId(serializedKpiId) - .setSamplingDurationS(samplingDurationS) - .setSamplingIntervalS(samplingIntervalS) - .setStartTimestamp(serializedStartTimestamp) - .setEndTimestamp(serializedEndTimestamp) - .build(); - - final var serializedSubDescriptor = serializer.serialize(subDescriptor); - - assertThat(serializedSubDescriptor).isEqualTo(expectedSubDescriptor); - } - - @Test - void shouldDeserializeSubDescriptor() { - final var subscriptionId = "subscriptionId"; - final var kpiId = "kpiId"; - final var samplingDurationS = 10f; - final var samplingIntervalS = 45f; - final var startTimestamp = 1.0; - final var endTimestamp = 100.0; - - final var expectedSubDescriptor = - new SubsDescriptor( - subscriptionId, - kpiId, - samplingDurationS, - samplingIntervalS, - startTimestamp, - endTimestamp); - - final var serializedSubscriptionIdUuid = serializer.serializeUuid(subscriptionId); - final var serializedSubscriptionId = - monitoring.Monitoring.SubscriptionID.newBuilder() - .setSubsId(serializedSubscriptionIdUuid) - .build(); - final var serializedKpiIdUuid = serializer.serializeUuid(kpiId); - final var serializedKpiId = KpiId.newBuilder().setKpiId(serializedKpiIdUuid).build(); - final var serializedStartTimestamp = - ContextOuterClass.Timestamp.newBuilder().setTimestamp(startTimestamp); - final var serializedEndTimestamp = - ContextOuterClass.Timestamp.newBuilder().setTimestamp(endTimestamp); - - final var serializedSubDescriptor = - Monitoring.SubsDescriptor.newBuilder() - .setSubsId(serializedSubscriptionId) - .setKpiId(serializedKpiId) - .setSamplingDurationS(samplingDurationS) - .setSamplingIntervalS(samplingIntervalS) - .setStartTimestamp(serializedStartTimestamp) - .setEndTimestamp(serializedEndTimestamp) - .build(); - - final var subDescriptor = serializer.deserialize(serializedSubDescriptor); - - assertThat(subDescriptor).usingRecursiveComparison().isEqualTo(expectedSubDescriptor); - } - - @Test - void shouldDeserializePolicyRuleCondition() { - final var expectedPolicyRuleConditionKpiId = "expectedPolicyRuleConditionKpiId"; - final var expectedPolicyRuleConditionNumericalOperator = - NumericalOperator.POLICY_RULE_CONDITION_NUMERICAL_GREATER_THAN; - final var expectedPolicyRuleConditionKpiValue = new IntegerKpiValue(34); - - final var expectedPolicyRuleCondition = - new PolicyRuleCondition( - expectedPolicyRuleConditionKpiId, - expectedPolicyRuleConditionNumericalOperator, - expectedPolicyRuleConditionKpiValue); - - final var serializedPolicyRuleCondition = serializer.serialize(expectedPolicyRuleCondition); - - final var policyRuleCondition = serializer.deserialize(serializedPolicyRuleCondition); - - assertThat(policyRuleCondition) - .usingRecursiveComparison() - .isEqualTo(expectedPolicyRuleCondition); - } - - private static Stream provideBooleanOperators() { - return Stream.of( - Arguments.of( - BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_AND, - PolicyCondition.BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_AND), - Arguments.of( - BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_OR, - PolicyCondition.BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_OR), - Arguments.of( - BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_UNDEFINED, - PolicyCondition.BooleanOperator.POLICYRULE_CONDITION_BOOLEAN_UNDEFINED)); - } - - @ParameterizedTest - @MethodSource("provideBooleanOperators") - void shouldSerializeBooleanOperator( - BooleanOperator booleanOperator, PolicyCondition.BooleanOperator expectedBooleanOperator) { - final var serializedBooleanOperator = serializer.serialize(booleanOperator); - - assertThat(serializedBooleanOperator).isEqualTo(expectedBooleanOperator); - } - - @ParameterizedTest - @MethodSource("provideBooleanOperators") - void shouldDeserializeBooleanOperator( - BooleanOperator expectedBooleanOperator, - PolicyCondition.BooleanOperator serializedBooleanOperator) { - final var booleanOperator = serializer.deserialize(serializedBooleanOperator); - - assertThat(booleanOperator).isEqualTo(expectedBooleanOperator); - } - private static Stream providePolicyRuleActionEnum() { return Stream.of( Arguments.of( @@ -3055,8 +2308,7 @@ class SerializerTest { final var expectedPolicyRuleId = policyRuleBasic.getPolicyRuleId(); final var expectedPolicyRuleState = policyRuleBasic.getPolicyRuleState(); final var expectedPolicyRuleActions = policyRuleBasic.getPolicyRuleActions(); - final var expectedPriority = policyRuleBasic.getPriority(); - final var expectedKpiId = policyRuleBasic.getKpiId(); + final var expectedPriority = policyRuleBasic.getPolicyRulePriority(); final var serializedPolicyRuleId = serializer.serializePolicyRuleId(expectedPolicyRuleId); final var serializedPolicyRuleState = serializer.serialize(expectedPolicyRuleState); @@ -3069,8 +2321,7 @@ class SerializerTest { final var expectedPolicyRuleBasic = Policy.PolicyRuleBasic.newBuilder() .setPolicyRuleId(serializedPolicyRuleId) - .setPriority(expectedPriority) - .setKpiId(KpiId.newBuilder().setKpiId(Uuid.newBuilder().setUuid("kpiId").build())) + .setPolicyRulePriority(expectedPriority) .setPolicyRuleState(serializedPolicyRuleState) .addAllActionList(serializedPolicyRuleActions) .build(); @@ -3088,8 +2339,7 @@ class SerializerTest { final var expectedPolicyRuleId = expectedPolicyRuleBasic.getPolicyRuleId(); final var expectedPolicyRuleState = expectedPolicyRuleBasic.getPolicyRuleState(); - final var expectedPriority = expectedPolicyRuleBasic.getPriority(); - final var expectedKpiId = expectedPolicyRuleBasic.getKpiId(); + final var expectedPriority = expectedPolicyRuleBasic.getPolicyRulePriority(); final var expectedPolicyRuleActions = expectedPolicyRuleBasic.getPolicyRuleActions(); final var serializedPolicyRuleId = serializer.serializePolicyRuleId(expectedPolicyRuleId); @@ -3104,8 +2354,7 @@ class SerializerTest { Policy.PolicyRuleBasic.newBuilder() .setPolicyRuleId(serializedPolicyRuleId) .setPolicyRuleState(serializedPolicyRuleState) - .setKpiId(KpiId.newBuilder().setKpiId(Uuid.newBuilder().setUuid("kpiId").build())) - .setPriority(expectedPriority) + .setPolicyRulePriority(expectedPriority) .addAllActionList(serializedPolicyRuleActions) .build(); @@ -3222,240 +2471,6 @@ class SerializerTest { assertThat(policyRuleDevice).usingRecursiveComparison().isEqualTo(expectedPolicyRuleDevice); } - @Test - void shouldSerializeKpiId() { - final var kpiId = "kpiId"; - - final var kpiIdUuid = serializer.serializeUuid(kpiId); - - final var expectedKpiId = Monitoring.KpiId.newBuilder().setKpiId(kpiIdUuid).build(); - - final var serializedKpiId = serializer.serializeKpiId(kpiId); - - assertThat(serializedKpiId).usingRecursiveComparison().isEqualTo(expectedKpiId); - } - - @Test - void shouldDeserializeKpiId() { - final var expectedKpiId = "expectedKpiId"; - - final var serializedKpiIdUuid = serializer.serializeUuid(expectedKpiId); - final var serializedKpiId = Monitoring.KpiId.newBuilder().setKpiId(serializedKpiIdUuid).build(); - - final var kpiId = serializer.deserialize(serializedKpiId); - - assertThat(kpiId).isEqualTo(expectedKpiId); - } - - @Test - void shouldSerializeKpi() { - final var expectedKpiId = "expectedKpiId"; - final var expectedTimestamp = 100.0; - final var expectedKpiValue = new FloatKpiValue(643.45f); - - final var kpi = new Kpi(expectedKpiId, expectedTimestamp, expectedKpiValue); - - final var serializedKpiId = serializer.serializeKpiId(expectedKpiId); - final var serializedKpiValue = serializer.serialize(expectedKpiValue); - final var serializedexpectedTimestamp = - context.ContextOuterClass.Timestamp.newBuilder().setTimestamp(expectedTimestamp); - - final var expectedKpi = - Monitoring.Kpi.newBuilder() - .setKpiId(serializedKpiId) - .setTimestamp(serializedexpectedTimestamp) - .setKpiValue(serializedKpiValue) - .build(); - - final var serializedKpi = serializer.serialize(kpi); - - assertThat(serializedKpi).usingRecursiveComparison().isEqualTo(expectedKpi); - } - - @Test - void shouldDeserializeKpi() { - final var expectedKpiId = "expectedKpiId"; - final var expectedTimestamp = 100.0; - final var expectedKpiValue = new BooleanKpiValue(true); - final var expectedKpi = new Kpi(expectedKpiId, expectedTimestamp, expectedKpiValue); - - final var serializedKpi = serializer.serialize(expectedKpi); - - final var kpi = serializer.deserialize(serializedKpi); - - assertThat(kpi).usingRecursiveComparison().isEqualTo(expectedKpi); - } - - @Test - void shouldSerializeKpisList() { - final var expectedKpiIdA = "expectedKpiIdA"; - final var expectedTimestampA = 100.0; - final var expectedKpiValueA = new FloatKpiValue(643.45f); - final var serializedKpiIdA = serializer.serializeKpiId(expectedKpiIdA); - final var serializedexpectedTimestampA = - context.ContextOuterClass.Timestamp.newBuilder().setTimestamp(expectedTimestampA); - final var serializedKpiValueA = serializer.serialize(expectedKpiValueA); - final var kpiA = new Kpi(expectedKpiIdA, expectedTimestampA, expectedKpiValueA); - - final var expectedKpiIdB = "expectedKpiIdB"; - final var expectedTimestampB = 100.0; - final var expectedKpiValueB = new IntegerKpiValue(32); - final var serializedKpiIdB = serializer.serializeKpiId(expectedKpiIdB); - final var serializedexpectedTimestampB = - context.ContextOuterClass.Timestamp.newBuilder().setTimestamp(expectedTimestampB); - final var serializedKpiValueB = serializer.serialize(expectedKpiValueB); - final var kpiB = new Kpi(expectedKpiIdB, expectedTimestampB, expectedKpiValueB); - - final var kpis = List.of(kpiA, kpiB); - - final var expectedKpiA = - Monitoring.Kpi.newBuilder() - .setKpiId(serializedKpiIdA) - .setTimestamp(serializedexpectedTimestampA) - .setKpiValue(serializedKpiValueA) - .build(); - - final var expectedKpiB = - Monitoring.Kpi.newBuilder() - .setKpiId(serializedKpiIdB) - .setTimestamp(serializedexpectedTimestampB) - .setKpiValue(serializedKpiValueB) - .build(); - - final var expectedKpis = List.of(expectedKpiA, expectedKpiB); - - final var serializedKpis = serializer.serialize(kpis); - - assertThat(serializedKpis).usingRecursiveComparison().isEqualTo(expectedKpis); - } - - @Test - void shouldDeserializeKpisList() { - final var expectedKpiIdA = "expectedKpiIdA"; - final var expectedTimestampA = 100.0; - final var expectedKpiValueA = new FloatKpiValue(643.45f); - final var serializedKpiIdA = serializer.serializeKpiId(expectedKpiIdA); - final var serializedexpectedTimestampA = - context.ContextOuterClass.Timestamp.newBuilder().setTimestamp(expectedTimestampA); - final var serializedKpiValueA = serializer.serialize(expectedKpiValueA); - final var expectedKpiA = new Kpi(expectedKpiIdA, expectedTimestampA, expectedKpiValueA); - - final var expectedKpiIdB = "expectedKpiIdB"; - final var expectedTimestampB = 200.0; - final var expectedKpiValueB = new IntegerKpiValue(32); - final var serializedKpiIdB = serializer.serializeKpiId(expectedKpiIdB); - final var serializedexpectedTimestampB = - context.ContextOuterClass.Timestamp.newBuilder().setTimestamp(expectedTimestampB); - final var serializedKpiValueB = serializer.serialize(expectedKpiValueB); - final var expectedKpiB = new Kpi(expectedKpiIdB, expectedTimestampB, expectedKpiValueB); - - final var expectedKpis = List.of(expectedKpiA, expectedKpiB); - - final var serializedKpiA = - Monitoring.Kpi.newBuilder() - .setKpiId(serializedKpiIdA) - .setTimestamp(serializedexpectedTimestampA) - .setKpiValue(serializedKpiValueA) - .build(); - - final var serializedKpiB = - Monitoring.Kpi.newBuilder() - .setKpiId(serializedKpiIdB) - .setTimestamp(serializedexpectedTimestampB) - .setKpiValue(serializedKpiValueB) - .build(); - - final var serializedKpis = List.of(serializedKpiA, serializedKpiB); - - final var kpis = serializer.deserialize(serializedKpis); - - assertThat(kpis).usingRecursiveComparison().isEqualTo(expectedKpis); - } - - @Test - void shouldSerializeKpiDescriptor() { - final var expectedKpiDescription = "expectedKpiDescription"; - final var expectedKpiSampleType = KpiSampleType.BYTES_RECEIVED; - final var expectedDeviceId = "expectedDeviceId"; - - final var expectedTopologyId = new TopologyId("contextId", "topologyId"); - final var expectedEndPointId = - new EndPointId(expectedTopologyId, expectedDeviceId, "endpointId"); - final var expectedServiceId = new ServiceId("contextId", "serviceId"); - final var expectedSliceId = new SliceId("contextId", "sliceId"); - - final var kpiDescriptor = - new KpiDescriptor( - expectedKpiDescription, - expectedKpiSampleType, - expectedDeviceId, - expectedEndPointId, - expectedServiceId, - expectedSliceId); - - final var serializedKpiSampleType = serializer.serialize(expectedKpiSampleType); - final var serializedDeviceId = serializer.serializeDeviceId(expectedDeviceId); - final var serializedEndPointId = serializer.serialize(expectedEndPointId); - final var serializedServiceId = serializer.serialize(expectedServiceId); - final var serializedSliceId = serializer.serialize(expectedSliceId); - - final var expectedKpiDescriptor = - Monitoring.KpiDescriptor.newBuilder() - .setKpiDescription(expectedKpiDescription) - .setKpiSampleType(serializedKpiSampleType) - .setDeviceId(serializedDeviceId) - .setEndpointId(serializedEndPointId) - .setServiceId(serializedServiceId) - .setSliceId(serializedSliceId) - .build(); - - final var serializedKpiDescriptor = serializer.serialize(kpiDescriptor); - - assertThat(serializedKpiDescriptor).usingRecursiveComparison().isEqualTo(expectedKpiDescriptor); - } - - @Test - void shouldDeserializeKpiDescriptor() { - final var expectedKpiDescription = "expectedKpiDescription"; - final var expectedKpiSampleType = KpiSampleType.BYTES_RECEIVED; - final var expectedDeviceId = "expectedDeviceId"; - - final var expectedTopologyId = new TopologyId("contextId", "topologyId"); - final var expectedEndPointId = - new EndPointId(expectedTopologyId, expectedDeviceId, "endpointId"); - final var expectedServiceId = new ServiceId("contextId", "serviceId"); - final var expectedSliceId = new SliceId("contextId", "sliceId"); - - final var expectedKpiDescriptor = - new KpiDescriptor( - expectedKpiDescription, - expectedKpiSampleType, - expectedDeviceId, - expectedEndPointId, - expectedServiceId, - expectedSliceId); - - final var serializedKpiSampleType = serializer.serialize(expectedKpiSampleType); - final var serializedDeviceId = serializer.serializeDeviceId(expectedDeviceId); - final var serializedEndPointId = serializer.serialize(expectedEndPointId); - final var serializedServiceId = serializer.serialize(expectedServiceId); - final var serializedSliceId = serializer.serialize(expectedSliceId); - - final var serializedKpiDescriptor = - Monitoring.KpiDescriptor.newBuilder() - .setKpiDescription(expectedKpiDescription) - .setKpiSampleType(serializedKpiSampleType) - .setDeviceId(serializedDeviceId) - .setEndpointId(serializedEndPointId) - .setServiceId(serializedServiceId) - .setSliceId(serializedSliceId) - .build(); - - final var kpiDescriptor = serializer.deserialize(serializedKpiDescriptor); - - assertThat(kpiDescriptor).usingRecursiveComparison().isEqualTo(expectedKpiDescriptor); - } - @Test void shouldSerializeDeviceConfig() { final var expectedConfigRuleCustomA = diff --git a/src/policy/target/generated-sources/grpc/policy/Policy.java b/src/policy/target/generated-sources/grpc/policy/Policy.java index 04d033e66..b14462ae8 100644 --- a/src/policy/target/generated-sources/grpc/policy/Policy.java +++ b/src/policy/target/generated-sources/grpc/policy/Policy.java @@ -53,7 +53,7 @@ public final class Policy { POLICY_VALIDATED(3), /** *
-         * Rule subscribed to Monitoring
+         * Rule subscribed to Analyzer
          * 
* * POLICY_PROVISIONED = 4; @@ -61,7 +61,7 @@ public final class Policy { POLICY_PROVISIONED(4), /** *
-         * Rule is currently active (alarm is just thrown by Monitoring)
+         * Rule is currently active (alarm is just thrown by Analyzer)
          * 
* * POLICY_ACTIVE = 5; @@ -147,7 +147,7 @@ public final class Policy { /** *
-         * Rule subscribed to Monitoring
+         * Rule subscribed to Analyzer
          * 
* * POLICY_PROVISIONED = 4; @@ -156,7 +156,7 @@ public final class Policy { /** *
-         * Rule is currently active (alarm is just thrown by Monitoring)
+         * Rule is currently active (alarm is just thrown by Analyzer)
          * 
* * POLICY_ACTIVE = 5; @@ -1474,111 +1474,70 @@ public final class Policy { policy.Policy.PolicyRuleIdOrBuilder getPolicyRuleIdOrBuilder(); /** - *
-         * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-         *  
- * - * .policy.PolicyRuleState policyRuleState = 2; - * @return Whether the policyRuleState field is set. + * .policy.PolicyRuleState policyRuleState = 2; + * @return Whether the policyRuleState field is set. */ boolean hasPolicyRuleState(); /** - *
-         * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-         *  
- * - * .policy.PolicyRuleState policyRuleState = 2; - * @return The policyRuleState. + * .policy.PolicyRuleState policyRuleState = 2; + * @return The policyRuleState. */ policy.Policy.PolicyRuleState getPolicyRuleState(); /** - *
-         * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-         *  
- * - * .policy.PolicyRuleState policyRuleState = 2; + * .policy.PolicyRuleState policyRuleState = 2; */ policy.Policy.PolicyRuleStateOrBuilder getPolicyRuleStateOrBuilder(); /** - * uint32 priority = 3; - * @return The priority. - */ - int getPriority(); - - /** - *
-         * to be migrated to: "kpi_manager.KpiId"
-         * 
- * - * .monitoring.KpiId kpiId = 4; - * @return Whether the kpiId field is set. - */ - boolean hasKpiId(); - - /** - *
-         * to be migrated to: "kpi_manager.KpiId"
-         * 
- * - * .monitoring.KpiId kpiId = 4; - * @return The kpiId. - */ - monitoring.Monitoring.KpiId getKpiId(); - - /** - *
-         * to be migrated to: "kpi_manager.KpiId"
-         * 
- * - * .monitoring.KpiId kpiId = 4; + * uint32 policyRulePriority = 3; + * @return The policyRulePriority. */ - monitoring.Monitoring.KpiIdOrBuilder getKpiIdOrBuilder(); + int getPolicyRulePriority(); /** *
-         * Event-Condition-Action (ECA) model
+         * One or more actions should be applied
          * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ java.util.List getActionListList(); /** *
-         * Event-Condition-Action (ECA) model
+         * One or more actions should be applied
          * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ policy.PolicyAction.PolicyRuleAction getActionList(int index); /** *
-         * Event-Condition-Action (ECA) model
+         * One or more actions should be applied
          * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ int getActionListCount(); /** *
-         * Event-Condition-Action (ECA) model
+         * One or more actions should be applied
          * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ java.util.List getActionListOrBuilderList(); /** *
-         * Event-Condition-Action (ECA) model
+         * One or more actions should be applied
          * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ policy.PolicyAction.PolicyRuleActionOrBuilder getActionListOrBuilder(int index); } @@ -1654,12 +1613,8 @@ public final class Policy { private policy.Policy.PolicyRuleState policyRuleState_; /** - *
-         * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-         *  
- * - * .policy.PolicyRuleState policyRuleState = 2; - * @return Whether the policyRuleState field is set. + * .policy.PolicyRuleState policyRuleState = 2; + * @return Whether the policyRuleState field is set. */ @java.lang.Override public boolean hasPolicyRuleState() { @@ -1667,12 +1622,8 @@ public final class Policy { } /** - *
-         * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-         *  
- * - * .policy.PolicyRuleState policyRuleState = 2; - * @return The policyRuleState. + * .policy.PolicyRuleState policyRuleState = 2; + * @return The policyRuleState. */ @java.lang.Override public policy.Policy.PolicyRuleState getPolicyRuleState() { @@ -1680,83 +1631,37 @@ public final class Policy { } /** - *
-         * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-         *  
- * - * .policy.PolicyRuleState policyRuleState = 2; + * .policy.PolicyRuleState policyRuleState = 2; */ @java.lang.Override public policy.Policy.PolicyRuleStateOrBuilder getPolicyRuleStateOrBuilder() { return policyRuleState_ == null ? policy.Policy.PolicyRuleState.getDefaultInstance() : policyRuleState_; } - public static final int PRIORITY_FIELD_NUMBER = 3; + public static final int POLICYRULEPRIORITY_FIELD_NUMBER = 3; - private int priority_ = 0; + private int policyRulePriority_ = 0; /** - * uint32 priority = 3; - * @return The priority. + * uint32 policyRulePriority = 3; + * @return The policyRulePriority. */ @java.lang.Override - public int getPriority() { - return priority_; + public int getPolicyRulePriority() { + return policyRulePriority_; } - public static final int KPIID_FIELD_NUMBER = 4; - - private monitoring.Monitoring.KpiId kpiId_; - - /** - *
-         * to be migrated to: "kpi_manager.KpiId"
-         * 
- * - * .monitoring.KpiId kpiId = 4; - * @return Whether the kpiId field is set. - */ - @java.lang.Override - public boolean hasKpiId() { - return kpiId_ != null; - } - - /** - *
-         * to be migrated to: "kpi_manager.KpiId"
-         * 
- * - * .monitoring.KpiId kpiId = 4; - * @return The kpiId. - */ - @java.lang.Override - public monitoring.Monitoring.KpiId getKpiId() { - return kpiId_ == null ? monitoring.Monitoring.KpiId.getDefaultInstance() : kpiId_; - } - - /** - *
-         * to be migrated to: "kpi_manager.KpiId"
-         * 
- * - * .monitoring.KpiId kpiId = 4; - */ - @java.lang.Override - public monitoring.Monitoring.KpiIdOrBuilder getKpiIdOrBuilder() { - return kpiId_ == null ? monitoring.Monitoring.KpiId.getDefaultInstance() : kpiId_; - } - - public static final int ACTIONLIST_FIELD_NUMBER = 5; + public static final int ACTIONLIST_FIELD_NUMBER = 4; @SuppressWarnings("serial") private java.util.List actionList_; /** *
-         * Event-Condition-Action (ECA) model
+         * One or more actions should be applied
          * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ @java.lang.Override public java.util.List getActionListList() { @@ -1765,10 +1670,10 @@ public final class Policy { /** *
-         * Event-Condition-Action (ECA) model
+         * One or more actions should be applied
          * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ @java.lang.Override public java.util.List getActionListOrBuilderList() { @@ -1777,10 +1682,10 @@ public final class Policy { /** *
-         * Event-Condition-Action (ECA) model
+         * One or more actions should be applied
          * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ @java.lang.Override public int getActionListCount() { @@ -1789,10 +1694,10 @@ public final class Policy { /** *
-         * Event-Condition-Action (ECA) model
+         * One or more actions should be applied
          * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ @java.lang.Override public policy.PolicyAction.PolicyRuleAction getActionList(int index) { @@ -1801,10 +1706,10 @@ public final class Policy { /** *
-         * Event-Condition-Action (ECA) model
+         * One or more actions should be applied
          * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ @java.lang.Override public policy.PolicyAction.PolicyRuleActionOrBuilder getActionListOrBuilder(int index) { @@ -1832,14 +1737,11 @@ public final class Policy { if (policyRuleState_ != null) { output.writeMessage(2, getPolicyRuleState()); } - if (priority_ != 0) { - output.writeUInt32(3, priority_); - } - if (kpiId_ != null) { - output.writeMessage(4, getKpiId()); + if (policyRulePriority_ != 0) { + output.writeUInt32(3, policyRulePriority_); } for (int i = 0; i < actionList_.size(); i++) { - output.writeMessage(5, actionList_.get(i)); + output.writeMessage(4, actionList_.get(i)); } getUnknownFields().writeTo(output); } @@ -1856,14 +1758,11 @@ public final class Policy { if (policyRuleState_ != null) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(2, getPolicyRuleState()); } - if (priority_ != 0) { - size += com.google.protobuf.CodedOutputStream.computeUInt32Size(3, priority_); - } - if (kpiId_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, getKpiId()); + if (policyRulePriority_ != 0) { + size += com.google.protobuf.CodedOutputStream.computeUInt32Size(3, policyRulePriority_); } for (int i = 0; i < actionList_.size(); i++) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, actionList_.get(i)); + size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, actionList_.get(i)); } size += getUnknownFields().getSerializedSize(); memoizedSize = size; @@ -1891,14 +1790,8 @@ public final class Policy { if (!getPolicyRuleState().equals(other.getPolicyRuleState())) return false; } - if (getPriority() != other.getPriority()) + if (getPolicyRulePriority() != other.getPolicyRulePriority()) return false; - if (hasKpiId() != other.hasKpiId()) - return false; - if (hasKpiId()) { - if (!getKpiId().equals(other.getKpiId())) - return false; - } if (!getActionListList().equals(other.getActionListList())) return false; if (!getUnknownFields().equals(other.getUnknownFields())) @@ -1921,12 +1814,8 @@ public final class Policy { hash = (37 * hash) + POLICYRULESTATE_FIELD_NUMBER; hash = (53 * hash) + getPolicyRuleState().hashCode(); } - hash = (37 * hash) + PRIORITY_FIELD_NUMBER; - hash = (53 * hash) + getPriority(); - if (hasKpiId()) { - hash = (37 * hash) + KPIID_FIELD_NUMBER; - hash = (53 * hash) + getKpiId().hashCode(); - } + hash = (37 * hash) + POLICYRULEPRIORITY_FIELD_NUMBER; + hash = (53 * hash) + getPolicyRulePriority(); if (getActionListCount() > 0) { hash = (37 * hash) + ACTIONLIST_FIELD_NUMBER; hash = (53 * hash) + getActionListList().hashCode(); @@ -2049,19 +1938,14 @@ public final class Policy { policyRuleStateBuilder_.dispose(); policyRuleStateBuilder_ = null; } - priority_ = 0; - kpiId_ = null; - if (kpiIdBuilder_ != null) { - kpiIdBuilder_.dispose(); - kpiIdBuilder_ = null; - } + policyRulePriority_ = 0; if (actionListBuilder_ == null) { actionList_ = java.util.Collections.emptyList(); } else { actionList_ = null; actionListBuilder_.clear(); } - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000008); return this; } @@ -2097,9 +1981,9 @@ public final class Policy { private void buildPartialRepeatedFields(policy.Policy.PolicyRuleBasic result) { if (actionListBuilder_ == null) { - if (((bitField0_ & 0x00000010) != 0)) { + if (((bitField0_ & 0x00000008) != 0)) { actionList_ = java.util.Collections.unmodifiableList(actionList_); - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000008); } result.actionList_ = actionList_; } else { @@ -2116,10 +2000,7 @@ public final class Policy { result.policyRuleState_ = policyRuleStateBuilder_ == null ? policyRuleState_ : policyRuleStateBuilder_.build(); } if (((from_bitField0_ & 0x00000004) != 0)) { - result.priority_ = priority_; - } - if (((from_bitField0_ & 0x00000008) != 0)) { - result.kpiId_ = kpiIdBuilder_ == null ? kpiId_ : kpiIdBuilder_.build(); + result.policyRulePriority_ = policyRulePriority_; } } @@ -2142,17 +2023,14 @@ public final class Policy { if (other.hasPolicyRuleState()) { mergePolicyRuleState(other.getPolicyRuleState()); } - if (other.getPriority() != 0) { - setPriority(other.getPriority()); - } - if (other.hasKpiId()) { - mergeKpiId(other.getKpiId()); + if (other.getPolicyRulePriority() != 0) { + setPolicyRulePriority(other.getPolicyRulePriority()); } if (actionListBuilder_ == null) { if (!other.actionList_.isEmpty()) { if (actionList_.isEmpty()) { actionList_ = other.actionList_; - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000008); } else { ensureActionListIsMutable(); actionList_.addAll(other.actionList_); @@ -2165,7 +2043,7 @@ public final class Policy { actionListBuilder_.dispose(); actionListBuilder_ = null; actionList_ = other.actionList_; - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000008); actionListBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getActionListFieldBuilder() : null; } else { actionListBuilder_.addAllMessages(other.actionList_); @@ -2211,19 +2089,12 @@ public final class Policy { // case 18 case 24: { - priority_ = input.readUInt32(); + policyRulePriority_ = input.readUInt32(); bitField0_ |= 0x00000004; break; } // case 24 case 34: - { - input.readMessage(getKpiIdFieldBuilder().getBuilder(), extensionRegistry); - bitField0_ |= 0x00000008; - break; - } - // case 34 - case 42: { policy.PolicyAction.PolicyRuleAction m = input.readMessage(policy.PolicyAction.PolicyRuleAction.parser(), extensionRegistry); if (actionListBuilder_ == null) { @@ -2234,7 +2105,7 @@ public final class Policy { } break; } - // case 42 + // case 34 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { @@ -2381,24 +2252,16 @@ public final class Policy { private com.google.protobuf.SingleFieldBuilderV3 policyRuleStateBuilder_; /** - *
-             * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-             *  
- * - * .policy.PolicyRuleState policyRuleState = 2; - * @return Whether the policyRuleState field is set. + * .policy.PolicyRuleState policyRuleState = 2; + * @return Whether the policyRuleState field is set. */ public boolean hasPolicyRuleState() { return ((bitField0_ & 0x00000002) != 0); } /** - *
-             * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-             *  
- * - * .policy.PolicyRuleState policyRuleState = 2; - * @return The policyRuleState. + * .policy.PolicyRuleState policyRuleState = 2; + * @return The policyRuleState. */ public policy.Policy.PolicyRuleState getPolicyRuleState() { if (policyRuleStateBuilder_ == null) { @@ -2409,11 +2272,7 @@ public final class Policy { } /** - *
-             * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-             *  
- * - * .policy.PolicyRuleState policyRuleState = 2; + * .policy.PolicyRuleState policyRuleState = 2; */ public Builder setPolicyRuleState(policy.Policy.PolicyRuleState value) { if (policyRuleStateBuilder_ == null) { @@ -2430,11 +2289,7 @@ public final class Policy { } /** - *
-             * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-             *  
- * - * .policy.PolicyRuleState policyRuleState = 2; + * .policy.PolicyRuleState policyRuleState = 2; */ public Builder setPolicyRuleState(policy.Policy.PolicyRuleState.Builder builderForValue) { if (policyRuleStateBuilder_ == null) { @@ -2448,11 +2303,7 @@ public final class Policy { } /** - *
-             * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-             *  
- * - * .policy.PolicyRuleState policyRuleState = 2; + * .policy.PolicyRuleState policyRuleState = 2; */ public Builder mergePolicyRuleState(policy.Policy.PolicyRuleState value) { if (policyRuleStateBuilder_ == null) { @@ -2470,11 +2321,7 @@ public final class Policy { } /** - *
-             * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-             *  
- * - * .policy.PolicyRuleState policyRuleState = 2; + * .policy.PolicyRuleState policyRuleState = 2; */ public Builder clearPolicyRuleState() { bitField0_ = (bitField0_ & ~0x00000002); @@ -2488,11 +2335,7 @@ public final class Policy { } /** - *
-             * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-             *  
- * - * .policy.PolicyRuleState policyRuleState = 2; + * .policy.PolicyRuleState policyRuleState = 2; */ public policy.Policy.PolicyRuleState.Builder getPolicyRuleStateBuilder() { bitField0_ |= 0x00000002; @@ -2501,11 +2344,7 @@ public final class Policy { } /** - *
-             * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-             *  
- * - * .policy.PolicyRuleState policyRuleState = 2; + * .policy.PolicyRuleState policyRuleState = 2; */ public policy.Policy.PolicyRuleStateOrBuilder getPolicyRuleStateOrBuilder() { if (policyRuleStateBuilder_ != null) { @@ -2516,11 +2355,7 @@ public final class Policy { } /** - *
-             * policy.proto:58:12: Explicit 'optional' labels are disallowed in the Proto3 syntax. To define 'optional' fields in Proto3, simply remove the 'optional' label, as fields are 'optional' by default.
-             *  
- * - * .policy.PolicyRuleState policyRuleState = 2; + * .policy.PolicyRuleState policyRuleState = 2; */ private com.google.protobuf.SingleFieldBuilderV3 getPolicyRuleStateFieldBuilder() { if (policyRuleStateBuilder_ == null) { @@ -2530,200 +2365,46 @@ public final class Policy { return policyRuleStateBuilder_; } - private int priority_; + private int policyRulePriority_; /** - * uint32 priority = 3; - * @return The priority. + * uint32 policyRulePriority = 3; + * @return The policyRulePriority. */ @java.lang.Override - public int getPriority() { - return priority_; + public int getPolicyRulePriority() { + return policyRulePriority_; } /** - * uint32 priority = 3; - * @param value The priority to set. + * uint32 policyRulePriority = 3; + * @param value The policyRulePriority to set. * @return This builder for chaining. */ - public Builder setPriority(int value) { - priority_ = value; + public Builder setPolicyRulePriority(int value) { + policyRulePriority_ = value; bitField0_ |= 0x00000004; onChanged(); return this; } /** - * uint32 priority = 3; + * uint32 policyRulePriority = 3; * @return This builder for chaining. */ - public Builder clearPriority() { + public Builder clearPolicyRulePriority() { bitField0_ = (bitField0_ & ~0x00000004); - priority_ = 0; + policyRulePriority_ = 0; onChanged(); return this; } - private monitoring.Monitoring.KpiId kpiId_; - - private com.google.protobuf.SingleFieldBuilderV3 kpiIdBuilder_; - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 4; - * @return Whether the kpiId field is set. - */ - public boolean hasKpiId() { - return ((bitField0_ & 0x00000008) != 0); - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 4; - * @return The kpiId. - */ - public monitoring.Monitoring.KpiId getKpiId() { - if (kpiIdBuilder_ == null) { - return kpiId_ == null ? monitoring.Monitoring.KpiId.getDefaultInstance() : kpiId_; - } else { - return kpiIdBuilder_.getMessage(); - } - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 4; - */ - public Builder setKpiId(monitoring.Monitoring.KpiId value) { - if (kpiIdBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - kpiId_ = value; - } else { - kpiIdBuilder_.setMessage(value); - } - bitField0_ |= 0x00000008; - onChanged(); - return this; - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 4; - */ - public Builder setKpiId(monitoring.Monitoring.KpiId.Builder builderForValue) { - if (kpiIdBuilder_ == null) { - kpiId_ = builderForValue.build(); - } else { - kpiIdBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000008; - onChanged(); - return this; - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 4; - */ - public Builder mergeKpiId(monitoring.Monitoring.KpiId value) { - if (kpiIdBuilder_ == null) { - if (((bitField0_ & 0x00000008) != 0) && kpiId_ != null && kpiId_ != monitoring.Monitoring.KpiId.getDefaultInstance()) { - getKpiIdBuilder().mergeFrom(value); - } else { - kpiId_ = value; - } - } else { - kpiIdBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000008; - onChanged(); - return this; - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 4; - */ - public Builder clearKpiId() { - bitField0_ = (bitField0_ & ~0x00000008); - kpiId_ = null; - if (kpiIdBuilder_ != null) { - kpiIdBuilder_.dispose(); - kpiIdBuilder_ = null; - } - onChanged(); - return this; - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 4; - */ - public monitoring.Monitoring.KpiId.Builder getKpiIdBuilder() { - bitField0_ |= 0x00000008; - onChanged(); - return getKpiIdFieldBuilder().getBuilder(); - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 4; - */ - public monitoring.Monitoring.KpiIdOrBuilder getKpiIdOrBuilder() { - if (kpiIdBuilder_ != null) { - return kpiIdBuilder_.getMessageOrBuilder(); - } else { - return kpiId_ == null ? monitoring.Monitoring.KpiId.getDefaultInstance() : kpiId_; - } - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 4; - */ - private com.google.protobuf.SingleFieldBuilderV3 getKpiIdFieldBuilder() { - if (kpiIdBuilder_ == null) { - kpiIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3(getKpiId(), getParentForChildren(), isClean()); - kpiId_ = null; - } - return kpiIdBuilder_; - } - private java.util.List actionList_ = java.util.Collections.emptyList(); private void ensureActionListIsMutable() { - if (!((bitField0_ & 0x00000010) != 0)) { + if (!((bitField0_ & 0x00000008) != 0)) { actionList_ = new java.util.ArrayList(actionList_); - bitField0_ |= 0x00000010; + bitField0_ |= 0x00000008; } } @@ -2731,10 +2412,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public java.util.List getActionListList() { if (actionListBuilder_ == null) { @@ -2746,10 +2427,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public int getActionListCount() { if (actionListBuilder_ == null) { @@ -2761,10 +2442,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public policy.PolicyAction.PolicyRuleAction getActionList(int index) { if (actionListBuilder_ == null) { @@ -2776,10 +2457,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public Builder setActionList(int index, policy.PolicyAction.PolicyRuleAction value) { if (actionListBuilder_ == null) { @@ -2797,10 +2478,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public Builder setActionList(int index, policy.PolicyAction.PolicyRuleAction.Builder builderForValue) { if (actionListBuilder_ == null) { @@ -2815,10 +2496,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public Builder addActionList(policy.PolicyAction.PolicyRuleAction value) { if (actionListBuilder_ == null) { @@ -2836,10 +2517,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public Builder addActionList(int index, policy.PolicyAction.PolicyRuleAction value) { if (actionListBuilder_ == null) { @@ -2857,10 +2538,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public Builder addActionList(policy.PolicyAction.PolicyRuleAction.Builder builderForValue) { if (actionListBuilder_ == null) { @@ -2875,10 +2556,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public Builder addActionList(int index, policy.PolicyAction.PolicyRuleAction.Builder builderForValue) { if (actionListBuilder_ == null) { @@ -2893,10 +2574,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public Builder addAllActionList(java.lang.Iterable values) { if (actionListBuilder_ == null) { @@ -2911,15 +2592,15 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public Builder clearActionList() { if (actionListBuilder_ == null) { actionList_ = java.util.Collections.emptyList(); - bitField0_ = (bitField0_ & ~0x00000010); + bitField0_ = (bitField0_ & ~0x00000008); onChanged(); } else { actionListBuilder_.clear(); @@ -2929,10 +2610,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public Builder removeActionList(int index) { if (actionListBuilder_ == null) { @@ -2947,10 +2628,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public policy.PolicyAction.PolicyRuleAction.Builder getActionListBuilder(int index) { return getActionListFieldBuilder().getBuilder(index); @@ -2958,10 +2639,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public policy.PolicyAction.PolicyRuleActionOrBuilder getActionListOrBuilder(int index) { if (actionListBuilder_ == null) { @@ -2973,10 +2654,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public java.util.List getActionListOrBuilderList() { if (actionListBuilder_ != null) { @@ -2988,10 +2669,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public policy.PolicyAction.PolicyRuleAction.Builder addActionListBuilder() { return getActionListFieldBuilder().addBuilder(policy.PolicyAction.PolicyRuleAction.getDefaultInstance()); @@ -2999,10 +2680,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public policy.PolicyAction.PolicyRuleAction.Builder addActionListBuilder(int index) { return getActionListFieldBuilder().addBuilder(index, policy.PolicyAction.PolicyRuleAction.getDefaultInstance()); @@ -3010,10 +2691,10 @@ public final class Policy { /** *
-             * Event-Condition-Action (ECA) model
+             * One or more actions should be applied
              * 
* - * repeated .policy.PolicyRuleAction actionList = 5; + * repeated .policy.PolicyRuleAction actionList = 4; */ public java.util.List getActionListBuilderList() { return getActionListFieldBuilder().getBuilderList(); @@ -3021,7 +2702,7 @@ public final class Policy { private com.google.protobuf.RepeatedFieldBuilderV3 getActionListFieldBuilder() { if (actionListBuilder_ == null) { - actionListBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3(actionList_, ((bitField0_ & 0x00000010) != 0), getParentForChildren(), isClean()); + actionListBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3(actionList_, ((bitField0_ & 0x00000008) != 0), getParentForChildren(), isClean()); actionList_ = null; } return actionListBuilder_; @@ -9359,14 +9040,14 @@ public final class Policy { private static com.google.protobuf.Descriptors.FileDescriptor descriptor; static { - java.lang.String[] descriptorData = { "\n\014policy.proto\022\006policy\032\rcontext.proto\032\026p" + "olicy_condition.proto\032\023policy_action.pro" + "to\032\020monitoring.proto\"+\n\014PolicyRuleId\022\033\n\004" + "uuid\030\001 \001(\0132\r.context.Uuid\"g\n\017PolicyRuleS" + "tate\0224\n\017policyRuleState\030\001 \001(\0162\033.policy.P" + "olicyRuleStateEnum\022\036\n\026policyRuleStateMes" + "sage\030\002 \001(\t\"\321\001\n\017PolicyRuleBasic\022*\n\014policy" + "RuleId\030\001 \001(\0132\024.policy.PolicyRuleId\0220\n\017po" + "licyRuleState\030\002 \001(\0132\027.policy.PolicyRuleS" + "tate\022\020\n\010priority\030\003 \001(\r\022 \n\005kpiId\030\004 \001(\0132\021." + "monitoring.KpiId\022,\n\nactionList\030\005 \003(\0132\030.p" + "olicy.PolicyRuleAction\"\223\001\n\021PolicyRuleSer" + "vice\0220\n\017policyRuleBasic\030\001 \001(\0132\027.policy.P" + "olicyRuleBasic\022%\n\tserviceId\030\002 \001(\0132\022.cont" + "ext.ServiceId\022%\n\ndeviceList\030\003 \003(\0132\021.cont" + "ext.DeviceId\"k\n\020PolicyRuleDevice\0220\n\017poli" + "cyRuleBasic\030\001 \001(\0132\027.policy.PolicyRuleBas" + "ic\022%\n\ndeviceList\030\002 \003(\0132\021.context.DeviceI" + "d\"u\n\nPolicyRule\022,\n\007service\030\001 \001(\0132\031.polic" + "y.PolicyRuleServiceH\000\022*\n\006device\030\002 \001(\0132\030." + "policy.PolicyRuleDeviceH\000B\r\n\013policy_rule" + "\"B\n\020PolicyRuleIdList\022.\n\020policyRuleIdList" + "\030\001 \003(\0132\024.policy.PolicyRuleId\"Q\n\025PolicyRu" + "leServiceList\0228\n\025policyRuleServiceList\030\001" + " \003(\0132\031.policy.PolicyRuleService\"N\n\024Polic" + "yRuleDeviceList\0226\n\024policyRuleDeviceList\030" + "\001 \003(\0132\030.policy.PolicyRuleDevice\"9\n\016Polic" + "yRuleList\022\'\n\013policyRules\030\001 \003(\0132\022.policy." + "PolicyRule*\377\001\n\023PolicyRuleStateEnum\022\024\n\020PO" + "LICY_UNDEFINED\020\000\022\021\n\rPOLICY_FAILED\020\001\022\023\n\017P" + "OLICY_INSERTED\020\002\022\024\n\020POLICY_VALIDATED\020\003\022\026" + "\n\022POLICY_PROVISIONED\020\004\022\021\n\rPOLICY_ACTIVE\020" + "\005\022\023\n\017POLICY_ENFORCED\020\006\022\026\n\022POLICY_INEFFEC" + "TIVE\020\007\022\024\n\020POLICY_EFFECTIVE\020\010\022\022\n\016POLICY_U" + "PDATED\020\t\022\022\n\016POLICY_REMOVED\020\n2\323\004\n\rPolicyS" + "ervice\022H\n\020PolicyAddService\022\031.policy.Poli" + "cyRuleService\032\027.policy.PolicyRuleState\"\000" + "\022F\n\017PolicyAddDevice\022\030.policy.PolicyRuleD" + "evice\032\027.policy.PolicyRuleState\"\000\022K\n\023Poli" + "cyUpdateService\022\031.policy.PolicyRuleServi" + "ce\032\027.policy.PolicyRuleState\"\000\022I\n\022PolicyU" + "pdateDevice\022\030.policy.PolicyRuleDevice\032\027." + "policy.PolicyRuleState\"\000\022?\n\014PolicyDelete" + "\022\024.policy.PolicyRuleId\032\027.policy.PolicyRu" + "leState\"\000\022E\n\020GetPolicyService\022\024.policy.P" + "olicyRuleId\032\031.policy.PolicyRuleService\"\000" + "\022C\n\017GetPolicyDevice\022\024.policy.PolicyRuleI" + "d\032\030.policy.PolicyRuleDevice\"\000\022K\n\024GetPoli" + "cyByServiceId\022\022.context.ServiceId\032\035.poli" + "cy.PolicyRuleServiceList\"\000b\006proto3" }; - descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { context.ContextOuterClass.getDescriptor(), policy.PolicyCondition.getDescriptor(), policy.PolicyAction.getDescriptor(), monitoring.Monitoring.getDescriptor() }); + java.lang.String[] descriptorData = { "\n\014policy.proto\022\006policy\032\rcontext.proto\032\023p" + "olicy_action.proto\"+\n\014PolicyRuleId\022\033\n\004uu" + "id\030\001 \001(\0132\r.context.Uuid\"g\n\017PolicyRuleSta" + "te\0224\n\017policyRuleState\030\001 \001(\0162\033.policy.Pol" + "icyRuleStateEnum\022\036\n\026policyRuleStateMessa" + "ge\030\002 \001(\t\"\271\001\n\017PolicyRuleBasic\022*\n\014policyRu" + "leId\030\001 \001(\0132\024.policy.PolicyRuleId\0220\n\017poli" + "cyRuleState\030\002 \001(\0132\027.policy.PolicyRuleSta" + "te\022\032\n\022policyRulePriority\030\003 \001(\r\022,\n\naction" + "List\030\004 \003(\0132\030.policy.PolicyRuleAction\"\223\001\n" + "\021PolicyRuleService\0220\n\017policyRuleBasic\030\001 " + "\001(\0132\027.policy.PolicyRuleBasic\022%\n\tserviceI" + "d\030\002 \001(\0132\022.context.ServiceId\022%\n\ndeviceLis" + "t\030\003 \003(\0132\021.context.DeviceId\"k\n\020PolicyRule" + "Device\0220\n\017policyRuleBasic\030\001 \001(\0132\027.policy" + ".PolicyRuleBasic\022%\n\ndeviceList\030\002 \003(\0132\021.c" + "ontext.DeviceId\"u\n\nPolicyRule\022,\n\007service" + "\030\001 \001(\0132\031.policy.PolicyRuleServiceH\000\022*\n\006d" + "evice\030\002 \001(\0132\030.policy.PolicyRuleDeviceH\000B" + "\r\n\013policy_rule\"B\n\020PolicyRuleIdList\022.\n\020po" + "licyRuleIdList\030\001 \003(\0132\024.policy.PolicyRule" + "Id\"Q\n\025PolicyRuleServiceList\0228\n\025policyRul" + "eServiceList\030\001 \003(\0132\031.policy.PolicyRuleSe" + "rvice\"N\n\024PolicyRuleDeviceList\0226\n\024policyR" + "uleDeviceList\030\001 \003(\0132\030.policy.PolicyRuleD" + "evice\"9\n\016PolicyRuleList\022\'\n\013policyRules\030\001" + " \003(\0132\022.policy.PolicyRule*\377\001\n\023PolicyRuleS" + "tateEnum\022\024\n\020POLICY_UNDEFINED\020\000\022\021\n\rPOLICY" + "_FAILED\020\001\022\023\n\017POLICY_INSERTED\020\002\022\024\n\020POLICY" + "_VALIDATED\020\003\022\026\n\022POLICY_PROVISIONED\020\004\022\021\n\r" + "POLICY_ACTIVE\020\005\022\023\n\017POLICY_ENFORCED\020\006\022\026\n\022" + "POLICY_INEFFECTIVE\020\007\022\024\n\020POLICY_EFFECTIVE" + "\020\010\022\022\n\016POLICY_UPDATED\020\t\022\022\n\016POLICY_REMOVED" + "\020\n2\323\004\n\rPolicyService\022H\n\020PolicyAddService" + "\022\031.policy.PolicyRuleService\032\027.policy.Pol" + "icyRuleState\"\000\022F\n\017PolicyAddDevice\022\030.poli" + "cy.PolicyRuleDevice\032\027.policy.PolicyRuleS" + "tate\"\000\022K\n\023PolicyUpdateService\022\031.policy.P" + "olicyRuleService\032\027.policy.PolicyRuleStat" + "e\"\000\022I\n\022PolicyUpdateDevice\022\030.policy.Polic" + "yRuleDevice\032\027.policy.PolicyRuleState\"\000\022?" + "\n\014PolicyDelete\022\024.policy.PolicyRuleId\032\027.p" + "olicy.PolicyRuleState\"\000\022E\n\020GetPolicyServ" + "ice\022\024.policy.PolicyRuleId\032\031.policy.Polic" + "yRuleService\"\000\022C\n\017GetPolicyDevice\022\024.poli" + "cy.PolicyRuleId\032\030.policy.PolicyRuleDevic" + "e\"\000\022K\n\024GetPolicyByServiceId\022\022.context.Se" + "rviceId\032\035.policy.PolicyRuleServiceList\"\000" + "b\006proto3" }; + descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { context.ContextOuterClass.getDescriptor(), policy.PolicyAction.getDescriptor() }); internal_static_policy_PolicyRuleId_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_policy_PolicyRuleId_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleId_descriptor, new java.lang.String[] { "Uuid" }); internal_static_policy_PolicyRuleState_descriptor = getDescriptor().getMessageTypes().get(1); internal_static_policy_PolicyRuleState_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleState_descriptor, new java.lang.String[] { "PolicyRuleState", "PolicyRuleStateMessage" }); internal_static_policy_PolicyRuleBasic_descriptor = getDescriptor().getMessageTypes().get(2); - internal_static_policy_PolicyRuleBasic_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleBasic_descriptor, new java.lang.String[] { "PolicyRuleId", "PolicyRuleState", "Priority", "KpiId", "ActionList" }); + internal_static_policy_PolicyRuleBasic_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleBasic_descriptor, new java.lang.String[] { "PolicyRuleId", "PolicyRuleState", "PolicyRulePriority", "ActionList" }); internal_static_policy_PolicyRuleService_descriptor = getDescriptor().getMessageTypes().get(3); internal_static_policy_PolicyRuleService_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleService_descriptor, new java.lang.String[] { "PolicyRuleBasic", "ServiceId", "DeviceList" }); internal_static_policy_PolicyRuleDevice_descriptor = getDescriptor().getMessageTypes().get(4); @@ -9382,9 +9063,7 @@ public final class Policy { internal_static_policy_PolicyRuleList_descriptor = getDescriptor().getMessageTypes().get(9); internal_static_policy_PolicyRuleList_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleList_descriptor, new java.lang.String[] { "PolicyRules" }); context.ContextOuterClass.getDescriptor(); - policy.PolicyCondition.getDescriptor(); policy.PolicyAction.getDescriptor(); - monitoring.Monitoring.getDescriptor(); } // @@protoc_insertion_point(outer_class_scope) } diff --git a/src/policy/target/generated-sources/grpc/policy/PolicyCondition.java b/src/policy/target/generated-sources/grpc/policy/PolicyCondition.java deleted file mode 100644 index f5b5fd967..000000000 --- a/src/policy/target/generated-sources/grpc/policy/PolicyCondition.java +++ /dev/null @@ -1,1318 +0,0 @@ -// Generated by the protocol buffer compiler. DO NOT EDIT! -// source: policy_condition.proto -package policy; - -public final class PolicyCondition { - - private PolicyCondition() { - } - - public static void registerAllExtensions(com.google.protobuf.ExtensionRegistryLite registry) { - } - - public static void registerAllExtensions(com.google.protobuf.ExtensionRegistry registry) { - registerAllExtensions((com.google.protobuf.ExtensionRegistryLite) registry); - } - - /** - *
-     * Operator to be used when comparing Kpis with condition values
-     * 
- * - * Protobuf enum {@code policy.NumericalOperator} - */ - public enum NumericalOperator implements com.google.protobuf.ProtocolMessageEnum { - - /** - *
-         * Kpi numerical operator undefined
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_UNDEFINED = 0; - */ - POLICYRULE_CONDITION_NUMERICAL_UNDEFINED(0), - /** - *
-         * Kpi is equal with value
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_EQUAL = 1; - */ - POLICYRULE_CONDITION_NUMERICAL_EQUAL(1), - /** - *
-         * Kpi is not equal with value
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_NOT_EQUAL = 2; - */ - POLICYRULE_CONDITION_NUMERICAL_NOT_EQUAL(2), - /** - *
-         * Kpi is less than value
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_LESS_THAN = 3; - */ - POLICYRULE_CONDITION_NUMERICAL_LESS_THAN(3), - /** - *
-         * Kpi is less than or equal with value
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL = 4; - */ - POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL(4), - /** - *
-         * Kpi is greater than value
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN = 5; - */ - POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN(5), - /** - *
-         * Kpi is less than or equal with value
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL = 6; - */ - POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL(6), - UNRECOGNIZED(-1); - - /** - *
-         * Kpi numerical operator undefined
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_UNDEFINED = 0; - */ - public static final int POLICYRULE_CONDITION_NUMERICAL_UNDEFINED_VALUE = 0; - - /** - *
-         * Kpi is equal with value
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_EQUAL = 1; - */ - public static final int POLICYRULE_CONDITION_NUMERICAL_EQUAL_VALUE = 1; - - /** - *
-         * Kpi is not equal with value
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_NOT_EQUAL = 2; - */ - public static final int POLICYRULE_CONDITION_NUMERICAL_NOT_EQUAL_VALUE = 2; - - /** - *
-         * Kpi is less than value
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_LESS_THAN = 3; - */ - public static final int POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_VALUE = 3; - - /** - *
-         * Kpi is less than or equal with value
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL = 4; - */ - public static final int POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL_VALUE = 4; - - /** - *
-         * Kpi is greater than value
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN = 5; - */ - public static final int POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_VALUE = 5; - - /** - *
-         * Kpi is less than or equal with value
-         * 
- * - * POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL = 6; - */ - public static final int POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL_VALUE = 6; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException("Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static NumericalOperator valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static NumericalOperator forNumber(int value) { - switch(value) { - case 0: - return POLICYRULE_CONDITION_NUMERICAL_UNDEFINED; - case 1: - return POLICYRULE_CONDITION_NUMERICAL_EQUAL; - case 2: - return POLICYRULE_CONDITION_NUMERICAL_NOT_EQUAL; - case 3: - return POLICYRULE_CONDITION_NUMERICAL_LESS_THAN; - case 4: - return POLICYRULE_CONDITION_NUMERICAL_LESS_THAN_EQUAL; - case 5: - return POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN; - case 6: - return POLICYRULE_CONDITION_NUMERICAL_GREATER_THAN_EQUAL; - default: - return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { - return internalValueMap; - } - - private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = new com.google.protobuf.Internal.EnumLiteMap() { - - public NumericalOperator findValueByNumber(int number) { - return NumericalOperator.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException("Can't get the descriptor of an unrecognized enum value."); - } - return getDescriptor().getValues().get(ordinal()); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { - return getDescriptor(); - } - - public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return policy.PolicyCondition.getDescriptor().getEnumTypes().get(0); - } - - private static final NumericalOperator[] VALUES = values(); - - public static NumericalOperator valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private NumericalOperator(int value) { - this.value = value; - } - } - - /** - *
-     * Operator to be used when evaluating each condition
-     * 
- * - * Protobuf enum {@code policy.BooleanOperator} - */ - public enum BooleanOperator implements com.google.protobuf.ProtocolMessageEnum { - - /** - *
-         * Boolean operator undefined
-         * 
- * - * POLICYRULE_CONDITION_BOOLEAN_UNDEFINED = 0; - */ - POLICYRULE_CONDITION_BOOLEAN_UNDEFINED(0), - /** - *
-         * Boolean AND operator
-         * 
- * - * POLICYRULE_CONDITION_BOOLEAN_AND = 1; - */ - POLICYRULE_CONDITION_BOOLEAN_AND(1), - /** - *
-         * Boolean OR operator
-         * 
- * - * POLICYRULE_CONDITION_BOOLEAN_OR = 2; - */ - POLICYRULE_CONDITION_BOOLEAN_OR(2), - UNRECOGNIZED(-1); - - /** - *
-         * Boolean operator undefined
-         * 
- * - * POLICYRULE_CONDITION_BOOLEAN_UNDEFINED = 0; - */ - public static final int POLICYRULE_CONDITION_BOOLEAN_UNDEFINED_VALUE = 0; - - /** - *
-         * Boolean AND operator
-         * 
- * - * POLICYRULE_CONDITION_BOOLEAN_AND = 1; - */ - public static final int POLICYRULE_CONDITION_BOOLEAN_AND_VALUE = 1; - - /** - *
-         * Boolean OR operator
-         * 
- * - * POLICYRULE_CONDITION_BOOLEAN_OR = 2; - */ - public static final int POLICYRULE_CONDITION_BOOLEAN_OR_VALUE = 2; - - public final int getNumber() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalArgumentException("Can't get the number of an unknown enum value."); - } - return value; - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - * @deprecated Use {@link #forNumber(int)} instead. - */ - @java.lang.Deprecated - public static BooleanOperator valueOf(int value) { - return forNumber(value); - } - - /** - * @param value The numeric wire value of the corresponding enum entry. - * @return The enum associated with the given numeric wire value. - */ - public static BooleanOperator forNumber(int value) { - switch(value) { - case 0: - return POLICYRULE_CONDITION_BOOLEAN_UNDEFINED; - case 1: - return POLICYRULE_CONDITION_BOOLEAN_AND; - case 2: - return POLICYRULE_CONDITION_BOOLEAN_OR; - default: - return null; - } - } - - public static com.google.protobuf.Internal.EnumLiteMap internalGetValueMap() { - return internalValueMap; - } - - private static final com.google.protobuf.Internal.EnumLiteMap internalValueMap = new com.google.protobuf.Internal.EnumLiteMap() { - - public BooleanOperator findValueByNumber(int number) { - return BooleanOperator.forNumber(number); - } - }; - - public final com.google.protobuf.Descriptors.EnumValueDescriptor getValueDescriptor() { - if (this == UNRECOGNIZED) { - throw new java.lang.IllegalStateException("Can't get the descriptor of an unrecognized enum value."); - } - return getDescriptor().getValues().get(ordinal()); - } - - public final com.google.protobuf.Descriptors.EnumDescriptor getDescriptorForType() { - return getDescriptor(); - } - - public static final com.google.protobuf.Descriptors.EnumDescriptor getDescriptor() { - return policy.PolicyCondition.getDescriptor().getEnumTypes().get(1); - } - - private static final BooleanOperator[] VALUES = values(); - - public static BooleanOperator valueOf(com.google.protobuf.Descriptors.EnumValueDescriptor desc) { - if (desc.getType() != getDescriptor()) { - throw new java.lang.IllegalArgumentException("EnumValueDescriptor is not for this type."); - } - if (desc.getIndex() == -1) { - return UNRECOGNIZED; - } - return VALUES[desc.getIndex()]; - } - - private final int value; - - private BooleanOperator(int value) { - this.value = value; - } - } - - public interface PolicyRuleConditionOrBuilder extends // @@protoc_insertion_point(interface_extends:policy.PolicyRuleCondition) - com.google.protobuf.MessageOrBuilder { - - /** - *
-         * to be migrated to: "kpi_manager.KpiId"
-         * 
- * - * .monitoring.KpiId kpiId = 1; - * @return Whether the kpiId field is set. - */ - boolean hasKpiId(); - - /** - *
-         * to be migrated to: "kpi_manager.KpiId"
-         * 
- * - * .monitoring.KpiId kpiId = 1; - * @return The kpiId. - */ - monitoring.Monitoring.KpiId getKpiId(); - - /** - *
-         * to be migrated to: "kpi_manager.KpiId"
-         * 
- * - * .monitoring.KpiId kpiId = 1; - */ - monitoring.Monitoring.KpiIdOrBuilder getKpiIdOrBuilder(); - - /** - * .policy.NumericalOperator numericalOperator = 2; - * @return The enum numeric value on the wire for numericalOperator. - */ - int getNumericalOperatorValue(); - - /** - * .policy.NumericalOperator numericalOperator = 2; - * @return The numericalOperator. - */ - policy.PolicyCondition.NumericalOperator getNumericalOperator(); - - /** - * .monitoring.KpiValue kpiValue = 3; - * @return Whether the kpiValue field is set. - */ - boolean hasKpiValue(); - - /** - * .monitoring.KpiValue kpiValue = 3; - * @return The kpiValue. - */ - monitoring.Monitoring.KpiValue getKpiValue(); - - /** - * .monitoring.KpiValue kpiValue = 3; - */ - monitoring.Monitoring.KpiValueOrBuilder getKpiValueOrBuilder(); - } - - /** - *
-     * Condition
-     * 
- * - * Protobuf type {@code policy.PolicyRuleCondition} - */ - public static final class PolicyRuleCondition extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:policy.PolicyRuleCondition) - PolicyRuleConditionOrBuilder { - - private static final long serialVersionUID = 0L; - - // Use PolicyRuleCondition.newBuilder() to construct. - private PolicyRuleCondition(com.google.protobuf.GeneratedMessageV3.Builder builder) { - super(builder); - } - - private PolicyRuleCondition() { - numericalOperator_ = 0; - } - - @java.lang.Override - @SuppressWarnings({ "unused" }) - protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new PolicyRuleCondition(); - } - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return policy.PolicyCondition.internal_static_policy_PolicyRuleCondition_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return policy.PolicyCondition.internal_static_policy_PolicyRuleCondition_fieldAccessorTable.ensureFieldAccessorsInitialized(policy.PolicyCondition.PolicyRuleCondition.class, policy.PolicyCondition.PolicyRuleCondition.Builder.class); - } - - public static final int KPIID_FIELD_NUMBER = 1; - - private monitoring.Monitoring.KpiId kpiId_; - - /** - *
-         * to be migrated to: "kpi_manager.KpiId"
-         * 
- * - * .monitoring.KpiId kpiId = 1; - * @return Whether the kpiId field is set. - */ - @java.lang.Override - public boolean hasKpiId() { - return kpiId_ != null; - } - - /** - *
-         * to be migrated to: "kpi_manager.KpiId"
-         * 
- * - * .monitoring.KpiId kpiId = 1; - * @return The kpiId. - */ - @java.lang.Override - public monitoring.Monitoring.KpiId getKpiId() { - return kpiId_ == null ? monitoring.Monitoring.KpiId.getDefaultInstance() : kpiId_; - } - - /** - *
-         * to be migrated to: "kpi_manager.KpiId"
-         * 
- * - * .monitoring.KpiId kpiId = 1; - */ - @java.lang.Override - public monitoring.Monitoring.KpiIdOrBuilder getKpiIdOrBuilder() { - return kpiId_ == null ? monitoring.Monitoring.KpiId.getDefaultInstance() : kpiId_; - } - - public static final int NUMERICALOPERATOR_FIELD_NUMBER = 2; - - private int numericalOperator_ = 0; - - /** - * .policy.NumericalOperator numericalOperator = 2; - * @return The enum numeric value on the wire for numericalOperator. - */ - @java.lang.Override - public int getNumericalOperatorValue() { - return numericalOperator_; - } - - /** - * .policy.NumericalOperator numericalOperator = 2; - * @return The numericalOperator. - */ - @java.lang.Override - public policy.PolicyCondition.NumericalOperator getNumericalOperator() { - policy.PolicyCondition.NumericalOperator result = policy.PolicyCondition.NumericalOperator.forNumber(numericalOperator_); - return result == null ? policy.PolicyCondition.NumericalOperator.UNRECOGNIZED : result; - } - - public static final int KPIVALUE_FIELD_NUMBER = 3; - - private monitoring.Monitoring.KpiValue kpiValue_; - - /** - * .monitoring.KpiValue kpiValue = 3; - * @return Whether the kpiValue field is set. - */ - @java.lang.Override - public boolean hasKpiValue() { - return kpiValue_ != null; - } - - /** - * .monitoring.KpiValue kpiValue = 3; - * @return The kpiValue. - */ - @java.lang.Override - public monitoring.Monitoring.KpiValue getKpiValue() { - return kpiValue_ == null ? monitoring.Monitoring.KpiValue.getDefaultInstance() : kpiValue_; - } - - /** - * .monitoring.KpiValue kpiValue = 3; - */ - @java.lang.Override - public monitoring.Monitoring.KpiValueOrBuilder getKpiValueOrBuilder() { - return kpiValue_ == null ? monitoring.Monitoring.KpiValue.getDefaultInstance() : kpiValue_; - } - - private byte memoizedIsInitialized = -1; - - @java.lang.Override - public final boolean isInitialized() { - byte isInitialized = memoizedIsInitialized; - if (isInitialized == 1) - return true; - if (isInitialized == 0) - return false; - memoizedIsInitialized = 1; - return true; - } - - @java.lang.Override - public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (kpiId_ != null) { - output.writeMessage(1, getKpiId()); - } - if (numericalOperator_ != policy.PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_UNDEFINED.getNumber()) { - output.writeEnum(2, numericalOperator_); - } - if (kpiValue_ != null) { - output.writeMessage(3, getKpiValue()); - } - getUnknownFields().writeTo(output); - } - - @java.lang.Override - public int getSerializedSize() { - int size = memoizedSize; - if (size != -1) - return size; - size = 0; - if (kpiId_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getKpiId()); - } - if (numericalOperator_ != policy.PolicyCondition.NumericalOperator.POLICYRULE_CONDITION_NUMERICAL_UNDEFINED.getNumber()) { - size += com.google.protobuf.CodedOutputStream.computeEnumSize(2, numericalOperator_); - } - if (kpiValue_ != null) { - size += com.google.protobuf.CodedOutputStream.computeMessageSize(3, getKpiValue()); - } - size += getUnknownFields().getSerializedSize(); - memoizedSize = size; - return size; - } - - @java.lang.Override - public boolean equals(final java.lang.Object obj) { - if (obj == this) { - return true; - } - if (!(obj instanceof policy.PolicyCondition.PolicyRuleCondition)) { - return super.equals(obj); - } - policy.PolicyCondition.PolicyRuleCondition other = (policy.PolicyCondition.PolicyRuleCondition) obj; - if (hasKpiId() != other.hasKpiId()) - return false; - if (hasKpiId()) { - if (!getKpiId().equals(other.getKpiId())) - return false; - } - if (numericalOperator_ != other.numericalOperator_) - return false; - if (hasKpiValue() != other.hasKpiValue()) - return false; - if (hasKpiValue()) { - if (!getKpiValue().equals(other.getKpiValue())) - return false; - } - if (!getUnknownFields().equals(other.getUnknownFields())) - return false; - return true; - } - - @java.lang.Override - public int hashCode() { - if (memoizedHashCode != 0) { - return memoizedHashCode; - } - int hash = 41; - hash = (19 * hash) + getDescriptor().hashCode(); - if (hasKpiId()) { - hash = (37 * hash) + KPIID_FIELD_NUMBER; - hash = (53 * hash) + getKpiId().hashCode(); - } - hash = (37 * hash) + NUMERICALOPERATOR_FIELD_NUMBER; - hash = (53 * hash) + numericalOperator_; - if (hasKpiValue()) { - hash = (37 * hash) + KPIVALUE_FIELD_NUMBER; - hash = (53 * hash) + getKpiValue().hashCode(); - } - hash = (29 * hash) + getUnknownFields().hashCode(); - memoizedHashCode = hash; - return hash; - } - - public static policy.PolicyCondition.PolicyRuleCondition parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static policy.PolicyCondition.PolicyRuleCondition parseFrom(java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static policy.PolicyCondition.PolicyRuleCondition parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static policy.PolicyCondition.PolicyRuleCondition parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static policy.PolicyCondition.PolicyRuleCondition parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data); - } - - public static policy.PolicyCondition.PolicyRuleCondition parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - return PARSER.parseFrom(data, extensionRegistry); - } - - public static policy.PolicyCondition.PolicyRuleCondition parseFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static policy.PolicyCondition.PolicyRuleCondition parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input, extensionRegistry); - } - - public static policy.PolicyCondition.PolicyRuleCondition parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); - } - - public static policy.PolicyCondition.PolicyRuleCondition parseDelimitedFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input, extensionRegistry); - } - - public static policy.PolicyCondition.PolicyRuleCondition parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); - } - - public static policy.PolicyCondition.PolicyRuleCondition parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input, extensionRegistry); - } - - @java.lang.Override - public Builder newBuilderForType() { - return newBuilder(); - } - - public static Builder newBuilder() { - return DEFAULT_INSTANCE.toBuilder(); - } - - public static Builder newBuilder(policy.PolicyCondition.PolicyRuleCondition prototype) { - return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); - } - - @java.lang.Override - public Builder toBuilder() { - return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); - } - - @java.lang.Override - protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - Builder builder = new Builder(parent); - return builder; - } - - /** - *
-         * Condition
-         * 
- * - * Protobuf type {@code policy.PolicyRuleCondition} - */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements // @@protoc_insertion_point(builder_implements:policy.PolicyRuleCondition) - policy.PolicyCondition.PolicyRuleConditionOrBuilder { - - public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return policy.PolicyCondition.internal_static_policy_PolicyRuleCondition_descriptor; - } - - @java.lang.Override - protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return policy.PolicyCondition.internal_static_policy_PolicyRuleCondition_fieldAccessorTable.ensureFieldAccessorsInitialized(policy.PolicyCondition.PolicyRuleCondition.class, policy.PolicyCondition.PolicyRuleCondition.Builder.class); - } - - // Construct using policy.PolicyCondition.PolicyRuleCondition.newBuilder() - private Builder() { - } - - private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { - super(parent); - } - - @java.lang.Override - public Builder clear() { - super.clear(); - bitField0_ = 0; - kpiId_ = null; - if (kpiIdBuilder_ != null) { - kpiIdBuilder_.dispose(); - kpiIdBuilder_ = null; - } - numericalOperator_ = 0; - kpiValue_ = null; - if (kpiValueBuilder_ != null) { - kpiValueBuilder_.dispose(); - kpiValueBuilder_ = null; - } - return this; - } - - @java.lang.Override - public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return policy.PolicyCondition.internal_static_policy_PolicyRuleCondition_descriptor; - } - - @java.lang.Override - public policy.PolicyCondition.PolicyRuleCondition getDefaultInstanceForType() { - return policy.PolicyCondition.PolicyRuleCondition.getDefaultInstance(); - } - - @java.lang.Override - public policy.PolicyCondition.PolicyRuleCondition build() { - policy.PolicyCondition.PolicyRuleCondition result = buildPartial(); - if (!result.isInitialized()) { - throw newUninitializedMessageException(result); - } - return result; - } - - @java.lang.Override - public policy.PolicyCondition.PolicyRuleCondition buildPartial() { - policy.PolicyCondition.PolicyRuleCondition result = new policy.PolicyCondition.PolicyRuleCondition(this); - if (bitField0_ != 0) { - buildPartial0(result); - } - onBuilt(); - return result; - } - - private void buildPartial0(policy.PolicyCondition.PolicyRuleCondition result) { - int from_bitField0_ = bitField0_; - if (((from_bitField0_ & 0x00000001) != 0)) { - result.kpiId_ = kpiIdBuilder_ == null ? kpiId_ : kpiIdBuilder_.build(); - } - if (((from_bitField0_ & 0x00000002) != 0)) { - result.numericalOperator_ = numericalOperator_; - } - if (((from_bitField0_ & 0x00000004) != 0)) { - result.kpiValue_ = kpiValueBuilder_ == null ? kpiValue_ : kpiValueBuilder_.build(); - } - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof policy.PolicyCondition.PolicyRuleCondition) { - return mergeFrom((policy.PolicyCondition.PolicyRuleCondition) other); - } else { - super.mergeFrom(other); - return this; - } - } - - public Builder mergeFrom(policy.PolicyCondition.PolicyRuleCondition other) { - if (other == policy.PolicyCondition.PolicyRuleCondition.getDefaultInstance()) - return this; - if (other.hasKpiId()) { - mergeKpiId(other.getKpiId()); - } - if (other.numericalOperator_ != 0) { - setNumericalOperatorValue(other.getNumericalOperatorValue()); - } - if (other.hasKpiValue()) { - mergeKpiValue(other.getKpiValue()); - } - this.mergeUnknownFields(other.getUnknownFields()); - onChanged(); - return this; - } - - @java.lang.Override - public final boolean isInitialized() { - return true; - } - - @java.lang.Override - public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { - if (extensionRegistry == null) { - throw new java.lang.NullPointerException(); - } - try { - boolean done = false; - while (!done) { - int tag = input.readTag(); - switch(tag) { - case 0: - done = true; - break; - case 10: - { - input.readMessage(getKpiIdFieldBuilder().getBuilder(), extensionRegistry); - bitField0_ |= 0x00000001; - break; - } - // case 10 - case 16: - { - numericalOperator_ = input.readEnum(); - bitField0_ |= 0x00000002; - break; - } - // case 16 - case 26: - { - input.readMessage(getKpiValueFieldBuilder().getBuilder(), extensionRegistry); - bitField0_ |= 0x00000004; - break; - } - // case 26 - default: - { - if (!super.parseUnknownField(input, extensionRegistry, tag)) { - // was an endgroup tag - done = true; - } - break; - } - } - // switch (tag) - } - // while (!done) - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.unwrapIOException(); - } finally { - onChanged(); - } - // finally - return this; - } - - private int bitField0_; - - private monitoring.Monitoring.KpiId kpiId_; - - private com.google.protobuf.SingleFieldBuilderV3 kpiIdBuilder_; - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 1; - * @return Whether the kpiId field is set. - */ - public boolean hasKpiId() { - return ((bitField0_ & 0x00000001) != 0); - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 1; - * @return The kpiId. - */ - public monitoring.Monitoring.KpiId getKpiId() { - if (kpiIdBuilder_ == null) { - return kpiId_ == null ? monitoring.Monitoring.KpiId.getDefaultInstance() : kpiId_; - } else { - return kpiIdBuilder_.getMessage(); - } - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 1; - */ - public Builder setKpiId(monitoring.Monitoring.KpiId value) { - if (kpiIdBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - kpiId_ = value; - } else { - kpiIdBuilder_.setMessage(value); - } - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 1; - */ - public Builder setKpiId(monitoring.Monitoring.KpiId.Builder builderForValue) { - if (kpiIdBuilder_ == null) { - kpiId_ = builderForValue.build(); - } else { - kpiIdBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 1; - */ - public Builder mergeKpiId(monitoring.Monitoring.KpiId value) { - if (kpiIdBuilder_ == null) { - if (((bitField0_ & 0x00000001) != 0) && kpiId_ != null && kpiId_ != monitoring.Monitoring.KpiId.getDefaultInstance()) { - getKpiIdBuilder().mergeFrom(value); - } else { - kpiId_ = value; - } - } else { - kpiIdBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000001; - onChanged(); - return this; - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 1; - */ - public Builder clearKpiId() { - bitField0_ = (bitField0_ & ~0x00000001); - kpiId_ = null; - if (kpiIdBuilder_ != null) { - kpiIdBuilder_.dispose(); - kpiIdBuilder_ = null; - } - onChanged(); - return this; - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 1; - */ - public monitoring.Monitoring.KpiId.Builder getKpiIdBuilder() { - bitField0_ |= 0x00000001; - onChanged(); - return getKpiIdFieldBuilder().getBuilder(); - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 1; - */ - public monitoring.Monitoring.KpiIdOrBuilder getKpiIdOrBuilder() { - if (kpiIdBuilder_ != null) { - return kpiIdBuilder_.getMessageOrBuilder(); - } else { - return kpiId_ == null ? monitoring.Monitoring.KpiId.getDefaultInstance() : kpiId_; - } - } - - /** - *
-             * to be migrated to: "kpi_manager.KpiId"
-             * 
- * - * .monitoring.KpiId kpiId = 1; - */ - private com.google.protobuf.SingleFieldBuilderV3 getKpiIdFieldBuilder() { - if (kpiIdBuilder_ == null) { - kpiIdBuilder_ = new com.google.protobuf.SingleFieldBuilderV3(getKpiId(), getParentForChildren(), isClean()); - kpiId_ = null; - } - return kpiIdBuilder_; - } - - private int numericalOperator_ = 0; - - /** - * .policy.NumericalOperator numericalOperator = 2; - * @return The enum numeric value on the wire for numericalOperator. - */ - @java.lang.Override - public int getNumericalOperatorValue() { - return numericalOperator_; - } - - /** - * .policy.NumericalOperator numericalOperator = 2; - * @param value The enum numeric value on the wire for numericalOperator to set. - * @return This builder for chaining. - */ - public Builder setNumericalOperatorValue(int value) { - numericalOperator_ = value; - bitField0_ |= 0x00000002; - onChanged(); - return this; - } - - /** - * .policy.NumericalOperator numericalOperator = 2; - * @return The numericalOperator. - */ - @java.lang.Override - public policy.PolicyCondition.NumericalOperator getNumericalOperator() { - policy.PolicyCondition.NumericalOperator result = policy.PolicyCondition.NumericalOperator.forNumber(numericalOperator_); - return result == null ? policy.PolicyCondition.NumericalOperator.UNRECOGNIZED : result; - } - - /** - * .policy.NumericalOperator numericalOperator = 2; - * @param value The numericalOperator to set. - * @return This builder for chaining. - */ - public Builder setNumericalOperator(policy.PolicyCondition.NumericalOperator value) { - if (value == null) { - throw new NullPointerException(); - } - bitField0_ |= 0x00000002; - numericalOperator_ = value.getNumber(); - onChanged(); - return this; - } - - /** - * .policy.NumericalOperator numericalOperator = 2; - * @return This builder for chaining. - */ - public Builder clearNumericalOperator() { - bitField0_ = (bitField0_ & ~0x00000002); - numericalOperator_ = 0; - onChanged(); - return this; - } - - private monitoring.Monitoring.KpiValue kpiValue_; - - private com.google.protobuf.SingleFieldBuilderV3 kpiValueBuilder_; - - /** - * .monitoring.KpiValue kpiValue = 3; - * @return Whether the kpiValue field is set. - */ - public boolean hasKpiValue() { - return ((bitField0_ & 0x00000004) != 0); - } - - /** - * .monitoring.KpiValue kpiValue = 3; - * @return The kpiValue. - */ - public monitoring.Monitoring.KpiValue getKpiValue() { - if (kpiValueBuilder_ == null) { - return kpiValue_ == null ? monitoring.Monitoring.KpiValue.getDefaultInstance() : kpiValue_; - } else { - return kpiValueBuilder_.getMessage(); - } - } - - /** - * .monitoring.KpiValue kpiValue = 3; - */ - public Builder setKpiValue(monitoring.Monitoring.KpiValue value) { - if (kpiValueBuilder_ == null) { - if (value == null) { - throw new NullPointerException(); - } - kpiValue_ = value; - } else { - kpiValueBuilder_.setMessage(value); - } - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - - /** - * .monitoring.KpiValue kpiValue = 3; - */ - public Builder setKpiValue(monitoring.Monitoring.KpiValue.Builder builderForValue) { - if (kpiValueBuilder_ == null) { - kpiValue_ = builderForValue.build(); - } else { - kpiValueBuilder_.setMessage(builderForValue.build()); - } - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - - /** - * .monitoring.KpiValue kpiValue = 3; - */ - public Builder mergeKpiValue(monitoring.Monitoring.KpiValue value) { - if (kpiValueBuilder_ == null) { - if (((bitField0_ & 0x00000004) != 0) && kpiValue_ != null && kpiValue_ != monitoring.Monitoring.KpiValue.getDefaultInstance()) { - getKpiValueBuilder().mergeFrom(value); - } else { - kpiValue_ = value; - } - } else { - kpiValueBuilder_.mergeFrom(value); - } - bitField0_ |= 0x00000004; - onChanged(); - return this; - } - - /** - * .monitoring.KpiValue kpiValue = 3; - */ - public Builder clearKpiValue() { - bitField0_ = (bitField0_ & ~0x00000004); - kpiValue_ = null; - if (kpiValueBuilder_ != null) { - kpiValueBuilder_.dispose(); - kpiValueBuilder_ = null; - } - onChanged(); - return this; - } - - /** - * .monitoring.KpiValue kpiValue = 3; - */ - public monitoring.Monitoring.KpiValue.Builder getKpiValueBuilder() { - bitField0_ |= 0x00000004; - onChanged(); - return getKpiValueFieldBuilder().getBuilder(); - } - - /** - * .monitoring.KpiValue kpiValue = 3; - */ - public monitoring.Monitoring.KpiValueOrBuilder getKpiValueOrBuilder() { - if (kpiValueBuilder_ != null) { - return kpiValueBuilder_.getMessageOrBuilder(); - } else { - return kpiValue_ == null ? monitoring.Monitoring.KpiValue.getDefaultInstance() : kpiValue_; - } - } - - /** - * .monitoring.KpiValue kpiValue = 3; - */ - private com.google.protobuf.SingleFieldBuilderV3 getKpiValueFieldBuilder() { - if (kpiValueBuilder_ == null) { - kpiValueBuilder_ = new com.google.protobuf.SingleFieldBuilderV3(getKpiValue(), getParentForChildren(), isClean()); - kpiValue_ = null; - } - return kpiValueBuilder_; - } - - @java.lang.Override - public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.setUnknownFields(unknownFields); - } - - @java.lang.Override - public final Builder mergeUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { - return super.mergeUnknownFields(unknownFields); - } - // @@protoc_insertion_point(builder_scope:policy.PolicyRuleCondition) - } - - // @@protoc_insertion_point(class_scope:policy.PolicyRuleCondition) - private static final policy.PolicyCondition.PolicyRuleCondition DEFAULT_INSTANCE; - - static { - DEFAULT_INSTANCE = new policy.PolicyCondition.PolicyRuleCondition(); - } - - public static policy.PolicyCondition.PolicyRuleCondition getDefaultInstance() { - return DEFAULT_INSTANCE; - } - - private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { - - @java.lang.Override - public PolicyRuleCondition parsePartialFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { - Builder builder = newBuilder(); - try { - builder.mergeFrom(input, extensionRegistry); - } catch (com.google.protobuf.InvalidProtocolBufferException e) { - throw e.setUnfinishedMessage(builder.buildPartial()); - } catch (com.google.protobuf.UninitializedMessageException e) { - throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); - } catch (java.io.IOException e) { - throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(builder.buildPartial()); - } - return builder.buildPartial(); - } - }; - - public static com.google.protobuf.Parser parser() { - return PARSER; - } - - @java.lang.Override - public com.google.protobuf.Parser getParserForType() { - return PARSER; - } - - @java.lang.Override - public policy.PolicyCondition.PolicyRuleCondition getDefaultInstanceForType() { - return DEFAULT_INSTANCE; - } - } - - private static final com.google.protobuf.Descriptors.Descriptor internal_static_policy_PolicyRuleCondition_descriptor; - - private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_policy_PolicyRuleCondition_fieldAccessorTable; - - public static com.google.protobuf.Descriptors.FileDescriptor getDescriptor() { - return descriptor; - } - - private static com.google.protobuf.Descriptors.FileDescriptor descriptor; - - static { - java.lang.String[] descriptorData = { "\n\026policy_condition.proto\022\006policy\032\020monito" + "ring.proto\"\225\001\n\023PolicyRuleCondition\022 \n\005kp" + "iId\030\001 \001(\0132\021.monitoring.KpiId\0224\n\021numerica" + "lOperator\030\002 \001(\0162\031.policy.NumericalOperat" + "or\022&\n\010kpiValue\030\003 \001(\0132\024.monitoring.KpiVal" + "ue*\343\002\n\021NumericalOperator\022,\n(POLICYRULE_C" + "ONDITION_NUMERICAL_UNDEFINED\020\000\022(\n$POLICY" + "RULE_CONDITION_NUMERICAL_EQUAL\020\001\022,\n(POLI" + "CYRULE_CONDITION_NUMERICAL_NOT_EQUAL\020\002\022," + "\n(POLICYRULE_CONDITION_NUMERICAL_LESS_TH" + "AN\020\003\0222\n.POLICYRULE_CONDITION_NUMERICAL_L" + "ESS_THAN_EQUAL\020\004\022/\n+POLICYRULE_CONDITION" + "_NUMERICAL_GREATER_THAN\020\005\0225\n1POLICYRULE_" + "CONDITION_NUMERICAL_GREATER_THAN_EQUAL\020\006" + "*\210\001\n\017BooleanOperator\022*\n&POLICYRULE_CONDI" + "TION_BOOLEAN_UNDEFINED\020\000\022$\n POLICYRULE_C" + "ONDITION_BOOLEAN_AND\020\001\022#\n\037POLICYRULE_CON" + "DITION_BOOLEAN_OR\020\002b\006proto3" }; - descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { monitoring.Monitoring.getDescriptor() }); - internal_static_policy_PolicyRuleCondition_descriptor = getDescriptor().getMessageTypes().get(0); - internal_static_policy_PolicyRuleCondition_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleCondition_descriptor, new java.lang.String[] { "KpiId", "NumericalOperator", "KpiValue" }); - monitoring.Monitoring.getDescriptor(); - } - // @@protoc_insertion_point(outer_class_scope) -} diff --git a/src/policy/target/kubernetes/kubernetes.yml b/src/policy/target/kubernetes/kubernetes.yml index 820135c62..6a45328b1 100644 --- a/src/policy/target/kubernetes/kubernetes.yml +++ b/src/policy/target/kubernetes/kubernetes.yml @@ -3,8 +3,8 @@ apiVersion: v1 kind: Service metadata: annotations: - app.quarkus.io/commit-id: 011890de6d6852d8308c9774d504a002cbbeca55 - app.quarkus.io/build-timestamp: 2025-11-11 - 19:21:22 +0000 + app.quarkus.io/commit-id: eb5af5697ca52e97a05476854dd7effb3bfa2d6b + app.quarkus.io/build-timestamp: 2026-02-18 - 12:55:59 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" @@ -17,18 +17,14 @@ metadata: name: policyservice spec: ports: - - name: https - port: 443 - protocol: TCP - targetPort: 8443 - - name: grpc - port: 6060 - protocol: TCP - targetPort: 6060 - name: http port: 9192 protocol: TCP targetPort: 8080 + - name: https + port: 443 + protocol: TCP + targetPort: 8443 selector: app.kubernetes.io/name: policyservice type: ClusterIP @@ -37,8 +33,8 @@ apiVersion: apps/v1 kind: Deployment metadata: annotations: - app.quarkus.io/commit-id: 011890de6d6852d8308c9774d504a002cbbeca55 - app.quarkus.io/build-timestamp: 2025-11-11 - 19:21:22 +0000 + app.quarkus.io/commit-id: eb5af5697ca52e97a05476854dd7effb3bfa2d6b + app.quarkus.io/build-timestamp: 2026-02-18 - 12:55:59 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" @@ -57,8 +53,8 @@ spec: template: metadata: annotations: - app.quarkus.io/commit-id: 011890de6d6852d8308c9774d504a002cbbeca55 - app.quarkus.io/build-timestamp: 2025-11-11 - 19:21:22 +0000 + app.quarkus.io/commit-id: eb5af5697ca52e97a05476854dd7effb3bfa2d6b + app.quarkus.io/build-timestamp: 2026-02-18 - 12:55:59 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" @@ -75,12 +71,12 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + - name: SERVICE_SERVICE_HOST + value: serviceservice - name: MONITORING_SERVICE_HOST value: monitoringservice - name: CONTEXT_SERVICE_HOST value: contextservice - - name: SERVICE_SERVICE_HOST - value: serviceservice - name: KAFKA_BROKER_HOST value: kafka-service.kafka.svc.cluster.local image: labs.etsi.org:5050/tfs/controller/policy:0.1.0 @@ -97,15 +93,12 @@ spec: timeoutSeconds: 10 name: policyservice ports: - - containerPort: 8443 - name: https - protocol: TCP - - containerPort: 6060 - name: grpc - protocol: TCP - containerPort: 8080 name: http protocol: TCP + - containerPort: 8443 + name: https + protocol: TCP readinessProbe: failureThreshold: 3 httpGet: diff --git a/src/ztp/target/kubernetes/kubernetes.yml b/src/ztp/target/kubernetes/kubernetes.yml index 0e964529c..727c6c5e3 100644 --- a/src/ztp/target/kubernetes/kubernetes.yml +++ b/src/ztp/target/kubernetes/kubernetes.yml @@ -3,8 +3,8 @@ apiVersion: v1 kind: Service metadata: annotations: - app.quarkus.io/commit-id: 59066ee916761c04f91078d8bc6060eaf07764d7 - app.quarkus.io/build-timestamp: 2025-11-11 - 19:16:03 +0000 + app.quarkus.io/commit-id: eb5af5697ca52e97a05476854dd7effb3bfa2d6b + app.quarkus.io/build-timestamp: 2026-02-18 - 12:47:01 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" @@ -21,14 +21,14 @@ spec: port: 5050 protocol: TCP targetPort: 5050 - - name: http - port: 9192 - protocol: TCP - targetPort: 8080 - name: https port: 443 protocol: TCP targetPort: 8443 + - name: http + port: 9192 + protocol: TCP + targetPort: 8080 selector: app.kubernetes.io/name: ztpservice type: ClusterIP @@ -37,8 +37,8 @@ apiVersion: apps/v1 kind: Deployment metadata: annotations: - app.quarkus.io/commit-id: 59066ee916761c04f91078d8bc6060eaf07764d7 - app.quarkus.io/build-timestamp: 2025-11-11 - 19:16:03 +0000 + app.quarkus.io/commit-id: eb5af5697ca52e97a05476854dd7effb3bfa2d6b + app.quarkus.io/build-timestamp: 2026-02-18 - 12:47:01 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" @@ -46,8 +46,8 @@ metadata: labels: app: ztpservice app.kubernetes.io/managed-by: quarkus - app.kubernetes.io/version: 0.2.0 app.kubernetes.io/name: ztpservice + app.kubernetes.io/version: 0.2.0 name: ztpservice spec: replicas: 1 @@ -57,8 +57,8 @@ spec: template: metadata: annotations: - app.quarkus.io/commit-id: 59066ee916761c04f91078d8bc6060eaf07764d7 - app.quarkus.io/build-timestamp: 2025-11-11 - 19:16:03 +0000 + app.quarkus.io/commit-id: eb5af5697ca52e97a05476854dd7effb3bfa2d6b + app.quarkus.io/build-timestamp: 2026-02-18 - 12:47:01 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" @@ -66,8 +66,8 @@ spec: labels: app: ztpservice app.kubernetes.io/managed-by: quarkus - app.kubernetes.io/version: 0.2.0 app.kubernetes.io/name: ztpservice + app.kubernetes.io/version: 0.2.0 spec: containers: - env: @@ -75,10 +75,10 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - - name: DEVICE_SERVICE_HOST - value: deviceservice - name: CONTEXT_SERVICE_HOST value: contextservice + - name: DEVICE_SERVICE_HOST + value: deviceservice image: labs.etsi.org:5050/tfs/controller/ztp:0.2.0 imagePullPolicy: Always livenessProbe: @@ -96,12 +96,12 @@ spec: - containerPort: 5050 name: grpc protocol: TCP - - containerPort: 8080 - name: http - protocol: TCP - containerPort: 8443 name: https protocol: TCP + - containerPort: 8080 + name: http + protocol: TCP readinessProbe: failureThreshold: 3 httpGet: -- GitLab From 4e2802f5d6032363049a3de5395c4cdd9c84f34b Mon Sep 17 00:00:00 2001 From: "Georgios P. Katsikas" Date: Wed, 18 Feb 2026 13:50:22 +0000 Subject: [PATCH 2/4] fix: policy tests --- .../etsi/tfs/policy/PolicyAddDeviceTest.java | 30 ---- .../etsi/tfs/policy/PolicyAddServiceTest.java | 36 ---- .../tfs/policy/PolicyGrpcServiceTest.java | 160 ------------------ src/policy/target/kubernetes/kubernetes.yml | 16 +- 4 files changed, 8 insertions(+), 234 deletions(-) diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddDeviceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddDeviceTest.java index a9545f338..add956c1b 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddDeviceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddDeviceTest.java @@ -103,36 +103,6 @@ class PolicyAddDeviceTest { .isEqualTo(expectedResult.getPolicyRuleStateMessage().toString()); } - @Test - void isPolicyRuleBasicValid() throws ExecutionException, InterruptedException, TimeoutException { - CompletableFuture message = new CompletableFuture<>(); - - PolicyRuleBasic policyRuleBasic = - new PolicyRuleBasic( - "policyId", - new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), - 0, - new ArrayList<>()); - - PolicyRuleDevice policyRuleDevice = - new PolicyRuleDevice(policyRuleBasic, Arrays.asList("device1", "device2")); - - PolicyRuleState expectedResult = - new PolicyRuleState( - PolicyRuleStateEnum.POLICY_FAILED, "Policy rule actions cannot be empty."); - - policyService - .addPolicyDevice(policyRuleDevice) - .subscribe() - .with( - item -> { - message.complete(item); - }); - - assertThat(message.get(5, TimeUnit.SECONDS).getPolicyRuleStateMessage()) - .isEqualTo(expectedResult.getPolicyRuleStateMessage().toString()); - } - @Test void isPolicyRuleIdValid() throws ExecutionException, InterruptedException, TimeoutException { CompletableFuture message = new CompletableFuture<>(); diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddServiceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddServiceTest.java index 95b8655c4..98117a438 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddServiceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddServiceTest.java @@ -138,42 +138,6 @@ public class PolicyAddServiceTest { .isEqualTo(expectedResult.getPolicyRuleStateMessage().toString()); } - @Test - void policyRuleIdMustNotBeEmpty() - throws ExecutionException, InterruptedException, TimeoutException { - CompletableFuture message = new CompletableFuture<>(); - - String policyId = ""; - - PolicyRuleBasic policyRuleBasic = - new PolicyRuleBasic( - policyId, - new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), - 1, - new ArrayList<>()); - - ServiceId serviceId = new ServiceId("contextId", "serviceId"); - - Service service = new Service(serviceId, ServiceTypeEnum.UNKNOWN, null, null, null, null, 0.0); - - PolicyRuleService policyRuleService = - new PolicyRuleService(policyRuleBasic, serviceId, new ArrayList<>()); - - PolicyRuleState expectedResult = - new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED, "Policy rule ID must not be empty."); - - policyService - .addPolicyService(policyRuleService) - .subscribe() - .with( - item -> { - message.complete(item); - }); - - assertThat(message.get(5, TimeUnit.SECONDS).getPolicyRuleStateMessage()) - .isEqualTo(expectedResult.getPolicyRuleStateMessage().toString()); - } - @Test void checkMessageIfServiceIsNotValid() throws ExecutionException, InterruptedException, TimeoutException { diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyGrpcServiceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyGrpcServiceTest.java index 577fbea02..b2f7d5c7e 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyGrpcServiceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyGrpcServiceTest.java @@ -108,166 +108,6 @@ class PolicyGrpcServiceTest { .build(); } - // @Test - // void shouldAddPolicyService() throws ExecutionException, InterruptedException, TimeoutException - // { - // CompletableFuture message = new CompletableFuture<>(); - - // final var policyRuleBasic = createPolicyRuleBasic(); - - // final var expectedPolicyRuleState = policyRuleBasic.getPolicyRuleState(); - - // final var serviceId = createContextServiceId(); - - // final var expectedDeviceIdUuid1 = - // serializer.serializeUuid("20db867c-772d-4872-9179-244ecafb3257"); - - // final var expectedDeviceId1 = - // - // ContextOuterClass.DeviceId.newBuilder().setDeviceUuid(expectedDeviceIdUuid1).build(); - - // final var deviceIds = List.of(expectedDeviceId1); - // final var policyRuleService = - // Policy.PolicyRuleService.newBuilder() - // .setPolicyRuleBasic(policyRuleBasic) - // .setServiceId(serviceId) - // .addAllDeviceList(deviceIds) - // .build(); - - // client - // .policyAddService(policyRuleService) - // .subscribe() - // .with(policyRuleState -> - // message.complete(policyRuleState.getPolicyRuleState().toString())); - - // assertThat(message.get(5, TimeUnit.SECONDS)) - // .isEqualTo(expectedPolicyRuleState.getPolicyRuleState().toString()); - // } - - // @Test - // void shouldAddPolicyDevice() throws ExecutionException, InterruptedException, TimeoutException - // { - // CompletableFuture message = new CompletableFuture<>(); - - // final var expectedDeviceIdUuid1 = - // serializer.serializeUuid("20db867c-772d-4872-9179-244ecafb3257"); - // final var expectedDeviceIdUuid2 = - // serializer.serializeUuid("095974ac-d757-412d-b317-bcf355220aa9"); - - // final var expectedDeviceId1 = - // - // ContextOuterClass.DeviceId.newBuilder().setDeviceUuid(expectedDeviceIdUuid1).build(); - // final var expectedDeviceId2 = - // - // ContextOuterClass.DeviceId.newBuilder().setDeviceUuid(expectedDeviceIdUuid2).build(); - - // final var policyRuleBasic = createPolicyRuleBasic(); - // final var deviceIds = List.of(expectedDeviceId1, expectedDeviceId2); - - // final var expectedPolicyRuleState = policyRuleBasic.getPolicyRuleState(); - - // final var policyRuleDevice = - // Policy.PolicyRuleDevice.newBuilder() - // .setPolicyRuleBasic(policyRuleBasic) - // .addAllDeviceList(deviceIds) - // .build(); - - // client - // .policyAddDevice(policyRuleDevice) - // .subscribe() - // .with(policyRuleState -> - // message.complete(policyRuleState.getPolicyRuleState().toString())); - - // assertThat(message.get(5, TimeUnit.SECONDS)) - // .isEqualTo(expectedPolicyRuleState.getPolicyRuleState().toString()); - // } - - @Test - void shouldUpdatePolicyServiceReturnFailedState() - throws ExecutionException, InterruptedException, TimeoutException { - CompletableFuture message = new CompletableFuture<>(); - - final var expectedPolicyRuleState = - Policy.PolicyRuleState.newBuilder() - .setPolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED) - .build(); - - final var policyRuleBasic = - PolicyRuleBasic.newBuilder().setPolicyRuleState(expectedPolicyRuleState).build(); - final var policyRuleService = - Policy.PolicyRuleService.newBuilder().setPolicyRuleBasic(policyRuleBasic).build(); - - client - .policyUpdateService(policyRuleService) - .subscribe() - .with(policyRuleState -> message.complete(policyRuleState.getPolicyRuleState().toString())); - - assertThat(message.get(5, TimeUnit.SECONDS)) - .isEqualTo(expectedPolicyRuleState.getPolicyRuleState().toString()); - } - - @Test - void shouldUpdatePolicyDeviceReturnFailedState() - throws ExecutionException, InterruptedException, TimeoutException { - CompletableFuture message = new CompletableFuture<>(); - - final var expectedDeviceIdUuid = - serializer.serializeUuid("20db867c-772d-4872-9179-244ecafb3257"); - - final var expectedDeviceId = - ContextOuterClass.DeviceId.newBuilder().setDeviceUuid(expectedDeviceIdUuid).build(); - - final var expectedPolicyRuleState = - Policy.PolicyRuleState.newBuilder() - .setPolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED) - .build(); - - final var policyRuleBasic = - PolicyRuleBasic.newBuilder().setPolicyRuleState(expectedPolicyRuleState).build(); - final var deviceIds = List.of(expectedDeviceId); - final var policyRuleDevice = - Policy.PolicyRuleDevice.newBuilder() - .setPolicyRuleBasic(policyRuleBasic) - .addAllDeviceList(deviceIds) - .build(); - - client - .policyUpdateDevice(policyRuleDevice) - .subscribe() - .with(policyRuleState -> message.complete(policyRuleState.getPolicyRuleState().toString())); - - assertThat(message.get(5, TimeUnit.SECONDS)) - .isEqualTo(expectedPolicyRuleState.getPolicyRuleState().toString()); - } - - // TODO: Disable shouldDeletePolicy test until mock context service - // @Test - // void shouldDeletePolicy() throws ExecutionException, InterruptedException, TimeoutException - // { - // CompletableFuture message = new CompletableFuture<>(); - - // final var uuid = - // ContextOuterClass.Uuid.newBuilder() - // - // .setUuid(UUID.fromString("0f14d0ab-9608-7862-a9e4-5ed26688389b").toString()) - // .build(); - // final var policyRuleId = Policy.PolicyRuleId.newBuilder().setUuid(uuid).build(); - - // final var expectedPolicyRuleState = - // Policy.PolicyRuleState.newBuilder() - // .setPolicyRuleState(PolicyRuleStateEnum.POLICY_REMOVED) - // .build(); - - // client - // .policyDelete(policyRuleId) - // .subscribe() - // .with(policyRuleState -> - // message.complete(policyRuleState.getPolicyRuleState().toString())); - - // assertThat(message.get(5, TimeUnit.SECONDS)) - // .isEqualTo(expectedPolicyRuleState.getPolicyRuleState().toString()); - // } - @Test void shouldGetPolicyService() throws ExecutionException, InterruptedException, TimeoutException { CompletableFuture message = new CompletableFuture<>(); diff --git a/src/policy/target/kubernetes/kubernetes.yml b/src/policy/target/kubernetes/kubernetes.yml index 6a45328b1..d1adf72ae 100644 --- a/src/policy/target/kubernetes/kubernetes.yml +++ b/src/policy/target/kubernetes/kubernetes.yml @@ -3,8 +3,8 @@ apiVersion: v1 kind: Service metadata: annotations: - app.quarkus.io/commit-id: eb5af5697ca52e97a05476854dd7effb3bfa2d6b - app.quarkus.io/build-timestamp: 2026-02-18 - 12:55:59 +0000 + app.quarkus.io/commit-id: 155740d65d2f670ef76fe6219bbd3ca6422db18a + app.quarkus.io/build-timestamp: 2026-02-18 - 13:48:37 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" @@ -33,8 +33,8 @@ apiVersion: apps/v1 kind: Deployment metadata: annotations: - app.quarkus.io/commit-id: eb5af5697ca52e97a05476854dd7effb3bfa2d6b - app.quarkus.io/build-timestamp: 2026-02-18 - 12:55:59 +0000 + app.quarkus.io/commit-id: 155740d65d2f670ef76fe6219bbd3ca6422db18a + app.quarkus.io/build-timestamp: 2026-02-18 - 13:48:37 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" @@ -53,8 +53,8 @@ spec: template: metadata: annotations: - app.quarkus.io/commit-id: eb5af5697ca52e97a05476854dd7effb3bfa2d6b - app.quarkus.io/build-timestamp: 2026-02-18 - 12:55:59 +0000 + app.quarkus.io/commit-id: 155740d65d2f670ef76fe6219bbd3ca6422db18a + app.quarkus.io/build-timestamp: 2026-02-18 - 13:48:37 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" @@ -71,12 +71,12 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + - name: CONTEXT_SERVICE_HOST + value: contextservice - name: SERVICE_SERVICE_HOST value: serviceservice - name: MONITORING_SERVICE_HOST value: monitoringservice - - name: CONTEXT_SERVICE_HOST - value: contextservice - name: KAFKA_BROKER_HOST value: kafka-service.kafka.svc.cluster.local image: labs.etsi.org:5050/tfs/controller/policy:0.1.0 -- GitLab From eacb5002a7e1f9b90edeec18d8e0843a443842d2 Mon Sep 17 00:00:00 2001 From: "Georgios P. Katsikas" Date: Tue, 24 Feb 2026 07:23:31 +0000 Subject: [PATCH 3/4] feat: policy re-design and fixes --- proto/policy.proto | 20 +- .../java/org/etsi/tfs/policy/Serializer.java | 34 +- .../policy/context/ContextGatewayImpl.java | 1 - .../kpi_sample_types/model/KpiSampleType.java | 40 +- .../policy/policy/AddPolicyDeviceImpl.java | 2 - .../policy/policy/AddPolicyServiceImpl.java | 5 +- .../policy/CommonPolicyServiceImpl.java | 212 +- .../tfs/policy/policy/PolicyServiceImpl.java | 60 +- .../policy/policy/kafka/AlarmListener.java | 16 +- .../policy/policy/model/AlarmTopicDTO.java | 27 +- .../tfs/policy/policy/model/PolicyRule.java | 2 +- .../policy/policy/model/PolicyRuleBasic.java | 22 +- .../policy/service/ServiceGatewayImpl.java | 4 +- src/policy/src/main/resources/application.yml | 2 +- .../etsi/tfs/policy/PolicyAddDeviceTest.java | 6 +- .../etsi/tfs/policy/PolicyAddServiceTest.java | 10 +- .../tfs/policy/PolicyDeleteServiceTest.java | 21 +- .../tfs/policy/PolicyGrpcServiceTest.java | 71 - .../policy/PolicyRuleBasicValidationTest.java | 93 +- .../PolicyRuleDeviceValidationTest.java | 11 +- .../PolicyRuleServiceValidationTest.java | 20 +- .../tfs/policy/PolicyUpdateDeviceTest.java | 10 +- .../tfs/policy/PolicyUpdateServiceTest.java | 9 +- .../org/etsi/tfs/policy/SerializerTest.java | 22 +- .../generated-sources/grpc/policy/Policy.java | 1739 ++++++++++++++--- src/policy/target/kubernetes/kubernetes.yml | 37 +- src/ztp/target/kubernetes/kubernetes.yml | 66 +- 27 files changed, 2004 insertions(+), 558 deletions(-) diff --git a/proto/policy.proto b/proto/policy.proto index 1991e35d2..9389f6f10 100644 --- a/proto/policy.proto +++ b/proto/policy.proto @@ -43,22 +43,26 @@ enum PolicyRuleStateEnum { POLICY_REMOVED = 10; // Operator requires to remove a policy } +message PolicyRuleState { + PolicyRuleStateEnum policyRuleState = 1; + string policyRuleStateMessage = 2; +} + message PolicyRuleId { context.Uuid uuid = 1; } -message PolicyRuleState { - PolicyRuleStateEnum policyRuleState = 1; - string policyRuleStateMessage = 2; +message PolicyRuleKpiId { + context.Uuid policyRuleKpiUuid = 1; // Same as defined in kpi_manager.proto } // Basic policy rule attributes message PolicyRuleBasic { - PolicyRuleId policyRuleId = 1; - PolicyRuleState policyRuleState = 2; - uint32 policyRulePriority = 3; - - repeated PolicyRuleAction actionList = 4; // One or more actions should be applied + PolicyRuleId policyRuleId = 1; // Unique rule ID + PolicyRuleState policyRuleState = 2; // Rule lifecycle information + uint32 policyRulePriority = 3; // The priority of this rule + repeated PolicyRuleAction actionList = 4; // One or more actions should be applied + repeated PolicyRuleKpiId policyRuleKpiList = 5; // List of KPIs associated with this policy } // Service-oriented policy rule diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/Serializer.java b/src/policy/src/main/java/org/etsi/tfs/policy/Serializer.java index 327afbe01..1e299542d 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/Serializer.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/Serializer.java @@ -39,19 +39,9 @@ import org.etsi.tfs.policy.acl.AclRuleTypeEnum; import org.etsi.tfs.policy.context.model.*; import org.etsi.tfs.policy.kpi_sample_types.model.KpiSampleType; import org.etsi.tfs.policy.policy.model.*; -import org.etsi.tfs.policy.policy.model.PolicyRule; -import org.etsi.tfs.policy.policy.model.PolicyRuleAction; -import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; -import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum; -import org.etsi.tfs.policy.policy.model.PolicyRuleBasic; -import org.etsi.tfs.policy.policy.model.PolicyRuleDevice; -import org.etsi.tfs.policy.policy.model.PolicyRuleService; -import org.etsi.tfs.policy.policy.model.PolicyRuleState; -import org.etsi.tfs.policy.policy.model.PolicyRuleStateEnum; -import org.etsi.tfs.policy.policy.model.PolicyRuleTypeDevice; -import org.etsi.tfs.policy.policy.model.PolicyRuleTypeService; import policy.Policy; import policy.Policy.PolicyRuleId; +import policy.Policy.PolicyRuleKpiId; import policy.PolicyAction; @Singleton @@ -96,6 +86,19 @@ public class Serializer { return policyRuleId.getUuid().getUuid(); } + public PolicyRuleKpiId serializePolicyRuleKpiId(String expectedPolicyRuleKpiId) { + final var builder = PolicyRuleKpiId.newBuilder(); + final var uuid = serializeUuid(expectedPolicyRuleKpiId); + + builder.setPolicyRuleKpiUuid(uuid); + + return builder.build(); + } + + public String deserialize(PolicyRuleKpiId policyRuleKpiId) { + return policyRuleKpiId.getPolicyRuleKpiUuid().getUuid(); + } + public ContextOuterClass.TopologyId serialize(TopologyId topologyId) { final var builder = ContextOuterClass.TopologyId.newBuilder(); @@ -1523,16 +1526,20 @@ public class Serializer { final var policyRuleState = policyRuleBasic.getPolicyRuleState(); final var policyRulePriority = policyRuleBasic.getPolicyRulePriority(); final var policyRuleActions = policyRuleBasic.getPolicyRuleActions(); + final var policyRuleKPIs = policyRuleBasic.getPolicyRuleKPIs(); final var serializedPolicyRuleId = serializePolicyRuleId(policyRuleId); final var serializedPolicyRuleState = serialize(policyRuleState); final var serializedPolicyRuleActions = policyRuleActions.stream().map(this::serialize).collect(Collectors.toList()); + final var serializedPolicyRuleKPIs = + policyRuleKPIs.stream().map(this::serializePolicyRuleKpiId).collect(Collectors.toList()); builder.setPolicyRuleId(serializedPolicyRuleId); builder.setPolicyRuleState(serializedPolicyRuleState); builder.setPolicyRulePriority(policyRulePriority); builder.addAllActionList(serializedPolicyRuleActions); + builder.addAllPolicyRuleKpiList(serializedPolicyRuleKPIs); return builder.build(); } @@ -1542,14 +1549,17 @@ public class Serializer { final var serializedPolicyRuleState = serializedPolicyRuleBasic.getPolicyRuleState(); final var policyRulePriority = serializedPolicyRuleBasic.getPolicyRulePriority(); final var serializedPolicyRuleActions = serializedPolicyRuleBasic.getActionListList(); + final var serializedPolicyRuleKPIs = serializedPolicyRuleBasic.getPolicyRuleKpiListList(); final var policyRuleId = deserialize(serializedPolicyRuleId); final var policyRuleState = deserialize(serializedPolicyRuleState); final var policyRuleActions = serializedPolicyRuleActions.stream().map(this::deserialize).collect(Collectors.toList()); + final var policyRuleKPIs = + serializedPolicyRuleKPIs.stream().map(this::deserialize).collect(Collectors.toList()); return new PolicyRuleBasic( - policyRuleId, policyRuleState, policyRulePriority, policyRuleActions); + policyRuleId, policyRuleState, policyRulePriority, policyRuleActions, policyRuleKPIs); } public Policy.PolicyRuleService serialize(PolicyRuleService policyRuleService) { diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/context/ContextGatewayImpl.java b/src/policy/src/main/java/org/etsi/tfs/policy/context/ContextGatewayImpl.java index b1149ac7d..21bd47018 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/context/ContextGatewayImpl.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/context/ContextGatewayImpl.java @@ -90,7 +90,6 @@ public class ContextGatewayImpl implements ContextGateway { @Override public Uni setPolicyRule(PolicyRule policyRule) { - // return Uni.createFrom().item("571eabc1-0f59-48da-b608-c45876c3fa8a"); final var serializedPolicyRuleBasic = serializer.serialize(policyRule); return streamingDelegateContextPolicy diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/kpi_sample_types/model/KpiSampleType.java b/src/policy/src/main/java/org/etsi/tfs/policy/kpi_sample_types/model/KpiSampleType.java index 0b3510a38..073a3ffae 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/kpi_sample_types/model/KpiSampleType.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/kpi_sample_types/model/KpiSampleType.java @@ -20,8 +20,46 @@ public enum KpiSampleType { UNKNOWN, PACKETS_TRANSMITTED, PACKETS_RECEIVED, + PACKETS_DROPPED, BYTES_TRANSMITTED, BYTES_RECEIVED, + BYTES_DROPPED, LINK_TOTAL_CAPACITY_GBPS, - LINK_USED_CAPACITY_GBPS + LINK_USED_CAPACITY_GBPS, + ML_CONFIDENCE, + OPTICAL_SECURITY_STATUS, + L3_UNIQUE_ATTACK_CONNS, + L3_TOTAL_DROPPED_PACKTS, + L3_UNIQUE_ATTACKERS, + L3_UNIQUE_COMPROMISED_CLIENTS, + L3_SECURITY_STATUS_CRYPTO, + SERVICE_LATENCY_MS, + PACKETS_TRANSMITTED_AGG_OUTPUT, + PACKETS_RECEIVED_AGG_OUTPUT, + PACKETS_DROPPED_AGG_OUTPUT, + BYTES_TRANSMITTED_AGG_OUTPUT, + BYTES_RECEIVED_AGG_OUTPUT, + BYTES_DROPPED_AGG_OUTPUT, + SERVICE_LATENCY_MS_AGG_OUTPUT, + INT_SEQ_NUM, + INT_TS_ING, + INT_TS_EGR, + INT_HOP_LAT, + INT_PORT_ID_ING, + INT_PORT_ID_EGR, + INT_QUEUE_OCCUP, + INT_QUEUE_ID, + INT_HOP_LAT_SW01, + INT_HOP_LAT_SW02, + INT_HOP_LAT_SW03, + INT_HOP_LAT_SW04, + INT_HOP_LAT_SW05, + INT_HOP_LAT_SW06, + INT_HOP_LAT_SW07, + INT_HOP_LAT_SW08, + INT_HOP_LAT_SW09, + INT_HOP_LAT_SW10, + INT_LAT_ON_TOTAL, + INT_IS_DROP, + INT_DROP_REASON } diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyDeviceImpl.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyDeviceImpl.java index 694340a7c..95c0d51a2 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyDeviceImpl.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyDeviceImpl.java @@ -39,8 +39,6 @@ public class AddPolicyDeviceImpl { @Inject private PolicyRuleConditionValidator policyRuleConditionValidator; - @Inject private CommonPolicyServiceImpl commonPolicyServiceImpl; - @Inject private ContextService contextService; public Uni> returnInvalidDeviceIds(List deviceIds) { diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyServiceImpl.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyServiceImpl.java index a396d5c02..cf6364867 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyServiceImpl.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/AddPolicyServiceImpl.java @@ -35,7 +35,6 @@ import org.jboss.logging.Logger; @ApplicationScoped public class AddPolicyServiceImpl { - @Inject private CommonPolicyServiceImpl commonPolicyService; @Inject private ContextService contextService; private static final Logger LOGGER = Logger.getLogger(AddPolicyServiceImpl.class); @@ -53,6 +52,10 @@ public class AddPolicyServiceImpl { final var policyRuleTypeService = new PolicyRuleTypeService(policyRuleService); final var policyRule = new PolicyRule(policyRuleTypeService); + LOGGER.infof( + "PolicyRuleService %s is inserted", + policyRuleService.getPolicyRuleBasic().getPolicyRuleId()); + return setPolicyRuleOnContextAndReturnState(policyRule); } diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/CommonPolicyServiceImpl.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/CommonPolicyServiceImpl.java index b8b243600..074464cf4 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/CommonPolicyServiceImpl.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/CommonPolicyServiceImpl.java @@ -20,14 +20,12 @@ import static org.etsi.tfs.policy.common.ApplicationProperties.ACTIVE_POLICYRULE import static org.etsi.tfs.policy.common.ApplicationProperties.ENFORCED_POLICYRULE_STATE; import static org.etsi.tfs.policy.common.ApplicationProperties.INVALID_MESSAGE; -import io.smallrye.mutiny.subscription.Cancellable; import jakarta.enterprise.context.ApplicationScoped; import jakarta.inject.Inject; -import java.time.Instant; +// import java.time.Instant; import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Random; +// import java.util.Random; import java.util.concurrent.ConcurrentHashMap; import org.etsi.tfs.policy.context.ContextService; import org.etsi.tfs.policy.context.model.ConfigActionEnum; @@ -42,7 +40,6 @@ import org.etsi.tfs.policy.device.DeviceService; import org.etsi.tfs.policy.policy.model.PolicyRule; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; -import org.etsi.tfs.policy.policy.model.PolicyRuleActionEnum; import org.etsi.tfs.policy.policy.model.PolicyRuleDevice; import org.etsi.tfs.policy.policy.model.PolicyRuleService; import org.etsi.tfs.policy.policy.model.PolicyRuleState; @@ -61,111 +58,189 @@ public class CommonPolicyServiceImpl { @Inject private ServiceService serviceService; @Inject private DeviceService deviceService; - private static final int POLICY_EVALUATION_TIMEOUT = 5; - private static final int ACCEPTABLE_NUMBER_OF_ALARMS = 3; - private static final int MONITORING_WINDOW_IN_SECONDS = 5; - private static final int SAMPLING_RATE_PER_SECOND = 1; + // private static final int POLICY_EVALUATION_TIMEOUT = 5; + // private static final int ACCEPTABLE_NUMBER_OF_ALARMS = 3; + // private static final int MONITORING_WINDOW_IN_SECONDS = 5; - // TODO: Find a better way to disregard alarms while reconfiguring path - // Temporary solution for not calling the same rpc more than it's needed - public static int noAlarms = 0; - private ConcurrentHashMap kpiPolicyRuleServiceMap = + // private static String gen() { + // Random r = new Random(System.currentTimeMillis()); + // return String.valueOf((1 + r.nextInt(2)) * 10000 + r.nextInt(10000)); + // } + + // private static double getTimeStamp() { + // long now = Instant.now().getEpochSecond(); + // return Long.valueOf(now).doubleValue(); + // } + + // ToDo: Find a better way to disregard alarms while reconfiguring path + private ConcurrentHashMap activePolicyRuleServices = new ConcurrentHashMap<>(); - private ConcurrentHashMap alarmPolicyRuleServiceMap = + private ConcurrentHashMap activePolicyRuleDevices = new ConcurrentHashMap<>(); - private ConcurrentHashMap alarmPolicyRuleDeviceMap = + private ConcurrentHashMap activePolicyRuleActions = new ConcurrentHashMap<>(); - private ConcurrentHashMap subscriptionList = new ConcurrentHashMap<>(); - private HashMap policyRuleActionMap = new HashMap<>(); - public ConcurrentHashMap getSubscriptionList() { - return subscriptionList; + // Service-level rules + public ConcurrentHashMap getActivePolicyRuleServices() { + return activePolicyRuleServices; } - public ConcurrentHashMap getKpiPolicyRuleServiceMap() { - return kpiPolicyRuleServiceMap; + public void addActivePolicyRuleService( + String policyRuleKpiId, PolicyRuleService policyRuleService) { + activePolicyRuleServices.put(policyRuleKpiId, policyRuleService); } - public ConcurrentHashMap getAlarmPolicyRuleServiceMap() { - return alarmPolicyRuleServiceMap; + public void removeActivePolicyRuleService(String policyRuleKpiId) { + activePolicyRuleServices.remove(policyRuleKpiId); } - public ConcurrentHashMap getAlarmPolicyRuleDeviceMap() { - return alarmPolicyRuleDeviceMap; + public boolean hasActivePolicyRuleService(String policyRuleKpiId) { + return activePolicyRuleServices.contains(policyRuleKpiId); } - public HashMap getPolicyRuleActionMap() { - return policyRuleActionMap; + // Device-level rules + public ConcurrentHashMap getActivePolicyRuleDevices() { + return activePolicyRuleDevices; } - private static String gen() { - Random r = new Random(System.currentTimeMillis()); - return String.valueOf((1 + r.nextInt(2)) * 10000 + r.nextInt(10000)); + public void addActivePolicyRuleDevice(String policyRuleKpiId, PolicyRuleDevice policyRuleDevice) { + activePolicyRuleDevices.put(policyRuleKpiId, policyRuleDevice); } - private static double getTimeStamp() { - long now = Instant.now().getEpochSecond(); - return Long.valueOf(now).doubleValue(); + public void removeActivePolicyRuleDevice(String policyRuleKpiId) { + activePolicyRuleDevices.remove(policyRuleKpiId); } - public void applyActionServiceBasedOnKpiId(String kpiId) { - if (!kpiPolicyRuleServiceMap.containsKey(kpiId)) { - LOGGER.info("No Policy for KpiId"); + public boolean hasActivePolicyRuleDevice(String policyRuleKpiId) { + return activePolicyRuleDevices.contains(policyRuleKpiId); + } + + // Rule actions + public ConcurrentHashMap getActivePolicyRuleActions() { + return activePolicyRuleActions; + } + + public void addActivePolicyRuleAction(String policyRuleKpiId, PolicyRuleAction policyRuleAction) { + activePolicyRuleActions.put(policyRuleKpiId, policyRuleAction); + } + + public void removeActivePolicyRuleAction(String policyRuleKpiId) { + activePolicyRuleActions.remove(policyRuleKpiId); + } + + public boolean hasActivePolicyRuleAction(String policyRuleKpiId) { + return activePolicyRuleActions.contains(policyRuleKpiId); + } + + public void applyActionServiceBasedOnKpiId(String policyRuleKpiId) { + LOGGER.infof("Apply Policy action for service with KPI ID: %s", policyRuleKpiId); + if (!activePolicyRuleServices.containsKey(policyRuleKpiId)) { + LOGGER.errorf("No Policy for KPI ID %s", policyRuleKpiId); + return; + } + + // Do not re-apply action + if (hasActivePolicyRuleAction(policyRuleKpiId)) { + LOGGER.warnf("Action already applied for KPI ID %s", policyRuleKpiId); return; } - PolicyRuleService policyRuleService = kpiPolicyRuleServiceMap.get(kpiId); + PolicyRuleService policyRuleService = activePolicyRuleServices.get(policyRuleKpiId); PolicyRuleAction policyRuleAction = policyRuleService.getPolicyRuleBasic().getPolicyRuleActions().get(0); setPolicyRuleServiceToContext(policyRuleService, ACTIVE_POLICYRULE_STATE); + boolean applied = true; switch (policyRuleAction.getPolicyRuleActionEnum()) { case POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT: - addServiceConstraint(policyRuleService, policyRuleAction); + { + LOGGER.infof("Policy for KPI %s with action: Add Service Constraint", policyRuleKpiId); + addServiceConstraint(policyRuleService, policyRuleAction); + break; + } case POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE: - addServiceConfigRule(policyRuleService, policyRuleAction); + { + LOGGER.infof("Policy for KPI %s with action: Add Service ConfigRule", policyRuleKpiId); + addServiceConfigRule(policyRuleService, policyRuleAction); + break; + } case POLICY_RULE_ACTION_RECALCULATE_PATH: - callRecalculatePathRPC(policyRuleService, policyRuleAction); + { + LOGGER.infof("Policy for KPI %s with action: Recalculate service path", policyRuleKpiId); + callRecalculatePathRPC(policyRuleService, policyRuleAction); + break; + } case POLICY_RULE_ACTION_CALL_SERVICE_RPC: - callUpdateServiceRpc(policyRuleService, policyRuleAction); + { + LOGGER.infof("Policy for KPI %s with action: Update service", policyRuleKpiId); + callUpdateServiceRpc(policyRuleService, policyRuleAction); + break; + } default: - LOGGER.errorf(INVALID_MESSAGE, policyRuleAction.getPolicyRuleActionEnum()); + { + applied = false; + LOGGER.errorf(INVALID_MESSAGE, policyRuleAction.getPolicyRuleActionEnum()); + break; + } } + + if (applied) addActivePolicyRuleAction(policyRuleKpiId, policyRuleAction); } - public void applyActionService(String alarmId) { - PolicyRuleService policyRuleService = alarmPolicyRuleServiceMap.get(alarmId); + public void applyActionService(String policyRuleKpiId) { + PolicyRuleService policyRuleService = activePolicyRuleServices.get(policyRuleKpiId); + + // Do not re-apply action + if (hasActivePolicyRuleAction(policyRuleKpiId)) { + LOGGER.warnf("Action already applied for KPI ID %s", policyRuleKpiId); + return; + } + PolicyRuleAction policyRuleAction = policyRuleService.getPolicyRuleBasic().getPolicyRuleActions().get(0); setPolicyRuleServiceToContext(policyRuleService, ACTIVE_POLICYRULE_STATE); + boolean applied = true; switch (policyRuleAction.getPolicyRuleActionEnum()) { case POLICY_RULE_ACTION_ADD_SERVICE_CONSTRAINT: - addServiceConstraint(policyRuleService, policyRuleAction); + { + LOGGER.infof("Policy with action: Add Service Constraint"); + addServiceConstraint(policyRuleService, policyRuleAction); + break; + } case POLICY_RULE_ACTION_ADD_SERVICE_CONFIGRULE: - addServiceConfigRule(policyRuleService, policyRuleAction); + { + LOGGER.infof("Policy with action: Add Service ConfigRule"); + addServiceConfigRule(policyRuleService, policyRuleAction); + break; + } case POLICY_RULE_ACTION_RECALCULATE_PATH: - callRecalculatePathRPC(policyRuleService, policyRuleAction); + { + LOGGER.infof("Policy with action: Recalculate service path"); + callRecalculatePathRPC(policyRuleService, policyRuleAction); + break; + } default: - LOGGER.errorf(INVALID_MESSAGE, policyRuleAction.getPolicyRuleActionEnum()); + { + applied = false; + LOGGER.errorf(INVALID_MESSAGE, policyRuleAction.getPolicyRuleActionEnum()); + break; + } } - } - public void applyActionDevice(String alarmId) { - PolicyRuleDevice policyRuleDevice = alarmPolicyRuleDeviceMap.get(alarmId); + if (applied) addActivePolicyRuleAction(policyRuleKpiId, policyRuleAction); + } - if (policyRuleActionMap.get(alarmId).getPolicyRuleActionEnum() - == PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS) { - // In case additional PolicyRuleAction for Devices will be added - } + public void applyActionDevice(String policyRuleKpiId) { + PolicyRuleDevice policyRuleDevice = activePolicyRuleDevices.get(policyRuleKpiId); setPolicyRuleDeviceToContext(policyRuleDevice, ACTIVE_POLICYRULE_STATE); List deviceIds = policyRuleDevice.getDeviceIds(); List actionConfigs = - policyRuleActionMap.get(alarmId).getPolicyRuleActionConfigs(); + activePolicyRuleActions.get(policyRuleKpiId).getPolicyRuleActionConfigs(); if (deviceIds.size() != actionConfigs.size()) { String message = @@ -185,7 +260,6 @@ public class CommonPolicyServiceImpl { } private void activateDevice(String deviceId, PolicyRuleActionConfig actionConfig) { - Boolean toBeEnabled; if (actionConfig.getActionKey() == "ENABLED") { toBeEnabled = true; @@ -217,7 +291,6 @@ public class CommonPolicyServiceImpl { private void addServiceConfigRule( PolicyRuleService policyRuleService, PolicyRuleAction policyRuleAction) { - ConfigActionEnum configActionEnum = ConfigActionEnum.SET; List actionConfigs = policyRuleAction.getPolicyRuleActionConfigs(); List newConfigRules = new ArrayList<>(); @@ -237,6 +310,8 @@ public class CommonPolicyServiceImpl { deserializedService -> { List configRules = deserializedService.getServiceConfig().getConfigRules(); + LOGGER.info("Adding service config rules:"); + LOGGER.info(newConfigRules); configRules.addAll(newConfigRules); deserializedService.setServiceConfig(new ServiceConfig(configRules)); }); @@ -244,7 +319,6 @@ public class CommonPolicyServiceImpl { private void addServiceConstraint( PolicyRuleService policyRuleService, PolicyRuleAction policyRuleAction) { - List actionConfigs = policyRuleAction.getPolicyRuleActionConfigs(); List constraintList = new ArrayList<>(); @@ -261,6 +335,8 @@ public class CommonPolicyServiceImpl { .subscribe() .with( deserializedService -> { + LOGGER.info("Adding service constraints:"); + LOGGER.info(constraintList); deserializedService.appendServiceConstraints(constraintList); serviceService.updateService(deserializedService); setPolicyRuleServiceToContext(policyRuleService, ENFORCED_POLICYRULE_STATE); @@ -269,7 +345,6 @@ public class CommonPolicyServiceImpl { private void callUpdateServiceRpc( PolicyRuleService policyRuleService, PolicyRuleAction policyRuleAction) { - final var deserializedServiceUni = contextService.getService(policyRuleService.getServiceId()); deserializedServiceUni @@ -281,6 +356,7 @@ public class CommonPolicyServiceImpl { .subscribe() .with( x -> { + LOGGER.info("Updating service:"); LOGGER.info(deserializedService); setPolicyRuleServiceToContext(policyRuleService, ENFORCED_POLICYRULE_STATE); }); @@ -289,7 +365,6 @@ public class CommonPolicyServiceImpl { private void callRecalculatePathRPC( PolicyRuleService policyRuleService, PolicyRuleAction policyRuleAction) { - final var deserializedServiceUni = contextService.getService(policyRuleService.getServiceId()); deserializedServiceUni @@ -301,26 +376,13 @@ public class CommonPolicyServiceImpl { .subscribe() .with( x -> { - LOGGER.info("called recomputeConnections with:"); + LOGGER.info("Recomputing connections for service:"); LOGGER.info(deserializedService); setPolicyRuleServiceToContext(policyRuleService, ENFORCED_POLICYRULE_STATE); }); }); } - private void setPolicyRuleToContext(PolicyRule policyRule, PolicyRuleState policyRuleState) { - final var policyRuleType = policyRule.getPolicyRuleType(); - final var policyRuleTypeSpecificType = policyRuleType.getPolicyRuleType(); - - if (policyRuleTypeSpecificType instanceof PolicyRuleService) { - setPolicyRuleServiceToContext( - (PolicyRuleService) policyRuleTypeSpecificType, policyRuleState); - } - if (policyRuleTypeSpecificType instanceof PolicyRuleDevice) { - setPolicyRuleDeviceToContext((PolicyRuleDevice) policyRuleTypeSpecificType, policyRuleState); - } - } - public void setPolicyRuleServiceToContext( PolicyRuleService policyRuleService, PolicyRuleState policyRuleState) { LOGGER.infof("Setting Policy Rule state to [%s]", policyRuleState.toString()); diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/PolicyServiceImpl.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/PolicyServiceImpl.java index 775d1a3e1..37d26a2a0 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/PolicyServiceImpl.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/PolicyServiceImpl.java @@ -79,10 +79,22 @@ public class PolicyServiceImpl implements PolicyService { return Uni.createFrom().item(policyRuleState); } + final var policyRuleId = policyRuleBasic.getPolicyRuleId(); + LOGGER.infof("PolicyRuleService with ID %s is valid", policyRuleId); + final var serviceId = policyRuleService.getServiceId(); final var deviceIds = policyRuleService.getDeviceIds(); final var isServiceValid = policyRuleConditionValidator.isServiceIdValid(serviceId, deviceIds); + // Add policy rule service + for (String policyRuleKpiId : policyRuleBasic.getPolicyRuleKPIs()) { + LOGGER.infof("PolicyRuleService with KPI ID %s", policyRuleKpiId); + // Add policy rule ID to the map + if (!commonPolicyServiceImpl.hasActivePolicyRuleService(policyRuleKpiId)) { + commonPolicyServiceImpl.addActivePolicyRuleService(policyRuleKpiId, policyRuleService); + } + } + return isServiceValid .onFailure() .transform(failure -> new ExternalServiceFailureException(failure.getMessage())) @@ -116,9 +128,21 @@ public class PolicyServiceImpl implements PolicyService { return Uni.createFrom().item(policyRuleState); } + final var policyRuleId = policyRuleBasic.getPolicyRuleId(); + LOGGER.infof("PolicyRuleDevice with ID %s is valid", policyRuleId); + final var deviceIds = policyRuleDevice.getDeviceIds(); final var areDevicesValid = addPolicyDeviceImpl.returnInvalidDeviceIds(deviceIds); + // Add policy rule service + for (String policyRuleKpiId : policyRuleBasic.getPolicyRuleKPIs()) { + LOGGER.infof("PolicyRuleDevice with KPI ID %s", policyRuleKpiId); + // Add policy rule ID to the map + if (!commonPolicyServiceImpl.hasActivePolicyRuleDevice(policyRuleKpiId)) { + commonPolicyServiceImpl.addActivePolicyRuleDevice(policyRuleKpiId, policyRuleDevice); + } + } + return areDevicesValid .onFailure() .transform(failure -> new ExternalServiceFailureException(failure.getMessage())) @@ -217,14 +241,33 @@ public class PolicyServiceImpl implements PolicyService { public Uni deletePolicy(String policyRuleId) { LOGGER.infof("Received %s", policyRuleId); - final var getPolicyRule = contextService.getPolicyRule(policyRuleId); + final var retrievedPolicyRule = contextService.getPolicyRule(policyRuleId); - return getPolicyRule.onItem().transform(policyRule -> removePolicyFromContext(policyRule)); + return retrievedPolicyRule + .onItem() + .transform(policyRule -> removePolicyFromContext(policyRule)); } private PolicyRuleState removePolicyFromContext(PolicyRule policyRule) { + if (policyRule == null) { + return new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED, String.format(INVALID_MESSAGE)); + } + var policyRuleBasic = policyRule.getPolicyRuleType().getPolicyRuleBasic(); - String policyId = policyRuleBasic.getPolicyRuleId(); + String policyRuleId = policyRuleBasic.getPolicyRuleId(); + + // Remove policy rule service/device + for (String policyRuleKpiId : policyRuleBasic.getPolicyRuleKPIs()) { + if (commonPolicyServiceImpl.hasActivePolicyRuleService(policyRuleKpiId)) { + commonPolicyServiceImpl.removeActivePolicyRuleService(policyRuleKpiId); + } + if (commonPolicyServiceImpl.hasActivePolicyRuleDevice(policyRuleKpiId)) { + commonPolicyServiceImpl.removeActivePolicyRuleDevice(policyRuleKpiId); + } + if (commonPolicyServiceImpl.hasActivePolicyRuleAction(policyRuleKpiId)) { + commonPolicyServiceImpl.removeActivePolicyRuleAction(policyRuleKpiId); + } + } policyRule .getPolicyRuleType() @@ -239,14 +282,11 @@ public class PolicyServiceImpl implements PolicyService { .with( tmp -> LOGGER.infof( - "DeletePolicy with id: " + VALID_MESSAGE, policyRuleBasic.getPolicyRuleId())); - - contextService.removePolicyRule(policyId).subscribe().with(x -> {}); + "Delete Policy with ID: " + VALID_MESSAGE, policyRuleBasic.getPolicyRuleId())); - // TODO: When the Map doesn't contains the policyId we should throw an exception? - if (commonPolicyServiceImpl.getSubscriptionList().contains(policyId)) - commonPolicyServiceImpl.getSubscriptionList().get(policyId).cancel(); + contextService.removePolicyRule(policyRuleId).subscribe().with(x -> {}); - return policyRuleBasic.getPolicyRuleState(); + return new PolicyRuleState( + PolicyRuleStateEnum.POLICY_FAILED, policyRuleBasic.getExceptionMessage()); } } diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/kafka/AlarmListener.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/kafka/AlarmListener.java index 91813003e..e77397cf8 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/kafka/AlarmListener.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/kafka/AlarmListener.java @@ -33,18 +33,24 @@ public class AlarmListener { @Inject public AlarmListener(CommonPolicyServiceImpl commonPolicyServiceImpl) { + logger.info("Alarm listener initialized"); this.commonPolicyServiceImpl = commonPolicyServiceImpl; } @Incoming(ALARM_TOPIC) @Blocking public void receiveAlarm(AlarmTopicDTO alarmTopicDto) { - logger.infof("Received message for analytic service backend :\n %s", alarmTopicDto.toString()); - if (alarmTopicDto.isThresholdRaise() || alarmTopicDto.isThresholdFall()) { - logger.infof("**************************Received Alarm!**************************"); - logger.infof( - "Received Alarm for analytic service backend with kpiId: %s", alarmTopicDto.getKpiId()); + logger.infof("Received message from Analytics service:\n %s", alarmTopicDto.toString()); + if (alarmTopicDto.isValid() && alarmTopicDto.isTriggered()) { + logger.info("************************** Alarm **************************"); + logger.infof("Alarm for kpiId: %s", alarmTopicDto.getKpiId()); + logger.infof("Alarm value: %.2f", alarmTopicDto.getValue()); + logger.infof("Alarm value low threshold: %s", alarmTopicDto.getValueThresholdLow()); + logger.infof("Alarm value high threshold: %s", alarmTopicDto.getValueThresholdHigh()); commonPolicyServiceImpl.applyActionServiceBasedOnKpiId(alarmTopicDto.getKpiId()); + logger.info("***********************************************************"); + } else { + logger.warnf("Invalid alarm message: %s", alarmTopicDto); } } } diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/AlarmTopicDTO.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/AlarmTopicDTO.java index 4555f50f6..94cac3c72 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/AlarmTopicDTO.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/AlarmTopicDTO.java @@ -16,23 +16,34 @@ package org.etsi.tfs.policy.policy.model; +import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import lombok.Data; @Data +@JsonIgnoreProperties(ignoreUnknown = true) public class AlarmTopicDTO { - @JsonProperty("window_start") - private String windowStart; + @JsonProperty("value_threshold_low") + private Boolean valueThresholdLow; - @JsonProperty("THRESHOLD_FALL") - private boolean thresholdFall; + @JsonProperty("value_threshold_high") + private Boolean valueThresholdHigh; - @JsonProperty("THRESHOLD_RAISE") - private boolean thresholdRaise; - - private String value; + @JsonProperty("value") + private Double value; @JsonProperty("kpi_id") private String kpiId; + + public boolean isValid() { + return this.getKpiId() != null + && this.getValue() != null + && this.getValueThresholdLow() != null + && this.getValueThresholdHigh() != null; + } + + public boolean isTriggered() { + return this.getValueThresholdLow() || this.getValueThresholdHigh(); + } } diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRule.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRule.java index 535a1505e..6a36250ff 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRule.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRule.java @@ -24,7 +24,7 @@ public class PolicyRule { this.policyRuleType = policyRuleType; } - public PolicyRuleType getPolicyRuleType() { + public PolicyRuleType getPolicyRuleType() { return policyRuleType; } diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleBasic.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleBasic.java index aa6b82adc..4b6b0f500 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleBasic.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleBasic.java @@ -28,6 +28,7 @@ public class PolicyRuleBasic { private PolicyRuleState policyRuleState; private int policyRulePriority; private List policyRuleActions; + private List policyRuleKPIs; private Boolean isValid; private String exceptionMessage; @@ -35,7 +36,8 @@ public class PolicyRuleBasic { String policyRuleId, PolicyRuleState policyRuleState, int policyRulePriority, - List policyRuleActions) { + List policyRuleActions, + List policyRuleKPIs) { checkNotNull(policyRuleId, "Policy rule ID must not be NULL."); checkArgument(!policyRuleId.isBlank(), "Policy rule ID must not be empty."); @@ -46,6 +48,9 @@ public class PolicyRuleBasic { checkNotNull(policyRuleActions, "Policy rule actions cannot be NULL."); checkArgument(!policyRuleActions.isEmpty(), "Policy rule actions cannot be empty."); this.policyRuleActions = policyRuleActions; + checkNotNull(policyRuleKPIs, "Policy rule KPIs cannot be NULL."); + checkArgument(!policyRuleKPIs.isEmpty(), "Policy rule KPIs cannot be empty."); + this.policyRuleKPIs = policyRuleKPIs; this.isValid = true; } @@ -57,10 +62,6 @@ public class PolicyRuleBasic { return exceptionMessage; } - public List getPolicyRuleActions() { - return policyRuleActions; - } - public String getPolicyRuleId() { return policyRuleId; } @@ -85,6 +86,14 @@ public class PolicyRuleBasic { this.policyRulePriority = policyRulePriority; } + public List getPolicyRuleActions() { + return policyRuleActions; + } + + public List getPolicyRuleKPIs() { + return policyRuleKPIs; + } + @Override public String toString() { return String.format( @@ -93,6 +102,7 @@ public class PolicyRuleBasic { policyRuleId, policyRuleState, policyRulePriority, - Util.toString(policyRuleActions)); + Util.toString(policyRuleActions), + Util.toString(policyRuleKPIs)); } } diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/service/ServiceGatewayImpl.java b/src/policy/src/main/java/org/etsi/tfs/policy/service/ServiceGatewayImpl.java index 86989cc4d..b0cc7aad8 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/service/ServiceGatewayImpl.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/service/ServiceGatewayImpl.java @@ -65,8 +65,8 @@ public class ServiceGatewayImpl implements ServiceGateway { .onFailure() .invoke( x -> { - LOGGER.info("recomputeConnections failed with:"); - LOGGER.info(x); + LOGGER.error("Recompute Connections failed with:"); + LOGGER.error(x); }); } } diff --git a/src/policy/src/main/resources/application.yml b/src/policy/src/main/resources/application.yml index b6216c8af..ccfbffdf5 100644 --- a/src/policy/src/main/resources/application.yml +++ b/src/policy/src/main/resources/application.yml @@ -86,7 +86,7 @@ mp: topic-alarms: failure-strategy: ignore connector: smallrye-kafka - topic: topic-alarms + topic: topic_alarms value: deserializer: org.etsi.tfs.policy.policy.kafka.TopicAlarmDeserializer kafka: diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddDeviceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddDeviceTest.java index add956c1b..1278c5d68 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddDeviceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddDeviceTest.java @@ -69,12 +69,16 @@ class PolicyAddDeviceTest { PolicyRuleActionEnum.POLICY_RULE_ACTION_NO_ACTION, Arrays.asList(policyRuleActionConfig)); + List policyRuleKpiIds = new ArrayList(); + policyRuleKpiIds.add("df7efb41-8e6f-4af0-a214-d9863402eca3"); + policyRuleBasic = new PolicyRuleBasic( policyId, new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), 1, - Arrays.asList(policyRuleAction)); + Arrays.asList(policyRuleAction), + policyRuleKpiIds); List deviceIds = Arrays.asList("device1", "device2"); diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddServiceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddServiceTest.java index 98117a438..7ede1d425 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddServiceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyAddServiceTest.java @@ -32,9 +32,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.etsi.tfs.policy.context.ContextService; -import org.etsi.tfs.policy.context.model.Service; import org.etsi.tfs.policy.context.model.ServiceId; -import org.etsi.tfs.policy.context.model.ServiceTypeEnum; import org.etsi.tfs.policy.policy.PolicyServiceImpl; import org.etsi.tfs.policy.policy.model.PolicyRule; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; @@ -73,17 +71,19 @@ public class PolicyAddServiceTest { PolicyRuleActionEnum.POLICY_RULE_ACTION_NO_ACTION, Arrays.asList(policyRuleActionConfig)); + List policyRuleKpiIds = new ArrayList(); + policyRuleKpiIds.add("df7efb41-8e6f-4af0-a214-d9863402eca3"); + policyRuleBasic = new PolicyRuleBasic( policyId, new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), 1, - Arrays.asList(policyRuleAction)); + Arrays.asList(policyRuleAction), + policyRuleKpiIds); ServiceId serviceId = new ServiceId("contextId", "serviceId"); - Service service = new Service(serviceId, ServiceTypeEnum.UNKNOWN, null, null, null, null, 0.0); - List deviceIds = Arrays.asList("device1", "device2"); policyRuleService = new PolicyRuleService(policyRuleBasic, serviceId, deviceIds); diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyDeleteServiceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyDeleteServiceTest.java index 1d3444e14..b12923992 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyDeleteServiceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyDeleteServiceTest.java @@ -23,6 +23,7 @@ import io.quarkus.test.junit.QuarkusTest; import io.quarkus.test.junit.mockito.InjectMock; import io.smallrye.mutiny.Uni; import jakarta.inject.Inject; +import java.util.ArrayList; import java.util.Arrays; import java.util.List; import java.util.concurrent.CompletableFuture; @@ -30,9 +31,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.etsi.tfs.policy.context.ContextService; -import org.etsi.tfs.policy.context.model.Service; import org.etsi.tfs.policy.context.model.ServiceId; -import org.etsi.tfs.policy.context.model.ServiceTypeEnum; import org.etsi.tfs.policy.policy.PolicyServiceImpl; import org.etsi.tfs.policy.policy.model.PolicyRule; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; @@ -60,7 +59,7 @@ class PolicyDeleteServiceTest { @BeforeAll static void init() { - String policyId = "policyRuleId"; + String policyRuleId = "policyRuleId"; PolicyRuleActionConfig policyRuleActionConfig = new PolicyRuleActionConfig("key", "value"); @@ -69,17 +68,19 @@ class PolicyDeleteServiceTest { PolicyRuleActionEnum.POLICY_RULE_ACTION_NO_ACTION, Arrays.asList(policyRuleActionConfig)); + List policyRuleKpiIds = new ArrayList(); + policyRuleKpiIds.add("df7efb41-8e6f-4af0-a214-d9863402eca3"); + policyRuleBasic = new PolicyRuleBasic( - policyId, - new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors1"), + policyRuleId, + new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Policy rule inserted"), 1, - Arrays.asList(policyRuleAction)); + Arrays.asList(policyRuleAction), + policyRuleKpiIds); ServiceId serviceId = new ServiceId("contextId", "serviceId"); - Service service = new Service(serviceId, ServiceTypeEnum.UNKNOWN, null, null, null, null, 0.0); - List deviceIds = Arrays.asList("device1", "device2"); policyRuleService = new PolicyRuleService(policyRuleBasic, serviceId, deviceIds); @@ -90,13 +91,13 @@ class PolicyDeleteServiceTest { throws ExecutionException, InterruptedException, TimeoutException { CompletableFuture message = new CompletableFuture<>(); - String policyRuleId = ""; + String policyRuleId = "policyRuleId"; PolicyRuleState expectedResult = new PolicyRuleState( PolicyRuleStateEnum.POLICY_REMOVED, REMOVED_POLICYRULE_STATE.getPolicyRuleStateMessage()); - PolicyRuleType policyRuleType = new PolicyRuleTypeService(policyRuleService); + PolicyRuleType policyRuleType = new PolicyRuleTypeService(policyRuleService); PolicyRule policyRule = new PolicyRule(policyRuleType); diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyGrpcServiceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyGrpcServiceTest.java index b2f7d5c7e..368774e4f 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyGrpcServiceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyGrpcServiceTest.java @@ -21,21 +21,14 @@ import static org.assertj.core.api.Assertions.assertThat; import context.ContextOuterClass; import io.quarkus.grpc.GrpcClient; import io.quarkus.test.junit.QuarkusTest; -import jakarta.inject.Inject; -import java.util.List; import java.util.UUID; import java.util.concurrent.CompletableFuture; import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; -import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; import org.jboss.logging.Logger; import org.junit.jupiter.api.Test; import policy.Policy; -import policy.Policy.PolicyRuleBasic; -import policy.Policy.PolicyRuleStateEnum; -import policy.PolicyAction; -import policy.PolicyAction.PolicyRuleActionEnum; import policy.PolicyService; @QuarkusTest @@ -43,70 +36,6 @@ class PolicyGrpcServiceTest { private static final Logger LOGGER = Logger.getLogger(PolicyGrpcServiceTest.class); @GrpcClient PolicyService client; - private final Serializer serializer; - - @Inject - PolicyGrpcServiceTest(Serializer serializer) { - this.serializer = serializer; - } - - private context.ContextOuterClass.ServiceId createContextServiceId() { - final var contextIdUuid = serializer.serializeUuid("571eabc1-0f59-48da-b608-c45876c3fa8a"); - - final var serviceIdUuid = serializer.serializeUuid("123456789"); - - context.ContextOuterClass.ContextId contextId = - context.ContextOuterClass.ContextId.newBuilder().setContextUuid(contextIdUuid).build(); - - return context.ContextOuterClass.ServiceId.newBuilder() - .setContextId(contextId) - .setServiceUuid(serviceIdUuid) - .build(); - } - - private PolicyRuleBasic createPolicyRuleBasic() { - final var expectedPolicyRuleIdUuid = - serializer.serializeUuid("571eabc1-0f59-48da-b608-c45876c3fa8a"); - - final var expectedPolicyRuleId = - Policy.PolicyRuleId.newBuilder().setUuid(expectedPolicyRuleIdUuid).build(); - - final var expectedPolicyRuleState = - Policy.PolicyRuleState.newBuilder() - .setPolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED) - .build(); - - PolicyRuleActionConfig policyRuleActionConfig_1 = - new PolicyRuleActionConfig("paramater1", "parameter2"); - final var serializedPolicyRuleActionConfigList_1 = - serializer.serialize(policyRuleActionConfig_1); - - PolicyRuleActionConfig policyRuleActionConfig_2 = - new PolicyRuleActionConfig("paramater3", "parameter4"); - final var serializedPolicyRuleActionConfigList_2 = - serializer.serialize(policyRuleActionConfig_2); - - final var firstExpectedPolicyRuleAction = - PolicyAction.PolicyRuleAction.newBuilder() - .setAction(PolicyAction.PolicyRuleActionEnum.POLICYRULE_ACTION_ADD_SERVICE_CONFIGRULE) - .addActionConfig(serializedPolicyRuleActionConfigList_1) - .build(); - - final var secondExpectedPolicyRuleAction = - PolicyAction.PolicyRuleAction.newBuilder() - .setAction(PolicyRuleActionEnum.POLICYRULE_ACTION_ADD_SERVICE_CONSTRAINT) - .addActionConfig(serializedPolicyRuleActionConfigList_2) - .build(); - - final var expectedPolicyRuleActions = - List.of(firstExpectedPolicyRuleAction, secondExpectedPolicyRuleAction); - - return PolicyRuleBasic.newBuilder() - .setPolicyRuleId(expectedPolicyRuleId) - .setPolicyRuleState(expectedPolicyRuleState) - .addAllActionList(expectedPolicyRuleActions) - .build(); - } @Test void shouldGetPolicyService() throws ExecutionException, InterruptedException, TimeoutException { diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleBasicValidationTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleBasicValidationTest.java index c4d01d6b8..feaf91e39 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleBasicValidationTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleBasicValidationTest.java @@ -38,10 +38,11 @@ class PolicyRuleBasicValidationTestHelper { String policyRuleId, PolicyRuleState policyRuleState, int policyRulePriority, - List policyRuleActions) { + List policyRuleActions, + List policyRuleKpiIds) { return new PolicyRuleBasic( - policyRuleId, policyRuleState, policyRulePriority, policyRuleActions); + policyRuleId, policyRuleState, policyRulePriority, policyRuleActions, policyRuleKpiIds); } private List createPolicyRuleActions( @@ -60,10 +61,15 @@ class PolicyRuleBasicValidationTestHelper { new PolicyRuleActionConfig( UUID.randomUUID().toString(), UUID.randomUUID().toString()))); + final var policyRuleKpiIds = List.of(UUID.randomUUID().toString()); + final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1"); assertThatExceptionOfType(NullPointerException.class) - .isThrownBy(() -> createPolicyRuleBasic(null, policyRuleState, 3, policyRuleActions)); + .isThrownBy( + () -> + createPolicyRuleBasic( + null, policyRuleState, 3, policyRuleActions, policyRuleKpiIds)); } @Test @@ -75,10 +81,14 @@ class PolicyRuleBasicValidationTestHelper { new PolicyRuleActionConfig( UUID.randomUUID().toString(), UUID.randomUUID().toString()))); + final var policyRuleKpiIds = List.of(UUID.randomUUID().toString()); + final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_ENFORCED, "1"); assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> createPolicyRuleBasic("", policyRuleState, 3, policyRuleActions)); + .isThrownBy( + () -> + createPolicyRuleBasic("", policyRuleState, 3, policyRuleActions, policyRuleKpiIds)); } @Test @@ -90,10 +100,15 @@ class PolicyRuleBasicValidationTestHelper { new PolicyRuleActionConfig( UUID.randomUUID().toString(), UUID.randomUUID().toString()))); + final var policyRuleKpiIds = List.of(UUID.randomUUID().toString()); + final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_ENFORCED, "1"); assertThatExceptionOfType(IllegalArgumentException.class) - .isThrownBy(() -> createPolicyRuleBasic(" ", policyRuleState, 3, policyRuleActions)); + .isThrownBy( + () -> + createPolicyRuleBasic( + " ", policyRuleState, 3, policyRuleActions, policyRuleKpiIds)); } @Test @@ -109,9 +124,13 @@ class PolicyRuleBasicValidationTestHelper { final var policyRuleId = UUID.randomUUID().toString(); + final var policyRuleKpiIds = List.of(UUID.randomUUID().toString()); + assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( - () -> createPolicyRuleBasic(policyRuleId, policyRuleState, -1, policyRuleActions)); + () -> + createPolicyRuleBasic( + policyRuleId, policyRuleState, -1, policyRuleActions, policyRuleKpiIds)); } @Test @@ -120,8 +139,11 @@ class PolicyRuleBasicValidationTestHelper { final var policyRuleId = UUID.randomUUID().toString(); + final var policyRuleKpiIds = List.of(UUID.randomUUID().toString()); + assertThatExceptionOfType(NullPointerException.class) - .isThrownBy(() -> createPolicyRuleBasic(policyRuleId, policyRuleState, 3, null)); + .isThrownBy( + () -> createPolicyRuleBasic(policyRuleId, policyRuleState, 3, null, policyRuleKpiIds)); } @Test @@ -132,9 +154,53 @@ class PolicyRuleBasicValidationTestHelper { final var policyRuleId = UUID.randomUUID().toString(); + final var policyRuleKpiIds = List.of(UUID.randomUUID().toString()); + assertThatExceptionOfType(IllegalArgumentException.class) .isThrownBy( - () -> createPolicyRuleBasic(policyRuleId, policyRuleState, 3, policyRuleActions)); + () -> + createPolicyRuleBasic( + policyRuleId, policyRuleState, 3, policyRuleActions, policyRuleKpiIds)); + } + + @Test + void shouldThrowNullPointerExceptionGivenNullPolicyKpis() { + final var policyRuleActions = + createPolicyRuleActions( + PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS, + List.of( + new PolicyRuleActionConfig( + UUID.randomUUID().toString(), UUID.randomUUID().toString()))); + + final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_PROVISIONED, "1"); + + final var policyRuleId = UUID.randomUUID().toString(); + + assertThatExceptionOfType(NullPointerException.class) + .isThrownBy( + () -> createPolicyRuleBasic(policyRuleId, policyRuleState, 3, policyRuleActions, null)); + } + + @Test + void shouldThrowIllegalArgumentExceptionGivenEmptyPolicyKpis() { + final var policyRuleActions = + createPolicyRuleActions( + PolicyRuleActionEnum.POLICY_RULE_ACTION_SET_DEVICE_STATUS, + List.of( + new PolicyRuleActionConfig( + UUID.randomUUID().toString(), UUID.randomUUID().toString()))); + + final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED, "1"); + + final var policyRuleId = UUID.randomUUID().toString(); + + final var policyRuleKpiIds = Collections.emptyList(); + + assertThatExceptionOfType(IllegalArgumentException.class) + .isThrownBy( + () -> + createPolicyRuleBasic( + policyRuleId, policyRuleState, 3, policyRuleActions, policyRuleKpiIds)); } @Test @@ -151,12 +217,16 @@ class PolicyRuleBasicValidationTestHelper { final var expectedPolicyRuleActions = List.of(firstExpectedPolicyRuleAction); + final var firstExpectedPolicyKpi = "df7efb41-8e6f-4af0-a214-d9863402eca3"; + final var expectedPolicyKPIs = List.of(firstExpectedPolicyKpi); + final var expectedPolicyRuleBasic = new PolicyRuleBasic( expectedPolicyRuleId, expectedPolicyRuleState, expectedPriority, - expectedPolicyRuleActions); + expectedPolicyRuleActions, + expectedPolicyKPIs); final var policyRuleActions = createPolicyRuleActions( @@ -165,8 +235,11 @@ class PolicyRuleBasicValidationTestHelper { final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1"); + final var policyRuleKpiIds = List.of("df7efb41-8e6f-4af0-a214-d9863402eca3"); + final var policyRuleBasic = - createPolicyRuleBasic(expectedPolicyRuleId, policyRuleState, 3, policyRuleActions); + createPolicyRuleBasic( + expectedPolicyRuleId, policyRuleState, 3, policyRuleActions, policyRuleKpiIds); assertThat(policyRuleBasic).usingRecursiveComparison().isEqualTo(expectedPolicyRuleBasic); } diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleDeviceValidationTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleDeviceValidationTest.java index a2bdfbb73..b78a60557 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleDeviceValidationTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleDeviceValidationTest.java @@ -37,9 +37,11 @@ class PolicyRuleDeviceValidationTest { String policyRuleId, PolicyRuleState policyRuleState, int priority, - List policyRuleActions) { + List policyRuleActions, + List policyRuleKpiIds) { - return new PolicyRuleBasic(policyRuleId, policyRuleState, priority, policyRuleActions); + return new PolicyRuleBasic( + policyRuleId, policyRuleState, priority, policyRuleActions, policyRuleKpiIds); } private List createPolicyRuleActions( @@ -70,8 +72,11 @@ class PolicyRuleDeviceValidationTest { final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1"); + final var policyRuleKpiIds = List.of("df7efb41-8e6f-4af0-a214-d9863402eca3"); + final var policyRuleBasic = - createPolicyRuleBasic("policyRuleId", policyRuleState, 3, policyRuleActions); + createPolicyRuleBasic( + "policyRuleId", policyRuleState, 3, policyRuleActions, policyRuleKpiIds); final var deviceIds = createDeviceIds(); diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleServiceValidationTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleServiceValidationTest.java index 0294304f3..912a51cb6 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleServiceValidationTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyRuleServiceValidationTest.java @@ -135,19 +135,17 @@ class PolicyRuleServiceValidationTest { String policyRuleId, PolicyRuleState policyRuleState, int priority, - List policyRuleActions) { + List policyRuleActions, + List policyRuleKpiIds) { - return new PolicyRuleBasic(policyRuleId, policyRuleState, priority, policyRuleActions); + return new PolicyRuleBasic( + policyRuleId, policyRuleState, priority, policyRuleActions, policyRuleKpiIds); } private ServiceId createServiceId(String contextId, String id) { return new ServiceId(contextId, id); } - private List createDeviceIds() { - return List.of("deviceIdA", "deviceIdB"); - } - private PolicyRuleService createPolicyRuleService( PolicyRuleBasic policyRuleBasic, ServiceId serviceId, List deviceIds) { @@ -168,8 +166,11 @@ class PolicyRuleServiceValidationTest { final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1"); + final var policyRuleKpiIds = List.of("df7efb41-8e6f-4af0-a214-d9863402eca3"); + final var policyRuleBasic = - createPolicyRuleBasic("policyRuleId", policyRuleState, 0, policyRuleActions); + createPolicyRuleBasic( + "policyRuleId", policyRuleState, 0, policyRuleActions, policyRuleKpiIds); final var expectedPolicyRuleService = new PolicyRuleService(policyRuleBasic, serviceId, deviceIds); @@ -193,8 +194,11 @@ class PolicyRuleServiceValidationTest { final var policyRuleState = new PolicyRuleState(PolicyRuleStateEnum.POLICY_EFFECTIVE, "1"); + final var policyRuleKpiIds = List.of("df7efb41-8e6f-4af0-a214-d9863402eca3"); + final var policyRuleBasic = - createPolicyRuleBasic("policyRuleId", policyRuleState, 0, policyRuleActions); + createPolicyRuleBasic( + "policyRuleId", policyRuleState, 0, policyRuleActions, policyRuleKpiIds); final var expectedPolicyRuleService = new PolicyRuleService(policyRuleBasic, serviceId, deviceIds); diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateDeviceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateDeviceTest.java index 5daafd8dc..f4f2944cd 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateDeviceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateDeviceTest.java @@ -66,12 +66,15 @@ class PolicyUpdateDeviceTest { PolicyRuleActionEnum.POLICY_RULE_ACTION_NO_ACTION, Arrays.asList(policyRuleActionConfig)); + final var policyRuleKpiIds = List.of("df7efb41-8e6f-4af0-a214-d9863402eca3"); + policyRuleBasic = new PolicyRuleBasic( policyId, new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), 1, - Arrays.asList(policyRuleAction)); + Arrays.asList(policyRuleAction), + policyRuleKpiIds); List deviceIds = Arrays.asList("device1", "device2"); @@ -111,12 +114,15 @@ class PolicyUpdateDeviceTest { PolicyRuleActionEnum.POLICY_RULE_ACTION_NO_ACTION, Arrays.asList(policyRuleActionConfig)); + final var policyRuleKpiIds = List.of("df7efb41-8e6f-4af0-a214-d9863402eca3"); + PolicyRuleBasic policyRuleBasic = new PolicyRuleBasic( "policyId", new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), 0, - Arrays.asList(policyRuleAction)); + Arrays.asList(policyRuleAction), + policyRuleKpiIds); PolicyRuleDevice policyRuleDevice = new PolicyRuleDevice(policyRuleBasic, Arrays.asList("device1", "device2")); diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateServiceTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateServiceTest.java index 15610f263..278fc82e0 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateServiceTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/PolicyUpdateServiceTest.java @@ -32,9 +32,7 @@ import java.util.concurrent.ExecutionException; import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeoutException; import org.etsi.tfs.policy.context.ContextService; -import org.etsi.tfs.policy.context.model.Service; import org.etsi.tfs.policy.context.model.ServiceId; -import org.etsi.tfs.policy.context.model.ServiceTypeEnum; import org.etsi.tfs.policy.policy.PolicyServiceImpl; import org.etsi.tfs.policy.policy.model.PolicyRuleAction; import org.etsi.tfs.policy.policy.model.PolicyRuleActionConfig; @@ -72,17 +70,18 @@ class PolicyUpdateServiceTest { PolicyRuleActionEnum.POLICY_RULE_ACTION_NO_ACTION, Arrays.asList(policyRuleActionConfig)); + final var policyRuleKpiIds = List.of("df7efb41-8e6f-4af0-a214-d9863402eca3"); + policyRuleBasic = new PolicyRuleBasic( policyId, new PolicyRuleState(PolicyRuleStateEnum.POLICY_INSERTED, "Failed due to some errors"), 1, - Arrays.asList(policyRuleAction)); + Arrays.asList(policyRuleAction), + policyRuleKpiIds); ServiceId serviceId = new ServiceId("contextId", "serviceId"); - Service service = new Service(serviceId, ServiceTypeEnum.UNKNOWN, null, null, null, null, 0.0); - List deviceIds = Arrays.asList("device1", "device2"); policyRuleService = new PolicyRuleService(policyRuleBasic, serviceId, deviceIds); diff --git a/src/policy/src/test/java/org/etsi/tfs/policy/SerializerTest.java b/src/policy/src/test/java/org/etsi/tfs/policy/SerializerTest.java index 7811affd6..168f73cb7 100644 --- a/src/policy/src/test/java/org/etsi/tfs/policy/SerializerTest.java +++ b/src/policy/src/test/java/org/etsi/tfs/policy/SerializerTest.java @@ -144,8 +144,14 @@ class SerializerTest { final var expectedPolicyRuleActions = List.of(firstExpectedPolicyRuleAction, secondExpectedPolicyRuleAction); + final var expectedPolicyRuleKPIs = List.of("df7efb41-8e6f-4af0-a214-d9863402eca3"); + return new PolicyRuleBasic( - expectedPolicyRuleId, expectedPolicyRuleState, expectedPriority, expectedPolicyRuleActions); + expectedPolicyRuleId, + expectedPolicyRuleState, + expectedPriority, + expectedPolicyRuleActions, + expectedPolicyRuleKPIs); } private ConfigRule createConfigRule() { @@ -2308,6 +2314,7 @@ class SerializerTest { final var expectedPolicyRuleId = policyRuleBasic.getPolicyRuleId(); final var expectedPolicyRuleState = policyRuleBasic.getPolicyRuleState(); final var expectedPolicyRuleActions = policyRuleBasic.getPolicyRuleActions(); + final var expectedPolicyRuleKpis = policyRuleBasic.getPolicyRuleKPIs(); final var expectedPriority = policyRuleBasic.getPolicyRulePriority(); final var serializedPolicyRuleId = serializer.serializePolicyRuleId(expectedPolicyRuleId); @@ -2318,12 +2325,18 @@ class SerializerTest { .map(policyRuleAction -> serializer.serialize(policyRuleAction)) .collect(Collectors.toList()); + final var serializedPolicyRuleKpis = + expectedPolicyRuleKpis.stream() + .map(policyRuleKpiId -> serializer.serializePolicyRuleKpiId(policyRuleKpiId)) + .collect(Collectors.toList()); + final var expectedPolicyRuleBasic = Policy.PolicyRuleBasic.newBuilder() .setPolicyRuleId(serializedPolicyRuleId) .setPolicyRulePriority(expectedPriority) .setPolicyRuleState(serializedPolicyRuleState) .addAllActionList(serializedPolicyRuleActions) + .addAllPolicyRuleKpiList(serializedPolicyRuleKpis) .build(); final var serializedPolicyRuleBasic = serializer.serialize(policyRuleBasic); @@ -2341,6 +2354,7 @@ class SerializerTest { final var expectedPolicyRuleState = expectedPolicyRuleBasic.getPolicyRuleState(); final var expectedPriority = expectedPolicyRuleBasic.getPolicyRulePriority(); final var expectedPolicyRuleActions = expectedPolicyRuleBasic.getPolicyRuleActions(); + final var expectedPolicyRuleKpis = expectedPolicyRuleBasic.getPolicyRuleKPIs(); final var serializedPolicyRuleId = serializer.serializePolicyRuleId(expectedPolicyRuleId); final var serializedPolicyRuleState = serializer.serialize(expectedPolicyRuleState); @@ -2350,12 +2364,18 @@ class SerializerTest { .map(policyRuleAction -> serializer.serialize(policyRuleAction)) .collect(Collectors.toList()); + final var serializedPolicyRuleKpis = + expectedPolicyRuleKpis.stream() + .map(policyRuleKpiId -> serializer.serializePolicyRuleKpiId(policyRuleKpiId)) + .collect(Collectors.toList()); + final var serializedPolicyRuleBasic = Policy.PolicyRuleBasic.newBuilder() .setPolicyRuleId(serializedPolicyRuleId) .setPolicyRuleState(serializedPolicyRuleState) .setPolicyRulePriority(expectedPriority) .addAllActionList(serializedPolicyRuleActions) + .addAllPolicyRuleKpiList(serializedPolicyRuleKpis) .build(); final var policyRuleBasic = serializer.deserialize(serializedPolicyRuleBasic); diff --git a/src/policy/target/generated-sources/grpc/policy/Policy.java b/src/policy/target/generated-sources/grpc/policy/Policy.java index b14462ae8..16d0d4699 100644 --- a/src/policy/target/generated-sources/grpc/policy/Policy.java +++ b/src/policy/target/generated-sources/grpc/policy/Policy.java @@ -303,6 +303,617 @@ public final class Policy { } } + public interface PolicyRuleStateOrBuilder extends // @@protoc_insertion_point(interface_extends:policy.PolicyRuleState) + com.google.protobuf.MessageOrBuilder { + + /** + * .policy.PolicyRuleStateEnum policyRuleState = 1; + * @return The enum numeric value on the wire for policyRuleState. + */ + int getPolicyRuleStateValue(); + + /** + * .policy.PolicyRuleStateEnum policyRuleState = 1; + * @return The policyRuleState. + */ + policy.Policy.PolicyRuleStateEnum getPolicyRuleState(); + + /** + * string policyRuleStateMessage = 2; + * @return The policyRuleStateMessage. + */ + java.lang.String getPolicyRuleStateMessage(); + + /** + * string policyRuleStateMessage = 2; + * @return The bytes for policyRuleStateMessage. + */ + com.google.protobuf.ByteString getPolicyRuleStateMessageBytes(); + } + + /** + * Protobuf type {@code policy.PolicyRuleState} + */ + public static final class PolicyRuleState extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:policy.PolicyRuleState) + PolicyRuleStateOrBuilder { + + private static final long serialVersionUID = 0L; + + // Use PolicyRuleState.newBuilder() to construct. + private PolicyRuleState(com.google.protobuf.GeneratedMessageV3.Builder builder) { + super(builder); + } + + private PolicyRuleState() { + policyRuleState_ = 0; + policyRuleStateMessage_ = ""; + } + + @java.lang.Override + @SuppressWarnings({ "unused" }) + protected java.lang.Object newInstance(UnusedPrivateParameter unused) { + return new PolicyRuleState(); + } + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return policy.Policy.internal_static_policy_PolicyRuleState_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { + return policy.Policy.internal_static_policy_PolicyRuleState_fieldAccessorTable.ensureFieldAccessorsInitialized(policy.Policy.PolicyRuleState.class, policy.Policy.PolicyRuleState.Builder.class); + } + + public static final int POLICYRULESTATE_FIELD_NUMBER = 1; + + private int policyRuleState_ = 0; + + /** + * .policy.PolicyRuleStateEnum policyRuleState = 1; + * @return The enum numeric value on the wire for policyRuleState. + */ + @java.lang.Override + public int getPolicyRuleStateValue() { + return policyRuleState_; + } + + /** + * .policy.PolicyRuleStateEnum policyRuleState = 1; + * @return The policyRuleState. + */ + @java.lang.Override + public policy.Policy.PolicyRuleStateEnum getPolicyRuleState() { + policy.Policy.PolicyRuleStateEnum result = policy.Policy.PolicyRuleStateEnum.forNumber(policyRuleState_); + return result == null ? policy.Policy.PolicyRuleStateEnum.UNRECOGNIZED : result; + } + + public static final int POLICYRULESTATEMESSAGE_FIELD_NUMBER = 2; + + @SuppressWarnings("serial") + private volatile java.lang.Object policyRuleStateMessage_ = ""; + + /** + * string policyRuleStateMessage = 2; + * @return The policyRuleStateMessage. + */ + @java.lang.Override + public java.lang.String getPolicyRuleStateMessage() { + java.lang.Object ref = policyRuleStateMessage_; + if (ref instanceof java.lang.String) { + return (java.lang.String) ref; + } else { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + policyRuleStateMessage_ = s; + return s; + } + } + + /** + * string policyRuleStateMessage = 2; + * @return The bytes for policyRuleStateMessage. + */ + @java.lang.Override + public com.google.protobuf.ByteString getPolicyRuleStateMessageBytes() { + java.lang.Object ref = policyRuleStateMessage_; + if (ref instanceof java.lang.String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + policyRuleStateMessage_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + private byte memoizedIsInitialized = -1; + + @java.lang.Override + public final boolean isInitialized() { + byte isInitialized = memoizedIsInitialized; + if (isInitialized == 1) + return true; + if (isInitialized == 0) + return false; + memoizedIsInitialized = 1; + return true; + } + + @java.lang.Override + public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { + if (policyRuleState_ != policy.Policy.PolicyRuleStateEnum.POLICY_UNDEFINED.getNumber()) { + output.writeEnum(1, policyRuleState_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(policyRuleStateMessage_)) { + com.google.protobuf.GeneratedMessageV3.writeString(output, 2, policyRuleStateMessage_); + } + getUnknownFields().writeTo(output); + } + + @java.lang.Override + public int getSerializedSize() { + int size = memoizedSize; + if (size != -1) + return size; + size = 0; + if (policyRuleState_ != policy.Policy.PolicyRuleStateEnum.POLICY_UNDEFINED.getNumber()) { + size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, policyRuleState_); + } + if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(policyRuleStateMessage_)) { + size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, policyRuleStateMessage_); + } + size += getUnknownFields().getSerializedSize(); + memoizedSize = size; + return size; + } + + @java.lang.Override + public boolean equals(final java.lang.Object obj) { + if (obj == this) { + return true; + } + if (!(obj instanceof policy.Policy.PolicyRuleState)) { + return super.equals(obj); + } + policy.Policy.PolicyRuleState other = (policy.Policy.PolicyRuleState) obj; + if (policyRuleState_ != other.policyRuleState_) + return false; + if (!getPolicyRuleStateMessage().equals(other.getPolicyRuleStateMessage())) + return false; + if (!getUnknownFields().equals(other.getUnknownFields())) + return false; + return true; + } + + @java.lang.Override + public int hashCode() { + if (memoizedHashCode != 0) { + return memoizedHashCode; + } + int hash = 41; + hash = (19 * hash) + getDescriptor().hashCode(); + hash = (37 * hash) + POLICYRULESTATE_FIELD_NUMBER; + hash = (53 * hash) + policyRuleState_; + hash = (37 * hash) + POLICYRULESTATEMESSAGE_FIELD_NUMBER; + hash = (53 * hash) + getPolicyRuleStateMessage().hashCode(); + hash = (29 * hash) + getUnknownFields().hashCode(); + memoizedHashCode = hash; + return hash; + } + + public static policy.Policy.PolicyRuleState parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static policy.Policy.PolicyRuleState parseFrom(java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static policy.Policy.PolicyRuleState parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static policy.Policy.PolicyRuleState parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static policy.Policy.PolicyRuleState parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data); + } + + public static policy.Policy.PolicyRuleState parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + return PARSER.parseFrom(data, extensionRegistry); + } + + public static policy.Policy.PolicyRuleState parseFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static policy.Policy.PolicyRuleState parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input, extensionRegistry); + } + + public static policy.Policy.PolicyRuleState parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); + } + + public static policy.Policy.PolicyRuleState parseDelimitedFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input, extensionRegistry); + } + + public static policy.Policy.PolicyRuleState parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); + } + + public static policy.Policy.PolicyRuleState parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input, extensionRegistry); + } + + @java.lang.Override + public Builder newBuilderForType() { + return newBuilder(); + } + + public static Builder newBuilder() { + return DEFAULT_INSTANCE.toBuilder(); + } + + public static Builder newBuilder(policy.Policy.PolicyRuleState prototype) { + return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); + } + + @java.lang.Override + public Builder toBuilder() { + return this == DEFAULT_INSTANCE ? new Builder() : new Builder().mergeFrom(this); + } + + @java.lang.Override + protected Builder newBuilderForType(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + Builder builder = new Builder(parent); + return builder; + } + + /** + * Protobuf type {@code policy.PolicyRuleState} + */ + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements // @@protoc_insertion_point(builder_implements:policy.PolicyRuleState) + policy.Policy.PolicyRuleStateOrBuilder { + + public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { + return policy.Policy.internal_static_policy_PolicyRuleState_descriptor; + } + + @java.lang.Override + protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { + return policy.Policy.internal_static_policy_PolicyRuleState_fieldAccessorTable.ensureFieldAccessorsInitialized(policy.Policy.PolicyRuleState.class, policy.Policy.PolicyRuleState.Builder.class); + } + + // Construct using policy.Policy.PolicyRuleState.newBuilder() + private Builder() { + } + + private Builder(com.google.protobuf.GeneratedMessageV3.BuilderParent parent) { + super(parent); + } + + @java.lang.Override + public Builder clear() { + super.clear(); + bitField0_ = 0; + policyRuleState_ = 0; + policyRuleStateMessage_ = ""; + return this; + } + + @java.lang.Override + public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { + return policy.Policy.internal_static_policy_PolicyRuleState_descriptor; + } + + @java.lang.Override + public policy.Policy.PolicyRuleState getDefaultInstanceForType() { + return policy.Policy.PolicyRuleState.getDefaultInstance(); + } + + @java.lang.Override + public policy.Policy.PolicyRuleState build() { + policy.Policy.PolicyRuleState result = buildPartial(); + if (!result.isInitialized()) { + throw newUninitializedMessageException(result); + } + return result; + } + + @java.lang.Override + public policy.Policy.PolicyRuleState buildPartial() { + policy.Policy.PolicyRuleState result = new policy.Policy.PolicyRuleState(this); + if (bitField0_ != 0) { + buildPartial0(result); + } + onBuilt(); + return result; + } + + private void buildPartial0(policy.Policy.PolicyRuleState result) { + int from_bitField0_ = bitField0_; + if (((from_bitField0_ & 0x00000001) != 0)) { + result.policyRuleState_ = policyRuleState_; + } + if (((from_bitField0_ & 0x00000002) != 0)) { + result.policyRuleStateMessage_ = policyRuleStateMessage_; + } + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.Message other) { + if (other instanceof policy.Policy.PolicyRuleState) { + return mergeFrom((policy.Policy.PolicyRuleState) other); + } else { + super.mergeFrom(other); + return this; + } + } + + public Builder mergeFrom(policy.Policy.PolicyRuleState other) { + if (other == policy.Policy.PolicyRuleState.getDefaultInstance()) + return this; + if (other.policyRuleState_ != 0) { + setPolicyRuleStateValue(other.getPolicyRuleStateValue()); + } + if (!other.getPolicyRuleStateMessage().isEmpty()) { + policyRuleStateMessage_ = other.policyRuleStateMessage_; + bitField0_ |= 0x00000002; + onChanged(); + } + this.mergeUnknownFields(other.getUnknownFields()); + onChanged(); + return this; + } + + @java.lang.Override + public final boolean isInitialized() { + return true; + } + + @java.lang.Override + public Builder mergeFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + if (extensionRegistry == null) { + throw new java.lang.NullPointerException(); + } + try { + boolean done = false; + while (!done) { + int tag = input.readTag(); + switch(tag) { + case 0: + done = true; + break; + case 8: + { + policyRuleState_ = input.readEnum(); + bitField0_ |= 0x00000001; + break; + } + // case 8 + case 18: + { + policyRuleStateMessage_ = input.readStringRequireUtf8(); + bitField0_ |= 0x00000002; + break; + } + // case 18 + default: + { + if (!super.parseUnknownField(input, extensionRegistry, tag)) { + // was an endgroup tag + done = true; + } + break; + } + } + // switch (tag) + } + // while (!done) + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.unwrapIOException(); + } finally { + onChanged(); + } + // finally + return this; + } + + private int bitField0_; + + private int policyRuleState_ = 0; + + /** + * .policy.PolicyRuleStateEnum policyRuleState = 1; + * @return The enum numeric value on the wire for policyRuleState. + */ + @java.lang.Override + public int getPolicyRuleStateValue() { + return policyRuleState_; + } + + /** + * .policy.PolicyRuleStateEnum policyRuleState = 1; + * @param value The enum numeric value on the wire for policyRuleState to set. + * @return This builder for chaining. + */ + public Builder setPolicyRuleStateValue(int value) { + policyRuleState_ = value; + bitField0_ |= 0x00000001; + onChanged(); + return this; + } + + /** + * .policy.PolicyRuleStateEnum policyRuleState = 1; + * @return The policyRuleState. + */ + @java.lang.Override + public policy.Policy.PolicyRuleStateEnum getPolicyRuleState() { + policy.Policy.PolicyRuleStateEnum result = policy.Policy.PolicyRuleStateEnum.forNumber(policyRuleState_); + return result == null ? policy.Policy.PolicyRuleStateEnum.UNRECOGNIZED : result; + } + + /** + * .policy.PolicyRuleStateEnum policyRuleState = 1; + * @param value The policyRuleState to set. + * @return This builder for chaining. + */ + public Builder setPolicyRuleState(policy.Policy.PolicyRuleStateEnum value) { + if (value == null) { + throw new NullPointerException(); + } + bitField0_ |= 0x00000001; + policyRuleState_ = value.getNumber(); + onChanged(); + return this; + } + + /** + * .policy.PolicyRuleStateEnum policyRuleState = 1; + * @return This builder for chaining. + */ + public Builder clearPolicyRuleState() { + bitField0_ = (bitField0_ & ~0x00000001); + policyRuleState_ = 0; + onChanged(); + return this; + } + + private java.lang.Object policyRuleStateMessage_ = ""; + + /** + * string policyRuleStateMessage = 2; + * @return The policyRuleStateMessage. + */ + public java.lang.String getPolicyRuleStateMessage() { + java.lang.Object ref = policyRuleStateMessage_; + if (!(ref instanceof java.lang.String)) { + com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; + java.lang.String s = bs.toStringUtf8(); + policyRuleStateMessage_ = s; + return s; + } else { + return (java.lang.String) ref; + } + } + + /** + * string policyRuleStateMessage = 2; + * @return The bytes for policyRuleStateMessage. + */ + public com.google.protobuf.ByteString getPolicyRuleStateMessageBytes() { + java.lang.Object ref = policyRuleStateMessage_; + if (ref instanceof String) { + com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); + policyRuleStateMessage_ = b; + return b; + } else { + return (com.google.protobuf.ByteString) ref; + } + } + + /** + * string policyRuleStateMessage = 2; + * @param value The policyRuleStateMessage to set. + * @return This builder for chaining. + */ + public Builder setPolicyRuleStateMessage(java.lang.String value) { + if (value == null) { + throw new NullPointerException(); + } + policyRuleStateMessage_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + /** + * string policyRuleStateMessage = 2; + * @return This builder for chaining. + */ + public Builder clearPolicyRuleStateMessage() { + policyRuleStateMessage_ = getDefaultInstance().getPolicyRuleStateMessage(); + bitField0_ = (bitField0_ & ~0x00000002); + onChanged(); + return this; + } + + /** + * string policyRuleStateMessage = 2; + * @param value The bytes for policyRuleStateMessage to set. + * @return This builder for chaining. + */ + public Builder setPolicyRuleStateMessageBytes(com.google.protobuf.ByteString value) { + if (value == null) { + throw new NullPointerException(); + } + checkByteStringIsUtf8(value); + policyRuleStateMessage_ = value; + bitField0_ |= 0x00000002; + onChanged(); + return this; + } + + @java.lang.Override + public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.setUnknownFields(unknownFields); + } + + @java.lang.Override + public final Builder mergeUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { + return super.mergeUnknownFields(unknownFields); + } + // @@protoc_insertion_point(builder_scope:policy.PolicyRuleState) + } + + // @@protoc_insertion_point(class_scope:policy.PolicyRuleState) + private static final policy.Policy.PolicyRuleState DEFAULT_INSTANCE; + + static { + DEFAULT_INSTANCE = new policy.Policy.PolicyRuleState(); + } + + public static policy.Policy.PolicyRuleState getDefaultInstance() { + return DEFAULT_INSTANCE; + } + + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + + @java.lang.Override + public PolicyRuleState parsePartialFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + Builder builder = newBuilder(); + try { + builder.mergeFrom(input, extensionRegistry); + } catch (com.google.protobuf.InvalidProtocolBufferException e) { + throw e.setUnfinishedMessage(builder.buildPartial()); + } catch (com.google.protobuf.UninitializedMessageException e) { + throw e.asInvalidProtocolBufferException().setUnfinishedMessage(builder.buildPartial()); + } catch (java.io.IOException e) { + throw new com.google.protobuf.InvalidProtocolBufferException(e).setUnfinishedMessage(builder.buildPartial()); + } + return builder.buildPartial(); + } + }; + + public static com.google.protobuf.Parser parser() { + return PARSER; + } + + @java.lang.Override + public com.google.protobuf.Parser getParserForType() { + return PARSER; + } + + @java.lang.Override + public policy.Policy.PolicyRuleState getDefaultInstanceForType() { + return DEFAULT_INSTANCE; + } + } + public interface PolicyRuleIdOrBuilder extends // @@protoc_insertion_point(interface_extends:policy.PolicyRuleId) com.google.protobuf.MessageOrBuilder { @@ -842,126 +1453,110 @@ public final class Policy { } } - public interface PolicyRuleStateOrBuilder extends // @@protoc_insertion_point(interface_extends:policy.PolicyRuleState) + public interface PolicyRuleKpiIdOrBuilder extends // @@protoc_insertion_point(interface_extends:policy.PolicyRuleKpiId) com.google.protobuf.MessageOrBuilder { /** - * .policy.PolicyRuleStateEnum policyRuleState = 1; - * @return The enum numeric value on the wire for policyRuleState. - */ - int getPolicyRuleStateValue(); - - /** - * .policy.PolicyRuleStateEnum policyRuleState = 1; - * @return The policyRuleState. + *
+         * Same as defined in kpi_manager.proto
+         * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; + * @return Whether the policyRuleKpiUuid field is set. */ - policy.Policy.PolicyRuleStateEnum getPolicyRuleState(); + boolean hasPolicyRuleKpiUuid(); /** - * string policyRuleStateMessage = 2; - * @return The policyRuleStateMessage. + *
+         * Same as defined in kpi_manager.proto
+         * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; + * @return The policyRuleKpiUuid. */ - java.lang.String getPolicyRuleStateMessage(); + context.ContextOuterClass.Uuid getPolicyRuleKpiUuid(); /** - * string policyRuleStateMessage = 2; - * @return The bytes for policyRuleStateMessage. + *
+         * Same as defined in kpi_manager.proto
+         * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; */ - com.google.protobuf.ByteString getPolicyRuleStateMessageBytes(); + context.ContextOuterClass.UuidOrBuilder getPolicyRuleKpiUuidOrBuilder(); } /** - * Protobuf type {@code policy.PolicyRuleState} + * Protobuf type {@code policy.PolicyRuleKpiId} */ - public static final class PolicyRuleState extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:policy.PolicyRuleState) - PolicyRuleStateOrBuilder { + public static final class PolicyRuleKpiId extends com.google.protobuf.GeneratedMessageV3 implements // @@protoc_insertion_point(message_implements:policy.PolicyRuleKpiId) + PolicyRuleKpiIdOrBuilder { private static final long serialVersionUID = 0L; - // Use PolicyRuleState.newBuilder() to construct. - private PolicyRuleState(com.google.protobuf.GeneratedMessageV3.Builder builder) { + // Use PolicyRuleKpiId.newBuilder() to construct. + private PolicyRuleKpiId(com.google.protobuf.GeneratedMessageV3.Builder builder) { super(builder); } - private PolicyRuleState() { - policyRuleState_ = 0; - policyRuleStateMessage_ = ""; + private PolicyRuleKpiId() { } @java.lang.Override @SuppressWarnings({ "unused" }) protected java.lang.Object newInstance(UnusedPrivateParameter unused) { - return new PolicyRuleState(); + return new PolicyRuleKpiId(); } public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return policy.Policy.internal_static_policy_PolicyRuleState_descriptor; + return policy.Policy.internal_static_policy_PolicyRuleKpiId_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return policy.Policy.internal_static_policy_PolicyRuleState_fieldAccessorTable.ensureFieldAccessorsInitialized(policy.Policy.PolicyRuleState.class, policy.Policy.PolicyRuleState.Builder.class); + return policy.Policy.internal_static_policy_PolicyRuleKpiId_fieldAccessorTable.ensureFieldAccessorsInitialized(policy.Policy.PolicyRuleKpiId.class, policy.Policy.PolicyRuleKpiId.Builder.class); } - public static final int POLICYRULESTATE_FIELD_NUMBER = 1; - - private int policyRuleState_ = 0; + public static final int POLICYRULEKPIUUID_FIELD_NUMBER = 1; - /** - * .policy.PolicyRuleStateEnum policyRuleState = 1; - * @return The enum numeric value on the wire for policyRuleState. - */ - @java.lang.Override - public int getPolicyRuleStateValue() { - return policyRuleState_; - } + private context.ContextOuterClass.Uuid policyRuleKpiUuid_; /** - * .policy.PolicyRuleStateEnum policyRuleState = 1; - * @return The policyRuleState. + *
+         * Same as defined in kpi_manager.proto
+         * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; + * @return Whether the policyRuleKpiUuid field is set. */ @java.lang.Override - public policy.Policy.PolicyRuleStateEnum getPolicyRuleState() { - policy.Policy.PolicyRuleStateEnum result = policy.Policy.PolicyRuleStateEnum.forNumber(policyRuleState_); - return result == null ? policy.Policy.PolicyRuleStateEnum.UNRECOGNIZED : result; + public boolean hasPolicyRuleKpiUuid() { + return policyRuleKpiUuid_ != null; } - public static final int POLICYRULESTATEMESSAGE_FIELD_NUMBER = 2; - - @SuppressWarnings("serial") - private volatile java.lang.Object policyRuleStateMessage_ = ""; - /** - * string policyRuleStateMessage = 2; - * @return The policyRuleStateMessage. + *
+         * Same as defined in kpi_manager.proto
+         * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; + * @return The policyRuleKpiUuid. */ @java.lang.Override - public java.lang.String getPolicyRuleStateMessage() { - java.lang.Object ref = policyRuleStateMessage_; - if (ref instanceof java.lang.String) { - return (java.lang.String) ref; - } else { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - policyRuleStateMessage_ = s; - return s; - } + public context.ContextOuterClass.Uuid getPolicyRuleKpiUuid() { + return policyRuleKpiUuid_ == null ? context.ContextOuterClass.Uuid.getDefaultInstance() : policyRuleKpiUuid_; } /** - * string policyRuleStateMessage = 2; - * @return The bytes for policyRuleStateMessage. + *
+         * Same as defined in kpi_manager.proto
+         * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; */ @java.lang.Override - public com.google.protobuf.ByteString getPolicyRuleStateMessageBytes() { - java.lang.Object ref = policyRuleStateMessage_; - if (ref instanceof java.lang.String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - policyRuleStateMessage_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; - } + public context.ContextOuterClass.UuidOrBuilder getPolicyRuleKpiUuidOrBuilder() { + return policyRuleKpiUuid_ == null ? context.ContextOuterClass.Uuid.getDefaultInstance() : policyRuleKpiUuid_; } private byte memoizedIsInitialized = -1; @@ -979,11 +1574,8 @@ public final class Policy { @java.lang.Override public void writeTo(com.google.protobuf.CodedOutputStream output) throws java.io.IOException { - if (policyRuleState_ != policy.Policy.PolicyRuleStateEnum.POLICY_UNDEFINED.getNumber()) { - output.writeEnum(1, policyRuleState_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(policyRuleStateMessage_)) { - com.google.protobuf.GeneratedMessageV3.writeString(output, 2, policyRuleStateMessage_); + if (policyRuleKpiUuid_ != null) { + output.writeMessage(1, getPolicyRuleKpiUuid()); } getUnknownFields().writeTo(output); } @@ -994,11 +1586,8 @@ public final class Policy { if (size != -1) return size; size = 0; - if (policyRuleState_ != policy.Policy.PolicyRuleStateEnum.POLICY_UNDEFINED.getNumber()) { - size += com.google.protobuf.CodedOutputStream.computeEnumSize(1, policyRuleState_); - } - if (!com.google.protobuf.GeneratedMessageV3.isStringEmpty(policyRuleStateMessage_)) { - size += com.google.protobuf.GeneratedMessageV3.computeStringSize(2, policyRuleStateMessage_); + if (policyRuleKpiUuid_ != null) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(1, getPolicyRuleKpiUuid()); } size += getUnknownFields().getSerializedSize(); memoizedSize = size; @@ -1010,14 +1599,16 @@ public final class Policy { if (obj == this) { return true; } - if (!(obj instanceof policy.Policy.PolicyRuleState)) { + if (!(obj instanceof policy.Policy.PolicyRuleKpiId)) { return super.equals(obj); } - policy.Policy.PolicyRuleState other = (policy.Policy.PolicyRuleState) obj; - if (policyRuleState_ != other.policyRuleState_) - return false; - if (!getPolicyRuleStateMessage().equals(other.getPolicyRuleStateMessage())) + policy.Policy.PolicyRuleKpiId other = (policy.Policy.PolicyRuleKpiId) obj; + if (hasPolicyRuleKpiUuid() != other.hasPolicyRuleKpiUuid()) return false; + if (hasPolicyRuleKpiUuid()) { + if (!getPolicyRuleKpiUuid().equals(other.getPolicyRuleKpiUuid())) + return false; + } if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; @@ -1030,60 +1621,60 @@ public final class Policy { } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); - hash = (37 * hash) + POLICYRULESTATE_FIELD_NUMBER; - hash = (53 * hash) + policyRuleState_; - hash = (37 * hash) + POLICYRULESTATEMESSAGE_FIELD_NUMBER; - hash = (53 * hash) + getPolicyRuleStateMessage().hashCode(); + if (hasPolicyRuleKpiUuid()) { + hash = (37 * hash) + POLICYRULEKPIUUID_FIELD_NUMBER; + hash = (53 * hash) + getPolicyRuleKpiUuid().hashCode(); + } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; } - public static policy.Policy.PolicyRuleState parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { + public static policy.Policy.PolicyRuleKpiId parseFrom(java.nio.ByteBuffer data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static policy.Policy.PolicyRuleState parseFrom(java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + public static policy.Policy.PolicyRuleKpiId parseFrom(java.nio.ByteBuffer data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static policy.Policy.PolicyRuleState parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { + public static policy.Policy.PolicyRuleKpiId parseFrom(com.google.protobuf.ByteString data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static policy.Policy.PolicyRuleState parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + public static policy.Policy.PolicyRuleKpiId parseFrom(com.google.protobuf.ByteString data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static policy.Policy.PolicyRuleState parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { + public static policy.Policy.PolicyRuleKpiId parseFrom(byte[] data) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data); } - public static policy.Policy.PolicyRuleState parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + public static policy.Policy.PolicyRuleKpiId parseFrom(byte[] data, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { return PARSER.parseFrom(data, extensionRegistry); } - public static policy.Policy.PolicyRuleState parseFrom(java.io.InputStream input) throws java.io.IOException { + public static policy.Policy.PolicyRuleKpiId parseFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); } - public static policy.Policy.PolicyRuleState parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + public static policy.Policy.PolicyRuleKpiId parseFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input, extensionRegistry); } - public static policy.Policy.PolicyRuleState parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { + public static policy.Policy.PolicyRuleKpiId parseDelimitedFrom(java.io.InputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input); } - public static policy.Policy.PolicyRuleState parseDelimitedFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + public static policy.Policy.PolicyRuleKpiId parseDelimitedFrom(java.io.InputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseDelimitedWithIOException(PARSER, input, extensionRegistry); } - public static policy.Policy.PolicyRuleState parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { + public static policy.Policy.PolicyRuleKpiId parseFrom(com.google.protobuf.CodedInputStream input) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input); } - public static policy.Policy.PolicyRuleState parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { + public static policy.Policy.PolicyRuleKpiId parseFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws java.io.IOException { return com.google.protobuf.GeneratedMessageV3.parseWithIOException(PARSER, input, extensionRegistry); } @@ -1096,7 +1687,7 @@ public final class Policy { return DEFAULT_INSTANCE.toBuilder(); } - public static Builder newBuilder(policy.Policy.PolicyRuleState prototype) { + public static Builder newBuilder(policy.Policy.PolicyRuleKpiId prototype) { return DEFAULT_INSTANCE.toBuilder().mergeFrom(prototype); } @@ -1112,21 +1703,21 @@ public final class Policy { } /** - * Protobuf type {@code policy.PolicyRuleState} + * Protobuf type {@code policy.PolicyRuleKpiId} */ - public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements // @@protoc_insertion_point(builder_implements:policy.PolicyRuleState) - policy.Policy.PolicyRuleStateOrBuilder { + public static final class Builder extends com.google.protobuf.GeneratedMessageV3.Builder implements // @@protoc_insertion_point(builder_implements:policy.PolicyRuleKpiId) + policy.Policy.PolicyRuleKpiIdOrBuilder { public static final com.google.protobuf.Descriptors.Descriptor getDescriptor() { - return policy.Policy.internal_static_policy_PolicyRuleState_descriptor; + return policy.Policy.internal_static_policy_PolicyRuleKpiId_descriptor; } @java.lang.Override protected com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internalGetFieldAccessorTable() { - return policy.Policy.internal_static_policy_PolicyRuleState_fieldAccessorTable.ensureFieldAccessorsInitialized(policy.Policy.PolicyRuleState.class, policy.Policy.PolicyRuleState.Builder.class); + return policy.Policy.internal_static_policy_PolicyRuleKpiId_fieldAccessorTable.ensureFieldAccessorsInitialized(policy.Policy.PolicyRuleKpiId.class, policy.Policy.PolicyRuleKpiId.Builder.class); } - // Construct using policy.Policy.PolicyRuleState.newBuilder() + // Construct using policy.Policy.PolicyRuleKpiId.newBuilder() private Builder() { } @@ -1138,24 +1729,27 @@ public final class Policy { public Builder clear() { super.clear(); bitField0_ = 0; - policyRuleState_ = 0; - policyRuleStateMessage_ = ""; + policyRuleKpiUuid_ = null; + if (policyRuleKpiUuidBuilder_ != null) { + policyRuleKpiUuidBuilder_.dispose(); + policyRuleKpiUuidBuilder_ = null; + } return this; } @java.lang.Override public com.google.protobuf.Descriptors.Descriptor getDescriptorForType() { - return policy.Policy.internal_static_policy_PolicyRuleState_descriptor; + return policy.Policy.internal_static_policy_PolicyRuleKpiId_descriptor; } @java.lang.Override - public policy.Policy.PolicyRuleState getDefaultInstanceForType() { - return policy.Policy.PolicyRuleState.getDefaultInstance(); + public policy.Policy.PolicyRuleKpiId getDefaultInstanceForType() { + return policy.Policy.PolicyRuleKpiId.getDefaultInstance(); } @java.lang.Override - public policy.Policy.PolicyRuleState build() { - policy.Policy.PolicyRuleState result = buildPartial(); + public policy.Policy.PolicyRuleKpiId build() { + policy.Policy.PolicyRuleKpiId result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } @@ -1163,8 +1757,8 @@ public final class Policy { } @java.lang.Override - public policy.Policy.PolicyRuleState buildPartial() { - policy.Policy.PolicyRuleState result = new policy.Policy.PolicyRuleState(this); + public policy.Policy.PolicyRuleKpiId buildPartial() { + policy.Policy.PolicyRuleKpiId result = new policy.Policy.PolicyRuleKpiId(this); if (bitField0_ != 0) { buildPartial0(result); } @@ -1172,36 +1766,28 @@ public final class Policy { return result; } - private void buildPartial0(policy.Policy.PolicyRuleState result) { + private void buildPartial0(policy.Policy.PolicyRuleKpiId result) { int from_bitField0_ = bitField0_; if (((from_bitField0_ & 0x00000001) != 0)) { - result.policyRuleState_ = policyRuleState_; - } - if (((from_bitField0_ & 0x00000002) != 0)) { - result.policyRuleStateMessage_ = policyRuleStateMessage_; + result.policyRuleKpiUuid_ = policyRuleKpiUuidBuilder_ == null ? policyRuleKpiUuid_ : policyRuleKpiUuidBuilder_.build(); } } @java.lang.Override public Builder mergeFrom(com.google.protobuf.Message other) { - if (other instanceof policy.Policy.PolicyRuleState) { - return mergeFrom((policy.Policy.PolicyRuleState) other); + if (other instanceof policy.Policy.PolicyRuleKpiId) { + return mergeFrom((policy.Policy.PolicyRuleKpiId) other); } else { super.mergeFrom(other); return this; } } - public Builder mergeFrom(policy.Policy.PolicyRuleState other) { - if (other == policy.Policy.PolicyRuleState.getDefaultInstance()) + public Builder mergeFrom(policy.Policy.PolicyRuleKpiId other) { + if (other == policy.Policy.PolicyRuleKpiId.getDefaultInstance()) return this; - if (other.policyRuleState_ != 0) { - setPolicyRuleStateValue(other.getPolicyRuleStateValue()); - } - if (!other.getPolicyRuleStateMessage().isEmpty()) { - policyRuleStateMessage_ = other.policyRuleStateMessage_; - bitField0_ |= 0x00000002; - onChanged(); + if (other.hasPolicyRuleKpiUuid()) { + mergePolicyRuleKpiUuid(other.getPolicyRuleKpiUuid()); } this.mergeUnknownFields(other.getUnknownFields()); onChanged(); @@ -1226,20 +1812,13 @@ public final class Policy { case 0: done = true; break; - case 8: + case 10: { - policyRuleState_ = input.readEnum(); + input.readMessage(getPolicyRuleKpiUuidFieldBuilder().getBuilder(), extensionRegistry); bitField0_ |= 0x00000001; break; } - // case 8 - case 18: - { - policyRuleStateMessage_ = input.readStringRequireUtf8(); - bitField0_ |= 0x00000002; - break; - } - // case 18 + // case 10 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { @@ -1263,138 +1842,158 @@ public final class Policy { private int bitField0_; - private int policyRuleState_ = 0; + private context.ContextOuterClass.Uuid policyRuleKpiUuid_; - /** - * .policy.PolicyRuleStateEnum policyRuleState = 1; - * @return The enum numeric value on the wire for policyRuleState. - */ - @java.lang.Override - public int getPolicyRuleStateValue() { - return policyRuleState_; - } + private com.google.protobuf.SingleFieldBuilderV3 policyRuleKpiUuidBuilder_; /** - * .policy.PolicyRuleStateEnum policyRuleState = 1; - * @param value The enum numeric value on the wire for policyRuleState to set. - * @return This builder for chaining. + *
+             * Same as defined in kpi_manager.proto
+             * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; + * @return Whether the policyRuleKpiUuid field is set. */ - public Builder setPolicyRuleStateValue(int value) { - policyRuleState_ = value; - bitField0_ |= 0x00000001; - onChanged(); - return this; + public boolean hasPolicyRuleKpiUuid() { + return ((bitField0_ & 0x00000001) != 0); } /** - * .policy.PolicyRuleStateEnum policyRuleState = 1; - * @return The policyRuleState. - */ - @java.lang.Override - public policy.Policy.PolicyRuleStateEnum getPolicyRuleState() { - policy.Policy.PolicyRuleStateEnum result = policy.Policy.PolicyRuleStateEnum.forNumber(policyRuleState_); - return result == null ? policy.Policy.PolicyRuleStateEnum.UNRECOGNIZED : result; + *
+             * Same as defined in kpi_manager.proto
+             * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; + * @return The policyRuleKpiUuid. + */ + public context.ContextOuterClass.Uuid getPolicyRuleKpiUuid() { + if (policyRuleKpiUuidBuilder_ == null) { + return policyRuleKpiUuid_ == null ? context.ContextOuterClass.Uuid.getDefaultInstance() : policyRuleKpiUuid_; + } else { + return policyRuleKpiUuidBuilder_.getMessage(); + } } /** - * .policy.PolicyRuleStateEnum policyRuleState = 1; - * @param value The policyRuleState to set. - * @return This builder for chaining. + *
+             * Same as defined in kpi_manager.proto
+             * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; */ - public Builder setPolicyRuleState(policy.Policy.PolicyRuleStateEnum value) { - if (value == null) { - throw new NullPointerException(); + public Builder setPolicyRuleKpiUuid(context.ContextOuterClass.Uuid value) { + if (policyRuleKpiUuidBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + policyRuleKpiUuid_ = value; + } else { + policyRuleKpiUuidBuilder_.setMessage(value); } bitField0_ |= 0x00000001; - policyRuleState_ = value.getNumber(); onChanged(); return this; } /** - * .policy.PolicyRuleStateEnum policyRuleState = 1; - * @return This builder for chaining. + *
+             * Same as defined in kpi_manager.proto
+             * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; */ - public Builder clearPolicyRuleState() { - bitField0_ = (bitField0_ & ~0x00000001); - policyRuleState_ = 0; + public Builder setPolicyRuleKpiUuid(context.ContextOuterClass.Uuid.Builder builderForValue) { + if (policyRuleKpiUuidBuilder_ == null) { + policyRuleKpiUuid_ = builderForValue.build(); + } else { + policyRuleKpiUuidBuilder_.setMessage(builderForValue.build()); + } + bitField0_ |= 0x00000001; onChanged(); return this; } - private java.lang.Object policyRuleStateMessage_ = ""; - /** - * string policyRuleStateMessage = 2; - * @return The policyRuleStateMessage. + *
+             * Same as defined in kpi_manager.proto
+             * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; */ - public java.lang.String getPolicyRuleStateMessage() { - java.lang.Object ref = policyRuleStateMessage_; - if (!(ref instanceof java.lang.String)) { - com.google.protobuf.ByteString bs = (com.google.protobuf.ByteString) ref; - java.lang.String s = bs.toStringUtf8(); - policyRuleStateMessage_ = s; - return s; + public Builder mergePolicyRuleKpiUuid(context.ContextOuterClass.Uuid value) { + if (policyRuleKpiUuidBuilder_ == null) { + if (((bitField0_ & 0x00000001) != 0) && policyRuleKpiUuid_ != null && policyRuleKpiUuid_ != context.ContextOuterClass.Uuid.getDefaultInstance()) { + getPolicyRuleKpiUuidBuilder().mergeFrom(value); + } else { + policyRuleKpiUuid_ = value; + } } else { - return (java.lang.String) ref; + policyRuleKpiUuidBuilder_.mergeFrom(value); } + bitField0_ |= 0x00000001; + onChanged(); + return this; } /** - * string policyRuleStateMessage = 2; - * @return The bytes for policyRuleStateMessage. + *
+             * Same as defined in kpi_manager.proto
+             * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; */ - public com.google.protobuf.ByteString getPolicyRuleStateMessageBytes() { - java.lang.Object ref = policyRuleStateMessage_; - if (ref instanceof String) { - com.google.protobuf.ByteString b = com.google.protobuf.ByteString.copyFromUtf8((java.lang.String) ref); - policyRuleStateMessage_ = b; - return b; - } else { - return (com.google.protobuf.ByteString) ref; + public Builder clearPolicyRuleKpiUuid() { + bitField0_ = (bitField0_ & ~0x00000001); + policyRuleKpiUuid_ = null; + if (policyRuleKpiUuidBuilder_ != null) { + policyRuleKpiUuidBuilder_.dispose(); + policyRuleKpiUuidBuilder_ = null; } + onChanged(); + return this; } /** - * string policyRuleStateMessage = 2; - * @param value The policyRuleStateMessage to set. - * @return This builder for chaining. + *
+             * Same as defined in kpi_manager.proto
+             * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; */ - public Builder setPolicyRuleStateMessage(java.lang.String value) { - if (value == null) { - throw new NullPointerException(); - } - policyRuleStateMessage_ = value; - bitField0_ |= 0x00000002; + public context.ContextOuterClass.Uuid.Builder getPolicyRuleKpiUuidBuilder() { + bitField0_ |= 0x00000001; onChanged(); - return this; + return getPolicyRuleKpiUuidFieldBuilder().getBuilder(); } /** - * string policyRuleStateMessage = 2; - * @return This builder for chaining. + *
+             * Same as defined in kpi_manager.proto
+             * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; */ - public Builder clearPolicyRuleStateMessage() { - policyRuleStateMessage_ = getDefaultInstance().getPolicyRuleStateMessage(); - bitField0_ = (bitField0_ & ~0x00000002); - onChanged(); - return this; + public context.ContextOuterClass.UuidOrBuilder getPolicyRuleKpiUuidOrBuilder() { + if (policyRuleKpiUuidBuilder_ != null) { + return policyRuleKpiUuidBuilder_.getMessageOrBuilder(); + } else { + return policyRuleKpiUuid_ == null ? context.ContextOuterClass.Uuid.getDefaultInstance() : policyRuleKpiUuid_; + } } /** - * string policyRuleStateMessage = 2; - * @param value The bytes for policyRuleStateMessage to set. - * @return This builder for chaining. + *
+             * Same as defined in kpi_manager.proto
+             * 
+ * + * .context.Uuid policyRuleKpiUuid = 1; */ - public Builder setPolicyRuleStateMessageBytes(com.google.protobuf.ByteString value) { - if (value == null) { - throw new NullPointerException(); + private com.google.protobuf.SingleFieldBuilderV3 getPolicyRuleKpiUuidFieldBuilder() { + if (policyRuleKpiUuidBuilder_ == null) { + policyRuleKpiUuidBuilder_ = new com.google.protobuf.SingleFieldBuilderV3(getPolicyRuleKpiUuid(), getParentForChildren(), isClean()); + policyRuleKpiUuid_ = null; } - checkByteStringIsUtf8(value); - policyRuleStateMessage_ = value; - bitField0_ |= 0x00000002; - onChanged(); - return this; + return policyRuleKpiUuidBuilder_; } @java.lang.Override @@ -1406,24 +2005,24 @@ public final class Policy { public final Builder mergeUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.mergeUnknownFields(unknownFields); } - // @@protoc_insertion_point(builder_scope:policy.PolicyRuleState) + // @@protoc_insertion_point(builder_scope:policy.PolicyRuleKpiId) } - // @@protoc_insertion_point(class_scope:policy.PolicyRuleState) - private static final policy.Policy.PolicyRuleState DEFAULT_INSTANCE; + // @@protoc_insertion_point(class_scope:policy.PolicyRuleKpiId) + private static final policy.Policy.PolicyRuleKpiId DEFAULT_INSTANCE; static { - DEFAULT_INSTANCE = new policy.Policy.PolicyRuleState(); + DEFAULT_INSTANCE = new policy.Policy.PolicyRuleKpiId(); } - public static policy.Policy.PolicyRuleState getDefaultInstance() { + public static policy.Policy.PolicyRuleKpiId getDefaultInstance() { return DEFAULT_INSTANCE; } - private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { + private static final com.google.protobuf.Parser PARSER = new com.google.protobuf.AbstractParser() { @java.lang.Override - public PolicyRuleState parsePartialFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { + public PolicyRuleKpiId parsePartialFrom(com.google.protobuf.CodedInputStream input, com.google.protobuf.ExtensionRegistryLite extensionRegistry) throws com.google.protobuf.InvalidProtocolBufferException { Builder builder = newBuilder(); try { builder.mergeFrom(input, extensionRegistry); @@ -1438,17 +2037,17 @@ public final class Policy { } }; - public static com.google.protobuf.Parser parser() { + public static com.google.protobuf.Parser parser() { return PARSER; } @java.lang.Override - public com.google.protobuf.Parser getParserForType() { + public com.google.protobuf.Parser getParserForType() { return PARSER; } @java.lang.Override - public policy.Policy.PolicyRuleState getDefaultInstanceForType() { + public policy.Policy.PolicyRuleKpiId getDefaultInstanceForType() { return DEFAULT_INSTANCE; } } @@ -1457,40 +2056,68 @@ public final class Policy { com.google.protobuf.MessageOrBuilder { /** + *
+         * Unique rule ID
+         * 
+ * * .policy.PolicyRuleId policyRuleId = 1; * @return Whether the policyRuleId field is set. */ boolean hasPolicyRuleId(); /** + *
+         * Unique rule ID
+         * 
+ * * .policy.PolicyRuleId policyRuleId = 1; * @return The policyRuleId. */ policy.Policy.PolicyRuleId getPolicyRuleId(); /** + *
+         * Unique rule ID
+         * 
+ * * .policy.PolicyRuleId policyRuleId = 1; */ policy.Policy.PolicyRuleIdOrBuilder getPolicyRuleIdOrBuilder(); /** + *
+         * Rule lifecycle information
+         * 
+ * * .policy.PolicyRuleState policyRuleState = 2; * @return Whether the policyRuleState field is set. */ boolean hasPolicyRuleState(); /** + *
+         * Rule lifecycle information
+         * 
+ * * .policy.PolicyRuleState policyRuleState = 2; * @return The policyRuleState. */ policy.Policy.PolicyRuleState getPolicyRuleState(); /** + *
+         * Rule lifecycle information
+         * 
+ * * .policy.PolicyRuleState policyRuleState = 2; */ policy.Policy.PolicyRuleStateOrBuilder getPolicyRuleStateOrBuilder(); /** + *
+         * The priority of this rule
+         * 
+ * * uint32 policyRulePriority = 3; * @return The policyRulePriority. */ @@ -1540,6 +2167,51 @@ public final class Policy { * repeated .policy.PolicyRuleAction actionList = 4; */ policy.PolicyAction.PolicyRuleActionOrBuilder getActionListOrBuilder(int index); + + /** + *
+         * List of KPIs associated with this policy
+         * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + java.util.List getPolicyRuleKpiListList(); + + /** + *
+         * List of KPIs associated with this policy
+         * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + policy.Policy.PolicyRuleKpiId getPolicyRuleKpiList(int index); + + /** + *
+         * List of KPIs associated with this policy
+         * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + int getPolicyRuleKpiListCount(); + + /** + *
+         * List of KPIs associated with this policy
+         * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + java.util.List getPolicyRuleKpiListOrBuilderList(); + + /** + *
+         * List of KPIs associated with this policy
+         * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + policy.Policy.PolicyRuleKpiIdOrBuilder getPolicyRuleKpiListOrBuilder(int index); } /** @@ -1561,6 +2233,7 @@ public final class Policy { private PolicyRuleBasic() { actionList_ = java.util.Collections.emptyList(); + policyRuleKpiList_ = java.util.Collections.emptyList(); } @java.lang.Override @@ -1583,6 +2256,10 @@ public final class Policy { private policy.Policy.PolicyRuleId policyRuleId_; /** + *
+         * Unique rule ID
+         * 
+ * * .policy.PolicyRuleId policyRuleId = 1; * @return Whether the policyRuleId field is set. */ @@ -1592,6 +2269,10 @@ public final class Policy { } /** + *
+         * Unique rule ID
+         * 
+ * * .policy.PolicyRuleId policyRuleId = 1; * @return The policyRuleId. */ @@ -1601,6 +2282,10 @@ public final class Policy { } /** + *
+         * Unique rule ID
+         * 
+ * * .policy.PolicyRuleId policyRuleId = 1; */ @java.lang.Override @@ -1613,6 +2298,10 @@ public final class Policy { private policy.Policy.PolicyRuleState policyRuleState_; /** + *
+         * Rule lifecycle information
+         * 
+ * * .policy.PolicyRuleState policyRuleState = 2; * @return Whether the policyRuleState field is set. */ @@ -1622,6 +2311,10 @@ public final class Policy { } /** + *
+         * Rule lifecycle information
+         * 
+ * * .policy.PolicyRuleState policyRuleState = 2; * @return The policyRuleState. */ @@ -1631,6 +2324,10 @@ public final class Policy { } /** + *
+         * Rule lifecycle information
+         * 
+ * * .policy.PolicyRuleState policyRuleState = 2; */ @java.lang.Override @@ -1643,6 +2340,10 @@ public final class Policy { private int policyRulePriority_ = 0; /** + *
+         * The priority of this rule
+         * 
+ * * uint32 policyRulePriority = 3; * @return The policyRulePriority. */ @@ -1716,6 +2417,71 @@ public final class Policy { return actionList_.get(index); } + public static final int POLICYRULEKPILIST_FIELD_NUMBER = 5; + + @SuppressWarnings("serial") + private java.util.List policyRuleKpiList_; + + /** + *
+         * List of KPIs associated with this policy
+         * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + @java.lang.Override + public java.util.List getPolicyRuleKpiListList() { + return policyRuleKpiList_; + } + + /** + *
+         * List of KPIs associated with this policy
+         * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + @java.lang.Override + public java.util.List getPolicyRuleKpiListOrBuilderList() { + return policyRuleKpiList_; + } + + /** + *
+         * List of KPIs associated with this policy
+         * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + @java.lang.Override + public int getPolicyRuleKpiListCount() { + return policyRuleKpiList_.size(); + } + + /** + *
+         * List of KPIs associated with this policy
+         * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + @java.lang.Override + public policy.Policy.PolicyRuleKpiId getPolicyRuleKpiList(int index) { + return policyRuleKpiList_.get(index); + } + + /** + *
+         * List of KPIs associated with this policy
+         * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + @java.lang.Override + public policy.Policy.PolicyRuleKpiIdOrBuilder getPolicyRuleKpiListOrBuilder(int index) { + return policyRuleKpiList_.get(index); + } + private byte memoizedIsInitialized = -1; @java.lang.Override @@ -1743,6 +2509,9 @@ public final class Policy { for (int i = 0; i < actionList_.size(); i++) { output.writeMessage(4, actionList_.get(i)); } + for (int i = 0; i < policyRuleKpiList_.size(); i++) { + output.writeMessage(5, policyRuleKpiList_.get(i)); + } getUnknownFields().writeTo(output); } @@ -1764,6 +2533,9 @@ public final class Policy { for (int i = 0; i < actionList_.size(); i++) { size += com.google.protobuf.CodedOutputStream.computeMessageSize(4, actionList_.get(i)); } + for (int i = 0; i < policyRuleKpiList_.size(); i++) { + size += com.google.protobuf.CodedOutputStream.computeMessageSize(5, policyRuleKpiList_.get(i)); + } size += getUnknownFields().getSerializedSize(); memoizedSize = size; return size; @@ -1794,6 +2566,8 @@ public final class Policy { return false; if (!getActionListList().equals(other.getActionListList())) return false; + if (!getPolicyRuleKpiListList().equals(other.getPolicyRuleKpiListList())) + return false; if (!getUnknownFields().equals(other.getUnknownFields())) return false; return true; @@ -1820,6 +2594,10 @@ public final class Policy { hash = (37 * hash) + ACTIONLIST_FIELD_NUMBER; hash = (53 * hash) + getActionListList().hashCode(); } + if (getPolicyRuleKpiListCount() > 0) { + hash = (37 * hash) + POLICYRULEKPILIST_FIELD_NUMBER; + hash = (53 * hash) + getPolicyRuleKpiListList().hashCode(); + } hash = (29 * hash) + getUnknownFields().hashCode(); memoizedHashCode = hash; return hash; @@ -1946,6 +2724,13 @@ public final class Policy { actionListBuilder_.clear(); } bitField0_ = (bitField0_ & ~0x00000008); + if (policyRuleKpiListBuilder_ == null) { + policyRuleKpiList_ = java.util.Collections.emptyList(); + } else { + policyRuleKpiList_ = null; + policyRuleKpiListBuilder_.clear(); + } + bitField0_ = (bitField0_ & ~0x00000010); return this; } @@ -1989,6 +2774,15 @@ public final class Policy { } else { result.actionList_ = actionListBuilder_.build(); } + if (policyRuleKpiListBuilder_ == null) { + if (((bitField0_ & 0x00000010) != 0)) { + policyRuleKpiList_ = java.util.Collections.unmodifiableList(policyRuleKpiList_); + bitField0_ = (bitField0_ & ~0x00000010); + } + result.policyRuleKpiList_ = policyRuleKpiList_; + } else { + result.policyRuleKpiList_ = policyRuleKpiListBuilder_.build(); + } } private void buildPartial0(policy.Policy.PolicyRuleBasic result) { @@ -2050,6 +2844,30 @@ public final class Policy { } } } + if (policyRuleKpiListBuilder_ == null) { + if (!other.policyRuleKpiList_.isEmpty()) { + if (policyRuleKpiList_.isEmpty()) { + policyRuleKpiList_ = other.policyRuleKpiList_; + bitField0_ = (bitField0_ & ~0x00000010); + } else { + ensurePolicyRuleKpiListIsMutable(); + policyRuleKpiList_.addAll(other.policyRuleKpiList_); + } + onChanged(); + } + } else { + if (!other.policyRuleKpiList_.isEmpty()) { + if (policyRuleKpiListBuilder_.isEmpty()) { + policyRuleKpiListBuilder_.dispose(); + policyRuleKpiListBuilder_ = null; + policyRuleKpiList_ = other.policyRuleKpiList_; + bitField0_ = (bitField0_ & ~0x00000010); + policyRuleKpiListBuilder_ = com.google.protobuf.GeneratedMessageV3.alwaysUseFieldBuilders ? getPolicyRuleKpiListFieldBuilder() : null; + } else { + policyRuleKpiListBuilder_.addAllMessages(other.policyRuleKpiList_); + } + } + } this.mergeUnknownFields(other.getUnknownFields()); onChanged(); return this; @@ -2106,6 +2924,18 @@ public final class Policy { break; } // case 34 + case 42: + { + policy.Policy.PolicyRuleKpiId m = input.readMessage(policy.Policy.PolicyRuleKpiId.parser(), extensionRegistry); + if (policyRuleKpiListBuilder_ == null) { + ensurePolicyRuleKpiListIsMutable(); + policyRuleKpiList_.add(m); + } else { + policyRuleKpiListBuilder_.addMessage(m); + } + break; + } + // case 42 default: { if (!super.parseUnknownField(input, extensionRegistry, tag)) { @@ -2134,6 +2964,10 @@ public final class Policy { private com.google.protobuf.SingleFieldBuilderV3 policyRuleIdBuilder_; /** + *
+             * Unique rule ID
+             * 
+ * * .policy.PolicyRuleId policyRuleId = 1; * @return Whether the policyRuleId field is set. */ @@ -2142,6 +2976,10 @@ public final class Policy { } /** + *
+             * Unique rule ID
+             * 
+ * * .policy.PolicyRuleId policyRuleId = 1; * @return The policyRuleId. */ @@ -2154,6 +2992,10 @@ public final class Policy { } /** + *
+             * Unique rule ID
+             * 
+ * * .policy.PolicyRuleId policyRuleId = 1; */ public Builder setPolicyRuleId(policy.Policy.PolicyRuleId value) { @@ -2171,6 +3013,10 @@ public final class Policy { } /** + *
+             * Unique rule ID
+             * 
+ * * .policy.PolicyRuleId policyRuleId = 1; */ public Builder setPolicyRuleId(policy.Policy.PolicyRuleId.Builder builderForValue) { @@ -2185,6 +3031,10 @@ public final class Policy { } /** + *
+             * Unique rule ID
+             * 
+ * * .policy.PolicyRuleId policyRuleId = 1; */ public Builder mergePolicyRuleId(policy.Policy.PolicyRuleId value) { @@ -2203,6 +3053,10 @@ public final class Policy { } /** + *
+             * Unique rule ID
+             * 
+ * * .policy.PolicyRuleId policyRuleId = 1; */ public Builder clearPolicyRuleId() { @@ -2217,6 +3071,10 @@ public final class Policy { } /** + *
+             * Unique rule ID
+             * 
+ * * .policy.PolicyRuleId policyRuleId = 1; */ public policy.Policy.PolicyRuleId.Builder getPolicyRuleIdBuilder() { @@ -2226,6 +3084,10 @@ public final class Policy { } /** + *
+             * Unique rule ID
+             * 
+ * * .policy.PolicyRuleId policyRuleId = 1; */ public policy.Policy.PolicyRuleIdOrBuilder getPolicyRuleIdOrBuilder() { @@ -2237,6 +3099,10 @@ public final class Policy { } /** + *
+             * Unique rule ID
+             * 
+ * * .policy.PolicyRuleId policyRuleId = 1; */ private com.google.protobuf.SingleFieldBuilderV3 getPolicyRuleIdFieldBuilder() { @@ -2252,6 +3118,10 @@ public final class Policy { private com.google.protobuf.SingleFieldBuilderV3 policyRuleStateBuilder_; /** + *
+             * Rule lifecycle information
+             * 
+ * * .policy.PolicyRuleState policyRuleState = 2; * @return Whether the policyRuleState field is set. */ @@ -2260,6 +3130,10 @@ public final class Policy { } /** + *
+             * Rule lifecycle information
+             * 
+ * * .policy.PolicyRuleState policyRuleState = 2; * @return The policyRuleState. */ @@ -2272,6 +3146,10 @@ public final class Policy { } /** + *
+             * Rule lifecycle information
+             * 
+ * * .policy.PolicyRuleState policyRuleState = 2; */ public Builder setPolicyRuleState(policy.Policy.PolicyRuleState value) { @@ -2289,6 +3167,10 @@ public final class Policy { } /** + *
+             * Rule lifecycle information
+             * 
+ * * .policy.PolicyRuleState policyRuleState = 2; */ public Builder setPolicyRuleState(policy.Policy.PolicyRuleState.Builder builderForValue) { @@ -2303,6 +3185,10 @@ public final class Policy { } /** + *
+             * Rule lifecycle information
+             * 
+ * * .policy.PolicyRuleState policyRuleState = 2; */ public Builder mergePolicyRuleState(policy.Policy.PolicyRuleState value) { @@ -2321,6 +3207,10 @@ public final class Policy { } /** + *
+             * Rule lifecycle information
+             * 
+ * * .policy.PolicyRuleState policyRuleState = 2; */ public Builder clearPolicyRuleState() { @@ -2335,6 +3225,10 @@ public final class Policy { } /** + *
+             * Rule lifecycle information
+             * 
+ * * .policy.PolicyRuleState policyRuleState = 2; */ public policy.Policy.PolicyRuleState.Builder getPolicyRuleStateBuilder() { @@ -2344,6 +3238,10 @@ public final class Policy { } /** + *
+             * Rule lifecycle information
+             * 
+ * * .policy.PolicyRuleState policyRuleState = 2; */ public policy.Policy.PolicyRuleStateOrBuilder getPolicyRuleStateOrBuilder() { @@ -2355,6 +3253,10 @@ public final class Policy { } /** + *
+             * Rule lifecycle information
+             * 
+ * * .policy.PolicyRuleState policyRuleState = 2; */ private com.google.protobuf.SingleFieldBuilderV3 getPolicyRuleStateFieldBuilder() { @@ -2368,6 +3270,10 @@ public final class Policy { private int policyRulePriority_; /** + *
+             * The priority of this rule
+             * 
+ * * uint32 policyRulePriority = 3; * @return The policyRulePriority. */ @@ -2377,6 +3283,10 @@ public final class Policy { } /** + *
+             * The priority of this rule
+             * 
+ * * uint32 policyRulePriority = 3; * @param value The policyRulePriority to set. * @return This builder for chaining. @@ -2389,6 +3299,10 @@ public final class Policy { } /** + *
+             * The priority of this rule
+             * 
+ * * uint32 policyRulePriority = 3; * @return This builder for chaining. */ @@ -2708,6 +3622,315 @@ public final class Policy { return actionListBuilder_; } + private java.util.List policyRuleKpiList_ = java.util.Collections.emptyList(); + + private void ensurePolicyRuleKpiListIsMutable() { + if (!((bitField0_ & 0x00000010) != 0)) { + policyRuleKpiList_ = new java.util.ArrayList(policyRuleKpiList_); + bitField0_ |= 0x00000010; + } + } + + private com.google.protobuf.RepeatedFieldBuilderV3 policyRuleKpiListBuilder_; + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public java.util.List getPolicyRuleKpiListList() { + if (policyRuleKpiListBuilder_ == null) { + return java.util.Collections.unmodifiableList(policyRuleKpiList_); + } else { + return policyRuleKpiListBuilder_.getMessageList(); + } + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public int getPolicyRuleKpiListCount() { + if (policyRuleKpiListBuilder_ == null) { + return policyRuleKpiList_.size(); + } else { + return policyRuleKpiListBuilder_.getCount(); + } + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public policy.Policy.PolicyRuleKpiId getPolicyRuleKpiList(int index) { + if (policyRuleKpiListBuilder_ == null) { + return policyRuleKpiList_.get(index); + } else { + return policyRuleKpiListBuilder_.getMessage(index); + } + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public Builder setPolicyRuleKpiList(int index, policy.Policy.PolicyRuleKpiId value) { + if (policyRuleKpiListBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePolicyRuleKpiListIsMutable(); + policyRuleKpiList_.set(index, value); + onChanged(); + } else { + policyRuleKpiListBuilder_.setMessage(index, value); + } + return this; + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public Builder setPolicyRuleKpiList(int index, policy.Policy.PolicyRuleKpiId.Builder builderForValue) { + if (policyRuleKpiListBuilder_ == null) { + ensurePolicyRuleKpiListIsMutable(); + policyRuleKpiList_.set(index, builderForValue.build()); + onChanged(); + } else { + policyRuleKpiListBuilder_.setMessage(index, builderForValue.build()); + } + return this; + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public Builder addPolicyRuleKpiList(policy.Policy.PolicyRuleKpiId value) { + if (policyRuleKpiListBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePolicyRuleKpiListIsMutable(); + policyRuleKpiList_.add(value); + onChanged(); + } else { + policyRuleKpiListBuilder_.addMessage(value); + } + return this; + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public Builder addPolicyRuleKpiList(int index, policy.Policy.PolicyRuleKpiId value) { + if (policyRuleKpiListBuilder_ == null) { + if (value == null) { + throw new NullPointerException(); + } + ensurePolicyRuleKpiListIsMutable(); + policyRuleKpiList_.add(index, value); + onChanged(); + } else { + policyRuleKpiListBuilder_.addMessage(index, value); + } + return this; + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public Builder addPolicyRuleKpiList(policy.Policy.PolicyRuleKpiId.Builder builderForValue) { + if (policyRuleKpiListBuilder_ == null) { + ensurePolicyRuleKpiListIsMutable(); + policyRuleKpiList_.add(builderForValue.build()); + onChanged(); + } else { + policyRuleKpiListBuilder_.addMessage(builderForValue.build()); + } + return this; + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public Builder addPolicyRuleKpiList(int index, policy.Policy.PolicyRuleKpiId.Builder builderForValue) { + if (policyRuleKpiListBuilder_ == null) { + ensurePolicyRuleKpiListIsMutable(); + policyRuleKpiList_.add(index, builderForValue.build()); + onChanged(); + } else { + policyRuleKpiListBuilder_.addMessage(index, builderForValue.build()); + } + return this; + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public Builder addAllPolicyRuleKpiList(java.lang.Iterable values) { + if (policyRuleKpiListBuilder_ == null) { + ensurePolicyRuleKpiListIsMutable(); + com.google.protobuf.AbstractMessageLite.Builder.addAll(values, policyRuleKpiList_); + onChanged(); + } else { + policyRuleKpiListBuilder_.addAllMessages(values); + } + return this; + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public Builder clearPolicyRuleKpiList() { + if (policyRuleKpiListBuilder_ == null) { + policyRuleKpiList_ = java.util.Collections.emptyList(); + bitField0_ = (bitField0_ & ~0x00000010); + onChanged(); + } else { + policyRuleKpiListBuilder_.clear(); + } + return this; + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public Builder removePolicyRuleKpiList(int index) { + if (policyRuleKpiListBuilder_ == null) { + ensurePolicyRuleKpiListIsMutable(); + policyRuleKpiList_.remove(index); + onChanged(); + } else { + policyRuleKpiListBuilder_.remove(index); + } + return this; + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public policy.Policy.PolicyRuleKpiId.Builder getPolicyRuleKpiListBuilder(int index) { + return getPolicyRuleKpiListFieldBuilder().getBuilder(index); + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public policy.Policy.PolicyRuleKpiIdOrBuilder getPolicyRuleKpiListOrBuilder(int index) { + if (policyRuleKpiListBuilder_ == null) { + return policyRuleKpiList_.get(index); + } else { + return policyRuleKpiListBuilder_.getMessageOrBuilder(index); + } + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public java.util.List getPolicyRuleKpiListOrBuilderList() { + if (policyRuleKpiListBuilder_ != null) { + return policyRuleKpiListBuilder_.getMessageOrBuilderList(); + } else { + return java.util.Collections.unmodifiableList(policyRuleKpiList_); + } + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public policy.Policy.PolicyRuleKpiId.Builder addPolicyRuleKpiListBuilder() { + return getPolicyRuleKpiListFieldBuilder().addBuilder(policy.Policy.PolicyRuleKpiId.getDefaultInstance()); + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public policy.Policy.PolicyRuleKpiId.Builder addPolicyRuleKpiListBuilder(int index) { + return getPolicyRuleKpiListFieldBuilder().addBuilder(index, policy.Policy.PolicyRuleKpiId.getDefaultInstance()); + } + + /** + *
+             * List of KPIs associated with this policy
+             * 
+ * + * repeated .policy.PolicyRuleKpiId policyRuleKpiList = 5; + */ + public java.util.List getPolicyRuleKpiListBuilderList() { + return getPolicyRuleKpiListFieldBuilder().getBuilderList(); + } + + private com.google.protobuf.RepeatedFieldBuilderV3 getPolicyRuleKpiListFieldBuilder() { + if (policyRuleKpiListBuilder_ == null) { + policyRuleKpiListBuilder_ = new com.google.protobuf.RepeatedFieldBuilderV3(policyRuleKpiList_, ((bitField0_ & 0x00000010) != 0), getParentForChildren(), isClean()); + policyRuleKpiList_ = null; + } + return policyRuleKpiListBuilder_; + } + @java.lang.Override public final Builder setUnknownFields(final com.google.protobuf.UnknownFieldSet unknownFields) { return super.setUnknownFields(unknownFields); @@ -8993,13 +10216,17 @@ public final class Policy { } } + private static final com.google.protobuf.Descriptors.Descriptor internal_static_policy_PolicyRuleState_descriptor; + + private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_policy_PolicyRuleState_fieldAccessorTable; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_policy_PolicyRuleId_descriptor; private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_policy_PolicyRuleId_fieldAccessorTable; - private static final com.google.protobuf.Descriptors.Descriptor internal_static_policy_PolicyRuleState_descriptor; + private static final com.google.protobuf.Descriptors.Descriptor internal_static_policy_PolicyRuleKpiId_descriptor; - private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_policy_PolicyRuleState_fieldAccessorTable; + private static final com.google.protobuf.GeneratedMessageV3.FieldAccessorTable internal_static_policy_PolicyRuleKpiId_fieldAccessorTable; private static final com.google.protobuf.Descriptors.Descriptor internal_static_policy_PolicyRuleBasic_descriptor; @@ -9040,27 +10267,29 @@ public final class Policy { private static com.google.protobuf.Descriptors.FileDescriptor descriptor; static { - java.lang.String[] descriptorData = { "\n\014policy.proto\022\006policy\032\rcontext.proto\032\023p" + "olicy_action.proto\"+\n\014PolicyRuleId\022\033\n\004uu" + "id\030\001 \001(\0132\r.context.Uuid\"g\n\017PolicyRuleSta" + "te\0224\n\017policyRuleState\030\001 \001(\0162\033.policy.Pol" + "icyRuleStateEnum\022\036\n\026policyRuleStateMessa" + "ge\030\002 \001(\t\"\271\001\n\017PolicyRuleBasic\022*\n\014policyRu" + "leId\030\001 \001(\0132\024.policy.PolicyRuleId\0220\n\017poli" + "cyRuleState\030\002 \001(\0132\027.policy.PolicyRuleSta" + "te\022\032\n\022policyRulePriority\030\003 \001(\r\022,\n\naction" + "List\030\004 \003(\0132\030.policy.PolicyRuleAction\"\223\001\n" + "\021PolicyRuleService\0220\n\017policyRuleBasic\030\001 " + "\001(\0132\027.policy.PolicyRuleBasic\022%\n\tserviceI" + "d\030\002 \001(\0132\022.context.ServiceId\022%\n\ndeviceLis" + "t\030\003 \003(\0132\021.context.DeviceId\"k\n\020PolicyRule" + "Device\0220\n\017policyRuleBasic\030\001 \001(\0132\027.policy" + ".PolicyRuleBasic\022%\n\ndeviceList\030\002 \003(\0132\021.c" + "ontext.DeviceId\"u\n\nPolicyRule\022,\n\007service" + "\030\001 \001(\0132\031.policy.PolicyRuleServiceH\000\022*\n\006d" + "evice\030\002 \001(\0132\030.policy.PolicyRuleDeviceH\000B" + "\r\n\013policy_rule\"B\n\020PolicyRuleIdList\022.\n\020po" + "licyRuleIdList\030\001 \003(\0132\024.policy.PolicyRule" + "Id\"Q\n\025PolicyRuleServiceList\0228\n\025policyRul" + "eServiceList\030\001 \003(\0132\031.policy.PolicyRuleSe" + "rvice\"N\n\024PolicyRuleDeviceList\0226\n\024policyR" + "uleDeviceList\030\001 \003(\0132\030.policy.PolicyRuleD" + "evice\"9\n\016PolicyRuleList\022\'\n\013policyRules\030\001" + " \003(\0132\022.policy.PolicyRule*\377\001\n\023PolicyRuleS" + "tateEnum\022\024\n\020POLICY_UNDEFINED\020\000\022\021\n\rPOLICY" + "_FAILED\020\001\022\023\n\017POLICY_INSERTED\020\002\022\024\n\020POLICY" + "_VALIDATED\020\003\022\026\n\022POLICY_PROVISIONED\020\004\022\021\n\r" + "POLICY_ACTIVE\020\005\022\023\n\017POLICY_ENFORCED\020\006\022\026\n\022" + "POLICY_INEFFECTIVE\020\007\022\024\n\020POLICY_EFFECTIVE" + "\020\010\022\022\n\016POLICY_UPDATED\020\t\022\022\n\016POLICY_REMOVED" + "\020\n2\323\004\n\rPolicyService\022H\n\020PolicyAddService" + "\022\031.policy.PolicyRuleService\032\027.policy.Pol" + "icyRuleState\"\000\022F\n\017PolicyAddDevice\022\030.poli" + "cy.PolicyRuleDevice\032\027.policy.PolicyRuleS" + "tate\"\000\022K\n\023PolicyUpdateService\022\031.policy.P" + "olicyRuleService\032\027.policy.PolicyRuleStat" + "e\"\000\022I\n\022PolicyUpdateDevice\022\030.policy.Polic" + "yRuleDevice\032\027.policy.PolicyRuleState\"\000\022?" + "\n\014PolicyDelete\022\024.policy.PolicyRuleId\032\027.p" + "olicy.PolicyRuleState\"\000\022E\n\020GetPolicyServ" + "ice\022\024.policy.PolicyRuleId\032\031.policy.Polic" + "yRuleService\"\000\022C\n\017GetPolicyDevice\022\024.poli" + "cy.PolicyRuleId\032\030.policy.PolicyRuleDevic" + "e\"\000\022K\n\024GetPolicyByServiceId\022\022.context.Se" + "rviceId\032\035.policy.PolicyRuleServiceList\"\000" + "b\006proto3" }; + java.lang.String[] descriptorData = { "\n\014policy.proto\022\006policy\032\rcontext.proto\032\023p" + "olicy_action.proto\"g\n\017PolicyRuleState\0224\n" + "\017policyRuleState\030\001 \001(\0162\033.policy.PolicyRu" + "leStateEnum\022\036\n\026policyRuleStateMessage\030\002 " + "\001(\t\"+\n\014PolicyRuleId\022\033\n\004uuid\030\001 \001(\0132\r.cont" + "ext.Uuid\";\n\017PolicyRuleKpiId\022(\n\021policyRul" + "eKpiUuid\030\001 \001(\0132\r.context.Uuid\"\355\001\n\017Policy" + "RuleBasic\022*\n\014policyRuleId\030\001 \001(\0132\024.policy" + ".PolicyRuleId\0220\n\017policyRuleState\030\002 \001(\0132\027" + ".policy.PolicyRuleState\022\032\n\022policyRulePri" + "ority\030\003 \001(\r\022,\n\nactionList\030\004 \003(\0132\030.policy" + ".PolicyRuleAction\0222\n\021policyRuleKpiList\030\005" + " \003(\0132\027.policy.PolicyRuleKpiId\"\223\001\n\021Policy" + "RuleService\0220\n\017policyRuleBasic\030\001 \001(\0132\027.p" + "olicy.PolicyRuleBasic\022%\n\tserviceId\030\002 \001(\013" + "2\022.context.ServiceId\022%\n\ndeviceList\030\003 \003(\013" + "2\021.context.DeviceId\"k\n\020PolicyRuleDevice\022" + "0\n\017policyRuleBasic\030\001 \001(\0132\027.policy.Policy" + "RuleBasic\022%\n\ndeviceList\030\002 \003(\0132\021.context." + "DeviceId\"u\n\nPolicyRule\022,\n\007service\030\001 \001(\0132" + "\031.policy.PolicyRuleServiceH\000\022*\n\006device\030\002" + " \001(\0132\030.policy.PolicyRuleDeviceH\000B\r\n\013poli" + "cy_rule\"B\n\020PolicyRuleIdList\022.\n\020policyRul" + "eIdList\030\001 \003(\0132\024.policy.PolicyRuleId\"Q\n\025P" + "olicyRuleServiceList\0228\n\025policyRuleServic" + "eList\030\001 \003(\0132\031.policy.PolicyRuleService\"N" + "\n\024PolicyRuleDeviceList\0226\n\024policyRuleDevi" + "ceList\030\001 \003(\0132\030.policy.PolicyRuleDevice\"9" + "\n\016PolicyRuleList\022\'\n\013policyRules\030\001 \003(\0132\022." + "policy.PolicyRule*\377\001\n\023PolicyRuleStateEnu" + "m\022\024\n\020POLICY_UNDEFINED\020\000\022\021\n\rPOLICY_FAILED" + "\020\001\022\023\n\017POLICY_INSERTED\020\002\022\024\n\020POLICY_VALIDA" + "TED\020\003\022\026\n\022POLICY_PROVISIONED\020\004\022\021\n\rPOLICY_" + "ACTIVE\020\005\022\023\n\017POLICY_ENFORCED\020\006\022\026\n\022POLICY_" + "INEFFECTIVE\020\007\022\024\n\020POLICY_EFFECTIVE\020\010\022\022\n\016P" + "OLICY_UPDATED\020\t\022\022\n\016POLICY_REMOVED\020\n2\323\004\n\r" + "PolicyService\022H\n\020PolicyAddService\022\031.poli" + "cy.PolicyRuleService\032\027.policy.PolicyRule" + "State\"\000\022F\n\017PolicyAddDevice\022\030.policy.Poli" + "cyRuleDevice\032\027.policy.PolicyRuleState\"\000\022" + "K\n\023PolicyUpdateService\022\031.policy.PolicyRu" + "leService\032\027.policy.PolicyRuleState\"\000\022I\n\022" + "PolicyUpdateDevice\022\030.policy.PolicyRuleDe" + "vice\032\027.policy.PolicyRuleState\"\000\022?\n\014Polic" + "yDelete\022\024.policy.PolicyRuleId\032\027.policy.P" + "olicyRuleState\"\000\022E\n\020GetPolicyService\022\024.p" + "olicy.PolicyRuleId\032\031.policy.PolicyRuleSe" + "rvice\"\000\022C\n\017GetPolicyDevice\022\024.policy.Poli" + "cyRuleId\032\030.policy.PolicyRuleDevice\"\000\022K\n\024" + "GetPolicyByServiceId\022\022.context.ServiceId" + "\032\035.policy.PolicyRuleServiceList\"\000b\006proto" + "3" }; descriptor = com.google.protobuf.Descriptors.FileDescriptor.internalBuildGeneratedFileFrom(descriptorData, new com.google.protobuf.Descriptors.FileDescriptor[] { context.ContextOuterClass.getDescriptor(), policy.PolicyAction.getDescriptor() }); - internal_static_policy_PolicyRuleId_descriptor = getDescriptor().getMessageTypes().get(0); - internal_static_policy_PolicyRuleId_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleId_descriptor, new java.lang.String[] { "Uuid" }); - internal_static_policy_PolicyRuleState_descriptor = getDescriptor().getMessageTypes().get(1); + internal_static_policy_PolicyRuleState_descriptor = getDescriptor().getMessageTypes().get(0); internal_static_policy_PolicyRuleState_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleState_descriptor, new java.lang.String[] { "PolicyRuleState", "PolicyRuleStateMessage" }); - internal_static_policy_PolicyRuleBasic_descriptor = getDescriptor().getMessageTypes().get(2); - internal_static_policy_PolicyRuleBasic_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleBasic_descriptor, new java.lang.String[] { "PolicyRuleId", "PolicyRuleState", "PolicyRulePriority", "ActionList" }); - internal_static_policy_PolicyRuleService_descriptor = getDescriptor().getMessageTypes().get(3); + internal_static_policy_PolicyRuleId_descriptor = getDescriptor().getMessageTypes().get(1); + internal_static_policy_PolicyRuleId_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleId_descriptor, new java.lang.String[] { "Uuid" }); + internal_static_policy_PolicyRuleKpiId_descriptor = getDescriptor().getMessageTypes().get(2); + internal_static_policy_PolicyRuleKpiId_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleKpiId_descriptor, new java.lang.String[] { "PolicyRuleKpiUuid" }); + internal_static_policy_PolicyRuleBasic_descriptor = getDescriptor().getMessageTypes().get(3); + internal_static_policy_PolicyRuleBasic_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleBasic_descriptor, new java.lang.String[] { "PolicyRuleId", "PolicyRuleState", "PolicyRulePriority", "ActionList", "PolicyRuleKpiList" }); + internal_static_policy_PolicyRuleService_descriptor = getDescriptor().getMessageTypes().get(4); internal_static_policy_PolicyRuleService_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleService_descriptor, new java.lang.String[] { "PolicyRuleBasic", "ServiceId", "DeviceList" }); - internal_static_policy_PolicyRuleDevice_descriptor = getDescriptor().getMessageTypes().get(4); + internal_static_policy_PolicyRuleDevice_descriptor = getDescriptor().getMessageTypes().get(5); internal_static_policy_PolicyRuleDevice_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleDevice_descriptor, new java.lang.String[] { "PolicyRuleBasic", "DeviceList" }); - internal_static_policy_PolicyRule_descriptor = getDescriptor().getMessageTypes().get(5); + internal_static_policy_PolicyRule_descriptor = getDescriptor().getMessageTypes().get(6); internal_static_policy_PolicyRule_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRule_descriptor, new java.lang.String[] { "Service", "Device", "PolicyRule" }); - internal_static_policy_PolicyRuleIdList_descriptor = getDescriptor().getMessageTypes().get(6); + internal_static_policy_PolicyRuleIdList_descriptor = getDescriptor().getMessageTypes().get(7); internal_static_policy_PolicyRuleIdList_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleIdList_descriptor, new java.lang.String[] { "PolicyRuleIdList" }); - internal_static_policy_PolicyRuleServiceList_descriptor = getDescriptor().getMessageTypes().get(7); + internal_static_policy_PolicyRuleServiceList_descriptor = getDescriptor().getMessageTypes().get(8); internal_static_policy_PolicyRuleServiceList_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleServiceList_descriptor, new java.lang.String[] { "PolicyRuleServiceList" }); - internal_static_policy_PolicyRuleDeviceList_descriptor = getDescriptor().getMessageTypes().get(8); + internal_static_policy_PolicyRuleDeviceList_descriptor = getDescriptor().getMessageTypes().get(9); internal_static_policy_PolicyRuleDeviceList_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleDeviceList_descriptor, new java.lang.String[] { "PolicyRuleDeviceList" }); - internal_static_policy_PolicyRuleList_descriptor = getDescriptor().getMessageTypes().get(9); + internal_static_policy_PolicyRuleList_descriptor = getDescriptor().getMessageTypes().get(10); internal_static_policy_PolicyRuleList_fieldAccessorTable = new com.google.protobuf.GeneratedMessageV3.FieldAccessorTable(internal_static_policy_PolicyRuleList_descriptor, new java.lang.String[] { "PolicyRules" }); context.ContextOuterClass.getDescriptor(); policy.PolicyAction.getDescriptor(); diff --git a/src/policy/target/kubernetes/kubernetes.yml b/src/policy/target/kubernetes/kubernetes.yml index d1adf72ae..cd578b34b 100644 --- a/src/policy/target/kubernetes/kubernetes.yml +++ b/src/policy/target/kubernetes/kubernetes.yml @@ -3,8 +3,8 @@ apiVersion: v1 kind: Service metadata: annotations: - app.quarkus.io/commit-id: 155740d65d2f670ef76fe6219bbd3ca6422db18a - app.quarkus.io/build-timestamp: 2026-02-18 - 13:48:37 +0000 + app.quarkus.io/commit-id: 9e3e0ebd57f108eb7c0e1946bfc122dfd1a3180e + app.quarkus.io/build-timestamp: 2026-02-21 - 15:35:10 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" @@ -17,14 +17,18 @@ metadata: name: policyservice spec: ports: - - name: http - port: 9192 + - name: grpc + port: 6060 protocol: TCP - targetPort: 8080 + targetPort: 6060 - name: https port: 443 protocol: TCP targetPort: 8443 + - name: http + port: 9192 + protocol: TCP + targetPort: 8080 selector: app.kubernetes.io/name: policyservice type: ClusterIP @@ -33,8 +37,8 @@ apiVersion: apps/v1 kind: Deployment metadata: annotations: - app.quarkus.io/commit-id: 155740d65d2f670ef76fe6219bbd3ca6422db18a - app.quarkus.io/build-timestamp: 2026-02-18 - 13:48:37 +0000 + app.quarkus.io/commit-id: 9e3e0ebd57f108eb7c0e1946bfc122dfd1a3180e + app.quarkus.io/build-timestamp: 2026-02-21 - 15:35:10 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" @@ -53,8 +57,8 @@ spec: template: metadata: annotations: - app.quarkus.io/commit-id: 155740d65d2f670ef76fe6219bbd3ca6422db18a - app.quarkus.io/build-timestamp: 2026-02-18 - 13:48:37 +0000 + app.quarkus.io/commit-id: 9e3e0ebd57f108eb7c0e1946bfc122dfd1a3180e + app.quarkus.io/build-timestamp: 2026-02-21 - 15:35:10 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" @@ -71,14 +75,14 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace + - name: KAFKA_BROKER_HOST + value: kafka-service.kafka.svc.cluster.local - name: CONTEXT_SERVICE_HOST value: contextservice - - name: SERVICE_SERVICE_HOST - value: serviceservice - name: MONITORING_SERVICE_HOST value: monitoringservice - - name: KAFKA_BROKER_HOST - value: kafka-service.kafka.svc.cluster.local + - name: SERVICE_SERVICE_HOST + value: serviceservice image: labs.etsi.org:5050/tfs/controller/policy:0.1.0 imagePullPolicy: Always livenessProbe: @@ -93,12 +97,15 @@ spec: timeoutSeconds: 10 name: policyservice ports: - - containerPort: 8080 - name: http + - containerPort: 6060 + name: grpc protocol: TCP - containerPort: 8443 name: https protocol: TCP + - containerPort: 8080 + name: http + protocol: TCP readinessProbe: failureThreshold: 3 httpGet: diff --git a/src/ztp/target/kubernetes/kubernetes.yml b/src/ztp/target/kubernetes/kubernetes.yml index 727c6c5e3..9d2196ea6 100644 --- a/src/ztp/target/kubernetes/kubernetes.yml +++ b/src/ztp/target/kubernetes/kubernetes.yml @@ -3,70 +3,69 @@ apiVersion: v1 kind: Service metadata: annotations: - app.quarkus.io/commit-id: eb5af5697ca52e97a05476854dd7effb3bfa2d6b - app.quarkus.io/build-timestamp: 2026-02-18 - 12:47:01 +0000 + app.quarkus.io/commit-id: 9e3e0ebd57f108eb7c0e1946bfc122dfd1a3180e + app.quarkus.io/build-timestamp: 2026-02-24 - 06:37:09 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" prometheus.io/scheme: http labels: - app.kubernetes.io/name: ztpservice + app.kubernetes.io/name: ztp app.kubernetes.io/version: 0.2.0 - app: ztpservice app.kubernetes.io/managed-by: quarkus - name: ztpservice + name: ztp spec: ports: - - name: grpc - port: 5050 - protocol: TCP - targetPort: 5050 - name: https port: 443 protocol: TCP targetPort: 8443 - name: http - port: 9192 + port: 80 protocol: TCP targetPort: 8080 + - name: grpc + port: 9000 + protocol: TCP + targetPort: 9000 selector: - app.kubernetes.io/name: ztpservice + app.kubernetes.io/name: ztp + app.kubernetes.io/version: 0.2.0 type: ClusterIP --- apiVersion: apps/v1 kind: Deployment metadata: annotations: - app.quarkus.io/commit-id: eb5af5697ca52e97a05476854dd7effb3bfa2d6b - app.quarkus.io/build-timestamp: 2026-02-18 - 12:47:01 +0000 + app.quarkus.io/commit-id: 9e3e0ebd57f108eb7c0e1946bfc122dfd1a3180e + app.quarkus.io/build-timestamp: 2026-02-24 - 06:37:09 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" prometheus.io/scheme: http labels: - app: ztpservice app.kubernetes.io/managed-by: quarkus - app.kubernetes.io/name: ztpservice + app.kubernetes.io/name: ztp app.kubernetes.io/version: 0.2.0 - name: ztpservice + name: ztp spec: replicas: 1 selector: matchLabels: - app.kubernetes.io/name: ztpservice + app.kubernetes.io/name: ztp + app.kubernetes.io/version: 0.2.0 template: metadata: annotations: - app.quarkus.io/commit-id: eb5af5697ca52e97a05476854dd7effb3bfa2d6b - app.quarkus.io/build-timestamp: 2026-02-18 - 12:47:01 +0000 + app.quarkus.io/commit-id: 9e3e0ebd57f108eb7c0e1946bfc122dfd1a3180e + app.quarkus.io/build-timestamp: 2026-02-24 - 06:37:09 +0000 prometheus.io/scrape: "true" prometheus.io/path: /q/metrics prometheus.io/port: "8080" prometheus.io/scheme: http labels: - app: ztpservice app.kubernetes.io/managed-by: quarkus - app.kubernetes.io/name: ztpservice + app.kubernetes.io/name: ztp app.kubernetes.io/version: 0.2.0 spec: containers: @@ -75,11 +74,7 @@ spec: valueFrom: fieldRef: fieldPath: metadata.namespace - - name: CONTEXT_SERVICE_HOST - value: contextservice - - name: DEVICE_SERVICE_HOST - value: deviceservice - image: labs.etsi.org:5050/tfs/controller/ztp:0.2.0 + image: ubuntu/ztp:0.2.0 imagePullPolicy: Always livenessProbe: failureThreshold: 3 @@ -87,38 +82,31 @@ spec: path: /q/health/live port: 8080 scheme: HTTP - initialDelaySeconds: 2 + initialDelaySeconds: 5 periodSeconds: 10 successThreshold: 1 timeoutSeconds: 10 - name: ztpservice + name: ztp ports: - - containerPort: 5050 - name: grpc - protocol: TCP - containerPort: 8443 name: https protocol: TCP - containerPort: 8080 name: http protocol: TCP + - containerPort: 9000 + name: grpc + protocol: TCP readinessProbe: failureThreshold: 3 httpGet: path: /q/health/ready port: 8080 scheme: HTTP - initialDelaySeconds: 2 + initialDelaySeconds: 5 periodSeconds: 10 successThreshold: 1 timeoutSeconds: 10 - resources: - limits: - cpu: 500m - memory: 2048Mi - requests: - cpu: 50m - memory: 512Mi startupProbe: failureThreshold: 3 httpGet: -- GitLab From 6e1d0a0be834a64645b6c0f04c76e61234f523a4 Mon Sep 17 00:00:00 2001 From: "Georgios P. Katsikas" Date: Tue, 24 Feb 2026 09:38:57 +0000 Subject: [PATCH 4/4] fix: policy test --- .../java/org/etsi/tfs/policy/policy/PolicyServiceImpl.java | 5 +++-- .../java/org/etsi/tfs/policy/policy/model/PolicyRule.java | 3 +-- .../org/etsi/tfs/policy/policy/model/PolicyRuleBasic.java | 3 ++- .../org/etsi/tfs/policy/policy/model/PolicyRuleService.java | 2 -- .../policy/policy/service/PolicyRuleConditionValidator.java | 2 -- 5 files changed, 6 insertions(+), 9 deletions(-) diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/PolicyServiceImpl.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/PolicyServiceImpl.java index 37d26a2a0..f2c48df72 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/PolicyServiceImpl.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/PolicyServiceImpl.java @@ -239,7 +239,7 @@ public class PolicyServiceImpl implements PolicyService { @Override public Uni deletePolicy(String policyRuleId) { - LOGGER.infof("Received %s", policyRuleId); + LOGGER.infof("Received policy %s for deletion", policyRuleId); final var retrievedPolicyRule = contextService.getPolicyRule(policyRuleId); @@ -250,6 +250,7 @@ public class PolicyServiceImpl implements PolicyService { private PolicyRuleState removePolicyFromContext(PolicyRule policyRule) { if (policyRule == null) { + LOGGER.error("Retrieved NULL policy rule from Context"); return new PolicyRuleState(PolicyRuleStateEnum.POLICY_FAILED, String.format(INVALID_MESSAGE)); } @@ -287,6 +288,6 @@ public class PolicyServiceImpl implements PolicyService { contextService.removePolicyRule(policyRuleId).subscribe().with(x -> {}); return new PolicyRuleState( - PolicyRuleStateEnum.POLICY_FAILED, policyRuleBasic.getExceptionMessage()); + PolicyRuleStateEnum.POLICY_REMOVED, REMOVED_POLICYRULE_STATE.getPolicyRuleStateMessage()); } } diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRule.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRule.java index 6a36250ff..47ade44dd 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRule.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRule.java @@ -30,7 +30,6 @@ public class PolicyRule { @Override public String toString() { - return String.format( - "%s:{configActionEnum:\"%s\", %s}", getClass().getSimpleName(), policyRuleType); + return String.format("%s:{configActionEnum: %s}", getClass().getSimpleName(), policyRuleType); } } diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleBasic.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleBasic.java index 4b6b0f500..66c3ee78a 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleBasic.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleBasic.java @@ -51,6 +51,7 @@ public class PolicyRuleBasic { checkNotNull(policyRuleKPIs, "Policy rule KPIs cannot be NULL."); checkArgument(!policyRuleKPIs.isEmpty(), "Policy rule KPIs cannot be empty."); this.policyRuleKPIs = policyRuleKPIs; + this.exceptionMessage = ""; this.isValid = true; } @@ -97,7 +98,7 @@ public class PolicyRuleBasic { @Override public String toString() { return String.format( - "%s:{policyRuleId:\"%s\", %s, policyRulePriority:%d, [%s]}", + "%s:{policyRuleId:\"%s\", %s, policyRulePriority:%d, [%s] [%s]}", getClass().getSimpleName(), policyRuleId, policyRuleState, diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleService.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleService.java index 607ea65e2..45d378c37 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleService.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/model/PolicyRuleService.java @@ -38,8 +38,6 @@ public class PolicyRuleService extends PolicyRuleBase { !serviceId.getContextId().isBlank(), "Context ID of Service ID must not be empty."); checkArgument(!serviceId.getId().isBlank(), "Service ID must not be empty."); this.serviceId = serviceId; - // TODO If device list not empty - // checkArgument(!deviceIds.isEmpty(), "Device IDs must not be empty."); this.deviceIds = deviceIds; this.isValid = true; this.exceptionMessage = ""; diff --git a/src/policy/src/main/java/org/etsi/tfs/policy/policy/service/PolicyRuleConditionValidator.java b/src/policy/src/main/java/org/etsi/tfs/policy/policy/service/PolicyRuleConditionValidator.java index dd7fdd920..a603e7854 100644 --- a/src/policy/src/main/java/org/etsi/tfs/policy/policy/service/PolicyRuleConditionValidator.java +++ b/src/policy/src/main/java/org/etsi/tfs/policy/policy/service/PolicyRuleConditionValidator.java @@ -33,8 +33,6 @@ import org.jboss.logging.Logger; public class PolicyRuleConditionValidator { private static final Logger LOGGER = Logger.getLogger(PolicyRuleConditionValidator.class); - private static final String INVALID_MESSAGE = "%s is invalid."; - private static final String VALID_MESSAGE = "%s is valid."; private final ContextService contextService; -- GitLab