Commit Graph

78 Commits

Author SHA1 Message Date
Joseph Doherty 5ee920a399 feat: complete WorkProcessor integration and bug fixes
- Fix hourly lookback bug: use hourly timestamp/interval (not daily)
- Update DI registrations across DataSync, DataAccess, Api layers
- Add WorkProcessor config to appsettings.json
- Remove deprecated DataSyncService (replaced by WorkProcessor)

All 340 DataSync tests pass. Legacy bug from OLD solution now fixed.
2026-01-07 06:26:45 -05:00
Joseph Doherty 91b516e197 feat: implement WorkProcessor and search execution services
- SearchRepository: Search table operations with Dapper
- SearchExecutionService: Search pipeline with proper cancellation handling
- WorkProcessor: Unified BackgroundService for syncs and searches
- SearchNotificationService: SignalR notifications in Api layer

All 45 new tests pass. Proper shutdown vs timeout distinction
prevents marking searches as error on host shutdown.
2026-01-07 06:18:35 -05:00
Joseph Doherty c814a7294b refactor(datasync): remove deprecated SyncMode and SyncModeConfig
- Delete SyncMode.cs enum file
- Remove SyncModes property from PipelineConfig
- Remove SyncModeConfig and DestinationOverride records
- Remove WithMode(SyncMode) from IEtlPipelineBuilder
- Remove BuildWithSyncModes() and related methods from EtlPipelineFactory
- Remove syncModes sections from all pipelines in pipelines.json
- Update tests to use schedules-only configuration

All pipelines now require 'schedules' format (mass/daily/hourly).
WithUpdateType(UpdateTypes) is the only way to set update type.
2026-01-07 05:16:20 -05:00
Joseph Doherty 1618b6664d refactor: remove unused CMS/JDE repositories and data sources
Remove legacy JDE and CMS direct-access code that is no longer used:
- Delete ICmsDataSource, IJdeDataSource interfaces
- Delete ISearchProcessor, IUpdateProcessor interfaces
- Delete IJdeRepository and ICmsRepository (all partials)
- Delete JdeRepository and CmsRepository implementations
- Delete JdeQueries and CmsQueries
- Delete JdeFileDataSource, JdeOracleDataSource
- Delete CmsFileDataSource, CmsOracleDataSource
- Remove unused methods from LotFinderRepository interfaces
- Delete associated unit tests (CmsRepositoryTests, JdeRepositoryTests)

All data sync now uses ETL pipelines via DataSync project.
2026-01-07 05:04:49 -05:00
Joseph Doherty 6952f686fa perf: optimize ExcelIO tests with fixture-based consolidation
- Add WorkbookFixtureBase and 4 concrete fixtures for shared workbooks
- Add ExcelTestHelpers with shared utility methods
- Create Integration/ folder with 7 fixture-based test classes:
  - MinimalSearchTests (5 tests)
  - SearchResultsSheetTests (5 tests)
  - MisInfoSheetTests (11 tests)
  - InvestigationSheetTests (7 tests)
  - ProtectionAndStyleTests (7 tests)
  - LegacyFormatTests (5 tests)
  - LargeDataSetTests (1 test)
- Delete redundant ExcelExportIntegrationTests.cs (26 tests)
- Delete redundant LegacyComparisonTests.cs (16 tests)
- Reduce workbook generations from ~42 to 4 fixtures
- Test runtime reduced from ~18 min to ~4 min (76% improvement)
- All 122 ExcelIO tests pass
2026-01-07 03:55:33 -05:00
Joseph Doherty fc5769b219 test: fix ServiceRegistrationTests config key (Ldap:UseFakeAuth) 2026-01-07 01:56:34 -05:00
Joseph Doherty da02784feb feat(datasync): add custom interval support to DataUpdateRepository
Add optional customIntervals parameter to GetSyncStatusAsync to allow
per-pipeline interval overrides instead of hardcoded defaults. This
enables tables like MisData to use longer sync intervals (e.g., 70 days)
while other tables use standard intervals.

Key changes:
- IDataUpdateRepository.GetSyncStatusAsync now accepts an optional
  Dictionary<string, int> for custom intervals keyed by "TableName_UpdateType"
- GetExpectedInterval and IsOverdue made public static for testing and reuse
- Added GetDefaultInterval method for accessing default values
- Updated DataSyncHealthCheck to use new signature
- Added comprehensive unit tests for custom interval behavior
2026-01-07 01:35:28 -05:00
Joseph Doherty e234c9f29a refactor(datasync): use WithUpdateType instead of WithMode in TableSyncOperation
Update TableSyncOperation to pass UpdateTypes directly to the pipeline
builder using WithUpdateType() instead of mapping to SyncMode and calling
the deprecated WithMode() method. This enables proper schedule-based
configuration handling where Daily and Hourly have distinct behaviors.

