]> Piment Noir Git Repositories - e-mobility-charging-stations-simulator.git/commit
refactor(ocpp): enforce strict version separation in OCPPServiceUtils
authorJérôme Benoit <jerome.benoit@sap.com>
Mon, 30 Mar 2026 22:44:20 +0000 (00:44 +0200)
committerJérôme Benoit <jerome.benoit@sap.com>
Mon, 30 Mar 2026 22:44:20 +0000 (00:44 +0200)
commite3ea37160d9fd43484f6cb0ef743ddb4fb3352f1
treeee5686283f8ab9a350c06d497ff39244cdfd91ef
parent91f9621473de2f50db59e35beea2e169acfa511c
refactor(ocpp): enforce strict version separation in OCPPServiceUtils

Extract version-specific logic from cross-version utilities:

- P1: Move buildStatusNotificationRequest into OCPP16ServiceUtils and
  OCPP20ServiceUtils as version-specific static methods
- P2: Move buildTransactionEndMeterValue to OCPP16ServiceUtils, remove
  dead OCPP 2.0 branch that was never called
- P3: Split buildMeterValue into thin dispatcher plus dedicated
  buildMeterValueForOCPP16/buildMeterValueForOCPP20 internal functions
- P4: Simplify checkConnectorStatusTransition to select transition
  tables by version then apply single shared lookup logic

Harmonize tests to match new module structure:
- Rename OCPPServiceUtils-StopTransaction.test.ts to
  OCPPServiceOperations.test.ts (functions moved to that module)
- Move mapStopReasonToOCPP20 tests to OCPPServiceUtils-pure.test.ts
  (function still lives in OCPPServiceUtils)
- Add dedicated unit tests for buildStatusNotificationRequest in both
  OCPP16ServiceUtils.test.ts and new OCPP20ServiceUtils-StatusNotification.test.ts
- Fix redundant describe nesting in OCPP20 test file
src/charging-station/ocpp/1.6/OCPP16RequestService.ts
src/charging-station/ocpp/1.6/OCPP16ResponseService.ts
src/charging-station/ocpp/1.6/OCPP16ServiceUtils.ts
src/charging-station/ocpp/2.0/OCPP20RequestService.ts
src/charging-station/ocpp/2.0/OCPP20ServiceUtils.ts
src/charging-station/ocpp/OCPPServiceUtils.ts
src/charging-station/ocpp/index.ts
tests/charging-station/ocpp/1.6/OCPP16ServiceUtils.test.ts
tests/charging-station/ocpp/2.0/OCPP20ServiceUtils-StatusNotification.test.ts [new file with mode: 0644]
tests/charging-station/ocpp/OCPPServiceOperations.test.ts [moved from tests/charging-station/ocpp/OCPPServiceUtils-StopTransaction.test.ts with 89% similarity]
tests/charging-station/ocpp/OCPPServiceUtils-pure.test.ts