Skip to content

Cross-runtime consistency fixes #52

@sliedig

Description

@sliedig

Summary

A set of fixes to align the Java runtime with the other runtimes (Python, TypeScript, .NET) for functional equivalence and cross-runtime consistency.


Contracts Service

Class rename

  • Renamed class ContractEventHandlerContractEventHandlerFunction in unicorn_contracts/ContractsService/src/main/java/contracts/ContractEventHandler.java
  • Renamed the file to ContractEventHandlerFunction.java
  • Updated CreateContractTests.java to reference ContractEventHandlerFunction

Timestamp type change (Contract.java)

  • Changed contractCreated field from Long to String
  • Changed contractLastModifiedOn field from Long to String

Timestamp storage in createContract

  • Replaced Instant.now().toEpochMilli() with Instant.now().toString()
  • Changed DynamoDB attribute storage from .n(String.valueOf(timestamp)) to .s(Instant.now().toString())
  • Applied to both contract_created and contract_last_modified_on attributes

Timestamp storage in updateContract

  • Changed expression attribute value :modifiedDate from .n(String.valueOf(Instant.now().toEpochMilli())) to .s(Instant.now().toString())

ResponseParser.java

  • Removed .map(Long::valueOf) from contract_created and contract_last_modified_on parsing chains (fields are now String, not Long)

Observability metrics

  • Added ContractCreated metric (MetricUnit.COUNT, value 1) to createContract success path
  • Added ContractUpdated metric (MetricUnit.COUNT, value 1) to updateContract success path
  • Uses MetricsFactory.getMetricsInstance().addMetric(...) (correct instance-based API for Powertools Java v2.x)

Web Service (Publication Manager)

Event source from environment variable (RequestApprovalFunction.java)

  • Added SERVICE_NAMESPACE field read from System.getenv("SERVICE_NAMESPACE")
  • Replaced hardcoded "Unicorn.Web" source in sendEvent with the SERVICE_NAMESPACE field

Complete event payload (RequestApprovalFunction.java)

  • Expanded the RequestApproval inner class to include all required fields: status, listprice (Float), images (List<String>), description, currency
  • Updated sendEvent to populate all fields from the Property object into the event detail

Observability metrics (RequestApprovalFunction.java)

  • Added ApprovalsRequested metric (MetricUnit.COUNT, value 1) to sendEvent success path

Evaluation result validation (PublicationEvaluationEventHandler.java)

  • Added guard to only process events where evaluationResult is APPROVED or DECLINED
  • Logs a warning and returns without writing to DynamoDB for any other value

Observability metrics (PublicationEvaluationEventHandler.java)

  • Added PropertiesApproved metric (MetricUnit.COUNT, value 1) to updatePropertyStatus success path

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions