Skip to content

Commit

Permalink
re-adding validation for tests
Browse files Browse the repository at this point in the history
Signed-off-by: Neil South <[email protected]>
  • Loading branch information
neildsouth committed Jan 15, 2024
1 parent 18fbfb7 commit 3e109c6
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
3 changes: 3 additions & 0 deletions src/InformaticsGateway/Logging/Log.5000.DataPlugins.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,5 +44,8 @@ public static partial class Log

[LoggerMessage(EventId = 5007, Level = LogLevel.Error, Message = "Error executing plug-in: {plugin}.")]
public static partial void ErrorAddingOutputDataPlugIn(this ILogger logger, Exception d, string plugin);

[LoggerMessage(EventId = 5008, Level = LogLevel.Trace, Message = "Import plugin executed: {pluginName}. now: {fileMetadata}")]
public static partial void InputDataPlugInEngineexecuted(this ILogger logger, string pluginName, string fileMetadata);
}
}
17 changes: 15 additions & 2 deletions src/InformaticsGateway/Services/HealthLevel7/MllpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -159,10 +159,23 @@ private async Task SendAcknowledgment(INetworkStream clientStream, Message messa

if (ShouldSendAcknowledgment(message))
{
var ackMessage = message.GetACK(true);
Message ackMessage = message;
try
{
ackMessage = message.GetACK(false);
}
catch (Exception ex)
{
_logger.ErrorGeneratingHl7Acknowledgment(ex, message.HL7Message);
_exceptions.Add(ex);
return;
}

if (ackMessage is null)
{
_logger.ErrorGeneratingHl7Acknowledgment(new Exception(), message.HL7Message);
var ex = new Exception("Error generating HL7 acknowledgment.");
_logger.ErrorGeneratingHl7Acknowledgment(ex, message.HL7Message);
_exceptions.Add(ex);
return;
}
var ackData = new ReadOnlyMemory<byte>(ackMessage.GetMLLP());
Expand Down
4 changes: 2 additions & 2 deletions src/InformaticsGateway/Services/HealthLevel7/MllpService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -284,7 +284,7 @@ public async Task SendMllp(IPAddress address, int port, string hl7Message, Cance
catch (Exception ex)
{
_logger.Hl7SendException(ex);
throw new Hl7SendException("Send exception");
throw new Hl7SendException($"Send exception: {ex.Message}");
}
}

Expand Down Expand Up @@ -340,7 +340,7 @@ private async Task EnsureAck(NetworkStream networkStream)
foreach (var message in _rawHl7Messages)
{
var hl7Message = new Message(message);
hl7Message.ParseMessage(true);
hl7Message.ParseMessage(false);
if (hl7Message.MessageStructure == "ACK")
{
return;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,8 @@ public async Task ReceiveData_InvalidMessage()
{
await Task.Run(() =>
{
Assert.Empty(results.Messages);
Assert.NotNull(results.AggregateException);
Assert.Single(results.AggregateException.InnerExceptions);
Assert.Contains("Failed to validate the message with error", results.AggregateException.InnerExceptions.First().Message);
Assert.Equal(2, results.AggregateException.InnerExceptions.Count);
});
});
await client.Start(action, _cancellationTokenSource.Token);
Expand Down

0 comments on commit 3e109c6

Please sign in to comment.