- Remove SyncMode mapping logic from ExecuteSyncCoreAsync
- Call WithUpdateType(task.UpdateType) directly
- Update log message to reflect UpdateType instead of SyncMode
- Add TableSyncOperationTests verifying WithUpdateType is called correctly
2026-01-07 01:25:24 -05:00
Joseph Doherty bb54994f2d feat(datasync): add WithUpdateType to IEtlPipelineBuilder
- Add WithUpdateType(UpdateTypes) method to IEtlPipelineBuilder interface
- Mark existing WithMode(SyncMode) as [Obsolete("Use WithUpdateType instead")]
- Update PipelineBuilder to store UpdateTypes instead of SyncMode
- Add GetEffectiveScheduleConfig method to merge pipeline schedules with defaults
- Add BuildWithSchedules method for new Schedules-based config
- Update validation to support both old SyncModes and new Schedules formats
- Pass ScheduleDefaults from PipelinesRoot to PipelineBuilder
- For Mass mode: use massQuery, apply prePurge/reIndex from schedule config
- For Daily/Hourly: use regular query with date parameters
- Add 8 new tests for WithUpdateType functionality
2026-01-07 01:15:18 -05:00
Joseph Doherty 4b3c900d52 feat(datasync): add GIW connection type to DbQuerySource
Add support for "giw" connection type in DbQuerySource to enable
the StatusCode pipeline to query from the GIW Oracle database.
2026-01-07 01:08:52 -05:00
Joseph Doherty c59a3160d0 feat(dataaccess): add GIW connection factory method
Add CreateGiwConnectionAsync to IDbConnectionFactory and DbConnectionFactory
for connecting to the GIW Oracle database. This connection is needed for the
StatusCode data sync pipeline.

- Reuses existing CreateOracleConnectionAsync helper with "GIW" data source
- Follows same pattern as JDE, JDEStage, and CMS connections
- Includes 4 unit tests covering missing/empty/invalid connection strings
2026-01-07 00:54:11 -05:00
Joseph Doherty 21f598f25c feat(datasync): add Schedules property to PipelineConfig
Add PipelineSchedules? Schedules parameter to PipelineConfig record between
SyncModes and Transformers for new schedule-based configuration. The existing
SyncModes property is now nullable for backward compatibility during the
transition to the new schedule system.
2026-01-07 00:41:03 -05:00
Joseph Doherty 15cfc1a010 feat(datasync): add ScheduleDefaults to PipelinesRoot
Add ScheduleDefaults? parameter to PipelinesRoot record and
EffectiveScheduleDefaults computed property that returns
defaults when null.

Updates all existing test usages to include the new parameter.
2026-01-07 00:33:18 -05:00
Joseph Doherty 1318dce18a feat(datasync): add ScheduleConfig and ScheduleDefaults models
Add configuration models for the new schedule-based pipeline configuration:
- ScheduleConfig: Per-schedule configuration (Enabled, IntervalMinutes, PrePurge, ReIndex, UpdateWhen)
- ScheduleDefaults: Default configurations for Mass (weekly), Daily, and Hourly schedules
- PipelineSchedules: Per-pipeline schedule overrides
- MergeWith method for merging pipeline overrides with defaults

Part of Task 1 from pipeline-schedule-alignment implementation plan.
2026-01-07 00:18:28 -05:00
Joseph Doherty 621dd41a97 refactor(ExcelIO): delete old attribute-based infrastructure
- Remove OutputColumnAttribute, OutputTableAttribute, OutputColumnCache
- Remove AttributeTableWriter and ColumnFormatter
- Remove duplicate ExcelFormats from Mapping (use Formatting version)
- Remove OutputColumn model
- Add FilterEntryMaps for criteria sheet filter models
- Update CriteriaSheetGenerator to use FluentTableWriter
- Remove attributes from filter entry models (now use fluent maps)
- Update DI to register filter entry maps and remove old services
- Update tests to use new fluent infrastructure
- Delete obsolete test files for removed infrastructure

