Skip to content

Enhance Submodel.Kind handling #88

Merged
mm-hsh merged 5 commits intodevelopfrom
feature/626-kind-Instance
Apr 1, 2026
Merged

Enhance Submodel.Kind handling #88
mm-hsh merged 5 commits intodevelopfrom
feature/626-kind-Instance

Conversation

@mm-hsh
Copy link
Copy Markdown
Contributor

@mm-hsh mm-hsh commented Mar 30, 2026

This pull request ensures that submodel templates returned by the template provider are always marked as Instance and improves the serialization of enum properties in ShellDescriptorDto. The changes include updates to JSON serialization behavior, new unit tests to verify these behaviors, and a helper method to set the submodel kind.

Serialization improvements:

  • Updated ShellDescriptorDto so that the AssetKind and AssetType properties are serialized as strings instead of integers by adding the JsonStringEnumConverter attribute.

  • Added a unit test in ShellDescriptorMapperProfileTests to verify that serialized DTOs use string values for asset enums.

Template provider enhancements:

  • Modified TemplateProvider to set the Kind property of returned submodel templates to ModellingKind.Instance by introducing the UpdateSubmodelTemplateKind helper method.

  • Added a unit test in TemplateProviderTests to confirm that the returned submodel template has Kind set to Instance.

Added JsonStringEnumConverter to AssetKind/AssetType in ShellDescriptorDto to ensure enums are serialized as strings. Updated TemplateProvider to set Submodel.Kind to ModellingKind.Instance after deserialization. Added and updated unit tests to verify these behaviors. Also included necessary using directives for serialization and enum handling.
@mm-hsh mm-hsh requested review from Copilot, mm-asha and mm-mcn March 30, 2026 11:34
@github-actions
Copy link
Copy Markdown

github-actions bot commented Mar 30, 2026

Dependency Review

✅ No vulnerabilities or license issues or OpenSSF Scorecard issues found.

Scanned Files

None

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adjusts template handling and API DTO serialization to better align with expected AAS semantics: submodel templates returned from the template provider are forced to ModellingKind.Instance, and ShellDescriptorDto asset enum properties are serialized as strings.

Changes:

  • Set ISubmodel.Kind = ModellingKind.Instance for submodels returned by TemplateProvider.GetSubmodelTemplateAsync.
  • Serialize ShellDescriptorDto.AssetKind / AssetType as strings via JsonStringEnumConverter.
  • Add unit tests covering the new submodel kind behavior and enum-string JSON serialization.

Reviewed changes

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

File Description
source/AAS.TwinEngine.DataEngine/Infrastructure/Providers/TemplateProvider/Services/TemplateProvider.cs Mutates deserialized submodel templates so their Kind is always Instance.
source/AAS.TwinEngine.DataEngine/Api/AasRegistry/Responses/ShellDescriptorDto.cs Adds enum-to-string JSON serialization for asset enum properties.
source/AAS.TwinEngine.DataEngine.UnitTests/Infrastructure/Providers/TemplateProvider/Services/TemplateProviderTests.cs Verifies returned submodel template Kind is set to Instance.
source/AAS.TwinEngine.DataEngine.UnitTests/Api/AasRegistry/MappingProfiles/ShellDescriptorMapperProfileTests.cs Adds a test asserting serialized DTO JSON contains string enum values.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

mm-hsh and others added 4 commits March 30, 2026 18:07
Removed per-property JsonStringEnumConverter attributes from ShellDescriptorDto and configured global enum string serialization in Program.cs. Added missing using for System.Text.Json.Serialization. This ensures all enums are serialized as strings consistently across the API.
Changed TestData to use string "Type" for assetKind and assetType instead of integer 0. Removed redundant test for enum string serialization in ShellDescriptorMapperProfileTests.
Replaced integer enum values with string representations for fields like "assetKind", "assetType", and "type" in test JSON files. Changed submodel "kind" from "Template" to "Instance" to align with updated API/model expectations and improve clarity.
@github-actions
Copy link
Copy Markdown

Test & Coverage Report

Test Results Summary

Metric Count
✅ Passed 1021
❌ Failed 0
⏭️ Skipped 0

View Detailed Test Results


Code Coverage

Unit Tests Coverage

Package Line Rate Branch Rate Complexity Health
AAS.TwinEngine.DataEngine 91% 83% 1505
Summary 91% (2560 / 2810) 83% (1075 / 1295) 1505

Minimum allowed line rate is 80%

Module Tests Coverage

Package Line Rate Branch Rate Complexity Health
AAS.TwinEngine.DataEngine 56% 42% 1505
Summary 56% (1563 / 2810) 42% (540 / 1295) 1505

@sonarqubecloud
Copy link
Copy Markdown

@mm-hsh mm-hsh merged commit ff6d4c9 into develop Apr 1, 2026
10 checks passed
@mm-hsh mm-hsh deleted the feature/626-kind-Instance branch April 6, 2026 06:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants