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

Lagt til klientMeldingId #73

Merged
merged 21 commits into from
Feb 15, 2022
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
d26f4fd
Lagt til klientMeldingId
jarleborsheim Jan 27, 2022
51cca47
Lagt til optional klientMeldingId
jarleborsheim Feb 3, 2022
d0e12ed
Oppdatert etter fiks på send.client
jarleborsheim Feb 3, 2022
4375ef4
Korrigert MeldingRequest til at KlientMeldingId skal ikke være requir…
jarleborsheim Feb 7, 2022
9750b11
KlienMeldingId korrekt optional på SvarSender også
jarleborsheim Feb 7, 2022
e1321f8
Fikset interface
jarleborsheim Feb 7, 2022
81e0422
Tatt bort using som ikke er i bruk
jarleborsheim Feb 8, 2022
93e3b1a
Mapper klientMeldingId til header i stedet for å være egen property
jarleborsheim Feb 9, 2022
f3aa628
Erstattet med const
jarleborsheim Feb 9, 2022
520e2d1
Bumpet til release av fiks-io-send-client
jarleborsheim Feb 9, 2022
3a388a4
Unit tests for FromSentMessageApiModel
jarleborsheim Feb 9, 2022
20b27af
Tatt bort auto generering av klientMeldingId på svar
jarleborsheim Feb 9, 2022
b77719f
Ny unit-test for MeldingRequest
jarleborsheim Feb 9, 2022
9527467
Logger feilmelding hvis KlientMeldingId ikke var på Guid format
jarleborsheim Feb 11, 2022
fa9a80a
Endret til ilogger
jarleborsheim Feb 13, 2022
5b3ba06
Merge branch 'master' into jb-klientMeldingId
jarleborsheim Feb 14, 2022
b0113c8
Tatt bort logging
jarleborsheim Feb 14, 2022
8d6479e
Merge
jarleborsheim Feb 14, 2022
533f616
TryParse guid
jarleborsheim Feb 14, 2022
e98bac0
Lagt til flere tester
jarleborsheim Feb 14, 2022
50e3d7b
Returner null hvis klientMeldingId var null og guid.empty hvis parsin…
jarleborsheim Feb 15, 2022
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
1 change: 1 addition & 0 deletions KS.Fiks.IO.Client.Tests/FiksIOClientFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ public FiksIOClientFixture()
public Mock<ISendHandler> SendHandlerMock { get; }

