fix(transport): preserve MinTimeBetweenRuns + ExternalSystem retry fields in bundle DTOs
Add TimeSpan? MinTimeBetweenRuns to TemplateScriptDto and int MaxRetries / TimeSpan RetryDelay to ExternalSystemDto; wire both directions in EntitySerializer. Extends the existing script round-trip assertion and adds Roundtrip_external_system_preserves_retry_config.
This commit is contained in:
@@ -87,7 +87,8 @@ public sealed record TemplateScriptDto(
|
|||||||
string? TriggerConfiguration,
|
string? TriggerConfiguration,
|
||||||
string? ParameterDefinitions,
|
string? ParameterDefinitions,
|
||||||
string? ReturnDefinition,
|
string? ReturnDefinition,
|
||||||
bool IsLocked);
|
bool IsLocked,
|
||||||
|
TimeSpan? MinTimeBetweenRuns);
|
||||||
|
|
||||||
public sealed record TemplateCompositionDto(
|
public sealed record TemplateCompositionDto(
|
||||||
string InstanceName,
|
string InstanceName,
|
||||||
@@ -103,6 +104,8 @@ public sealed record ExternalSystemDto(
|
|||||||
string Name,
|
string Name,
|
||||||
string BaseUrl,
|
string BaseUrl,
|
||||||
string AuthType,
|
string AuthType,
|
||||||
|
int MaxRetries,
|
||||||
|
TimeSpan RetryDelay,
|
||||||
IReadOnlyList<ExternalSystemMethodDto> Methods,
|
IReadOnlyList<ExternalSystemMethodDto> Methods,
|
||||||
SecretsBlock? Secrets);
|
SecretsBlock? Secrets);
|
||||||
|
|
||||||
|
|||||||
@@ -55,7 +55,8 @@ public sealed class EntitySerializer
|
|||||||
TriggerConfiguration: s.TriggerConfiguration,
|
TriggerConfiguration: s.TriggerConfiguration,
|
||||||
ParameterDefinitions: s.ParameterDefinitions,
|
ParameterDefinitions: s.ParameterDefinitions,
|
||||||
ReturnDefinition: s.ReturnDefinition,
|
ReturnDefinition: s.ReturnDefinition,
|
||||||
IsLocked: s.IsLocked)).ToList(),
|
IsLocked: s.IsLocked,
|
||||||
|
MinTimeBetweenRuns: s.MinTimeBetweenRuns)).ToList(),
|
||||||
Compositions: t.Compositions.Select(c => new TemplateCompositionDto(
|
Compositions: t.Compositions.Select(c => new TemplateCompositionDto(
|
||||||
InstanceName: c.InstanceName,
|
InstanceName: c.InstanceName,
|
||||||
ComposedTemplateName: templateNameById.TryGetValue(c.ComposedTemplateId, out var cn) ? cn : string.Empty)).ToList())).ToList(),
|
ComposedTemplateName: templateNameById.TryGetValue(c.ComposedTemplateId, out var cn) ? cn : string.Empty)).ToList())).ToList(),
|
||||||
@@ -89,6 +90,8 @@ public sealed class EntitySerializer
|
|||||||
Name: sys.Name,
|
Name: sys.Name,
|
||||||
BaseUrl: sys.EndpointUrl,
|
BaseUrl: sys.EndpointUrl,
|
||||||
AuthType: sys.AuthType,
|
AuthType: sys.AuthType,
|
||||||
|
MaxRetries: sys.MaxRetries,
|
||||||
|
RetryDelay: sys.RetryDelay,
|
||||||
Methods: methods,
|
Methods: methods,
|
||||||
Secrets: secrets);
|
Secrets: secrets);
|
||||||
}).ToList(),
|
}).ToList(),
|
||||||
@@ -204,6 +207,7 @@ public sealed class EntitySerializer
|
|||||||
ParameterDefinitions = s.ParameterDefinitions,
|
ParameterDefinitions = s.ParameterDefinitions,
|
||||||
ReturnDefinition = s.ReturnDefinition,
|
ReturnDefinition = s.ReturnDefinition,
|
||||||
IsLocked = s.IsLocked,
|
IsLocked = s.IsLocked,
|
||||||
|
MinTimeBetweenRuns = s.MinTimeBetweenRuns,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
return t;
|
return t;
|
||||||
@@ -253,6 +257,8 @@ public sealed class EntitySerializer
|
|||||||
{
|
{
|
||||||
Id = ix + 1,
|
Id = ix + 1,
|
||||||
AuthConfiguration = dto.Secrets?.Values.TryGetValue("AuthConfiguration", out var auth) == true ? auth : null,
|
AuthConfiguration = dto.Secrets?.Values.TryGetValue("AuthConfiguration", out var auth) == true ? auth : null,
|
||||||
|
MaxRetries = dto.MaxRetries,
|
||||||
|
RetryDelay = dto.RetryDelay,
|
||||||
};
|
};
|
||||||
externalSystems.Add(sys);
|
externalSystems.Add(sys);
|
||||||
foreach (var m in dto.Methods)
|
foreach (var m in dto.Methods)
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ public sealed class EntitySerializerTests
|
|||||||
ParameterDefinitions = "[]",
|
ParameterDefinitions = "[]",
|
||||||
ReturnDefinition = "void",
|
ReturnDefinition = "void",
|
||||||
IsLocked = false,
|
IsLocked = false,
|
||||||
|
MinTimeBetweenRuns = TimeSpan.FromSeconds(30),
|
||||||
});
|
});
|
||||||
|
|
||||||
var assembly = new Template("Assembly") { Id = 2, FolderId = 1 };
|
var assembly = new Template("Assembly") { Id = 2, FolderId = 1 };
|
||||||
@@ -133,6 +134,7 @@ public sealed class EntitySerializerTests
|
|||||||
Assert.Equal("OnUpdate", rtScript.Name);
|
Assert.Equal("OnUpdate", rtScript.Name);
|
||||||
Assert.Equal("return 1;", rtScript.Code);
|
Assert.Equal("return 1;", rtScript.Code);
|
||||||
Assert.Equal("Periodic", rtScript.TriggerType);
|
Assert.Equal("Periodic", rtScript.TriggerType);
|
||||||
|
Assert.Equal(TimeSpan.FromSeconds(30), rtScript.MinTimeBetweenRuns);
|
||||||
|
|
||||||
var rtAssembly = Assert.Single(roundTripped.Templates, t => t.Name == "Assembly");
|
var rtAssembly = Assert.Single(roundTripped.Templates, t => t.Name == "Assembly");
|
||||||
var rtComp = Assert.Single(rtAssembly.Compositions);
|
var rtComp = Assert.Single(rtAssembly.Compositions);
|
||||||
@@ -164,6 +166,27 @@ public sealed class EntitySerializerTests
|
|||||||
Assert.Equal(rtRoot.Id, rtChild.ParentFolderId);
|
Assert.Equal(rtRoot.Id, rtChild.ParentFolderId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[Fact]
|
||||||
|
public void Roundtrip_external_system_preserves_retry_config()
|
||||||
|
{
|
||||||
|
var sys = new ExternalSystemDefinition("billing", "https://billing/api", "Basic")
|
||||||
|
{
|
||||||
|
Id = 1,
|
||||||
|
MaxRetries = 5,
|
||||||
|
RetryDelay = TimeSpan.FromSeconds(15),
|
||||||
|
};
|
||||||
|
var aggregate = MakeEmptyAggregate() with { ExternalSystems = new[] { sys } };
|
||||||
|
|
||||||
|
var sut = new EntitySerializer();
|
||||||
|
var dto = sut.ToBundleContent(aggregate);
|
||||||
|
var roundTripped = sut.FromBundleContent(dto);
|
||||||
|
|
||||||
|
var rtSys = Assert.Single(roundTripped.ExternalSystems);
|
||||||
|
Assert.Equal("billing", rtSys.Name);
|
||||||
|
Assert.Equal(5, rtSys.MaxRetries);
|
||||||
|
Assert.Equal(TimeSpan.FromSeconds(15), rtSys.RetryDelay);
|
||||||
|
}
|
||||||
|
|
||||||
[Fact]
|
[Fact]
|
||||||
public void FromDto_with_null_SecretsBlock_yields_entity_with_default_empty_secrets()
|
public void FromDto_with_null_SecretsBlock_yields_entity_with_default_empty_secrets()
|
||||||
{
|
{
|
||||||
@@ -173,7 +196,7 @@ public sealed class EntitySerializerTests
|
|||||||
SharedScripts: Array.Empty<SharedScriptDto>(),
|
SharedScripts: Array.Empty<SharedScriptDto>(),
|
||||||
ExternalSystems: new[]
|
ExternalSystems: new[]
|
||||||
{
|
{
|
||||||
new ExternalSystemDto("erp", "https://x", "None", Array.Empty<ExternalSystemMethodDto>(), Secrets: null),
|
new ExternalSystemDto("erp", "https://x", "None", MaxRetries: 3, RetryDelay: TimeSpan.FromSeconds(5), Array.Empty<ExternalSystemMethodDto>(), Secrets: null),
|
||||||
},
|
},
|
||||||
DatabaseConnections: Array.Empty<DatabaseConnectionDto>(),
|
DatabaseConnections: Array.Empty<DatabaseConnectionDto>(),
|
||||||
NotificationLists: Array.Empty<NotificationListDto>(),
|
NotificationLists: Array.Empty<NotificationListDto>(),
|
||||||
|
|||||||
Reference in New Issue
Block a user