{"id":22886343,"url":"https://github.com/defra/btms-backend","last_synced_at":"2026-05-15T22:37:57.134Z","repository":{"id":266291980,"uuid":"897939369","full_name":"DEFRA/btms-backend","owner":"DEFRA","description":"Git repository for service btms-backend","archived":false,"fork":false,"pushed_at":"2025-05-15T11:28:11.000Z","size":4439,"stargazers_count":0,"open_issues_count":2,"forks_count":1,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-06-15T07:48:51.784Z","etag":null,"topics":["backend","cdp","dotnet","service"],"latest_commit_sha":null,"homepage":null,"language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/DEFRA.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2024-12-03T14:03:07.000Z","updated_at":"2025-05-01T08:10:50.000Z","dependencies_parsed_at":"2024-12-03T15:19:55.427Z","dependency_job_id":"57088047-bb46-48bb-8c84-5e5b04d2e1e3","html_url":"https://github.com/DEFRA/btms-backend","commit_stats":null,"previous_names":["defra/btms-backend"],"tags_count":228,"template":false,"template_full_name":null,"purl":"pkg:github/DEFRA/btms-backend","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fbtms-backend","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fbtms-backend/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fbtms-backend/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fbtms-backend/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/DEFRA","download_url":"https://codeload.github.com/DEFRA/btms-backend/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/DEFRA%2Fbtms-backend/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":273595739,"owners_count":25134258,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-09-04T02:00:08.968Z","response_time":61,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","cdp","dotnet","service"],"created_at":"2024-12-13T20:17:50.016Z","updated_at":"2026-05-15T22:37:57.089Z","avatar_url":"https://github.com/DEFRA.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"# BTMS Backend\n\nCore delivery C# ASP.NET backend template.\n\n* [MongoDB](#mongodb)\n* [Testing](#testing)\n* [Running](#running)\n* [Test Data](#test-data)\n\n# MongoDB\n\nRun MongoDB as a container. See btms-frontend repository for necessary compose configuration.\n\n# Testing\n\nIf running integration tests, start the MongoDB dependencies as noted above.\n\nAlso start the Azure Service Bus emulator included in the compose.yml file.\n\nAll tests within the solution should then run locally.\n\n# Running\n\nOpen the btms-backend solution and run the Btms.Backend profile.\n\n\n# Test Data\nWe are able to obtain test data to use in our tests a few ways.\n\n## Canned test data\nThis is data that we created by hand based on examples of messages that we had obtained. Canned test data can be found in [`Btms.Backend.IntegrationTests/Fixtures/SmokeTest`](Btms.Backend.IntegrationTests/Fixtures/SmokeTest). In there you will find relevant folders for the messages that you want to simulate:\n* ALVS - Custom Record notifications from CDS\n* DECISIONS - Decision that is made by BTMS.\n* GVMSAPIRESPONSE - ??\n* IPAFFS - CHED notifications from IPAFFS\n  * CHEDA\n  * CHEDD\n  * CHEDP\n  * CHEDPP\n\n## Using the Test Data Generator\nThe Test Data Generator can be found in the `tools` project ([`tools/TestDataGenerator`](TestDataGenerator/TestDataGenerator.csproj)). The test data is generated based on specifications provided in a scenario e.g. [`ChedASimpleMatchScenarioGenerator.cs`](TestDataGenerator/Scenarios/ChedASimpleMatchScenarioGenerator.cs). A scenario should container at least a `GetNotificationBuilder` or `GetClearanceRequestBuilder`.\n\nExample usage of `GetNotificationBuilder`\n```csharp\nvar notification = GetNotificationBuilder(\"cheda-one-commodity\")\n    .WithCreationDate(entryDate)\n    .WithRandomArrivalDateTime(config.ArrivalDateRange)\n    .WithReferenceNumber(ImportNotificationTypeEnum.Cveda, scenario, entryDate, item)\n    .ValidateAndBuild();\n```\n\nExample usage of `GetClearanceRequestBuilder`\n```csharp\nvar clearanceRequest = GetClearanceRequestBuilder(\"cr-one-item\")\n    .WithCreationDate(entryDate)\n    .WithArrivalDateTimeOffset(notification.PartOne!.ArrivalDate, notification.PartOne!.ArrivalTime)\n    .WithReferenceNumber(notification.ReferenceNumber!)\n    .ValidateAndBuild();\n```\nNote: \n* Both the Notification Builder and Clearance Request Builder both take a sample file which it uses as a basis to create the test data. The sample file is located in [`Scenarios/Samples`](TestDataGenerator/Scenarios/Samples). \n\nAfter creating your scenario your will need to add it to `ConfigureTestGenerationServices` in [`BuilderExtensions.cs`](TestDataGenerator/Helpers/BuilderExtensions.cs). \n\nNext, you will need to create a dataset that's specified in [`Program.cs`](TestDataGenerator/Program.cs).\nExample dataset:\n```csharp\n var datasets = new[]\n    {\n        new\n        {\n            Dataset = \"All-CHED-No-Match\",\n            RootPath = \"GENERATED-ALL-CHED-NO-MATCH\",\n            Scenarios = new[] { app.CreateScenarioConfig\u003cAllChedsNoMatchScenarioGenerator\u003e(1, 1) }\n        },\n        ...\n    }\n```\n\n* Dataset - Name of the dataset \n* RootPath - Folder where the data will be created in. The folder will be in [`TestDataGenerator/.test-data-generator`](TestDataGenerator/.test-data-generator). \n* Scenarios - List of scenarios to create test data for. The CreateScenarioConfig generates scenarios based on the Scenario types from the [`Scenarios`](TestDataGenerator/Scenarios) folder.\n\nAnd finally, in order to trigger the data creation you will need to add some configuration to [`Properties/launchSettings.json`](TestDataGenerator/Properties/launchSettings.json):\n```json\n{\n    \"profiles\": {\n        \"Generate All CHED no match\": {\n            \"commandName\": \"Project\",\n            \"commandLineArgs\": \"All-CHED-No-Match\",\n            \"environmentVariables\": {\n                \"DMP_ENVIRONMENT\": \"dev\",\n                \"DMP_SERVICE_BUS_NAME\": \"DEVTREINFSB1001\",\n                \"DMP_BLOB_STORAGE_NAME\": \"devdmpinfdl1001\",\n                \"DMP_SLOT\": \"1003\",\n                \"AZURE_TENANT_ID\": \"c9d74090-b4e6-4b04-981d-e6757a160812\"\n            }\n        }\n    }\n}\n```\n\n* Give the profile a name. This can be free text.\n* commandLineArgs - The name of the new dataset.\n* The rest of the configuration can be copied from the other profiles.\n\n### Creating new sample file\nYou may want to a new sample if you are creating data for a new scenario. To do this:\n* Place the new sample file with the relevant JSON in the [`Samples`](TestDataGenerator/Scenarios/Samples) folder.\n* Change the Properties of the file in Rider:\n  * Build action: **Content**\n  * Copy to output directory: **Copy if newer**\n\n## Using data from Blob Storage\nWe have imported redacted production data that is stored in a Blob Storage. We can use BTMS Backend to import this data.\n\n* Update [`local.env`](Btms.Backend/Properties/local.env):\n  * For one day dataset - `BusinessOptions:DmpBlobRootFolder=PRODREDACTED-20241204`\n  * For one month dataset - `BusinessOptions:DmpBlobRootFolder=PRODREDACTED-202411`\n  * When importing the data set the following:\n    ```dotenv\n    BlobServiceOptions:CacheWriteEnabled=true\n    # BlobServiceOptions:CacheReadEnabled=true\n    ```\n  * After importing update the config to be the following so the data doesn't get imported again when you call the `initialise` API (http://0.0.0.0:5002/mgmt/initialise?syncPeriod=All)\n    ```dotenv\n    # BlobServiceOptions:CacheWriteEnabled=true\n    BlobServiceOptions:CacheReadEnabled=true\n    ```\n  * Once the config has been updated, start BTMS Backend and call the `initialise` API (http://0.0.0.0:5002/mgmt/initialise?syncPeriod=All). Note that a large amount of data will be loaded, particularly the full month dataset. It is also advisable to run Backend from a standalone terminal rather than from Rider as it struggles running this task.\n      \n\n## PAT Token\nTo Access the BTMS Test Data repo, a PAT token needs to be generated.  If/When the PAT needs to be regenerated, it should be updated within the secrets and variables of the project\nhttps://github.com/actions/checkout?tab=readme-ov-file#Checkout-multiple-repos-private\n\nhttps://github.com/DEFRA/btms-backend/settings/secrets/actions","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fbtms-backend","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdefra%2Fbtms-backend","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdefra%2Fbtms-backend/lists"}