refactor(configmanager): migrate to per-file pipeline system
Align ConfigManager with DataSync's per-file pipeline format (pipeline.*.json) by reusing EtlPipelineConfig types directly, eliminating duplicate models and simplifying the codebase. Removes ~3200 lines of obsolete code.
This commit is contained in:
+50
-28
@@ -1,26 +1,42 @@
|
||||
using JdeScoping.ConfigManager.Models;
|
||||
using JdeScoping.ConfigManager.ViewModels.PipelineSteps;
|
||||
using JdeScoping.DataSync.Configuration;
|
||||
using System.Text.Json;
|
||||
|
||||
namespace JdeScoping.ConfigManager.Tests.ViewModels;
|
||||
|
||||
public class RegexTransformerViewModelTests
|
||||
{
|
||||
private static readonly JsonSerializerOptions JsonOptions = new()
|
||||
{
|
||||
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
|
||||
};
|
||||
|
||||
private static TransformElement CreateElement(object config)
|
||||
{
|
||||
var json = JsonSerializer.Serialize(config, JsonOptions);
|
||||
using var doc = JsonDocument.Parse(json);
|
||||
return new TransformElement
|
||||
{
|
||||
TransformType = "Regex",
|
||||
Config = doc.RootElement.Clone()
|
||||
};
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_FromModel_LoadsAllProperties()
|
||||
public void Constructor_FromElement_LoadsAllProperties()
|
||||
{
|
||||
// Arrange
|
||||
var model = new TransformerModel
|
||||
var element = CreateElement(new
|
||||
{
|
||||
Type = "Regex",
|
||||
ColumnName = "BatchID",
|
||||
Pattern = "^IIS_",
|
||||
Replacement = "",
|
||||
IgnoreCase = true,
|
||||
NonMatchBehavior = NonMatchBehavior.ReturnEmpty
|
||||
};
|
||||
columnName = "BatchID",
|
||||
pattern = "^IIS_",
|
||||
replacement = "",
|
||||
ignoreCase = true,
|
||||
nonMatchBehavior = "ReturnEmpty"
|
||||
});
|
||||
|
||||
// Act
|
||||
var vm = new RegexTransformerViewModel(model, () => { });
|
||||
var vm = new RegexTransformerViewModel(element, () => { });
|
||||
|
||||
// Assert
|
||||
Assert.Equal("BatchID", vm.ColumnName);
|
||||
@@ -32,19 +48,17 @@ public class RegexTransformerViewModelTests
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public void Constructor_FromModel_MatchExtractMode_WhenReplacementNull()
|
||||
public void Constructor_FromElement_MatchExtractMode_WhenReplacementNull()
|
||||
{
|
||||
// Arrange
|
||||
var model = new TransformerModel
|
||||
var element = CreateElement(new
|
||||
{
|
||||
Type = "Regex",
|
||||
ColumnName = "Code",
|
||||
Pattern = @"(\d+)",
|
||||
Replacement = null
|
||||
};
|
||||
columnName = "Code",
|
||||
pattern = @"(\d+)"
|
||||
});
|
||||
|
||||
// Act
|
||||
var vm = new RegexTransformerViewModel(model, () => { });
|
||||
var vm = new RegexTransformerViewModel(element, () => { });
|
||||
|
||||
// Assert
|
||||
Assert.False(vm.IsFindReplaceMode);
|
||||
@@ -66,15 +80,18 @@ public class RegexTransformerViewModelTests
|
||||
};
|
||||
|
||||
// Act
|
||||
var model = vm.ToModel();
|
||||
var element = vm.ToModel();
|
||||
|
||||
// Assert
|
||||
Assert.Equal("Regex", model.Type);
|
||||
Assert.Equal("BatchID", model.ColumnName);
|
||||
Assert.Equal("^IIS_", model.Pattern);
|
||||
Assert.Equal("", model.Replacement);
|
||||
Assert.True(model.IgnoreCase);
|
||||
Assert.Equal(NonMatchBehavior.KeepOriginal, model.NonMatchBehavior);
|
||||
Assert.Equal("Regex", element.TransformType);
|
||||
Assert.True(element.Config.HasValue);
|
||||
|
||||
// Parse the config to verify
|
||||
var config = element.Config!.Value;
|
||||
Assert.Equal("BatchID", config.GetProperty("columnName").GetString());
|
||||
Assert.Equal("^IIS_", config.GetProperty("pattern").GetString());
|
||||
Assert.Equal("", config.GetProperty("replacement").GetString());
|
||||
Assert.True(config.GetProperty("ignoreCase").GetBoolean());
|
||||
}
|
||||
|
||||
[Fact]
|
||||
@@ -89,10 +106,15 @@ public class RegexTransformerViewModelTests
|
||||
};
|
||||
|
||||
// Act
|
||||
var model = vm.ToModel();
|
||||
var element = vm.ToModel();
|
||||
|
||||
// Assert
|
||||
Assert.Null(model.Replacement); // null indicates Match & Extract mode
|
||||
Assert.True(element.Config.HasValue);
|
||||
var config = element.Config!.Value;
|
||||
|
||||
// replacement should be null in Match & Extract mode
|
||||
Assert.True(config.TryGetProperty("replacement", out var replacement));
|
||||
Assert.Equal(JsonValueKind.Null, replacement.ValueKind);
|
||||
}
|
||||
|
||||
[Fact]
|
||||
|
||||
Reference in New Issue
Block a user