Task 16 of fluent-excel-mapping-implementation plan.
2026-01-06 23:56:02 -05:00
Joseph Doherty 671f8ce357 test(ExcelIO): add unit tests for fluent mapping infrastructure 2026-01-06 23:26:11 -05:00
Joseph Doherty 2c82ac78e3 test: update test to use SqlObjects.SubmitSearch constant 2026-01-06 16:05:06 -05:00
Joseph Doherty 691a6d1ffd refactor(data-access): remove TVP code and simplify SearchModel
- Remove all List<*FilterEntry> properties and *FilterEnabled computed properties from SearchModel
- Delete TableValuedParameterExtensions.cs
- Delete entire FilterEntries folder and all filter entry model classes
- Delete FilterHandlers folder and all filter handler classes
- Delete IFilterHandler interface and FilterResult model
- Update MisQueryBuilder to use SQL extraction functions instead of model properties
- Update SearchProcessor to get ExtractMisData from database using fn_GetSearchExtractMisData
- Update DependencyInjection to remove filter handler registrations
- Delete obsolete tests for TVP extensions and filter handlers

Filter criteria are now stored as JSON in Search.Criteria column and extracted using SQL functions (fn_GetSearch*) during query execution.
2026-01-06 14:32:03 -05:00
Joseph Doherty 3c728dd575 refactor(datasync): update tests to remove FetcherTypeName
- Remove FetcherTypeName assignments from test fixtures in ScheduleCheckerTests
  and SyncOrchestratorTests
- Remove PrepurgeData and ReIndexData assignments from MassConfig in tests
- Mark FetcherTypeName, PostProcessorTypeName, PrepurgeData, and ReIndexData
  as obsolete with deprecation warnings pointing to pipelines.json
- Change FetcherTypeName from required to optional to allow tests to compile
  without providing the deprecated property
2026-01-06 14:22:26 -05:00
Joseph Doherty edff5859b9 docs: add protobuf cache conversion implementation plan
10-task plan covering converter tool creation, ProtobufZstdFileSource,
DevEtl migrations, and cleanup of obsolete JSON source files.
2026-01-06 14:18:27 -05:00
Joseph Doherty 4965b49c4e refactor(datasync): remove obsolete integration tests project 2026-01-06 14:13:43 -05:00
Joseph Doherty 6074424524 refactor(data-access): update ISearchQueryBuilder to use SearchId only
- Change interface methods to accept int searchId instead of SearchModel
- Update SqlKataSearchQueryBuilder to generate SQL using extraction functions
- SQL now calls dbo.fn_GetSearchWorkOrders(@SearchId) etc instead of TVPs
- Update SearchProcessor to pass model.Id to query builder
- Update tests for new method signatures
2026-01-06 14:08:47 -05:00
Joseph Doherty 832911c5f2 test(db): add validation stored procedure tests 2026-01-06 13:48:16 -05:00
Joseph Doherty 795c15df56 feat(datasync): add EtlPipelineFactory with JSON config support
- Implement IEtlPipelineFactory with ForTable() method returning a builder
- Load pipeline config from JSON file path (from PipelineOptions)
- Parse config using System.Text.Json with PropertyNameCaseInsensitive
- Builder supports WithMode() and WithMinimumDate() fluent methods
- Create DbQuerySource for source with ParameterFormatConverter for JDE dates
- Create DbBulkMergeDestination or DbBulkImportDestination based on sync mode
- Mass mode defaults to bulkImport, incremental defaults to bulkMerge
- Support destination override in sync mode config
- Execute pre/post scripts from config (prePurge, reIndex, custom scripts)
- Validate config: require mass and incremental modes, reject runtime params
- Add comprehensive tests for factory, builder, and config validation
2026-01-06 13:45:36 -05:00
Joseph Doherty afb6ad4f09 test(db): add complex table extraction function tests 2026-01-06 13:44:32 -05:00
Joseph Doherty e0d0ffa8fc test(db): add simple table extraction function tests
Add comprehensive tests for the 5 simple table extraction functions:
- fn_GetSearchWorkOrders
- fn_GetSearchItemNumbers
- fn_GetSearchProfitCenters
- fn_GetSearchWorkCenters
- fn_GetSearchOperatorIDs

Each function tested for:
- Valid array returns all values
- Empty array returns empty
- Missing property returns empty
- Search not found returns empty
- NULL criteria returns empty
- Invalid JSON returns empty
- Bad type values (nulls) filtered out

Additional edge case tests for large arrays and long values.
Total: 38 tests (7 per function + 2 additional edge cases).
2026-01-06 13:40:22 -05:00
Joseph Doherty 13ae0091dd test(db): add scalar extraction function tests
Tests all 3 scalar functions:
- fn_GetSearchMinimumDt
- fn_GetSearchMaximumDt
- fn_GetSearchExtractMisData

Test cases cover:
- Valid JSON extraction
- Missing property returns NULL
- Search not found returns NULL
- NULL criteria returns NULL
- Invalid JSON returns NULL

