diff --git a/Common/src/ArmoniK.Core.Common.csproj b/Common/src/ArmoniK.Core.Common.csproj index b066b5d62..04617df18 100644 --- a/Common/src/ArmoniK.Core.Common.csproj +++ b/Common/src/ArmoniK.Core.Common.csproj @@ -26,7 +26,7 @@ - + diff --git a/Common/src/gRPC/FilterRangeExt.cs b/Common/src/gRPC/FilterRangeExt.cs index 80654ba08..1f7619251 100644 --- a/Common/src/gRPC/FilterRangeExt.cs +++ b/Common/src/gRPC/FilterRangeExt.cs @@ -30,62 +30,107 @@ namespace ArmoniK.Core.Common.gRPC; public static class FilterRangeExt { /// - /// Convert gRPC field to that represent which operation has to be performed + /// Generate a filter for operations on strings /// - /// The gRPC Enum + /// Type of the value and field on which the operation is applied + /// Status enum type used for the comparison + /// The gRPC enum that selects the operation + /// The to select the field on which to apply the operation + /// Value for the operation /// - /// The that represent the operation + /// The that represents the operation on the field with the given value /// - public static ExpressionType ToExpressionType(this FilterStatusOperator filterOperator) + public static Expression> ToFilter(this FilterStatusOperator filterOperator, + Expression> field, + TStatus value) => filterOperator switch { FilterStatusOperator.Unspecified => throw new ArgumentOutOfRangeException(), - FilterStatusOperator.Equal => ExpressionType.Equal, - FilterStatusOperator.NotEqual => ExpressionType.NotEqual, - _ => throw new ArgumentOutOfRangeException(), + FilterStatusOperator.Equal => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.Equal), + FilterStatusOperator.NotEqual => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.NotEqual), + _ => throw new ArgumentOutOfRangeException(), }; - /// - /// Convert gRPC field to that represent which operation has to be performed + /// Generate a filter for operations on strings /// - /// The gRPC Enum + /// Type of the value and field on which the operation is applied + /// The gRPC enum that selects the operation + /// The to select the field on which to apply the operation + /// Value for the operation /// - /// The that represent the operation + /// The that represents the operation on the field with the given value /// - public static ExpressionType ToExpressionType(this FilterDateOperator filterOperator) + public static Expression> ToFilter(this FilterDateOperator filterOperator, + Expression> field, + DateTime? value) => filterOperator switch { - FilterDateOperator.Before => ExpressionType.LessThan, - FilterDateOperator.BeforeOrEqual => ExpressionType.LessThanOrEqual, - FilterDateOperator.Equal => ExpressionType.Equal, - FilterDateOperator.NotEqual => ExpressionType.NotEqual, - FilterDateOperator.AfterOrEqual => ExpressionType.GreaterThanOrEqual, - FilterDateOperator.After => ExpressionType.GreaterThan, - FilterDateOperator.Unspecified => throw new ArgumentOutOfRangeException(), - _ => throw new ArgumentOutOfRangeException(), + FilterDateOperator.Unspecified => throw new ArgumentOutOfRangeException(), + FilterDateOperator.Before => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.LessThan), + FilterDateOperator.BeforeOrEqual => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.LessThanOrEqual), + FilterDateOperator.Equal => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.Equal), + FilterDateOperator.AfterOrEqual => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.GreaterThanOrEqual), + FilterDateOperator.After => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.GreaterThan), + FilterDateOperator.NotEqual => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.NotEqual), + _ => throw new ArgumentOutOfRangeException(), }; + /// - /// Convert gRPC field to that represent which operation has to be performed + /// Generate a filter for operations on strings /// - /// The gRPC Enum + /// Type of the value and field on which the operation is applied + /// The gRPC enum that selects the operation + /// The to select the field on which to apply the operation + /// Value for the operation /// - /// The that represent the operation + /// The that represents the operation on the field with the given value /// - public static ExpressionType ToExpressionType(this FilterNumberOperator filterOperator) + public static Expression> ToFilter(this FilterNumberOperator filterOperator, + Expression> field, + long value) => filterOperator switch { - FilterNumberOperator.LessThan => ExpressionType.LessThan, - FilterNumberOperator.LessThanOrEqual => ExpressionType.LessThanOrEqual, - FilterNumberOperator.Equal => ExpressionType.Equal, - FilterNumberOperator.NotEqual => ExpressionType.NotEqual, - FilterNumberOperator.GreaterThanOrEqual => ExpressionType.GreaterThanOrEqual, - FilterNumberOperator.GreaterThan => ExpressionType.GreaterThan, - FilterNumberOperator.Unspecified => throw new ArgumentOutOfRangeException(), - _ => throw new ArgumentOutOfRangeException(), + FilterNumberOperator.Unspecified => throw new ArgumentOutOfRangeException(), + FilterNumberOperator.LessThan => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.LessThan), + FilterNumberOperator.LessThanOrEqual => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.LessThanOrEqual), + FilterNumberOperator.Equal => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.Equal), + FilterNumberOperator.NotEqual => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.NotEqual), + FilterNumberOperator.GreaterThanOrEqual => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.GreaterThanOrEqual), + FilterNumberOperator.GreaterThan => ExpressionBuilders.MakeBinary(field, + value, + ExpressionType.GreaterThan), + _ => throw new ArgumentOutOfRangeException(), }; + /// /// Generate a filter for operations on strings /// diff --git a/Common/src/gRPC/ListApplicationsRequestExt.cs b/Common/src/gRPC/ListApplicationsRequestExt.cs index 1feed091f..5eff3fda9 100644 --- a/Common/src/gRPC/ListApplicationsRequestExt.cs +++ b/Common/src/gRPC/ListApplicationsRequestExt.cs @@ -57,95 +57,6 @@ public static class ListApplicationsRequestExt } } - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterString filter) - => filter.Field.FieldCase switch - { - ApplicationField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - ApplicationField.FieldOneofCase.ApplicationField_ => filter.Operator.ToFilter(filter.Field.ApplicationField_.Field.ToField(), - filter.Value), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterNumber filter) - => filter.Field.FieldCase switch - { - ApplicationField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - ApplicationField.FieldOneofCase.ApplicationField_ => ExpressionBuilders.MakeBinary(filter.Field.ApplicationField_.Field.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterDate filter) - => filter.Field.FieldCase switch - { - ApplicationField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - ApplicationField.FieldOneofCase.ApplicationField_ => ExpressionBuilders.MakeBinary(filter.Field.ApplicationField_.Field.ToField(), - filter.Value.ToDateTime(), - filter.Operator.ToExpressionType()), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterBoolean filter) - => filter.Field.FieldCase switch - { - ApplicationField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - ApplicationField.FieldOneofCase.ApplicationField_ => ExpressionBuilders.MakeBinary(filter.Field.ApplicationField_.Field.ToField(), - filter.Value, - ExpressionType.Equal), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterArray filter) - => filter.Field.FieldCase switch - { - ApplicationField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - ApplicationField.FieldOneofCase.ApplicationField_ => filter.Operator.ToFilter(filter.Field.ApplicationField_.Field.ToField(), - filter.Value), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// /// Converts gRPC message filters into an that represents the filter conditions /// @@ -168,24 +79,13 @@ public static Expression> ToApplicationFilter(this Filters var predicateAnd = PredicateBuilder.New(data => true); foreach (var filterField in filtersAnd.And) { - switch (filterField.FilterCase) + switch (filterField.ValueConditionCase) { - case FilterField.FilterOneofCase.String: - predicateAnd = predicateAnd.And(filterField.String.ToExpression()); - break; - case FilterField.FilterOneofCase.Number: - predicateAnd = predicateAnd.And(filterField.Number.ToExpression()); - break; - case FilterField.FilterOneofCase.Date: - predicateAnd = predicateAnd.And(filterField.Date.ToExpression()); - break; - case FilterField.FilterOneofCase.Boolean: - predicateAnd = predicateAnd.And(filterField.Boolean.ToExpression()); - break; - case FilterField.FilterOneofCase.Array: - predicateAnd = predicateAnd.And(filterField.Array.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterString: + predicateAnd = predicateAnd.And(filterField.FilterString.Operator.ToFilter(filterField.Field.ApplicationField_.Field.ToField(), + filterField.FilterString.Value)); break; - case FilterField.FilterOneofCase.None: + case FilterField.ValueConditionOneofCase.None: default: throw new ArgumentOutOfRangeException(); } diff --git a/Common/src/gRPC/ListPartitionsRequestExt.cs b/Common/src/gRPC/ListPartitionsRequestExt.cs index de00e439b..0ac6e6631 100644 --- a/Common/src/gRPC/ListPartitionsRequestExt.cs +++ b/Common/src/gRPC/ListPartitionsRequestExt.cs @@ -50,92 +50,12 @@ public static class ListPartitionsRequestExt } } - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterString filter) - => filter.Field.FieldCase switch - { - PartitionField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - PartitionField.FieldOneofCase.PartitionRawField => filter.Operator.ToFilter(filter.Field.PartitionRawField.Field.ToField(), - filter.Value), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterNumber filter) - => filter.Field.FieldCase switch - { - PartitionField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - PartitionField.FieldOneofCase.PartitionRawField => ExpressionBuilders.MakeBinary(filter.Field.PartitionRawField.Field.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterDate filter) - => filter.Field.FieldCase switch - { - PartitionField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - PartitionField.FieldOneofCase.PartitionRawField => ExpressionBuilders.MakeBinary(filter.Field.PartitionRawField.Field.ToField(), - filter.Value.ToDateTime(), - filter.Operator.ToExpressionType()), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterBoolean filter) - => filter.Field.FieldCase switch + public static Expression> ToField(this PartitionField taskField) + => taskField.FieldCase switch { - PartitionField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - PartitionField.FieldOneofCase.PartitionRawField => ExpressionBuilders.MakeBinary(filter.Field.PartitionRawField.Field.ToField(), - filter.Value, - ExpressionType.Equal), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterArray filter) - => filter.Field.FieldCase switch - { - PartitionField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - PartitionField.FieldOneofCase.PartitionRawField => filter.Operator.ToFilter(filter.Field.PartitionRawField.Field.ToField(), - filter.Value), - _ => throw new ArgumentOutOfRangeException(), + PartitionField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), + PartitionField.FieldOneofCase.PartitionRawField => taskField.PartitionRawField.Field.ToField(), + _ => throw new ArgumentOutOfRangeException(), }; /// @@ -160,24 +80,26 @@ public static Expression> ToPartitionFilter(this Filte var predicateAnd = PredicateBuilder.New(data => true); foreach (var filterField in filtersAnd.And) { - switch (filterField.FilterCase) + switch (filterField.ValueConditionCase) { - case FilterField.FilterOneofCase.String: - predicateAnd = predicateAnd.And(filterField.String.ToExpression()); - break; - case FilterField.FilterOneofCase.Number: - predicateAnd = predicateAnd.And(filterField.Number.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterString: + predicateAnd = predicateAnd.And(filterField.FilterString.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterString.Value)); break; - case FilterField.FilterOneofCase.Date: - predicateAnd = predicateAnd.And(filterField.Date.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterNumber: + predicateAnd = predicateAnd.And(filterField.FilterNumber.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterNumber.Value)); break; - case FilterField.FilterOneofCase.Boolean: - predicateAnd = predicateAnd.And(filterField.Boolean.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterBoolean: + predicateAnd = predicateAnd.And(ExpressionBuilders.MakeBinary(filterField.Field.ToField(), + filterField.FilterBoolean.Value, + ExpressionType.Equal)); break; - case FilterField.FilterOneofCase.Array: - predicateAnd = predicateAnd.And(filterField.Array.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterArray: + predicateAnd = predicateAnd.And(filterField.FilterArray.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterArray.Value)); break; - case FilterField.FilterOneofCase.None: + case FilterField.ValueConditionOneofCase.None: default: throw new ArgumentOutOfRangeException(); } diff --git a/Common/src/gRPC/ListResultsRequestExt.cs b/Common/src/gRPC/ListResultsRequestExt.cs index d47efe2ff..2c88b0979 100644 --- a/Common/src/gRPC/ListResultsRequestExt.cs +++ b/Common/src/gRPC/ListResultsRequestExt.cs @@ -48,112 +48,12 @@ public static class ListResultsRequestExt } } - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterString filter) - => filter.Field.FieldCase switch + public static Expression> ToField(this ResultField taskField) + => taskField.FieldCase switch { - ResultField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - ResultField.FieldOneofCase.ResultRawField => filter.Operator.ToFilter(filter.Field.ResultRawField.Field.ToField(), - filter.Value), - _ => throw new ArgumentOutOfRangeException(), - }; - - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterNumber filter) - => filter.Field.FieldCase switch - { - ResultField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - ResultField.FieldOneofCase.ResultRawField => ExpressionBuilders.MakeBinary(filter.Field.ResultRawField.Field.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - _ => throw new ArgumentOutOfRangeException(), - }; - - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterDate filter) - => filter.Field.FieldCase switch - { - ResultField.FieldOneofCase.ResultRawField => ExpressionBuilders.MakeBinary(filter.Field.ResultRawField.Field.ToField(), - filter.Value.ToDateTime(), - filter.Operator.ToExpressionType()), - ResultField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterBoolean filter) - => filter.Field.FieldCase switch - { - ResultField.FieldOneofCase.ResultRawField => ExpressionBuilders.MakeBinary(filter.Field.ResultRawField.Field.ToField(), - filter.Value, - ExpressionType.Equal), - ResultField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterArray filter) - => filter.Field.FieldCase switch - { - ResultField.FieldOneofCase.ResultRawField => filter.Operator.ToFilter(filter.Field.ResultRawField.Field.ToField(), - filter.Value), - ResultField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterStatus filter) - => filter.Field.FieldCase switch - { - ResultField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - ResultField.FieldOneofCase.ResultRawField => ExpressionBuilders.MakeBinary(filter.Field.ResultRawField.Field.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - _ => throw new ArgumentOutOfRangeException(), + ResultField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), + ResultField.FieldOneofCase.ResultRawField => taskField.ResultRawField.Field.ToField(), + _ => throw new ArgumentOutOfRangeException(), }; /// @@ -178,27 +78,25 @@ public static Expression> ToResultFilter(this Filters filters var predicateAnd = PredicateBuilder.New(data => true); foreach (var filterField in filtersAnd.And) { - switch (filterField.FilterCase) + switch (filterField.ValueConditionCase) { - case FilterField.FilterOneofCase.String: - predicateAnd = predicateAnd.And(filterField.String.ToExpression()); - break; - case FilterField.FilterOneofCase.Number: - predicateAnd = predicateAnd.And(filterField.Number.ToExpression()); - break; - case FilterField.FilterOneofCase.Date: - predicateAnd = predicateAnd.And(filterField.Date.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterString: + predicateAnd = predicateAnd.And(filterField.FilterString.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterString.Value)); break; - case FilterField.FilterOneofCase.Boolean: - predicateAnd = predicateAnd.And(filterField.Boolean.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterStatus: + predicateAnd = predicateAnd.And(filterField.FilterStatus.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterStatus.Value)); break; - case FilterField.FilterOneofCase.Array: - predicateAnd = predicateAnd.And(filterField.Array.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterDate: + predicateAnd = predicateAnd.And(filterField.FilterDate.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterDate.Value.ToDateTime())); break; - case FilterField.FilterOneofCase.Status: - predicateAnd = predicateAnd.And(filterField.Status.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterArray: + predicateAnd = predicateAnd.And(filterField.FilterArray.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterArray.Value)); break; - case FilterField.FilterOneofCase.None: + case FilterField.ValueConditionOneofCase.None: default: throw new ArgumentOutOfRangeException(); } diff --git a/Common/src/gRPC/ListSessionsRequestExt.cs b/Common/src/gRPC/ListSessionsRequestExt.cs index a573d18a5..109a17a1e 100644 --- a/Common/src/gRPC/ListSessionsRequestExt.cs +++ b/Common/src/gRPC/ListSessionsRequestExt.cs @@ -52,142 +52,14 @@ public static class ListSessionsRequestExt } } - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterString filter) - => filter.Field.FieldCase switch - { - SessionField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - SessionField.FieldOneofCase.SessionRawField => filter.Operator.ToFilter(filter.Field.SessionRawField.Field.ToField(), - filter.Value), - SessionField.FieldOneofCase.TaskOptionField => filter.Operator.ToFilter(filter.Field.TaskOptionField.Field.ToField(), - filter.Value), - SessionField.FieldOneofCase.TaskOptionGenericField => filter.Operator.ToFilter(filter.Field.TaskOptionGenericField.ToField(), - filter.Value), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterNumber filter) - => filter.Field.FieldCase switch - { - SessionField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - SessionField.FieldOneofCase.SessionRawField => ExpressionBuilders.MakeBinary(filter.Field.SessionRawField.Field.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - SessionField.FieldOneofCase.TaskOptionField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionField.Field.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - SessionField.FieldOneofCase.TaskOptionGenericField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionGenericField.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterDate filter) - => filter.Field.FieldCase switch - { - SessionField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - SessionField.FieldOneofCase.SessionRawField => ExpressionBuilders.MakeBinary(filter.Field.SessionRawField.Field.ToField(), - filter.Value.ToDateTime(), - filter.Operator.ToExpressionType()), - SessionField.FieldOneofCase.TaskOptionField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionField.Field.ToField(), - filter.Value.ToDateTime(), - filter.Operator.ToExpressionType()), - SessionField.FieldOneofCase.TaskOptionGenericField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionGenericField.ToField(), - filter.Value.ToDateTime(), - filter.Operator.ToExpressionType()), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterBoolean filter) - => filter.Field.FieldCase switch - { - SessionField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - SessionField.FieldOneofCase.SessionRawField => ExpressionBuilders.MakeBinary(filter.Field.SessionRawField.Field.ToField(), - filter.Value, - ExpressionType.Equal), - SessionField.FieldOneofCase.TaskOptionField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionField.Field.ToField(), - filter.Value, - ExpressionType.Equal), - SessionField.FieldOneofCase.TaskOptionGenericField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionGenericField.ToField(), - filter.Value, - ExpressionType.Equal), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterArray filter) - => filter.Field.FieldCase switch - { - SessionField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - SessionField.FieldOneofCase.SessionRawField => filter.Operator.ToFilter(filter.Field.SessionRawField.Field.ToField(), - filter.Value), - SessionField.FieldOneofCase.TaskOptionField => filter.Operator.ToFilter(filter.Field.TaskOptionField.Field.ToField(), - filter.Value), - SessionField.FieldOneofCase.TaskOptionGenericField => filter.Operator.ToFilter(filter.Field.TaskOptionGenericField.ToField(), - filter.Value), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterStatus filter) - => filter.Field.FieldCase switch + public static Expression> ToField(this SessionField taskField) + => taskField.FieldCase switch { - SessionField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - SessionField.FieldOneofCase.SessionRawField => ExpressionBuilders.MakeBinary(filter.Field.SessionRawField.Field.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - SessionField.FieldOneofCase.TaskOptionField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionField.Field.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - SessionField.FieldOneofCase.TaskOptionGenericField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionGenericField.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - _ => throw new ArgumentOutOfRangeException(), + SessionField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), + SessionField.FieldOneofCase.SessionRawField => taskField.SessionRawField.Field.ToField(), + SessionField.FieldOneofCase.TaskOptionField => taskField.TaskOptionField.Field.ToField(), + SessionField.FieldOneofCase.TaskOptionGenericField => taskField.TaskOptionGenericField.ToField(), + _ => throw new ArgumentOutOfRangeException(), }; /// @@ -212,27 +84,34 @@ public static Expression> ToSessionDataFilter(this Filte var predicateAnd = PredicateBuilder.New(data => true); foreach (var filterField in filtersAnd.And) { - switch (filterField.FilterCase) + switch (filterField.ValueConditionCase) { - case FilterField.FilterOneofCase.String: - predicateAnd = predicateAnd.And(filterField.String.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterString: + predicateAnd = predicateAnd.And(filterField.FilterString.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterString.Value)); break; - case FilterField.FilterOneofCase.Number: - predicateAnd = predicateAnd.And(filterField.Number.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterNumber: + predicateAnd = predicateAnd.And(filterField.FilterNumber.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterNumber.Value)); break; - case FilterField.FilterOneofCase.Date: - predicateAnd = predicateAnd.And(filterField.Date.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterBoolean: + predicateAnd = predicateAnd.And(ExpressionBuilders.MakeBinary(filterField.Field.ToField(), + filterField.FilterBoolean.Value, + ExpressionType.Equal)); break; - case FilterField.FilterOneofCase.Boolean: - predicateAnd = predicateAnd.And(filterField.Boolean.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterStatus: + predicateAnd = predicateAnd.And(filterField.FilterStatus.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterStatus.Value)); break; - case FilterField.FilterOneofCase.Array: - predicateAnd = predicateAnd.And(filterField.Array.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterDate: + predicateAnd = predicateAnd.And(filterField.FilterDate.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterDate.Value.ToDateTime())); break; - case FilterField.FilterOneofCase.Status: - predicateAnd = predicateAnd.And(filterField.Status.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterArray: + predicateAnd = predicateAnd.And(filterField.FilterArray.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterArray.Value)); break; - case FilterField.FilterOneofCase.None: + case FilterField.ValueConditionOneofCase.None: default: throw new ArgumentOutOfRangeException(); } diff --git a/Common/src/gRPC/ListTasksRequestExt.cs b/Common/src/gRPC/ListTasksRequestExt.cs index 3109e6398..10da8705b 100644 --- a/Common/src/gRPC/ListTasksRequestExt.cs +++ b/Common/src/gRPC/ListTasksRequestExt.cs @@ -26,6 +26,7 @@ using LinqKit; + namespace ArmoniK.Core.Common.gRPC; public static class ListTasksRequestExt @@ -54,142 +55,14 @@ public static class ListTasksRequestExt } } - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterString filter) - => filter.Field.FieldCase switch - { - TaskField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - TaskField.FieldOneofCase.TaskSummaryField => filter.Operator.ToFilter(filter.Field.TaskSummaryField.Field.ToField(), - filter.Value), - TaskField.FieldOneofCase.TaskOptionField => filter.Operator.ToFilter(filter.Field.TaskOptionField.Field.ToField(), - filter.Value), - TaskField.FieldOneofCase.TaskOptionGenericField => filter.Operator.ToFilter(filter.Field.TaskOptionGenericField.ToField(), - filter.Value), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterNumber filter) - => filter.Field.FieldCase switch - { - TaskField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - TaskField.FieldOneofCase.TaskSummaryField => ExpressionBuilders.MakeBinary(filter.Field.TaskSummaryField.Field.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - TaskField.FieldOneofCase.TaskOptionField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionField.Field.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - TaskField.FieldOneofCase.TaskOptionGenericField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionGenericField.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterDate filter) - => filter.Field.FieldCase switch - { - TaskField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - TaskField.FieldOneofCase.TaskSummaryField => ExpressionBuilders.MakeBinary(filter.Field.TaskSummaryField.Field.ToField(), - filter.Value?.ToDateTime(), - filter.Operator.ToExpressionType()), - TaskField.FieldOneofCase.TaskOptionField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionField.Field.ToField(), - filter.Value?.ToDateTime(), - filter.Operator.ToExpressionType()), - TaskField.FieldOneofCase.TaskOptionGenericField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionGenericField.ToField(), - filter.Value?.ToDateTime(), - filter.Operator.ToExpressionType()), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterBoolean filter) - => filter.Field.FieldCase switch - { - TaskField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - TaskField.FieldOneofCase.TaskSummaryField => ExpressionBuilders.MakeBinary(filter.Field.TaskSummaryField.Field.ToField(), - filter.Value, - ExpressionType.Equal), - TaskField.FieldOneofCase.TaskOptionField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionField.Field.ToField(), - filter.Value, - ExpressionType.Equal), - TaskField.FieldOneofCase.TaskOptionGenericField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionGenericField.ToField(), - filter.Value, - ExpressionType.Equal), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterArray filter) - => filter.Field.FieldCase switch - { - TaskField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - TaskField.FieldOneofCase.TaskSummaryField => filter.Operator.ToFilter(filter.Field.TaskSummaryField.Field.ToField(), - filter.Value), - TaskField.FieldOneofCase.TaskOptionField => filter.Operator.ToFilter(filter.Field.TaskOptionField.Field.ToField(), - filter.Value), - TaskField.FieldOneofCase.TaskOptionGenericField => filter.Operator.ToFilter(filter.Field.TaskOptionGenericField.ToField(), - filter.Value), - _ => throw new ArgumentOutOfRangeException(), - }; - - /// - /// Converts gRPC message filter into an that represents the filter condition - /// - /// The gPRC filter - /// - /// The that represents the filter condition - /// - /// the given message is not recognized - public static Expression> ToExpression(this FilterStatus filter) - => filter.Field.FieldCase switch + public static Expression> ToField(this TaskField taskField) + => taskField.FieldCase switch { - TaskField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), - TaskField.FieldOneofCase.TaskSummaryField => ExpressionBuilders.MakeBinary(filter.Field.TaskSummaryField.Field.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - TaskField.FieldOneofCase.TaskOptionField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionField.Field.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - TaskField.FieldOneofCase.TaskOptionGenericField => ExpressionBuilders.MakeBinary(filter.Field.TaskOptionGenericField.ToField(), - filter.Value, - filter.Operator.ToExpressionType()), - _ => throw new ArgumentOutOfRangeException(), + TaskField.FieldOneofCase.None => throw new ArgumentOutOfRangeException(), + TaskField.FieldOneofCase.TaskSummaryField => taskField.TaskSummaryField.Field.ToField(), + TaskField.FieldOneofCase.TaskOptionField => taskField.TaskOptionField.Field.ToField(), + TaskField.FieldOneofCase.TaskOptionGenericField => taskField.TaskOptionGenericField.ToField(), + _ => throw new ArgumentOutOfRangeException(), }; /// @@ -214,27 +87,37 @@ public static Expression> ToTaskDataFilter(this Filters fil var predicateAnd = PredicateBuilder.New(data => true); foreach (var filterField in filtersAnd.And) { - switch (filterField.FilterCase) + switch (filterField.ValueConditionCase) { - case FilterField.FilterOneofCase.String: - predicateAnd = predicateAnd.And(filterField.String.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterString: + predicateAnd = predicateAnd.And(filterField.FilterString.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterString.Value)); break; - case FilterField.FilterOneofCase.Number: - predicateAnd = predicateAnd.And(filterField.Number.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterNumber: + predicateAnd = predicateAnd.And(filterField.FilterNumber.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterNumber.Value)); break; - case FilterField.FilterOneofCase.Date: - predicateAnd = predicateAnd.And(filterField.Date.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterBoolean: + predicateAnd = predicateAnd.And(ExpressionBuilders.MakeBinary(filterField.Field.ToField(), + filterField.FilterBoolean.Value, + ExpressionType.Equal)); break; - case FilterField.FilterOneofCase.Boolean: - predicateAnd = predicateAnd.And(filterField.Boolean.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterStatus: + predicateAnd = predicateAnd.And(filterField.FilterStatus.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterStatus.Value)); break; - case FilterField.FilterOneofCase.Array: - predicateAnd = predicateAnd.And(filterField.Array.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterDate: + var val = filterField.FilterDate.Value; + predicateAnd = predicateAnd.And(filterField.FilterDate.Operator.ToFilter(filterField.Field.ToField(), + val == null + ? null + : val.ToDateTime())); break; - case FilterField.FilterOneofCase.Status: - predicateAnd = predicateAnd.And(filterField.Status.ToExpression()); + case FilterField.ValueConditionOneofCase.FilterArray: + predicateAnd = predicateAnd.And(filterField.FilterArray.Operator.ToFilter(filterField.Field.ToField(), + filterField.FilterArray.Value)); break; - case FilterField.FilterOneofCase.None: + case FilterField.ValueConditionOneofCase.None: default: throw new ArgumentOutOfRangeException(); } diff --git a/Common/tests/Helpers/FilterFieldExt.cs b/Common/tests/Helpers/FilterFieldExt.cs deleted file mode 100644 index 9dfd552eb..000000000 --- a/Common/tests/Helpers/FilterFieldExt.cs +++ /dev/null @@ -1,195 +0,0 @@ -// This file is part of the ArmoniK project -// -// Copyright (C) ANEO, 2021-2023. All rights reserved. -// -// This program is free software: you can redistribute it and/or modify -// it under the terms of the GNU Affero General Public License as published -// by the Free Software Foundation, either version 3 of the License, or -// (at your option) any later version. -// -// This program is distributed in the hope that it will be useful, -// but WITHOUT ANY WARRANTY, without even the implied warranty of -// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -// GNU Affero General Public License for more details. -// -// You should have received a copy of the GNU Affero General Public License -// along with this program. If not, see . - -using System; - -using ArmoniK.Api.gRPC.V1.Applications; - -using Armonik.Api.Grpc.V1.Partitions; - -using ArmoniK.Api.gRPC.V1.Results; -using ArmoniK.Api.gRPC.V1.Sessions; - -using Armonik.Api.gRPC.V1.Tasks; - -using FilterField = Armonik.Api.gRPC.V1.Tasks.FilterField; - -namespace ArmoniK.Core.Common.Tests.Helpers; - -public static class FilterFieldExt -{ - private static string ToDisplay(this TaskField field) - { - switch (field.FieldCase) - { - case TaskField.FieldOneofCase.TaskSummaryField: - return field.FieldCase + " " + field.TaskSummaryField.Field; - case TaskField.FieldOneofCase.TaskOptionField: - return field.FieldCase + " " + field.TaskOptionField.Field; - case TaskField.FieldOneofCase.TaskOptionGenericField: - return field.FieldCase + " " + field.TaskOptionGenericField.Field; - case TaskField.FieldOneofCase.None: - default: - throw new ArgumentOutOfRangeException(); - } - } - - private static string ToDisplay(this ApplicationField field) - { - switch (field.FieldCase) - { - case ApplicationField.FieldOneofCase.ApplicationField_: - return field.FieldCase + " " + field.ApplicationField_.Field; - case ApplicationField.FieldOneofCase.None: - default: - throw new ArgumentOutOfRangeException(); - } - } - - private static string ToDisplay(this PartitionField field) - { - switch (field.FieldCase) - { - case PartitionField.FieldOneofCase.PartitionRawField: - return field.FieldCase + " " + field.PartitionRawField.Field; - case PartitionField.FieldOneofCase.None: - default: - throw new ArgumentOutOfRangeException(); - } - } - - private static string ToDisplay(this ResultField field) - { - switch (field.FieldCase) - { - case ResultField.FieldOneofCase.ResultRawField: - return field.FieldCase + " " + field.ResultRawField.Field; - case ResultField.FieldOneofCase.None: - default: - throw new ArgumentOutOfRangeException(); - } - } - - private static string ToDisplay(this SessionField field) - { - switch (field.FieldCase) - { - case SessionField.FieldOneofCase.SessionRawField: - return field.FieldCase + " " + field.SessionRawField.Field; - case SessionField.FieldOneofCase.TaskOptionField: - return field.FieldCase + " " + field.TaskOptionField.Field; - case SessionField.FieldOneofCase.TaskOptionGenericField: - return field.FieldCase + " " + field.TaskOptionGenericField.Field; - case SessionField.FieldOneofCase.None: - default: - throw new ArgumentOutOfRangeException(); - } - } - - public static string ToDisplay(this FilterField filterField) - { - switch (filterField.FilterCase) - { - case FilterField.FilterOneofCase.Status: - case FilterField.FilterOneofCase.Boolean: - case FilterField.FilterOneofCase.Number: - case FilterField.FilterOneofCase.String: - return filterField.ToString(); - case FilterField.FilterOneofCase.Date: - return filterField.FilterCase + " " + filterField.Date.Field.ToDisplay(); - case FilterField.FilterOneofCase.Array: - return filterField.ToString(); - case FilterField.FilterOneofCase.None: - default: - throw new ArgumentOutOfRangeException(); - } - } - - public static string ToDisplay(this Api.gRPC.V1.Applications.FilterField filterField) - { - switch (filterField.FilterCase) - { - case Api.gRPC.V1.Applications.FilterField.FilterOneofCase.Boolean: - case Api.gRPC.V1.Applications.FilterField.FilterOneofCase.Number: - case Api.gRPC.V1.Applications.FilterField.FilterOneofCase.String: - return filterField.ToString(); - case Api.gRPC.V1.Applications.FilterField.FilterOneofCase.Date: - return filterField.FilterCase + " " + filterField.Date.Field.ToDisplay(); - case Api.gRPC.V1.Applications.FilterField.FilterOneofCase.Array: - return filterField.ToString(); - case Api.gRPC.V1.Applications.FilterField.FilterOneofCase.None: - default: - throw new ArgumentOutOfRangeException(); - } - } - - public static string ToDisplay(this Armonik.Api.Grpc.V1.Partitions.FilterField filterField) - { - switch (filterField.FilterCase) - { - case Armonik.Api.Grpc.V1.Partitions.FilterField.FilterOneofCase.Boolean: - case Armonik.Api.Grpc.V1.Partitions.FilterField.FilterOneofCase.Number: - case Armonik.Api.Grpc.V1.Partitions.FilterField.FilterOneofCase.String: - return filterField.ToString(); - case Armonik.Api.Grpc.V1.Partitions.FilterField.FilterOneofCase.Date: - return filterField.FilterCase + " " + filterField.Date.Field.ToDisplay(); - case Armonik.Api.Grpc.V1.Partitions.FilterField.FilterOneofCase.Array: - return filterField.ToString(); - case Armonik.Api.Grpc.V1.Partitions.FilterField.FilterOneofCase.None: - default: - throw new ArgumentOutOfRangeException(); - } - } - - public static string ToDisplay(this Api.gRPC.V1.Results.FilterField filterField) - { - switch (filterField.FilterCase) - { - case Api.gRPC.V1.Results.FilterField.FilterOneofCase.Status: - case Api.gRPC.V1.Results.FilterField.FilterOneofCase.Boolean: - case Api.gRPC.V1.Results.FilterField.FilterOneofCase.Number: - case Api.gRPC.V1.Results.FilterField.FilterOneofCase.String: - return filterField.ToString(); - case Api.gRPC.V1.Results.FilterField.FilterOneofCase.Date: - return filterField.FilterCase + " " + filterField.Date.Field.ToDisplay(); - case Api.gRPC.V1.Results.FilterField.FilterOneofCase.Array: - return filterField.ToString(); - case Api.gRPC.V1.Results.FilterField.FilterOneofCase.None: - default: - throw new ArgumentOutOfRangeException(); - } - } - - public static string ToDisplay(this Api.gRPC.V1.Sessions.FilterField filterField) - { - switch (filterField.FilterCase) - { - case Api.gRPC.V1.Sessions.FilterField.FilterOneofCase.Status: - case Api.gRPC.V1.Sessions.FilterField.FilterOneofCase.Boolean: - case Api.gRPC.V1.Sessions.FilterField.FilterOneofCase.Number: - case Api.gRPC.V1.Sessions.FilterField.FilterOneofCase.String: - return filterField.ToString(); - case Api.gRPC.V1.Sessions.FilterField.FilterOneofCase.Date: - return filterField.FilterCase + " " + filterField.Date.Field.ToDisplay(); - case Api.gRPC.V1.Sessions.FilterField.FilterOneofCase.Array: - return filterField.ToString(); - case Api.gRPC.V1.Sessions.FilterField.FilterOneofCase.None: - default: - throw new ArgumentOutOfRangeException(); - } - } -} diff --git a/Common/tests/ListApplicationsRequestExt/ToApplicationFilterTest.cs b/Common/tests/ListApplicationsRequestExt/ToApplicationFilterTest.cs index 4bcbcd11f..053e99683 100644 --- a/Common/tests/ListApplicationsRequestExt/ToApplicationFilterTest.cs +++ b/Common/tests/ListApplicationsRequestExt/ToApplicationFilterTest.cs @@ -126,37 +126,18 @@ public static FilterField CreateListApplicationsFilterString(ApplicationRawEnumF string value) => new() { - String = new FilterString - { - Field = new ApplicationField - { - ApplicationField_ = new ApplicationRawField - { - Field = field, - }, - }, - Operator = op, - Value = value, - }, - }; - - public FilterField CreateListApplicationsFilterNumber(ApplicationRawEnumField field, - FilterNumberOperator op, - long value) - => new() - { - Number = new FilterNumber - { - Field = new ApplicationField - { - ApplicationField_ = new ApplicationRawField - { - Field = field, - }, - }, - Operator = op, - Value = value, - }, + Field = new ApplicationField + { + ApplicationField_ = new ApplicationRawField + { + Field = field, + }, + }, + FilterString = new FilterString + { + Operator = op, + Value = value, + }, }; [Test] @@ -178,14 +159,14 @@ TestCaseData CaseTrue(FilterField filterField) { filterField, }, - true).SetArgDisplayNames(filterField.ToDisplay()); + true).SetArgDisplayNames(filterField.ToString()); TestCaseData CaseFalse(FilterField filterField) => new TestCaseData(new[] { filterField, }, - false).SetArgDisplayNames(filterField.ToDisplay()); + false).SetArgDisplayNames(filterField.ToString()); yield return CaseTrue(CreateListApplicationsFilterString(ApplicationRawEnumField.Name, FilterStringOperator.Equal, diff --git a/Common/tests/ListPartitionsRequestExt/ListPartitionsHelper.cs b/Common/tests/ListPartitionsRequestExt/ListPartitionsHelper.cs index e7f9bd390..2f1524519 100644 --- a/Common/tests/ListPartitionsRequestExt/ListPartitionsHelper.cs +++ b/Common/tests/ListPartitionsRequestExt/ListPartitionsHelper.cs @@ -49,18 +49,18 @@ public static FilterField CreateListPartitionsFilterString(PartitionRawEnumField string value) => new() { - String = new FilterString - { - Field = new PartitionField - { - PartitionRawField = new PartitionRawField - { - Field = field, - }, - }, - Operator = op, - Value = value, - }, + Field = new PartitionField + { + PartitionRawField = new PartitionRawField + { + Field = field, + }, + }, + FilterString = new FilterString + { + Operator = op, + Value = value, + }, }; public static FilterField CreateListPartitionsFilterNumber(PartitionRawEnumField field, @@ -68,18 +68,18 @@ public static FilterField CreateListPartitionsFilterNumber(PartitionRawEnumField long value) => new() { - Number = new FilterNumber - { - Field = new PartitionField - { - PartitionRawField = new PartitionRawField - { - Field = field, - }, - }, - Operator = op, - Value = value, - }, + Field = new PartitionField + { + PartitionRawField = new PartitionRawField + { + Field = field, + }, + }, + FilterNumber = new FilterNumber + { + Operator = op, + Value = value, + }, }; public static FilterField CreateListPartitionsFilterArray(PartitionRawEnumField field, @@ -87,17 +87,17 @@ public static FilterField CreateListPartitionsFilterArray(PartitionRawEnumField string value) => new() { - Array = new FilterArray + Field = new PartitionField { - Field = new PartitionField - { - PartitionRawField = new PartitionRawField - { - Field = field, - }, - }, - Operator = op, - Value = value, + PartitionRawField = new PartitionRawField + { + Field = field, + }, }, + FilterArray = new FilterArray + { + Operator = op, + Value = value, + }, }; } diff --git a/Common/tests/ListPartitionsRequestExt/ToPartitionDataFieldTest.cs b/Common/tests/ListPartitionsRequestExt/ToPartitionDataFieldTest.cs index e06f37c7d..aee239276 100644 --- a/Common/tests/ListPartitionsRequestExt/ToPartitionDataFieldTest.cs +++ b/Common/tests/ListPartitionsRequestExt/ToPartitionDataFieldTest.cs @@ -84,18 +84,18 @@ public void InvokeShouldReturnExpectedValue(PartitionRawField field, { new FilterField { - String = new FilterString - { - Field = new PartitionField - { - PartitionRawField = new PartitionRawField - { - Field = PartitionRawEnumField.Id, - }, - }, - Operator = FilterStringOperator.Equal, - Value = "PartitionId", - }, + Field = new PartitionField + { + PartitionRawField = new PartitionRawField + { + Field = PartitionRawEnumField.Id, + }, + }, + FilterString = new FilterString + { + Operator = FilterStringOperator.Equal, + Value = "PartitionId", + }, }, }, }, diff --git a/Common/tests/ListPartitionsRequestExt/ToTaskDataFilterTest.cs b/Common/tests/ListPartitionsRequestExt/ToTaskDataFilterTest.cs index a385c9da1..ddce8e099 100644 --- a/Common/tests/ListPartitionsRequestExt/ToTaskDataFilterTest.cs +++ b/Common/tests/ListPartitionsRequestExt/ToTaskDataFilterTest.cs @@ -85,14 +85,14 @@ TestCaseData CaseTrue(FilterField filterField) { filterField, }, - true).SetArgDisplayNames(filterField.ToDisplay()); + true).SetArgDisplayNames(filterField.ToString()); TestCaseData CaseFalse(FilterField filterField) => new TestCaseData(new[] { filterField, }, - false).SetArgDisplayNames(filterField.ToDisplay()); + false).SetArgDisplayNames(filterField.ToString()); yield return CaseTrue(ListPartitionsHelper.CreateListPartitionsFilterString(PartitionRawEnumField.Id, FilterStringOperator.Equal, diff --git a/Common/tests/ListResultsRequestExt/ToResultFilterTest.cs b/Common/tests/ListResultsRequestExt/ToResultFilterTest.cs index 524fa9f12..e83fd84ec 100644 --- a/Common/tests/ListResultsRequestExt/ToResultFilterTest.cs +++ b/Common/tests/ListResultsRequestExt/ToResultFilterTest.cs @@ -33,6 +33,8 @@ using static Google.Protobuf.WellKnownTypes.Timestamp; +using FilterStatus = ArmoniK.Api.gRPC.V1.Results.FilterStatus; + namespace ArmoniK.Core.Common.Tests.ListResultsRequestExt; [TestFixture(TestOf = typeof(ToResultFilterTest))] @@ -92,56 +94,38 @@ public static FilterField CreateListResultsFilterString(ResultRawEnumField fie string value) => new() { - String = new FilterString - { - Field = new ResultField - { - ResultRawField = new ResultRawField - { - Field = field, - }, - }, - Operator = op, - Value = value, - }, + Field = new ResultField + { + ResultRawField = new ResultRawField + { + Field = field, + }, + }, + FilterString = new FilterString + { + Operator = op, + Value = value, + }, }; - public static FilterField CreateListResultsFilterNumber(ResultRawEnumField field, - FilterNumberOperator op, - long value) - => new() - { - Number = new FilterNumber - { - Field = new ResultField - { - ResultRawField = new ResultRawField - { - Field = field, - }, - }, - Operator = op, - Value = value, - }, - }; public static FilterField CreateListResultsFilterArray(ResultRawEnumField field, FilterArrayOperator op, string value) => new() { - Array = new FilterArray + Field = new ResultField { - Field = new ResultField - { - ResultRawField = new ResultRawField - { - Field = field, - }, - }, - Operator = op, - Value = value, + ResultRawField = new ResultRawField + { + Field = field, + }, }, + FilterArray = new FilterArray + { + Operator = op, + Value = value, + }, }; public static FilterField CreateListResultsFilterStatus(ResultRawEnumField field, @@ -149,18 +133,18 @@ public static FilterField CreateListResultsFilterStatus(ResultRawEnumField fie ResultStatus value) => new() { - Status = new FilterStatus - { - Field = new ResultField - { - ResultRawField = new ResultRawField - { - Field = field, - }, - }, - Operator = op, - Value = value, - }, + Field = new ResultField + { + ResultRawField = new ResultRawField + { + Field = field, + }, + }, + FilterStatus = new FilterStatus + { + Operator = op, + Value = value, + }, }; public static FilterField CreateListResultsFilterDate(ResultRawEnumField field, @@ -168,18 +152,18 @@ public static FilterField CreateListResultsFilterDate(ResultRawEnumField field, DateTime value) => new() { - Date = new FilterDate - { - Field = new ResultField - { - ResultRawField = new ResultRawField - { - Field = field, - }, - }, - Operator = op, - Value = FromDateTime(value), - }, + Field = new ResultField + { + ResultRawField = new ResultRawField + { + Field = field, + }, + }, + FilterDate = new FilterDate + { + Operator = op, + Value = FromDateTime(value), + }, }; [Test] @@ -201,14 +185,14 @@ TestCaseData CaseTrue(FilterField filterField) { filterField, }, - true).SetArgDisplayNames(filterField.ToDisplay()); + true).SetArgDisplayNames(filterField.ToString()); TestCaseData CaseFalse(FilterField filterField) => new TestCaseData(new[] { filterField, }, - false).SetArgDisplayNames(filterField.ToDisplay()); + false).SetArgDisplayNames(filterField.ToString()); yield return CaseTrue(CreateListResultsFilterStatus(ResultRawEnumField.Status, FilterStatusOperator.Equal, diff --git a/Common/tests/ListSessionsRequestExt/ToSessionDataFilterTest.cs b/Common/tests/ListSessionsRequestExt/ToSessionDataFilterTest.cs index 0413fcfe5..301f22734 100644 --- a/Common/tests/ListSessionsRequestExt/ToSessionDataFilterTest.cs +++ b/Common/tests/ListSessionsRequestExt/ToSessionDataFilterTest.cs @@ -33,6 +33,7 @@ using static Google.Protobuf.WellKnownTypes.Timestamp; +using FilterStatus = ArmoniK.Api.gRPC.V1.Sessions.FilterStatus; using TaskOptions = ArmoniK.Core.Base.DataStructures.TaskOptions; namespace ArmoniK.Core.Common.Tests.ListSessionsRequestExt; @@ -103,12 +104,12 @@ public static FilterField CreateListSessionsFilterString(SessionField fi string value) => new() { - String = new FilterString - { - Field = field, - Operator = op, - Value = value, - }, + Field = field, + FilterString = new FilterString + { + Operator = op, + Value = value, + }, }; @@ -143,18 +144,18 @@ public static FilterField CreateListSessionsFilterNumber(SessionRawEnumField fi long value) => new() { - Number = new FilterNumber - { - Field = new SessionField - { - SessionRawField = new SessionRawField - { - Field = field, - }, - }, - Operator = op, - Value = value, - }, + Field = new SessionField + { + SessionRawField = new SessionRawField + { + Field = field, + }, + }, + FilterNumber = new FilterNumber + { + Operator = op, + Value = value, + } }; public static FilterField CreateListSessionsFilterArray(SessionRawEnumField field, @@ -162,18 +163,18 @@ public static FilterField CreateListSessionsFilterArray(SessionRawEnumField fiel string value) => new() { - Array = new FilterArray + Field = new SessionField { - Field = new SessionField - { - SessionRawField = new SessionRawField - { - Field = field, - }, - }, - Operator = op, - Value = value, + SessionRawField = new SessionRawField + { + Field = field, + }, }, + FilterArray = new FilterArray + { + Operator = op, + Value = value, + }, }; public static FilterField CreateListSessionsFilterStatus(SessionRawEnumField field, @@ -181,18 +182,18 @@ public static FilterField CreateListSessionsFilterStatus(SessionRawEnumField fi SessionStatus value) => new() { - Status = new FilterStatus - { - Field = new SessionField - { - SessionRawField = new SessionRawField - { - Field = field, - }, - }, - Operator = op, - Value = value, - }, + Field = new SessionField + { + SessionRawField = new SessionRawField + { + Field = field, + }, + }, + FilterStatus = new FilterStatus + { + Operator = op, + Value = value, + }, }; public static FilterField CreateListSessionsFilterDate(SessionRawEnumField field, @@ -200,18 +201,18 @@ public static FilterField CreateListSessionsFilterDate(SessionRawEnumField field DateTime value) => new() { - Date = new FilterDate - { - Field = new SessionField - { - SessionRawField = new SessionRawField - { - Field = field, - }, - }, - Operator = op, - Value = FromDateTime(value), - }, + Field = new SessionField + { + SessionRawField = new SessionRawField + { + Field = field, + }, + }, + FilterDate = new FilterDate + { + Operator = op, + Value = FromDateTime(value), + }, }; [Test] @@ -233,14 +234,14 @@ TestCaseData CaseTrue(FilterField filterField) { filterField, }, - true).SetArgDisplayNames(filterField.ToDisplay()); + true).SetArgDisplayNames(filterField.ToString()); TestCaseData CaseFalse(FilterField filterField) => new TestCaseData(new[] { filterField, }, - false).SetArgDisplayNames(filterField.ToDisplay()); + false).SetArgDisplayNames(filterField.ToString()); yield return CaseTrue(CreateListSessionsFilterStatus(SessionRawEnumField.Status, FilterStatusOperator.Equal, diff --git a/Common/tests/ListTasksRequestExt/ListTasksHelper.cs b/Common/tests/ListTasksRequestExt/ListTasksHelper.cs index 1dc6099b7..6df2c07ab 100644 --- a/Common/tests/ListTasksRequestExt/ListTasksHelper.cs +++ b/Common/tests/ListTasksRequestExt/ListTasksHelper.cs @@ -28,6 +28,8 @@ using static Google.Protobuf.WellKnownTypes.Timestamp; +using FilterStatus = Armonik.Api.gRPC.V1.Tasks.FilterStatus; + namespace ArmoniK.Core.Common.Tests.ListTasksRequestExt; public static class ListTasksHelper @@ -57,12 +59,12 @@ public static FilterField CreateListTasksFilterString(TaskField field string value) => new() { - String = new FilterString - { - Field = field, - Operator = op, - Value = value, - }, + Field = field, + FilterString = new FilterString + { + Operator = op, + Value = value, + }, }; @@ -110,18 +112,19 @@ public static FilterField CreateListTasksFilterNumber(TaskOptionEnumField field long value) => new() { - Number = new FilterNumber - { - Field = new TaskField - { - TaskOptionField = new TaskOptionField - { - Field = field, - }, - }, - Operator = op, - Value = value, - }, + Field = new TaskField + { + TaskOptionField = new TaskOptionField + { + Field = field, + }, + }, + + FilterNumber = new FilterNumber + { + Operator = op, + Value = value, + }, }; public static FilterField CreateListTasksFilterStatus(TaskSummaryEnumField field, @@ -129,18 +132,18 @@ public static FilterField CreateListTasksFilterStatus(TaskSummaryEnumField field TaskStatus value) => new() { - Status = new FilterStatus - { - Field = new TaskField - { - TaskSummaryField = new TaskSummaryField - { - Field = field, - }, - }, - Operator = op, - Value = value, - }, + Field = new TaskField + { + TaskSummaryField = new TaskSummaryField + { + Field = field, + }, + }, + FilterStatus = new FilterStatus + { + Operator = op, + Value = value, + }, }; public static FilterField CreateListTasksFilterDate(TaskSummaryEnumField field, @@ -148,19 +151,19 @@ public static FilterField CreateListTasksFilterDate(TaskSummaryEnumField field, DateTime? value) => new() { - Date = new FilterDate - { - Field = new TaskField - { - TaskSummaryField = new TaskSummaryField - { - Field = field, - }, - }, - Operator = op, - Value = value is null - ? null - : FromDateTime(value.Value), - }, + Field = new TaskField + { + TaskSummaryField = new TaskSummaryField + { + Field = field, + }, + }, + FilterDate = new FilterDate + { + Operator = op, + Value = value is null + ? null + : FromDateTime(value.Value), + }, }; } diff --git a/Common/tests/ListTasksRequestExt/ToTaskDataFieldTest.cs b/Common/tests/ListTasksRequestExt/ToTaskDataFieldTest.cs index 779cf22e8..58d6bd1ea 100644 --- a/Common/tests/ListTasksRequestExt/ToTaskDataFieldTest.cs +++ b/Common/tests/ListTasksRequestExt/ToTaskDataFieldTest.cs @@ -188,18 +188,18 @@ public void InvokeShouldReturnExpectedValue(TaskField field, { new FilterField { - String = new FilterString - { - Field = new TaskField - { - TaskSummaryField = new TaskSummaryField - { - Field = TaskSummaryEnumField.SessionId, - }, - }, - Value = "SessionId", - Operator = FilterStringOperator.Equal, - }, + Field = new TaskField + { + TaskSummaryField = new TaskSummaryField + { + Field = TaskSummaryEnumField.SessionId, + }, + }, + FilterString = new FilterString + { + Value = "SessionId", + Operator = FilterStringOperator.Equal, + }, }, }, }, @@ -232,18 +232,18 @@ public void KeyNotFoundShouldFail() { new FilterField { - String = new FilterString - { - Field = new TaskField - { - TaskSummaryField = new TaskSummaryField - { - Field = TaskSummaryEnumField.SessionId, - }, - }, - Value = "SessionId", - Operator = FilterStringOperator.Equal, - }, + Field = new TaskField + { + TaskSummaryField = new TaskSummaryField + { + Field = TaskSummaryEnumField.SessionId, + }, + }, + FilterString = new FilterString + { + Value = "SessionId", + Operator = FilterStringOperator.Equal, + }, }, }, }, diff --git a/Common/tests/ListTasksRequestExt/ToTaskDataFilterTest.cs b/Common/tests/ListTasksRequestExt/ToTaskDataFilterTest.cs index 6c2e97fc8..0ea7acc53 100644 --- a/Common/tests/ListTasksRequestExt/ToTaskDataFilterTest.cs +++ b/Common/tests/ListTasksRequestExt/ToTaskDataFilterTest.cs @@ -28,7 +28,6 @@ using ArmoniK.Api.gRPC.V1.Tasks; using ArmoniK.Core.Common.gRPC; using ArmoniK.Core.Common.Storage; -using ArmoniK.Core.Common.Tests.Helpers; using NUnit.Framework; @@ -73,8 +72,12 @@ public class ToTaskDataFilterTest TaskStatus.Completed, "StatusMessage", Options, - DateTime.UtcNow, - DateTime.Now, + new DateTime(2020, + 3, + 14), + new DateTime(2020, + 3, + 16), null, null, null, @@ -85,6 +88,10 @@ public class ToTaskDataFilterTest new Output(true, "")); + private static readonly DateTime DateToCompare = new DateTime(2020, + 3, + 15).ToUniversalTime(); + private static readonly ListTasksRequest.Types.Sort Sort = new() { Direction = SortDirection.Asc, @@ -123,60 +130,60 @@ TestCaseData CaseTrue(FilterField filterField) { filterField, }, - true).SetArgDisplayNames(filterField.ToDisplay()); + true).SetArgDisplayNames(filterField.ToString()); TestCaseData CaseFalse(FilterField filterField) => new TestCaseData(new[] { filterField, }, - false).SetArgDisplayNames(filterField.ToDisplay()); + false).SetArgDisplayNames(filterField.ToString()); yield return CaseTrue(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.CreatedAt, - FilterDateOperator.After, - DateTime.UtcNow)); + FilterDateOperator.Before, + DateToCompare)); yield return CaseFalse(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.CreatedAt, - FilterDateOperator.Before, - DateTime.UtcNow)); + FilterDateOperator.After, + DateToCompare)); yield return CaseTrue(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.SubmittedAt, FilterDateOperator.AfterOrEqual, - DateTime.UtcNow)); + DateToCompare)); yield return CaseFalse(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.SubmittedAt, FilterDateOperator.BeforeOrEqual, - DateTime.UtcNow)); + DateToCompare)); // end date is null yield return CaseFalse(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.EndedAt, FilterDateOperator.After, - DateTime.UtcNow)); + DateToCompare)); yield return CaseFalse(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.EndedAt, FilterDateOperator.Before, - DateTime.UtcNow)); + DateToCompare)); // start date is null yield return CaseFalse(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.StartedAt, FilterDateOperator.After, - DateTime.UtcNow)); + DateToCompare)); yield return CaseFalse(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.StartedAt, FilterDateOperator.Before, - DateTime.UtcNow)); + DateToCompare)); yield return CaseTrue(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.StartedAt, FilterDateOperator.Equal, null)); yield return CaseTrue(new FilterField { - Date = new FilterDate - { - Field = new TaskField - { - TaskSummaryField = new TaskSummaryField - { - Field = TaskSummaryEnumField.StartedAt, - }, - }, - Operator = FilterDateOperator.Equal, - }, + Field = new TaskField + { + TaskSummaryField = new TaskSummaryField + { + Field = TaskSummaryEnumField.StartedAt, + }, + }, + FilterDate = new FilterDate + { + Operator = FilterDateOperator.Equal, + }, }); yield return CaseTrue(ListTasksHelper.CreateListTasksFilterString(TaskSummaryEnumField.SessionId, diff --git a/Common/tests/TestBase/PartitionTableTestBase.cs b/Common/tests/TestBase/PartitionTableTestBase.cs index 3dd605cb6..b4a568227 100644 --- a/Common/tests/TestBase/PartitionTableTestBase.cs +++ b/Common/tests/TestBase/PartitionTableTestBase.cs @@ -26,7 +26,6 @@ using ArmoniK.Core.Common.Exceptions; using ArmoniK.Core.Common.gRPC; using ArmoniK.Core.Common.Storage; -using ArmoniK.Core.Common.Tests.Helpers; using ArmoniK.Core.Common.Tests.ListPartitionsRequestExt; using Microsoft.Extensions.Diagnostics.HealthChecks; @@ -292,7 +291,7 @@ TestCaseData CaseTrue(FilterField filterField) FilterStringOperator.Equal, "PartitionId2"), }), - 1).SetArgDisplayNames(filterField.ToDisplay() + " true"); + 1).SetArgDisplayNames(filterField + " true"); TestCaseData CaseFalse(FilterField filterField) => new TestCaseData(ListPartitionsHelper.CreateListPartitionsRequest(new ListPartitionsRequest.Types.Sort(), @@ -303,7 +302,7 @@ TestCaseData CaseFalse(FilterField filterField) FilterStringOperator.Equal, "PartitionId2"), }), - 0).SetArgDisplayNames(filterField.ToDisplay() + " false"); + 0).SetArgDisplayNames(filterField + " false"); yield return CaseTrue(ListPartitionsHelper.CreateListPartitionsFilterString(PartitionRawEnumField.Id, FilterStringOperator.Equal, diff --git a/Common/tests/TestBase/TaskTableTestBase.cs b/Common/tests/TestBase/TaskTableTestBase.cs index f57333134..d0859f244 100644 --- a/Common/tests/TestBase/TaskTableTestBase.cs +++ b/Common/tests/TestBase/TaskTableTestBase.cs @@ -38,7 +38,6 @@ using ArmoniK.Core.Common.gRPC; using ArmoniK.Core.Common.gRPC.Validators; using ArmoniK.Core.Common.Storage; -using ArmoniK.Core.Common.Tests.Helpers; using ArmoniK.Core.Common.Tests.ListTasksRequestExt; using ArmoniK.Core.Common.Utils; using ArmoniK.Utils; @@ -47,11 +46,9 @@ using NUnit.Framework; -using FilterDate = Armonik.Api.gRPC.V1.Tasks.FilterDate; using FilterField = ArmoniK.Api.gRPC.V1.Applications.FilterField; using Filters = ArmoniK.Api.gRPC.V1.Applications.Filters; using FiltersAnd = ArmoniK.Api.gRPC.V1.Applications.FiltersAnd; -using FilterString = ArmoniK.Api.gRPC.V1.Applications.FilterString; using TaskStatus = ArmoniK.Api.gRPC.V1.TaskStatus; namespace ArmoniK.Core.Common.Tests.TestBase; @@ -142,6 +139,10 @@ Options with new Output(true, "")); + private static readonly DateTime DateToCompare = new DateTime(2020, + 3, + 15).ToUniversalTime(); + private readonly TaskData taskCreatingData_ = new("SessionId", "TaskCreatingId", "OwnerPodId", @@ -1294,18 +1295,18 @@ public async Task ListApplicationFromTasksShouldSucceed() { new FilterField { - String = new FilterString - { - Field = new ApplicationField - { - ApplicationField_ = new ApplicationRawField - { - Field = ApplicationRawEnumField.Name, - }, - }, - Operator = FilterStringOperator.Equal, - Value = Options.ApplicationName, - }, + Field = new ApplicationField + { + ApplicationField_ = new ApplicationRawField + { + Field = ApplicationRawEnumField.Name, + }, + }, + FilterString = new FilterString + { + Operator = FilterStringOperator.Equal, + Value = Options.ApplicationName, + }, }, }, }, @@ -1463,18 +1464,18 @@ taskData1 with { new FilterField { - String = new FilterString - { - Field = new ApplicationField - { - ApplicationField_ = new ApplicationRawField - { - Field = ApplicationRawEnumField.Name, - }, - }, - Operator = FilterStringOperator.Equal, - Value = applicationName, - }, + Field = new ApplicationField + { + ApplicationField_ = new ApplicationRawField + { + Field = ApplicationRawEnumField.Name, + }, + }, + FilterString = new FilterString + { + Operator = FilterStringOperator.Equal, + Value = applicationName, + }, }, }, }, @@ -1572,18 +1573,19 @@ public async Task ListTaskWithRequestOrderByTaskOptionsOptionsShouldSucceed() { new Armonik.Api.gRPC.V1.Tasks.FilterField { - String = new Armonik.Api.gRPC.V1.Tasks.FilterString - { - Value = "SessionId", - Field = new TaskField - { - TaskSummaryField = new TaskSummaryField - { - Field = TaskSummaryEnumField.SessionId, - }, - }, - Operator = FilterStringOperator.Equal, - }, + Field = new TaskField + { + TaskSummaryField = new TaskSummaryField + { + Field = TaskSummaryEnumField.SessionId, + }, + }, + FilterString = new FilterString + { + Value = "SessionId", + + Operator = FilterStringOperator.Equal, + }, }, }, }, @@ -1692,7 +1694,7 @@ TestCaseData CaseTrue(Armonik.Api.gRPC.V1.Tasks.FilterField filterField) FilterStringOperator.Equal, "TaskCompletedId"), }), - 1).SetArgDisplayNames(filterField.ToDisplay() + " true"); + 1).SetArgDisplayNames(filterField + " true"); TestCaseData CaseFalse(Armonik.Api.gRPC.V1.Tasks.FilterField filterField) => new TestCaseData(ListTasksHelper.CreateListSessionsRequest(new ListTasksRequest.Types.Sort(), @@ -1703,37 +1705,37 @@ TestCaseData CaseFalse(Armonik.Api.gRPC.V1.Tasks.FilterField filterField) FilterStringOperator.Equal, "TaskCompletedId"), }), - 0).SetArgDisplayNames(filterField.ToDisplay() + " false"); + 0).SetArgDisplayNames(filterField + " false"); yield return CaseTrue(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.CreatedAt, FilterDateOperator.After, - DateTime.UtcNow)); + DateToCompare)); yield return CaseTrue(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.CreatedAt, FilterDateOperator.AfterOrEqual, - DateTime.UtcNow)); + DateToCompare)); yield return CaseFalse(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.CreatedAt, FilterDateOperator.Before, - DateTime.UtcNow)); + DateToCompare)); yield return CaseFalse(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.CreatedAt, FilterDateOperator.BeforeOrEqual, - DateTime.UtcNow)); + DateToCompare)); yield return CaseTrue(ListTasksHelper.CreateListTasksFilterDate(TaskSummaryEnumField.StartedAt, FilterDateOperator.Equal, null)); yield return CaseTrue(new Armonik.Api.gRPC.V1.Tasks.FilterField { - Date = new FilterDate - { - Field = new TaskField - { - TaskSummaryField = new TaskSummaryField - { - Field = TaskSummaryEnumField.StartedAt, - }, - }, - Operator = FilterDateOperator.Equal, - }, + Field = new TaskField + { + TaskSummaryField = new TaskSummaryField + { + Field = TaskSummaryEnumField.StartedAt, + }, + }, + FilterDate = new FilterDate + { + Operator = FilterDateOperator.Equal, + }, }); yield return CaseTrue(ListTasksHelper.CreateListTasksFilterString(TaskSummaryEnumField.SessionId, diff --git a/Tests/Bench/Client/src/Program.cs b/Tests/Bench/Client/src/Program.cs index a9cbc53cb..643703def 100644 --- a/Tests/Bench/Client/src/Program.cs +++ b/Tests/Bench/Client/src/Program.cs @@ -52,12 +52,9 @@ using Serilog; using Serilog.Formatting.Compact; -using FilterArray = Armonik.Api.Grpc.V1.Partitions.FilterArray; using FilterField = Armonik.Api.Grpc.V1.Partitions.FilterField; -using FilterNumber = Armonik.Api.Grpc.V1.Partitions.FilterNumber; using Filters = Armonik.Api.Grpc.V1.Partitions.Filters; using FiltersAnd = Armonik.Api.Grpc.V1.Partitions.FiltersAnd; -using FilterString = Armonik.Api.Grpc.V1.Partitions.FilterString; using TaskStatus = ArmoniK.Api.gRPC.V1.TaskStatus; namespace ArmoniK.Samples.Bench.Client; @@ -105,98 +102,95 @@ private static async Task Main() { new FilterField { - String = new FilterString - { - Field = new PartitionField - { - PartitionRawField = new PartitionRawField - { - Field = PartitionRawEnumField.Id, - }, - }, - Operator = FilterStringOperator.Equal, - Value = "", - }, + Field = new PartitionField + { + PartitionRawField = new PartitionRawField + { + Field = PartitionRawEnumField.Id, + }, + }, + FilterString = new FilterString + { + Operator = FilterStringOperator.Equal, + Value = "", + }, }, new FilterField { - Array = new FilterArray + Field = new PartitionField { - Field = new PartitionField - { - PartitionRawField = new PartitionRawField - { - Field = PartitionRawEnumField - .ParentPartitionIds, - }, - }, - Operator = FilterArrayOperator.Contains, - Value = "", + PartitionRawField = new PartitionRawField + { + Field = PartitionRawEnumField + .ParentPartitionIds, + }, }, + FilterArray = new FilterArray + { + Operator = FilterArrayOperator.Contains, + Value = "", + }, }, new FilterField { - Number = new FilterNumber - { - Field = new PartitionField - { - PartitionRawField = new PartitionRawField - { - Field = PartitionRawEnumField - .PodMax, - }, - }, - Operator = FilterNumberOperator.Equal, - Value = 0, - }, + Field = new PartitionField + { + PartitionRawField = new PartitionRawField + { + Field = PartitionRawEnumField.PodMax, + }, + }, + FilterNumber = new FilterNumber + { + Operator = FilterNumberOperator.Equal, + Value = 0, + }, }, new FilterField { - Number = new FilterNumber - { - Field = new PartitionField - { - PartitionRawField = new PartitionRawField - { - Field = PartitionRawEnumField - .PodReserved, - }, - }, - Operator = FilterNumberOperator.Equal, - Value = 0, - }, + Field = new PartitionField + { + PartitionRawField = new PartitionRawField + { + Field = PartitionRawEnumField.PodReserved, + }, + }, + FilterNumber = new FilterNumber + { + Operator = FilterNumberOperator.Equal, + Value = 0, + }, }, new FilterField { - Number = new FilterNumber - { - Field = new PartitionField - { - PartitionRawField = new PartitionRawField - { - Field = PartitionRawEnumField - .PreemptionPercentage, - }, - }, - Operator = FilterNumberOperator.Equal, - Value = 0, - }, + Field = new PartitionField + { + PartitionRawField = new PartitionRawField + { + Field = PartitionRawEnumField + .PreemptionPercentage, + }, + }, + FilterNumber = new FilterNumber + { + Operator = FilterNumberOperator.Equal, + Value = 0, + }, }, new FilterField { - Number = new FilterNumber - { - Field = new PartitionField - { - PartitionRawField = new PartitionRawField - { - Field = PartitionRawEnumField - .Priority, - }, - }, - Operator = FilterNumberOperator.Equal, - Value = 0, - }, + Field = new PartitionField + { + PartitionRawField = new PartitionRawField + { + Field = PartitionRawEnumField.Priority, + }, + }, + FilterNumber = new FilterNumber + { + Operator = FilterNumberOperator.Equal, + Value = 0, + }, }, }, }, diff --git a/Tests/Bench/Server/src/ArmoniK.Samples.Bench.Server.csproj b/Tests/Bench/Server/src/ArmoniK.Samples.Bench.Server.csproj index c13eac42d..9f8a7692e 100644 --- a/Tests/Bench/Server/src/ArmoniK.Samples.Bench.Server.csproj +++ b/Tests/Bench/Server/src/ArmoniK.Samples.Bench.Server.csproj @@ -25,7 +25,7 @@ - + diff --git a/Tests/Common/Client/src/ArmoniK.Core.Common.Tests.Client.csproj b/Tests/Common/Client/src/ArmoniK.Core.Common.Tests.Client.csproj index 1882e7af9..67a9f50c6 100644 --- a/Tests/Common/Client/src/ArmoniK.Core.Common.Tests.Client.csproj +++ b/Tests/Common/Client/src/ArmoniK.Core.Common.Tests.Client.csproj @@ -25,7 +25,7 @@ - + diff --git a/Tests/Common/Client/src/GrpcChannelExt.cs b/Tests/Common/Client/src/GrpcChannelExt.cs index 5546420e1..c4d51eb5c 100644 --- a/Tests/Common/Client/src/GrpcChannelExt.cs +++ b/Tests/Common/Client/src/GrpcChannelExt.cs @@ -35,12 +35,10 @@ using Microsoft.Extensions.Logging; -using FilterDate = Armonik.Api.gRPC.V1.Tasks.FilterDate; using FilterField = Armonik.Api.gRPC.V1.Tasks.FilterField; using Filters = Armonik.Api.gRPC.V1.Tasks.Filters; using FiltersAnd = Armonik.Api.gRPC.V1.Tasks.FiltersAnd; using FilterStatus = Armonik.Api.gRPC.V1.Tasks.FilterStatus; -using FilterString = Armonik.Api.gRPC.V1.Tasks.FilterString; using TaskStatus = ArmoniK.Api.gRPC.V1.TaskStatus; namespace ArmoniK.Core.Common.Tests.Client; @@ -102,18 +100,18 @@ public static async Task LogStatsFromSessionAsync(this ChannelBase channel, { new FilterField { - String = new FilterString - { - Field = new TaskField - { - TaskSummaryField = new TaskSummaryField - { - Field = TaskSummaryEnumField.SessionId, - }, - }, - Value = sessionId, - Operator = FilterStringOperator.Equal, - }, + Field = new TaskField + { + TaskSummaryField = new TaskSummaryField + { + Field = TaskSummaryEnumField.SessionId, + }, + }, + FilterString = new FilterString + { + Value = sessionId, + Operator = FilterStringOperator.Equal, + }, }, }, }, @@ -293,48 +291,48 @@ private static IEnumerable FilterStatus(Timestamp createdA { new FilterField { - Date = new FilterDate - { - Field = new TaskField - { - TaskSummaryField = new TaskSummaryField - { - Field = TaskSummaryEnumField.CreatedAt, - }, - }, - Operator = FilterDateOperator.After, - Value = createdAfter, - }, + Field = new TaskField + { + TaskSummaryField = new TaskSummaryField + { + Field = TaskSummaryEnumField.CreatedAt, + }, + }, + FilterDate = new FilterDate + { + Operator = FilterDateOperator.After, + Value = createdAfter, + }, }, new FilterField { - Date = new FilterDate - { - Field = new TaskField - { - TaskSummaryField = new TaskSummaryField - { - Field = TaskSummaryEnumField.EndedAt, - }, - }, - Operator = FilterDateOperator.Before, - Value = endedBefore, - }, + Field = new TaskField + { + TaskSummaryField = new TaskSummaryField + { + Field = TaskSummaryEnumField.EndedAt, + }, + }, + FilterDate = new FilterDate + { + Operator = FilterDateOperator.Before, + Value = endedBefore, + }, }, new FilterField { - Status = new FilterStatus - { - Field = new TaskField - { - TaskSummaryField = new TaskSummaryField - { - Field = TaskSummaryEnumField.Status, - }, - }, - Operator = FilterStatusOperator.Equal, - Value = status, - }, + Field = new TaskField + { + TaskSummaryField = new TaskSummaryField + { + Field = TaskSummaryEnumField.Status, + }, + }, + FilterStatus = new FilterStatus + { + Operator = FilterStatusOperator.Equal, + Value = status, + }, }, }, }); diff --git a/Tests/HtcMock/Server/src/ArmoniK.Samples.HtcMock.Server.csproj b/Tests/HtcMock/Server/src/ArmoniK.Samples.HtcMock.Server.csproj index 9de5d46d7..2a4ccee23 100644 --- a/Tests/HtcMock/Server/src/ArmoniK.Samples.HtcMock.Server.csproj +++ b/Tests/HtcMock/Server/src/ArmoniK.Samples.HtcMock.Server.csproj @@ -25,7 +25,7 @@ - + diff --git a/Tests/Stream/Client/ArmoniK.Extensions.Common.StreamWrapper.Tests.Client.csproj b/Tests/Stream/Client/ArmoniK.Extensions.Common.StreamWrapper.Tests.Client.csproj index 892f8a798..66fb49b81 100644 --- a/Tests/Stream/Client/ArmoniK.Extensions.Common.StreamWrapper.Tests.Client.csproj +++ b/Tests/Stream/Client/ArmoniK.Extensions.Common.StreamWrapper.Tests.Client.csproj @@ -25,7 +25,7 @@ - + diff --git a/Tests/Stream/Server/ArmoniK.Extensions.Common.StreamWrapper.Tests.Server.csproj b/Tests/Stream/Server/ArmoniK.Extensions.Common.StreamWrapper.Tests.Server.csproj index 01d750310..2f3570d60 100644 --- a/Tests/Stream/Server/ArmoniK.Extensions.Common.StreamWrapper.Tests.Server.csproj +++ b/Tests/Stream/Server/ArmoniK.Extensions.Common.StreamWrapper.Tests.Server.csproj @@ -25,7 +25,7 @@ - +