Skip to content
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
13 changes: 13 additions & 0 deletions .config/dotnet-tools.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"version": 1,
"isRoot": true,
"tools": {
"csharpier": {
"version": "0.30.6",
"commands": [
"dotnet-csharpier"
],
"rollForward": false
}
}
}
13 changes: 12 additions & 1 deletion .github/workflows/dependabot-automerge.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,18 @@ jobs:
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
if: ${{ github.actor == 'dependabot[bot]' }}
steps:
- uses: actions/checkout@v4
- name: Verify commit signature.
run: |
curl -s https://github.com/web-flow.gpg | gpg --import
echo "Imported GitHub keys."

echo "Verifying signature of commit: $GITHUB_SHA"
if ! git verify-commit "$GITHUB_SHA"; then
echo "Commit signature verification failed."
exit 1
fi
- name: Approve a PR
run: gh pr review --approve "$PR_URL"
- name: Enable auto-merge for Dependabot PRs
run: gh pr merge --auto --squash "$PR_URL"
run: gh pr merge --auto --squash "$PR_URL"
14 changes: 6 additions & 8 deletions .github/workflows/formatter.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: dotnet-format
name: csharpier

on: [push, pull_request]

Expand All @@ -7,13 +7,11 @@ jobs:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup .NET
- name: Setup .NET 8
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.100
- name: Install dotnet-format
run: |
dotnet tool install -g dotnet-format
- name: Run dotnet-format
working-directory: ./TransformerBeeClient
run: dotnet-format TransformerBeeClient.sln --check
- name: Restore .NET tools
run: dotnet tool restore
- name: Run CSharpier
run: dotnet csharpier . --check
6 changes: 3 additions & 3 deletions .github/workflows/integrationtests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
dotnet-version: ["6.0.201", "7.0.100", "8.0.100"]
dotnet-version: ["9"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
Expand All @@ -25,13 +25,13 @@ jobs:
- name: Log into registry
# GHCR_PAT is a personal access token for the Github Container Registry; You can create it using the following steps:
# 1) Go to https://github.com/settings/tokens
# 2) Create a new token (classic as of 2024-01-31)
# 2) Create a new token (classic as of 2025-04-02)
# 3) Select the following scopes: read:packages
# GHCR_USR is the username for the Github Container Registry; it has to match the PAT and is the username of the Github account that created the PAT
# You can update the tokens in the repository settings:
# https://github.com/Hochfrequenz/transformer.bee_client.net/settings/secrets/actions/GHCR_PAT
# https://github.com/Hochfrequenz/transformer.bee_client.net/settings/secrets/actions/GHCR_USR
# Tokens will expire 2025-01-31
# Tokens will expire 2026-04-01
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ secrets.GHCR_USR }} --password-stdin
- name: Start containers
run: docker compose -f "TransformerBeeClient/TransformerBeeClient.IntegrationTest/docker-compose.yml" up -d
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release_nuget.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,20 +12,20 @@ jobs:
- name: Setup .NET Core
uses: actions/setup-dotnet@v4
with:
dotnet-version: 8.0.100
dotnet-version: 9
- name: Build/Check for compile errors (dotnet build)
working-directory: "TransformerBeeClient"
run: dotnet build --configuration Release
- name: Log into registry
# GHCR_PAT is a personal access token for the Github Container Registry; You can create it using the following steps:
# 1) Go to https://github.com/settings/tokens
# 2) Create a new token (classic as of 2024-01-31)
# 2) Create a new token (classic as of 2025-04-02)
# 3) Select the following scopes: read:packages
# GHCR_USR is the username for the Github Container Registry; it has to match the PAT and is the username of the Github account that created the PAT
# You can update the tokens in the repository settings:
# https://github.com/Hochfrequenz/transformer.bee_client.net/settings/secrets/actions/GHCR_PAT
# https://github.com/Hochfrequenz/transformer.bee_client.net/settings/secrets/actions/GHCR_USR
# Tokens will expire 2025-01-31
# Tokens will expire 2026-04-01
run: echo "${{ secrets.GHCR_PAT }}" | docker login ghcr.io -u ${{ secrets.GHCR_USR }} --password-stdin
- name: Start containers
run: docker compose -f "TransformerBeeClient/TransformerBeeClient.IntegrationTest/docker-compose.yml" up -d
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/unittests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ jobs:
strategy:
matrix:
os: [ubuntu-latest]
dotnet-version: ["6.0.201", "7.0.100", "8.0.100"]
dotnet-version: ["9"]
runs-on: ${{ matrix.os }}
steps:
- name: Checkout code
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System.Net;
using System.Net.Http.Json;
using System.Text.Json;
using System.Text.Json.Serialization;
using FluentAssertions;
Expand All @@ -20,10 +20,10 @@ public ApplicationTest(WebApplicationFactory<Program> factory)
public async Task Test_That_Setup_Works_As_Designed()
{
var client = Factory.CreateDefaultClient();
var response = await client.GetAsync("/talkToTransformerBee");
response.StatusCode.Should().Be(HttpStatusCode.OK);
var content = await response.Content.ReadAsStringAsync();
var bo4e = JsonSerializer.Deserialize<BOneyComb>(content, new JsonSerializerOptions { Converters = { new JsonStringEnumConverter() } });
var bo4e = await client.GetFromJsonAsync<BOneyComb>(
"/talkToTransformerBee",
new JsonSerializerOptions { Converters = { new JsonStringEnumConverter() } }
);
bo4e.Should().NotBeNull();
}
}
Original file line number Diff line number Diff line change
@@ -1,12 +1,13 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<TargetFramework>net9.0</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Original file line number Diff line number Diff line change
@@ -1 +1 @@
global using Xunit;
global using Xunit;
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<PreserveCompilationContext>true</PreserveCompilationContext>
<TargetFrameworks>net8.0;net9.0</TargetFrameworks>
<LangVersion>latest</LangVersion>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\TransformerBeeClient\TransformerBeeClient.csproj"/>
Expand Down
41 changes: 27 additions & 14 deletions TransformerBeeClient/ExampleAspNetCoreApplication/Program.cs
Original file line number Diff line number Diff line change
@@ -1,29 +1,42 @@
using System.Text.Json;
using System.Text.Json.Serialization;
using EDILibrary;
using TransformerBeeClient;

