diff --git a/src/Basisregisters.IntegrationDb.Bosa/Infrastructure/DatabaseSetup.cs b/src/Basisregisters.IntegrationDb.Bosa/Infrastructure/DatabaseSetup.cs deleted file mode 100644 index 37f6b20..0000000 --- a/src/Basisregisters.IntegrationDb.Bosa/Infrastructure/DatabaseSetup.cs +++ /dev/null @@ -1,39 +0,0 @@ -namespace Basisregisters.IntegrationDB.Bosa.Infrastructure -{ - using System; - using Dapper; - using Npgsql; - - public class DatabaseSetup - { - public const string Schema = "integration_bosa"; - public const string PostalCrabVersionsTable = "postal_crab_versions"; - public const string MunicipalityCrabVersionsTable = "municipality_crab_versions"; - public const string StreetNameCrabVersionsTable = "streetname_crab_versions"; - public const string AddressCrabVersionsTable = "address_crab_versions"; - - private readonly string _connectionString; - - public DatabaseSetup(string connectionString) - { - _connectionString = connectionString; - } - - public void CheckIfDataPresent() - { - using var connection = new NpgsqlConnection(_connectionString); - - CheckTableData(connection, PostalCrabVersionsTable); - CheckTableData(connection, MunicipalityCrabVersionsTable); - CheckTableData(connection, StreetNameCrabVersionsTable); - CheckTableData(connection, AddressCrabVersionsTable); - } - - private static void CheckTableData(NpgsqlConnection connection, string table) - { - var postal = connection.Execute($"SELECT * FROM {Schema}.{table} LIMIT 1"); - if(postal == 0) - throw new InvalidOperationException($"No data found in the {table} table"); - } - } -} diff --git a/src/Basisregisters.IntegrationDb.Bosa/Infrastructure/Program.cs b/src/Basisregisters.IntegrationDb.Bosa/Infrastructure/Program.cs index 666f5e3..746c9c8 100644 --- a/src/Basisregisters.IntegrationDb.Bosa/Infrastructure/Program.cs +++ b/src/Basisregisters.IntegrationDb.Bosa/Infrastructure/Program.cs @@ -74,8 +74,6 @@ public static async Task Main(string[] args) var connectionString = hostContext.Configuration.GetConnectionString("Integration") ?? throw new ArgumentNullException("hostContext.Configuration.GetConnectionString(\"Integration\")"); - services.AddSingleton(_ => new DatabaseSetup(connectionString)); - services.AddTransient(_ => new PostalInfoRepository(connectionString)); services.AddTransient(); @@ -113,7 +111,7 @@ public static async Task Main(string[] args) LogResponse = true }) : new AmazonS3Client(); - + return new S3BlobClient(s3Client, options.UploadBucket); }); @@ -124,7 +122,7 @@ public static async Task Main(string[] args) return new AsyncFtpClient(options.Host, options.Username, options.Password, options.Port ?? 0); }); - + services.AddHostedService(); }) .UseConsoleLifetime() @@ -140,8 +138,6 @@ public static async Task Main(string[] args) await DistributedLock.RunAsync( async () => { - host.Services.GetRequiredService().CheckIfDataPresent(); - await host.RunAsync().ConfigureAwait(false); }, DistributedLockOptions.LoadFromConfiguration(configuration), diff --git a/test/Basisregisters.IntegrationDb.Bosa.Tests/XmlAddressTests.cs b/test/Basisregisters.IntegrationDb.Bosa.Tests/XmlAddressTests.cs index d2e537d..ebbc127 100644 --- a/test/Basisregisters.IntegrationDb.Bosa.Tests/XmlAddressTests.cs +++ b/test/Basisregisters.IntegrationDb.Bosa.Tests/XmlAddressTests.cs @@ -4,6 +4,8 @@ namespace Basisregisters.IntegrationDb.Bosa.Tests using System.IO; using System.Text; using System.Threading.Tasks; + using Be.Vlaanderen.Basisregisters.GrAr.Common; + using Be.Vlaanderen.Basisregisters.GrAr.Extracts; using FluentAssertions; using Microsoft.Extensions.Logging.Abstractions; using Model.Database; @@ -101,6 +103,7 @@ public XmlAddressTests() [Fact] public async Task GivenAddress_ThenSerializesCorrectly() { + var s =SystemClock.Instance.GetCurrentInstant().ToBelgianDateTimeOffset().FromDateTimeOffset(); var municipalities = new Municipality[] { new (MunicipalityNamespace, "13013", Date, "Gemeente", "GemeenteFR", "GemeenteDE", "GemeenteEN", MunicipalityStatus.Current),