Skip to content

Commit

Permalink
fix: test fixes, gRPC DateTime parsing corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
tpz committed Dec 5, 2023
1 parent 0d8b9fe commit 64e8bd9
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 11 deletions.
17 changes: 12 additions & 5 deletions EvitaDB.Client/Converters/DataTypes/EvitaDataTypesConverter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -653,14 +653,21 @@ public static DateTimeOffset ToDateTimeOffset(GrpcOffsetDateTime offsetDateTimeV
TimeSpan.FromHours(int.Parse(offsetDateTimeValue.Offset.Substring(1, 2)));
bool add = offsetDateTimeValue.Offset.ElementAt(0) == '+';
TimeSpan offset = add ? hourOffset : hourOffset.Negate();
return ToDateTimeOffset(offsetDateTimeValue.Timestamp)
.ToOffset(offset);
try
{
// because when max value is present in UTC, we cannot add the offset to it
return ToDateTimeOffset(offsetDateTimeValue.Timestamp)
.ToOffset(offset);
}
catch (Exception)
{
return ToDateTimeOffset(offsetDateTimeValue.Timestamp);
}
}

private static DateTimeOffset ToDateTimeOffset(Timestamp timestamp)
{
int milliseconds = timestamp.Nanos / 1000000;
return DateTimeOffset.UnixEpoch.AddSeconds(timestamp.Seconds).AddMilliseconds(milliseconds);
return timestamp.ToDateTimeOffset();
}

public static DateTimeOffset[] ToDateTimeOffsetArray(GrpcOffsetDateTimeArray arrayValue)
Expand Down Expand Up @@ -1101,4 +1108,4 @@ public static GrpcPredecessor ToGrpcPredecessor(Predecessor predecessor)
return predecessor.Head ? Predecessor.Head :
predecessor.PredecessorId.HasValue ? new Predecessor(predecessor.PredecessorId.Value) : null;
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ public override void WriteJson(JsonWriter writer, object? value, JsonSerializer
public override object ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer)
{
// Implement if needed for deserialization
throw new NotImplementedException();
throw new NotSupportedException();
}

public override bool CanConvert(Type objectType)
Expand Down
12 changes: 10 additions & 2 deletions EvitaDB.QueryValidator/evita-csharp-query-template.txt
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,16 @@ using static EvitaDB.Client.Queries.Requires.EmptyHierarchicalEntityBehaviour;

public class DynamicClass
{
private static readonly EvitaClientConfiguration EvitaClientConfiguration = new EvitaClientConfiguration.Builder()
.SetHost("#HOST#")
private const string Host = "#HOST#";
private static readonly EvitaClientConfiguration EvitaClientConfiguration =
Host == "localhost" ? new EvitaClientConfiguration.Builder()
.SetHost(Host)
.SetPort(5556)
.SetUseGeneratedCertificate(true)
.SetUsingTrustedRootCaCertificate(false)
.Build() :
new EvitaClientConfiguration.Builder()
.SetHost(Host)
.SetPort(5556)
.SetUseGeneratedCertificate(false)
.SetUsingTrustedRootCaCertificate(true)
Expand Down
2 changes: 1 addition & 1 deletion EvitaDB.Test/SetupFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,4 +158,4 @@ public EvitaTestSuite(EvitaClient client, IContainer container)
Container = container;
}
}
}
}
2 changes: 0 additions & 2 deletions EvitaDB.Test/Tests/EvitaClientDemoQueryTest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,6 @@ public void ShouldBeAbleToExecuteComplexQueryAndGetResults()
Collection("Product"),
FilterBy(
Or(
AttributeInSet("visibility", "yes", "no"),
EntityLocaleEquals(new CultureInfo("cs-CZ")),
HierarchyWithin("categories", null, ExcludingRoot()),
Not(
Expand All @@ -141,7 +140,6 @@ public void ShouldBeAbleToExecuteComplexQueryAndGetResults()
PriceBetween(100m, 200.5m),
PriceValidInNow()
),
AttributeBetween("frekvence-od", 20m, 95.3m),
UserFilter(
FacetHaving("variantParameters", EntityPrimaryKeyInSet(1, 2, 3))
)
Expand Down

0 comments on commit 64e8bd9

Please sign in to comment.