var builder = WebApplication.CreateBuilder(args);
builder.Services.AddHttpClient();

builder.Services.AddTransient<ITransformerBeeAuthenticator, NoAuthenticator>(); // Or you could use ClientIdClientSecretAuthenticator
builder.Services.AddHttpClient("TransformerBee", client =>
{
client.BaseAddress = new Uri("http://localhost:5021/"); // or https://transformerstage.utilibee.io
});
builder.Services.AddHttpClient(
"TransformerBee",
client =>
{
client.BaseAddress = new Uri("http://localhost:5021/"); // or https://transformerstage.utilibee.io
}
);
builder.Services.AddTransient<ICanConvertToBo4e, TransformerBeeRestClient>();
builder.Services.AddTransient<ICanConvertToEdifact, TransformerBeeRestClient>();

var app = builder.Build();

app.MapGet("/", () => "I ❤ BO4E");
app.MapGet("/talkToTransformerBee", async (ICanConvertToBo4e transformerBeeRestClient) =>
{
var bo4e = await transformerBeeRestClient.ConvertToBo4e(
"UNA:+,? 'UNB+UNOC:3+9912345789012:500+9909876543210:500+230703:1059+ASDFHGJ'UNH+11223344556678+UTILMD:D:11A:UN:S1.1'BGM+E01+918273746512345678901'DTM+137:202306300558?+00:303'NAD+MS+9912345789012::293'NAD+MR+9909876543210::293'IDE+24+918273746512345678901'IMD++Z36+Z13'DTM+92:202212312300?+00:303'STS+7++E01'LOC+Z16+78889918283'LOC+Z17+DE0000111122223333444455556667778'RFF+Z13:55001'SEQ+Z01'CCI+Z30++Z07'CCI+Z19++11X0-0000-0116-J'CCI+++Z15'CCI+++Z88'CAV+Z74:::Z09'CAV+Z73:::Z11'SEQ+Z12'QTY+Z16:0:P1'SEQ+Z03'CCI+++E13'CAV+Z30:::788811123'SEQ+Z75'CCI+Z61++ZG1'NAD+Z09+++Schaefer:Ulrike:::Frau:Z01'NAD+Z04+++Schaefer:Ulrike:::Frau:Z01+Flughafenstrasse::64+Vilseck++92247+DE'NAD+DP++++Flughafenstrasse::64+Vilseck++92247+DE'NAD+Z05+++Schaefer:Ulrike:::Frau:Z01+Flughafenstrasse::64+Vilseck++92247+DE'UNT+31+11223344556678'UNZ+1+ASDFHGJ'",
EdifactFormatVersion.FV2310);
return bo4e.Single().Transaktionen.Single();
});
app.MapGet(
"/talkToTransformerBee",
async (HttpContext context, ICanConvertToBo4e transformerBeeRestClient) =>
{
var bo4e = await transformerBeeRestClient.ConvertToBo4e(
"UNA:+,? 'UNB+UNOC:3+9912345789012:500+9909876543210:500+230703:1059+ASDFHGJ'UNH+11223344556678+UTILMD:D:11A:UN:S1.1'BGM+E01+918273746512345678901'DTM+137:202306300558?+00:303'NAD+MS+9912345789012::293'NAD+MR+9909876543210::293'IDE+24+918273746512345678901'IMD++Z36+Z13'DTM+92:202212312300?+00:303'STS+7++E01'LOC+Z16+78889918283'LOC+Z17+DE0000111122223333444455556667778'RFF+Z13:55001'SEQ+Z01'CCI+Z30++Z07'CCI+Z19++11X0-0000-0116-J'CCI+++Z15'CCI+++Z88'CAV+Z74:::Z09'CAV+Z73:::Z11'SEQ+Z12'QTY+Z16:0:P1'SEQ+Z03'CCI+++E13'CAV+Z30:::788811123'SEQ+Z75'CCI+Z61++ZG1'NAD+Z09+++Schaefer:Ulrike:::Frau:Z01'NAD+Z04+++Schaefer:Ulrike:::Frau:Z01+Flughafenstrasse::64+Vilseck++92247+DE'NAD+DP++++Flughafenstrasse::64+Vilseck++92247+DE'NAD+Z05+++Schaefer:Ulrike:::Frau:Z01+Flughafenstrasse::64+Vilseck++92247+DE'UNT+31+11223344556678'UNZ+1+ASDFHGJ'",
EdifactFormatVersion.FV2310
);
context.Response.ContentType = System.Net.Mime.MediaTypeNames.Application.Json;
var result = bo4e.Single().Transaktionen.Single();
var json = JsonSerializer.Serialize(
result,
new JsonSerializerOptions() { Converters = { new JsonStringEnumConverter() } }
);
await context.Response.WriteAsync(json);
}
);
app.Run();

