diff --git a/testdata-generator-common/src/main/java/io/openepcis/testdata/generator/model/AbstractEventCreationModel.java b/testdata-generator-common/src/main/java/io/openepcis/testdata/generator/model/AbstractEventCreationModel.java index 8e63b46..9faa352 100644 --- a/testdata-generator-common/src/main/java/io/openepcis/testdata/generator/model/AbstractEventCreationModel.java +++ b/testdata-generator-common/src/main/java/io/openepcis/testdata/generator/model/AbstractEventCreationModel.java @@ -103,9 +103,24 @@ protected void configure(final E epcisEvent, final List epcisEvent.setSensorElementList(typeInfo.getSensorElementList()); } - // Add the certificationInfo + // Add the certificationInfo by formatting from UserExtension syntax if (typeInfo.getCertificationInfo() != null && !typeInfo.getCertificationInfo().isEmpty()) { - epcisEvent.setCertificationInfo(typeInfo.getCertificationInfo()); + final List formattedCertificationInfo = typeInfo.getCertificationInfo().stream() + .flatMap(root -> { + if (CollectionUtils.isNotEmpty(root.getChildren())) { + // Stream over children if present + return root.getChildren().stream().flatMap(c -> c.toMap().entrySet().stream()); + } else if (root.getRawJsonld() instanceof Map) { + // Stream over rawJsonld if it's a Map + return root.toMap().entrySet().stream(); + } + // Return an empty stream if neither are present + return Stream.empty(); + }).collect(Collectors.toList()); + + if (!formattedCertificationInfo.isEmpty()) { + epcisEvent.setCertificationInfo(formattedCertificationInfo); + } } // User extensions addition diff --git a/testdata-generator-common/src/main/java/io/openepcis/testdata/generator/template/EPCISEventType.java b/testdata-generator-common/src/main/java/io/openepcis/testdata/generator/template/EPCISEventType.java index cea1631..2317d3c 100644 --- a/testdata-generator-common/src/main/java/io/openepcis/testdata/generator/template/EPCISEventType.java +++ b/testdata-generator-common/src/main/java/io/openepcis/testdata/generator/template/EPCISEventType.java @@ -192,9 +192,9 @@ public class EPCISEventType implements Serializable { private @Valid String hashAlgorithm; @Schema( - type = SchemaType.STRING, - description = "URL at which certification details can be found.") - private String certificationInfo; + type = SchemaType.ARRAY, + description = "Certification information associated with the event in GS1 Web Vocabulary or Raw JSON-LD format") + private List<@Valid UserExtensionSyntax> certificationInfo; @Schema( type = SchemaType.ARRAY,