public MeldingRequest DefaultRequest => new MeldingRequest(
Guid.NewGuid(),
Guid.NewGuid(),
Guid.NewGuid(),
"defaultType");
Expand Down
1 change: 1 addition & 0 deletions KS.Fiks.IO.Client.Tests/FiksIOClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -154,6 +154,7 @@ public async Task SendReturnsExpectedSentMessage()
{
var expectedMessage = new SendtMelding(
meldingId: Guid.NewGuid(),
Guid.NewGuid(),
meldingType: "msgType",
avsenderKontoId: Guid.NewGuid(),
mottakerKontoId: Guid.NewGuid(),
Expand Down
2 changes: 1 addition & 1 deletion KS.Fiks.IO.Client.Tests/KS.Fiks.IO.Client.Tests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
<PackageReference Include="FluentAssertions" Version="5.10.3" />
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.10.0" />
<PackageReference Include="KS.Fiks.ASiC-E" Version="1.0.3" />
<PackageReference Include="KS.Fiks.IO.Send.Client" Version="1.0.7" />
<PackageReference Include="KS.Fiks.IO.Send.Client" Version="1.0.8-build.20220203105354562" />
<PackageReference Include="KS.Fiks.Maskinporten.Client" Version="1.0.7" />
<PackageReference Include="Moq" Version="4.16.1" />
<PackageReference Include="Newtonsoft.Json" Version="[11.0.1, 13.0.1]" />
Expand Down
7 changes: 7 additions & 0 deletions KS.Fiks.IO.Client.Tests/Send/SendHandlerFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,15 @@ public SendHandlerFixture()
public MeldingRequest DefaultRequest => new MeldingRequest(
Guid.NewGuid(),
Guid.NewGuid(),
klientMeldingId: Guid.NewGuid(),
"defaultType");

public MeldingRequest DefaultRequest2 => new MeldingRequest(
Guid.NewGuid(),
Guid.NewGuid(),
klientMeldingId: Guid.NewGuid(),
"defaultType", TimeSpan.Zero, new Dictionary<string, string> {});

public SendHandlerFixture WithPublicKey(X509Certificate publicKey)
{
_publicKey = publicKey;
Expand Down
1 change: 1 addition & 0 deletions KS.Fiks.IO.Client.Tests/Send/SendHandlerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ public async Task CallsSendWithExpectedMessageSpecificationApiModel()
var request = new MeldingRequest(
avsenderKontoId: Guid.NewGuid(),
mottakerKontoId: Guid.NewGuid(),
klientMeldingId: Guid.NewGuid(),
meldingType: "Meldingsprotokoll",
ttl: TimeSpan.FromDays(2),
headere: null,
Expand Down
5 changes: 2 additions & 3 deletions KS.Fiks.IO.Client.Tests/Send/SvarSenderFixture.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,13 @@ public SvarSenderFixture WithNackRequeue(Action nackRequeue)
internal SvarSender CreateSut()
{
SetupMocks();
return new SvarSender(SendHandlerMock.Object, _mottattMelding,
new AmqpAcknowledgeManager(_ack, _nack, _nackWithRequeue));
return new SvarSender(SendHandlerMock.Object, _mottattMelding, new AmqpAcknowledgeManager(_ack, _nack, _nackWithRequeue));
}

private void SetupMocks()
{
SendHandlerMock.Setup(_ => _.Send(It.IsAny<MeldingRequest>(), It.IsAny<IPayload[]>()))
.ReturnsAsync(new SendtMelding(Guid.NewGuid(), "sendtMelding", Guid.NewGuid(), Guid.NewGuid(),
.ReturnsAsync(new SendtMelding(Guid.NewGuid(), Guid.NewGuid(), "sendtMelding", Guid.NewGuid(), Guid.NewGuid(),
TimeSpan.Zero, null));
}
}
Expand Down
2 changes: 1 addition & 1 deletion KS.Fiks.IO.Client/KS.Fiks.IO.Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
<ItemGroup>
<PackageReference Include="KS.Fiks.ASiC-E" Version="1.0.3" />
<PackageReference Include="KS.Fiks.Crypto" Version="1.0.4" />
<PackageReference Include="KS.Fiks.IO.Send.Client" Version="1.0.7" />
<PackageReference Include="KS.Fiks.IO.Send.Client" Version="1.0.8-build.20220203105354562" />
<PackageReference Include="KS.Fiks.Maskinporten.Client" Version="1.0.7" />
<PackageReference Include="RabbitMQ.Client" Version="6.2.1" />
<PackageReference Include="Newtonsoft.Json" Version="[11.0.1, 13.0.1]" />
Expand Down
2 changes: 2 additions & 0 deletions KS.Fiks.IO.Client/Models/IMelding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ public interface IMelding
{
Guid MeldingId { get; }

Guid? KlientMeldingId { get; }

string MeldingType { get; }

Guid AvsenderKontoId { get; }
Expand Down
5 changes: 5 additions & 0 deletions KS.Fiks.IO.Client/Models/MeldingBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ protected MeldingBase()

protected MeldingBase(
Guid meldingId,
Guid? klientMeldingId,
string meldingType,
Guid avsenderKontoId,
Guid mottakerKontoId,
Expand All @@ -21,6 +22,7 @@ protected MeldingBase(
Guid? svarPaMelding = null)
{
MeldingId = meldingId;
KlientMeldingId = klientMeldingId;
MeldingType = meldingType;
AvsenderKontoId = avsenderKontoId;
MottakerKontoId = mottakerKontoId;
Expand All @@ -33,6 +35,7 @@ protected MeldingBase(
protected MeldingBase(IMelding melding)
{
MeldingId = melding.MeldingId;
KlientMeldingId = melding.KlientMeldingId;
MeldingType = melding.MeldingType;
AvsenderKontoId = melding.AvsenderKontoId;
MottakerKontoId = melding.MottakerKontoId;
Expand All @@ -43,6 +46,8 @@ protected MeldingBase(IMelding melding)

public Guid MeldingId { get; protected set; }

public Guid? KlientMeldingId { get; protected set; }

public string MeldingType { get; protected set; }

public Guid AvsenderKontoId { get; protected set; }
Expand Down
3 changes: 3 additions & 0 deletions KS.Fiks.IO.Client/Models/MeldingRequest.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,15 @@ public class MeldingRequest : MeldingBase
public MeldingRequest(
Guid avsenderKontoId,
Guid mottakerKontoId,
Guid? klientMeldingId,
string meldingType,
TimeSpan? ttl = null,
Dictionary<string, string> headere = null,
Guid? svarPaMelding = null)
: base(
meldingId: Guid.Empty,
meldingType: meldingType,
klientMeldingId: klientMeldingId,
avsenderKontoId: avsenderKontoId,
mottakerKontoId: mottakerKontoId,
ttl: ttl ?? TimeSpan.FromDays(DefaultTtlInDays),
Expand All @@ -31,6 +33,7 @@ public MeldingSpesifikasjonApiModel ToApiModel()
return new MeldingSpesifikasjonApiModel(
avsenderKontoId: AvsenderKontoId,
mottakerKontoId: MottakerKontoId,
klientMeldingId: KlientMeldingId,
meldingType: MeldingType,
ttl: (long)Ttl.TotalMilliseconds,
headere: Headere,
Expand Down
4 changes: 3 additions & 1 deletion KS.Fiks.IO.Client/Models/SendtMelding.cs
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ public static SendtMelding FromSentMessageApiModel(SendtMeldingApiModel sendtMel
{
return new SendtMelding(
sendtMeldingApiModel.MeldingId,
sendtMeldingApiModel.KlientMeldingID,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

De andre suffix er pascalcase på id

sendtMeldingApiModel.MeldingType,
sendtMeldingApiModel.AvsenderKontoId,
sendtMeldingApiModel.MottakerKontoId,
Expand All @@ -20,13 +21,14 @@ public static SendtMelding FromSentMessageApiModel(SendtMeldingApiModel sendtMel

internal SendtMelding(
Guid meldingId,
Guid? klientMeldingId,
string meldingType,
Guid avsenderKontoId,
Guid mottakerKontoId,
TimeSpan ttl,
Dictionary<string, string> headere,
Guid? svarPaMelding=null)
: base(meldingId, meldingType, avsenderKontoId, mottakerKontoId, ttl, svarPaMelding: svarPaMelding)
: base(meldingId, klientMeldingId, meldingType, avsenderKontoId, mottakerKontoId, ttl, svarPaMelding: svarPaMelding)
{
}
}
Expand Down
11 changes: 6 additions & 5 deletions KS.Fiks.IO.Client/Send/ISvarSender.cs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Threading.Tasks;
Expand All @@ -7,15 +8,15 @@ namespace KS.Fiks.IO.Client.Send
{
public interface ISvarSender
{
Task<SendtMelding> Svar(string meldingType, IList<IPayload> payloads);
Task<SendtMelding> Svar(string meldingType, IList<IPayload> payloads, Guid klientMeldingId);

Task<SendtMelding> Svar(string meldingType, Stream melding, string filnavn);
Task<SendtMelding> Svar(string meldingType, Stream melding, string filnavn, Guid klientMeldingId);

Task<SendtMelding> Svar(string meldingType, string melding, string filnavn);
Task<SendtMelding> Svar(string meldingType, string melding, string filnavn, Guid klientMeldingId);

Task<SendtMelding> Svar(string meldingType, string filLokasjon);
Task<SendtMelding> Svar(string meldingType, string filLokasjon, Guid klientMeldingId);

Task<SendtMelding> Svar(string meldingType);
Task<SendtMelding> Svar(string meldingType, Guid klientMeldingId);

/**
* Acknowledges that the message has been consumed
Expand Down
33 changes: 20 additions & 13 deletions KS.Fiks.IO.Client/Send/SvarSender.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Security.Cryptography.X509Certificates;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Denne er ikke i bruk

using System.Threading.Tasks;
using KS.Fiks.IO.Client.Amqp;
using KS.Fiks.IO.Client.Models;
Expand All @@ -22,32 +23,32 @@ public SvarSender(ISendHandler sendHandler, MottattMelding mottattMelding, IAmqp
_amqpAcknowledgeManager = amqpAcknowledgeManager;
}

public async Task<SendtMelding> Svar(string meldingType, IList<IPayload> payloads)
public async Task<SendtMelding> Svar(string meldingType, IList<IPayload> payloads, Guid klientMeldingId = default)
{
return await _sendHandler.Send(CreateMessageRequest(meldingType), payloads).ConfigureAwait(false);
return await _sendHandler.Send(CreateMessageRequest(meldingType, klientMeldingId), payloads).ConfigureAwait(false);
}

public async Task<SendtMelding> Svar(string meldingType, Stream melding, string filnavn)
public async Task<SendtMelding> Svar(string meldingType, Stream melding, string filnavn, Guid klientMeldingId = default)
{
return await Reply(meldingType, new StreamPayload(melding, filnavn))
return await Reply(meldingType, new StreamPayload(melding, filnavn), klientMeldingId)
.ConfigureAwait(false);
}

public async Task<SendtMelding> Svar(string meldingType, string melding, string filnavn)
public async Task<SendtMelding> Svar(string meldingType, string melding, string filnavn, Guid klientMeldingId = default)
{
return await Reply(meldingType, new StringPayload(melding, filnavn))
return await Reply(meldingType, new StringPayload(melding, filnavn), klientMeldingId)
.ConfigureAwait(false);
}

public async Task<SendtMelding> Svar(string meldingType, string filLokasjon)
public async Task<SendtMelding> Svar(string meldingType, string filLokasjon, Guid klientMeldingId = default)
{
return await Reply(meldingType, new FilePayload(filLokasjon))
return await Reply(meldingType, new FilePayload(filLokasjon), klientMeldingId)
.ConfigureAwait(false);
}

public async Task<SendtMelding> Svar(string meldingType)
public async Task<SendtMelding> Svar(string meldingType, Guid klientMeldingId = default)
{
return await Svar(meldingType, new List<IPayload>())
return await Svar(meldingType, new List<IPayload>(), klientMeldingId)
.ConfigureAwait(false);
}

Expand All @@ -66,16 +67,22 @@ public void NackWithRequeue()
this._amqpAcknowledgeManager.NackWithRequeue().Invoke();
}

private async Task<SendtMelding> Reply(string messageType, IPayload payload)
private async Task<SendtMelding> Reply(string messageType, IPayload payload, Guid klientMeldingId)
{
return await Svar(messageType, new List<IPayload> {payload}).ConfigureAwait(false);
return await Svar(messageType, new List<IPayload> {payload}, klientMeldingId).ConfigureAwait(false);
}

private MeldingRequest CreateMessageRequest(string messageType)
private MeldingRequest CreateMessageRequest(string messageType, Guid klientMeldingId)
{
if (klientMeldingId == Guid.Empty)
{
klientMeldingId = Guid.NewGuid();
}

return new MeldingRequest(
avsenderKontoId: _mottattMelding.MottakerKontoId,
mottakerKontoId: _mottattMelding.AvsenderKontoId,
klientMeldingId: klientMeldingId,
meldingType: messageType,
ttl: null,
headere: null,
Expand Down