From 60ca350ffce01a8ceb64dc7ffa656ae71208fa1c Mon Sep 17 00:00:00 2001 From: "jack.lewis" Date: Tue, 9 Jan 2024 09:47:56 +0000 Subject: [PATCH] code review fixes --- .../Ingest/Image/Appetiser/AppetiserClientTests.cs | 1 - .../Ingest/Image/Appetiser/AppetiserClient.cs | 7 +++---- .../Image/Appetiser/Models/AppetiserResponse.cs | 3 +-- .../Appetiser/Models/AppetiserResponseErrorModel.cs | 6 +----- .../Appetiser/Models/AppetiserResponseModel.cs | 13 +------------ 5 files changed, 6 insertions(+), 24 deletions(-) diff --git a/src/protagonist/Engine.Tests/Ingest/Image/Appetiser/AppetiserClientTests.cs b/src/protagonist/Engine.Tests/Ingest/Image/Appetiser/AppetiserClientTests.cs index 132a4037a..be3d7d951 100644 --- a/src/protagonist/Engine.Tests/Ingest/Image/Appetiser/AppetiserClientTests.cs +++ b/src/protagonist/Engine.Tests/Ingest/Image/Appetiser/AppetiserClientTests.cs @@ -82,7 +82,6 @@ public async Task ProcessImage_CreatesAndRemovesRequiredDirectories() [Fact] public async Task ProcessImage_False_IfImageProcessorCallFails() { - // Arrange // Arrange var imageProcessorResponse = new AppetiserResponseErrorModel() { diff --git a/src/protagonist/Engine/Ingest/Image/Appetiser/AppetiserClient.cs b/src/protagonist/Engine/Ingest/Image/Appetiser/AppetiserClient.cs index e27abd9ef..86c3c3e1d 100644 --- a/src/protagonist/Engine/Ingest/Image/Appetiser/AppetiserClient.cs +++ b/src/protagonist/Engine/Ingest/Image/Appetiser/AppetiserClient.cs @@ -98,7 +98,7 @@ public async Task ProcessImage(IngestionContext context) return (dest, thumb); } - private async Task CallImageProcessor(IngestionContext context, + private async Task CallImageProcessor(IngestionContext context, ImageProcessorFlags processorFlags) { // call tizer/appetiser @@ -113,9 +113,8 @@ private async Task CallImageProcessor(IngestionContext contex } using var response = await httpClient.SendAsync(request); - - // TODO - it's possible to get a 200 when appetiser doesn't do anything, e.g. body not understood - AppetiserResponse? responseModel = null; + + IAppetiserResponse? responseModel; if (response.IsSuccessStatusCode) { diff --git a/src/protagonist/Engine/Ingest/Image/Appetiser/Models/AppetiserResponse.cs b/src/protagonist/Engine/Ingest/Image/Appetiser/Models/AppetiserResponse.cs index 1e8cd938e..5efd975ed 100644 --- a/src/protagonist/Engine/Ingest/Image/Appetiser/Models/AppetiserResponse.cs +++ b/src/protagonist/Engine/Ingest/Image/Appetiser/Models/AppetiserResponse.cs @@ -1,6 +1,5 @@ namespace Engine.Ingest.Image.Appetiser; -public class AppetiserResponse +public interface IAppetiserResponse { - public ResponseType ResponseType { get; init; } } \ No newline at end of file diff --git a/src/protagonist/Engine/Ingest/Image/Appetiser/Models/AppetiserResponseErrorModel.cs b/src/protagonist/Engine/Ingest/Image/Appetiser/Models/AppetiserResponseErrorModel.cs index b803a2d82..6b2729e5f 100644 --- a/src/protagonist/Engine/Ingest/Image/Appetiser/Models/AppetiserResponseErrorModel.cs +++ b/src/protagonist/Engine/Ingest/Image/Appetiser/Models/AppetiserResponseErrorModel.cs @@ -3,12 +3,8 @@ /// /// Response model for receiving error requests back from Appetiser. /// -public class AppetiserResponseErrorModel : AppetiserResponse +public class AppetiserResponseErrorModel : IAppetiserResponse { - public AppetiserResponseErrorModel() - { - ResponseType = ResponseType.ErrorResponse; - } public string Message { get; set; } public string Status { get; set; } } \ No newline at end of file diff --git a/src/protagonist/Engine/Ingest/Image/Appetiser/Models/AppetiserResponseModel.cs b/src/protagonist/Engine/Ingest/Image/Appetiser/Models/AppetiserResponseModel.cs index 3befdca64..0c81f0f08 100644 --- a/src/protagonist/Engine/Ingest/Image/Appetiser/Models/AppetiserResponseModel.cs +++ b/src/protagonist/Engine/Ingest/Image/Appetiser/Models/AppetiserResponseModel.cs @@ -1,21 +1,10 @@ namespace Engine.Ingest.Image.Appetiser; -public enum ResponseType -{ - SuccessResponse, - ErrorResponse -} - /// /// Response model for receiving requests back from Appetiser. /// -public class AppetiserResponseModel : AppetiserResponse +public class AppetiserResponseModel : IAppetiserResponse { - public AppetiserResponseModel() - { - ResponseType = ResponseType.SuccessResponse; - } - public string ImageId { get; set; } public string JobId { get; set; } public string Optimisation { get; set; }