👨💻 Technical ACs (Gherkin)
Context: The system is starting message processing
GIVEN
The system is starting message processing
Applied to: 1:Initialize System Configuration
WHEN
Administrative configuration is being initialized
THEN
The system should retrieve admin segment with table ID 'AD' and sequence ID 'ADMINID', and if not found, set default Merlin ID to 'OM01247'
Context: The system has initialized configuration
GIVEN
The system has initialized configuration
Applied to: 2:Load Incoming Messages
WHEN
Loading messages from the queue
THEN
The system should connect to MQ manager, open the queue, and get messages with conversion options enabled
Context: A message retrieval attempt has been made
GIVEN
A message retrieval attempt has been made
Applied to: Message Available?
WHEN
The completion code is MQCC-OK and message entries are greater than 1 and backout count equals 0
THEN
The message should be marked as good for processing, otherwise skip or terminate based on specific conditions
Context: A valid message is being processed
GIVEN
A valid message is being processed
Applied to: 3:Determine Message Type
WHEN
M10 segment reference number starts with 'TRAIN'
THEN
The message should be classified as Train type, or if M10 reference number starts with 'CARGO' then classify as Cargo type, or if neither but M11 segment exists then extract cargo information from M11
Context: An M10 segment is being processed
GIVEN
An M10 segment is being processed
Applied to: Test Message?
WHEN
The table reference number equals 'TRAINCPRSTESTTRAIN0000000000' or 'CARGOCPRS940000000000'
THEN
The message should be processed as a special test case with timestamp updates to T1 table segment
Context: A message has been classified as Train or Cargo
GIVEN
A message has been classified as Train or Cargo
Applied to: Train or Cargo?
WHEN
M10 manifest type code is 'P', 'X', 'Y', 'T', or 'S'
THEN
The system should set status update flag to true, and if manifest type code is 'H' for trains, set delete status flag to true
Context: A message has been classified as Train type
GIVEN
A message has been classified as Train type
Applied to: 16:Retrieve Train Records
WHEN
Retrieving train records using the train ID from M10 data
THEN
The system should call train I/O module with GET function for root record only, and if not found, log error message indicating train ID was not found
Context: A message has been classified as Cargo type
GIVEN
A message has been classified as Cargo type
Applied to: 15:Retrieve Cargo Records
WHEN
Retrieving cargo records using the cargo control number from M10 data
THEN
The system should call cargo I/O module with GET function for cargo segment, and if not found, log error message indicating cargo control number was not found
Context: Message segments are available for processing
GIVEN
Message segments are available for processing
Applied to: 6:Process Message Segments
WHEN
Processing segments by type where M10 contains manifest data, P4 contains additional data, N10 contains line release number, K1 contains message text, and K3 contains acceptance data
THEN
The system should process each segment type appropriately and continue until end marker or spaces are encountered
Context: Message segments have been processed
GIVEN
Message segments have been processed
Applied to: 8:Validate Required Segments
WHEN
Checking for required segments
THEN
The system should log error if M10 segment not found, or if P4 segment not found, or if K3 segment not found and create default K3 segment
Context: A K3 segment is being processed
GIVEN
A K3 segment is being processed
Applied to: 9:Process Rejection Information
WHEN
K3 total reject count equals zero and total accept count is greater than zero
THEN
The system should set ACK status, but if total reject count is greater than zero, set ERROR status, and if both counts are zero, set ACK status with warning message
Context: K3 acceptance data has been processed with zero rejections and positive acceptances
GIVEN
K3 acceptance data has been processed with zero rejections and positive acceptances
Applied to: 10:Determine Final Status
WHEN
Train is in pre-arrived status
THEN
The system should set pre-arrival status, or if train review is complete, set review-completed status, otherwise set standard ACK status
Context: An error status has been determined
GIVEN
An error status has been determined
Applied to: 12:Send Error Messages
WHEN
Error status flag is set
THEN
The system should send error notification message via EMCSEND to configured Merlin recipients
Context: Train processing requires status update
GIVEN
Train processing requires status update
Applied to: 17:Update Train Status
WHEN
Train is deleted and status is ACK, or train is delete-pending and status is ACK
THEN
The system should set status to 'DELETED', or if train is not deleted or delete-pending, update with current status
Context: Cargo processing requires status update
GIVEN
Cargo processing requires status update
Applied to: 18:Update Cargo Status
WHEN
Status is ACK and saved status description is spaces
THEN
The system should set cargo ACK flags, or if saved status exists, restore saved status and description, or if status is error, save current status and set error flags
Context: Train status has been updated
GIVEN
Train status has been updated
Applied to: 19:Check AEI Train Qualification
WHEN
Train has ACK status and AEI-SEND flag and ENROUTE-NOT-REPORTED flag and train ID position 23 equals 'T'
THEN
The system should qualify train for AEI processing and prepare customs transaction data
Applied to: 23:Process Automatic Train Arrival
WHEN
Train has ACK status and ARRIVED-PENDING flag
THEN
The system should trigger automatic train arrival processing with current date and time
Context: Train qualifies for AEI processing
GIVEN
Train qualifies for AEI processing
Applied to: 20:Load Train Car Information
WHEN
Loading car information where container indicator is not 'C'
THEN
The system should load car initials, numbers, and equipment types, and determine loaded/empty status based on next car's container indicator
Context: Train has AEI-SEND flag set
GIVEN
Train has AEI-SEND flag set
Applied to: 21:Send AEI Status Messages
WHEN
Sending AEI status messages
THEN
The system should retrieve AEI Merlin recipients from database, format train and status information, and send via EMCSEND3
Context: Train status processing is complete
GIVEN
Train status processing is complete
Applied to: 22:Send Terminal Status Messages
WHEN
Train has ACK status and AEI-SEND flag and ENROUTE-REPORTED flag
THEN
The system should send enroute message to AEI Merlin recipients
Context: Message processing activities need to be logged
GIVEN
Message processing activities need to be logged
Applied to: 13:Log Message Processing
WHEN
Creating log entries
THEN
The system should format different log messages for cargo versus train operations, and use special format when status should not be updated
Context: Processing activities require reporting
GIVEN
Processing activities require reporting
Applied to: 26:Send Merlin Reports
WHEN
Sending Merlin reports
THEN
The system should send reports to primary recipients and copy to administrative recipients with appropriate error handling
Context: Special test message is being processed
GIVEN
Special test message is being processed
Applied to: 25:Update Administrative Tables
WHEN
Manifest type is 'P'
THEN
The system should update T1-309-ACK timestamp, or if manifest type is 'H', update T1-353-ACK timestamp, or if manifest type is 'S', update T1-358-ACK timestamp
Context: Message processing is complete or terminated
GIVEN
Message processing is complete or terminated
Applied to: 27:Close MQ Connections
WHEN
Closing MQ resources
THEN
The system should close queue handle and disconnect from MQ manager with appropriate error handling