Skip to content

Commit e10819d

Browse files
committed
Fix test assertion for FilterOlEventTestData and support null in FilterOlMessage
1 parent 4108022 commit e10819d

File tree

4 files changed

+14
-4
lines changed

4 files changed

+14
-4
lines changed

function-app/adb-to-purview/src/Function.Domain/Helpers/OlProcessing/ValidateOlEvent.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ public ValidateOlEvent(ILoggerFactory loggerFactory)
3939
/// </summary>
4040
/// <param name="olEvent">OpenLineage Event message</param>
4141
/// <returns>true if input is valid, false if not</returns>
42-
public bool Validate(Event olEvent){
42+
public bool Validate(Event? olEvent){
43+
if (olEvent == null){
44+
_log.LogWarning("Event considered NOT valid as it was null");
45+
return false;
46+
}
4347
_log.LogInformation($"Validating input of an event with {olEvent.Inputs.Count} inputs and {olEvent.Outputs.Count} outputs");
4448
if (olEvent.Inputs.Count > 0 && olEvent.Outputs.Count > 0)
4549
{

function-app/adb-to-purview/src/Function.Domain/Services/IOlFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ namespace Function.Domain.Services
88
{
99
public interface IOlFilter
1010
{
11-
bool FilterOlMessage(Event olEvent);
11+
bool FilterOlMessage(Event? olEvent);
1212
string GetJobNamespace(Event olEvent);
1313
}
1414
}

function-app/adb-to-purview/src/Function.Domain/Services/OlFilter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ public OlFilter(ILoggerFactory loggerFactory)
3838
/// true: if the message should be passed on for further processing
3939
/// false: if the message should be filtered out
4040
/// </returns>
41-
public bool FilterOlMessage(Event olEvent)
41+
public bool FilterOlMessage(Event? olEvent)
4242
{
4343
try {
4444
var validateEvent = new ValidateOlEvent(_loggerFactory);

function-app/adb-to-purview/tests/unit-tests/Function.Domain/Services/OlFilterTests.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,13 @@
44
using Xunit;
55
using Microsoft.Extensions.Logging.Abstractions;
66
using Function.Domain.Services;
7+
using Function.Domain.Helpers;
8+
using Microsoft.Extensions.Logging;
79

810
namespace UnitTests.Function.Domain.Services
911
{
1012
public class OlFilterTests{
13+
private IEventParser _eventParser;
1114

1215
private NullLoggerFactory _mockLoggerFactory;
1316

@@ -21,7 +24,10 @@ public OlFilterTests()
2124
public void FilterOlEvent_bool_FilterGoodEvents(string msgEvent, bool expectedResult)
2225
{
2326
IOlFilter filterOlEvent = new OlFilter(_mockLoggerFactory);
24-
var rslt = filterOlEvent.FilterOlMessage(msgEvent);
27+
var _log = _mockLoggerFactory.CreateLogger<OlFilterTests>();
28+
var _eventParser = new EventParser(_log);
29+
var parsedEvent = _eventParser.ParseOlEvent(msgEvent);
30+
var rslt = filterOlEvent.FilterOlMessage(parsedEvent);
2531

2632
Xunit.Assert.Equal(expectedResult, rslt);
2733
}

0 commit comments

Comments
 (0)