public partial class Program
{
} // required for integration testing; If you miss this the test will complain, that it cannot find a 'testhost.deps.json'
public partial class Program { } // required for integration testing; If you miss this the test will complain, that it cannot find a 'testhost.deps.json'
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,19 @@ public Bo4eToEdifactTests(ClientFixture clientFixture)
public async Task BOneyComb_Can_Be_Converted_To_Edifact()
{
var httpClientFactory = _client.HttpClientFactory;
ICanConvertToEdifact client = new TransformerBeeRestClient(httpClientFactory, _authenticator);
ICanConvertToEdifact client = new TransformerBeeRestClient(
httpClientFactory,
_authenticator
);
var boneyCombString = await File.ReadAllTextAsync("TestEdifacts/FV2310/55001.json");
var deserializerOptions = new JsonSerializerOptions
{
Converters =
{
new JsonStringEnumConverter()
}
Converters = { new JsonStringEnumConverter() },
};
var boneyComb = System.Text.Json.JsonSerializer.Deserialize<BOneyComb>(boneyCombString, deserializerOptions);
var boneyComb = System.Text.Json.JsonSerializer.Deserialize<BOneyComb>(
boneyCombString,
deserializerOptions
);
boneyComb.Should().NotBeNull();
var result = await client.ConvertToEdifact(boneyComb, EdifactFormatVersion.FV2310);
result.Should().BeOfType<string>().And.StartWith("UNB+UNOC");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ public class ClientFixture : IClassFixture<ClientFixture>
public ClientFixture()
{
var services = new ServiceCollection();
services.AddHttpClient("TransformerBee", client =>
{
client.BaseAddress = new Uri("http://localhost:5021"); // Check docker-compose.yml
});
services.AddHttpClient(
"TransformerBee",
client =>
{
client.BaseAddress = new Uri("http://localhost:5021"); // Check docker-compose.yml
}
);
var serviceProvider = services.BuildServiceProvider();
ServiceCollection = services;
HttpClientFactory = serviceProvider.GetService<IHttpClientFactory>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ namespace TransformerBeeClient.IntegrationTest;
/// </summary>
public class ConnectionTests : IClassFixture<ClientFixture>
{

private readonly ClientFixture _client;
private readonly ITransformerBeeAuthenticator _authenticator;

Expand All @@ -32,12 +31,18 @@ public async Task IsAvailable_Returns_True_If_Service_Is_Available()
public async Task IsAvailable_Throws_Exception_If_Host_Is_Unavailable()
{
var services = new ServiceCollection();
services.AddHttpClient("TransformerBee", client =>
{
client.BaseAddress = new Uri("http://localhost:1234"); // <-- no service running under this address
});
services.AddHttpClient(
"TransformerBee",
client =>
{
client.BaseAddress = new Uri("http://localhost:1234"); // <-- no service running under this address
}
);
var serviceProvider = services.BuildServiceProvider();
var client = new TransformerBeeRestClient(serviceProvider.GetService<IHttpClientFactory>(), _authenticator);
var client = new TransformerBeeRestClient(
serviceProvider.GetService<IHttpClientFactory>(),
_authenticator
);
var checkIfIsAvailable = async () => await client.IsAvailable();
await checkIfIsAvailable.Should().ThrowAsync<HttpRequestException>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,10 @@ public class EdifactToBo4eTestsWithAuthentication : IClassFixture<GithubActionCl

ITestOutputHelper _output;

public EdifactToBo4eTestsWithAuthentication(GithubActionClientFixture clientFixture, ITestOutputHelper output)
public EdifactToBo4eTestsWithAuthentication(
GithubActionClientFixture clientFixture,
ITestOutputHelper output
)
{
_client = clientFixture;
_authenticationProvider = clientFixture.AuthenticationProvider;
Expand All @@ -61,7 +64,10 @@ public async Task Edifact_Can_Be_Converted_To_Bo4e_With_Authentication()
}
Skip.If(_authenticationProvider is null, "No authentication provider available");
var httpClientFactory = _client.HttpClientFactory;
ICanConvertToBo4e client = new TransformerBeeRestClient(httpClientFactory, _authenticationProvider);
ICanConvertToBo4e client = new TransformerBeeRestClient(
httpClientFactory,
_authenticationProvider
);
var edifactString = await File.ReadAllTextAsync("TestEdifacts/FV2310/55001.edi");
var result = await client.ConvertToBo4e(edifactString, EdifactFormatVersion.FV2310);
result.Should().BeOfType<List<Marktnachricht>>();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,19 @@ public GithubActionClientFixture()
return;
}
var services = new ServiceCollection();
services.AddHttpClient("TransformerBee", client => { client.BaseAddress = new Uri("http://transformerstage.utilibee.io"); });
services.AddHttpClient(
"TransformerBee",
client =>
{
client.BaseAddress = new Uri("http://transformerstage.utilibee.io");
}
);
var serviceProvider = services.BuildServiceProvider();
ServiceCollection = services;
HttpClientFactory = serviceProvider.GetService<IHttpClientFactory>();
AuthenticationProvider = new ClientIdClientSecretAuthenticator(clientId: clientId, clientSecret: clientSecret);
AuthenticationProvider = new ClientIdClientSecretAuthenticator(
clientId: clientId,
clientSecret: clientSecret
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,7 @@ internal class MyHttpClientFactory : IHttpClientFactory
{
public HttpClient CreateClient(string name)
{
return new HttpClient
{
BaseAddress = new Uri("http://localhost:5021")
};
return new HttpClient { BaseAddress = new Uri("http://localhost:5021") };
}
}

Expand All @@ -28,6 +25,9 @@ public async Task Test_Transformer_Bee_Communication()
IHttpClientFactory myFactory = new MyHttpClientFactory();
ITransformerBeeAuthenticator myAuthenticator = new NoAuthenticator(); // or use ClientIdClientSecretAuthenticator
var client = new TransformerBeeRestClient(myFactory, myAuthenticator);
await client.ConvertToBo4e("UNA:+,? 'UNB+UNOC:3+9912345789012:500+9909876543210:500+230703:1059+ASDFHGJ'UNH+11223344556678+UTILMD:D:11A:UN:S1.1'BGM+E01+918273746512345678901'DTM+137:202306300558?+00:303'NAD+MS+9912345789012::293'NAD+MR+9909876543210::293'IDE+24+918273746512345678901'IMD++Z36+Z13'DTM+92:202212312300?+00:303'STS+7++E01'LOC+Z16+78889918283'LOC+Z17+DE0000111122223333444455556667778'RFF+Z13:55001'SEQ+Z01'CCI+Z30++Z07'CCI+Z19++11X0-0000-0116-J'CCI+++Z15'CCI+++Z88'CAV+Z74:::Z09'CAV+Z73:::Z11'SEQ+Z12'QTY+Z16:0:P1'SEQ+Z03'CCI+++E13'CAV+Z30:::788811123'SEQ+Z75'CCI+Z61++ZG1'NAD+Z09+++Schaefer:Ulrike:::Frau:Z01'NAD+Z04+++Schaefer:Ulrike:::Frau:Z01+Flughafenstrasse::64+Vilseck++92247+DE'NAD+DP++++Flughafenstrasse::64+Vilseck++92247+DE'NAD+Z05+++Schaefer:Ulrike:::Frau:Z01+Flughafenstrasse::64+Vilseck++92247+DE'UNT+31+11223344556678'UNZ+1+ASDFHGJ'", EdifactFormatVersion.FV2310);
await client.ConvertToBo4e(
"UNA:+,? 'UNB+UNOC:3+9912345789012:500+9909876543210:500+230703:1059+ASDFHGJ'UNH+11223344556678+UTILMD:D:11A:UN:S1.1'BGM+E01+918273746512345678901'DTM+137:202306300558?+00:303'NAD+MS+9912345789012::293'NAD+MR+9909876543210::293'IDE+24+918273746512345678901'IMD++Z36+Z13'DTM+92:202212312300?+00:303'STS+7++E01'LOC+Z16+78889918283'LOC+Z17+DE0000111122223333444455556667778'RFF+Z13:55001'SEQ+Z01'CCI+Z30++Z07'CCI+Z19++11X0-0000-0116-J'CCI+++Z15'CCI+++Z88'CAV+Z74:::Z09'CAV+Z73:::Z11'SEQ+Z12'QTY+Z16:0:P1'SEQ+Z03'CCI+++E13'CAV+Z30:::788811123'SEQ+Z75'CCI+Z61++ZG1'NAD+Z09+++Schaefer:Ulrike:::Frau:Z01'NAD+Z04+++Schaefer:Ulrike:::Frau:Z01+Flughafenstrasse::64+Vilseck++92247+DE'NAD+DP++++Flughafenstrasse::64+Vilseck++92247+DE'NAD+Z05+++Schaefer:Ulrike:::Frau:Z01+Flughafenstrasse::64+Vilseck++92247+DE'UNT+31+11223344556678'UNZ+1+ASDFHGJ'",
EdifactFormatVersion.FV2310
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@

<IsPackable>false</IsPackable>
<IsTestProject>true</IsTestProject>
<TargetFrameworks>net8.0;net6.0;net7.0</TargetFrameworks>
<TargetFramework>net9.0</TargetFramework>
<LangVersion>latest</LangVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
Loading