Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rename statuscode to align with altinn-notifications #14

Merged
merged 2 commits into from
Feb 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/Altinn.Notifications.Sms.Core/Status/SmsSendResult.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ public enum SmsSendResult
Failed_Expired,

/// <summary>
/// Sms send operation failed due to invalid receiver
/// Sms send operation failed due to invalid recipient e.g. receiver number
/// </summary>
Failed_InvalidReceiver,
Failed_InvalidRecipient,

/// <summary>
/// The SMS was undeliverable (not a valid number or no available route to destination).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ public async Task<Result<string, SmsClientErrorResponse>> SendAsync(Core.Sending

if (result.StatusText.StartsWith("Invalid RCV"))
{
return new SmsClientErrorResponse { SendResult = SmsSendResult.Failed_InvalidReceiver, ErrorMessage = result.StatusText };
return new SmsClientErrorResponse { SendResult = SmsSendResult.Failed_InvalidRecipient, ErrorMessage = result.StatusText };
}

_logger.LogInformation("// SmsClient // SendAsync // Failed to send SMS. Status: {StatusText}", result.StatusText);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,22 +47,22 @@ public async Task SendAsync_GatewayReferenceGenerated_SendingAccepted()
}

[Fact]
public async Task SendAsync_InvalidReceiver_PublishedToExpectedKafkaTopic()
public async Task SendAsync_InvalidRecipient_PublishedToExpectedKafkaTopic()
{
// Arrange
Guid id = Guid.NewGuid();
Notifications.Sms.Core.Sending.Sms sms = new(id, "sender", "recipient", "message");

Mock<ISmsClient> clientMock = new();
clientMock.Setup(c => c.SendAsync(It.IsAny<Notifications.Sms.Core.Sending.Sms>()))
.ReturnsAsync(new SmsClientErrorResponse { SendResult = SmsSendResult.Failed_InvalidReceiver, ErrorMessage = "Receiver is wrong" });
.ReturnsAsync(new SmsClientErrorResponse { SendResult = SmsSendResult.Failed_InvalidRecipient, ErrorMessage = "Receiver is wrong" });

Mock<ICommonProducer> producerMock = new();
producerMock.Setup(p => p.ProduceAsync(
It.Is<string>(s => s.Equals(nameof(_topicSettings.SmsStatusUpdatedTopicName))),
It.Is<string>(s =>
s.Contains($"\"notificationId\":\"{id}\"") &&
s.Contains("\"sendResult\":\"Failed_InvalidReceiver\""))));
s.Contains("\"sendResult\":\"Failed_InvalidRecipient\""))));

var sut = new SendingService(clientMock.Object, producerMock.Object, _topicSettings);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ await result.Match(
async actualErrorResponse =>
{
await Task.CompletedTask;
Assert.Equal(SmsSendResult.Failed_InvalidReceiver, actualErrorResponse.SendResult);
Assert.Equal(SmsSendResult.Failed_InvalidRecipient, actualErrorResponse.SendResult);
Assert.NotNull(actualErrorResponse.ErrorMessage);
});
}
Expand Down
Loading