Uses DatabaseTestBase infrastructure with FluentAssertions and Dapper.
2026-01-06 13:36:12 -05:00
Joseph Doherty 8af4f9915f feat(datasync): extend DbBulkMergeDestination with excludeFromUpdate and updateCondition 2026-01-06 13:35:25 -05:00
Joseph Doherty 61f927bd0e feat(tests): add database test infrastructure
Add DatabaseTestBase.cs with xUnit Collection for test isolation:
- DatabaseTestCollection disables parallel execution
- DatabaseTestFixture verifies database connectivity
- DatabaseTestBase provides connection and cleanup helpers
- InsertTestSearchAsync for creating test data with SearchCriteria
- InsertTestSearchWithRawCriteriaAsync for testing invalid JSON scenarios

Also adds required packages: Dapper, FluentAssertions, Microsoft.Data.SqlClient
2026-01-06 13:30:34 -05:00
Joseph Doherty eb85ab6f34 feat(datasync): add generic DbQuerySource for JDE/CMS/LotFinder
Extend DbQuerySource to support multiple connection types:
- Add connectionType parameter ("jde", "cms", "lotfinder")
- Use appropriate IDbConnectionFactory method for each type
- Support Dictionary<string, object> parameters
- Use DbConnection/DbCommand for cross-database compatibility
2026-01-06 13:30:00 -05:00
Joseph Doherty 1f7fd9f0f2 feat(datasync): add ParameterFormatConverter with JDE date/time support 2026-01-06 13:25:15 -05:00
Joseph Doherty bff947d1e8 test: add AuthApiClientIntegrationTests
Add 5 integration tests for AuthApiClient:
- GetPublicKeyAsync_ReturnsValidPublicKey
- LoginAsync_WithValidCredentials_ReturnsSuccess
- GetCurrentUserAsync_AfterLogin_ReturnsUserInfo
- GetCurrentUserAsync_WithoutAuth_ReturnsUnauthorized
- LogoutAsync_AfterLogin_InvalidatesSession

Tests use RSA encryption pattern for login credentials and
verify auth cookie behavior across requests.
2026-01-06 11:39:09 -05:00
Joseph Doherty f7e683703d test: add SearchApiClientIntegrationTests for search endpoint validation
Add integration tests for SearchApiClient covering:
- GetUserSearchesAsync with authentication returns success
- GetUserSearchesAsync without authentication returns unauthorized
- GetSearchAsync with non-existent ID returns not found
2026-01-06 11:37:43 -05:00
Joseph Doherty 54de0ce1c3 test: add LookupApiClientIntegrationTests for lookup endpoint validation
Add 4 integration tests for LookupApiClient that verify lookup endpoints
work correctly through the actual HTTP pipeline without authentication.
2026-01-06 11:37:36 -05:00
Joseph Doherty 3ed2d7324d test: add ClientIntegrationTestBase with shared auth HttpClient 2026-01-06 11:36:13 -05:00
Joseph Doherty 7e5ac56525 build: add Client project reference to integration tests
Add JdeScoping.Client project reference to Api.IntegrationTests
to enable testing API client classes against the real API.
2026-01-06 11:34:23 -05:00
Joseph Doherty 6cb852c164 test: add FileApiClientTests with route, success, and error tests
Add comprehensive unit tests for FileApiClient covering:
- Route verification tests for all 4 download endpoints (POST method)
- Route verification tests for 2 upload endpoints (POST method)
- Success tests for downloads returning byte arrays
- Success tests verifying existing data can be passed to downloads
- Success tests for uploads returning IReadOnlyList<T>
- Multipart content-type and filename verification test
- Error tests (404 for download, 400 validation error for upload)
2026-01-06 11:33:31 -05:00
Joseph Doherty 55bfdb3532 test: add AuthApiClientTests with route and success tests
Add unit tests for AuthApiClient covering:
- Route verification tests for GetPublicKey, Login, Logout, GetCurrentUser
- Success tests for all 4 methods
- Proper handling of 204 NoContent for Logout (returns Unit)
2026-01-06 11:31:49 -05:00
Joseph Doherty d06d5f27e2 test: add LookupApiClientTests with route and encoding tests
- Route verification tests for all 4 methods (FindItems, FindProfitCenters,
  FindWorkCenters, FindOperators)
- Query string encoding tests verifying special characters (&, =) and spaces
  are properly URL-encoded
- Success tests for all lookup methods verifying deserialization
- Representative error test for 500 status code
2026-01-06 11:29:46 -05:00
Joseph Doherty 76ce35458c test: add SearchApiClientTests with route and success/error tests
Add comprehensive unit tests for SearchApiClient covering:
- Route verification tests for all 6 methods (GetUserSearches, GetQueuedSearches,
  GetSearch, CopySearch, CreateSearch, GetResults)
- Success tests verifying deserialization for all methods
- Representative error tests (404 for GetSearch, 401 for GetUserSearches)

Uses MockHttpMessageHandler to verify correct API routes are called
and ApiResult<T> pattern maps responses correctly.
2026-01-06 11:27:33 -05:00
Joseph Doherty 299099f716 test: add POST and bytes tests to ApiClientBaseTests
Added 11 new tests covering:
- POST method tests (200 success, 401 unauthorized, no-body variant)
- Bytes tests (GET 200, GET 404, POST 200)
- Non-GET status code tests (POST 400 validation, bytes 500, multipart 401/200)

All 23 ApiClientBaseTests now pass.
2026-01-06 11:25:49 -05:00
Joseph Doherty c626ffbd69 test: add edge case tests to ApiClientBaseTests
Add 7 edge case tests for ApiClientBase:
- GetAsync_Returns200_EmptyBody_MapsToApiError
- GetAsync_Returns200_InvalidJson_MapsToApiError
- GetAsync_Returns204_ForUnitType_MapsToSuccess
- GetAsync_Returns204_ForNonUnitType_MapsToApiError
- GetAsync_NetworkException_MapsToApiError
- GetAsync_Timeout_MapsToApiError
- GetAsync_Returns400_WithoutValidationFormat_MapsToApiError

Also fix bug in ApiClientBase where 204 NoContent for Unit type
failed due to incorrect type casting. The implicit conversion from
Unit to ApiResult<Unit> must be applied before the runtime cast.
2026-01-06 11:23:54 -05:00
Joseph Doherty 6af5a4f9d6 test: add all 6 status code mapping tests to ApiClientBaseTests
- Add GetAsync_Returns404_MapsToNotFound test
- Add GetAsync_Returns400_WithValidationErrors_MapsToValidationError test
- Add GetAsync_Returns401_MapsToUnauthorized test
- Add GetAsync_Returns403_MapsToForbidden test
- Add GetAsync_Returns500_MapsToApiError test
- Add FrameworkReference to Microsoft.AspNetCore.App for ValidationProblemDetails
2026-01-06 11:20:43 -05:00
Joseph Doherty e75ebe1ffb test: add ApiClientBaseTests with 200 OK mapping test 2026-01-06 11:17:19 -05:00
Joseph Doherty 626b7a63f2 test: add TestableApiClient helper for ApiClientBase unit tests 2026-01-06 11:15:10 -05:00
Joseph Doherty a8f79c26b2 refactor: add ApiRoutes import to FileControllerIntegrationTests
Added using statement for JdeScoping.Core.ApiContracts. The existing
routes (/api/file/...) are left unchanged as they test legacy download
by cache key endpoints which differ from the new FileIO routes.
2026-01-06 11:13:55 -05:00
Joseph Doherty 13976dea3b refactor: use ApiRoutes constants in AuthenticationTests
Replace hardcoded route strings with ApiRoutes.* constants:
- ApiRoutes.Auth.PublicKey, Login, Logout, Me
- ApiRoutes.Search.Base
- ApiRoutes.Lookup.Items, ProfitCenters, WorkCenters, Operators
2026-01-06 11:12:17 -05:00
Joseph Doherty 81b07ce027 feat: extract DevEtl to JdeScoping.DataSync.Dev project
- Create JdeScoping.DataSync.Dev for sandbox testing ETL code
- Create JdeScoping.DataSync.Dev.Tests for associated tests
- Move 22 source files and 8 test files
- Update namespaces from DevEtl to Dev
- Add both projects to solution
2026-01-06 10:18:09 -05:00
Joseph Doherty 380ffb9a82 fix(test): correct connection string name and cache directory path 2026-01-03 16:42:11 -05:00
Joseph Doherty e04e81b178 test(datasync): add integration tests for BranchDevEtl
Add integration tests for the Branch development ETL pipeline:
- BranchDevEtlTests with tests for pipeline creation and execution
- Tests verify pipeline creates correctly and loads data from cache files
- Added appsettings.json with local connection string and cache directory
- Added necessary packages (Configuration.Json, SqlClient, Dapper)

Tests require local SQL Server and CACHED_DB_FILES directory with
branch.json.zstd to pass; tests silently skip if resources unavailable.
2026-01-03 16:38:11 -05:00