From e0b1498022b3ce048934f14e22122a0072cb2085 Mon Sep 17 00:00:00 2001 From: AnuragNagpure Date: Thu, 25 Apr 2024 12:16:18 +0530 Subject: [PATCH] changes in test cases and functionality added --- .../Repositories/PolicyRepository.cs | 2 +- .../20240424045703_feat-25-policy-seeding.cs | 2 +- .../Seeder/BatchUpdateSeeder.cs | 2 +- .../Seeder/Data/policies.json | 26 +--- .../Seeder/Data/policy_assigned_types.json | 9 +- .../Data/policy_assigned_use_cases.json | 6 +- .../policy_attribute_assigned_use_cases.json | 136 ++++++++---------- .../Seeder/Data/policy_attributes.json | 33 ++--- .../BusinessLogic/PolicyHubBusinessLogic.cs | 9 +- .../PolicyRepositoryTests.cs | 21 ++- .../PolicyHubBusinessLogicTests.cs | 2 +- .../Controllers/PolicyHubControllerTests.cs | 23 ++- 12 files changed, 102 insertions(+), 169 deletions(-) diff --git a/src/database/PolicyHub.DbAccess/Repositories/PolicyRepository.cs b/src/database/PolicyHub.DbAccess/Repositories/PolicyRepository.cs index 96ceaa2..a32c05e 100644 --- a/src/database/PolicyHub.DbAccess/Repositories/PolicyRepository.cs +++ b/src/database/PolicyHub.DbAccess/Repositories/PolicyRepository.cs @@ -56,7 +56,7 @@ public IAsyncEnumerable GetPolicyTypes(PolicyTypeId? type, U .Select(p => new ValueTuple>, string?>( true, p.LeftOperandValue ?? p.TechnicalKey, - new ValueTuple>(p.AttributeKeyId, p.AttributeKey!.PolicyAttributes.Where(pa => pa.IsActive && pa.PolicyId == p.Id).Select(a => a.AttributeValue)), + new ValueTuple>(p.AttributeKeyId, p.AttributeKey!.PolicyAttributes.Where(pa => pa.IsActive && pa.PolicyId == p.Id && (useCase == null || pa.PolicyAttributeAssignedUseCases.Any(x => x.UseCaseId == useCase))).Select(a => a.AttributeValue)), p.PolicyKind!.Configuration!.RightOperandValue )) .FirstOrDefaultAsync(); diff --git a/src/database/PolicyHub.Migrations/Migrations/20240424045703_feat-25-policy-seeding.cs b/src/database/PolicyHub.Migrations/Migrations/20240424045703_feat-25-policy-seeding.cs index 8d9ff66..4aa6632 100644 --- a/src/database/PolicyHub.Migrations/Migrations/20240424045703_feat-25-policy-seeding.cs +++ b/src/database/PolicyHub.Migrations/Migrations/20240424045703_feat-25-policy-seeding.cs @@ -1,4 +1,4 @@ -/******************************************************************************** +/******************************************************************************** * Copyright (c) 2023 Contributors to the Eclipse Foundation * * See the NOTICE file(s) distributed with this work for additional diff --git a/src/database/PolicyHub.Migrations/Seeder/BatchUpdateSeeder.cs b/src/database/PolicyHub.Migrations/Seeder/BatchUpdateSeeder.cs index ff172d4..01e958d 100644 --- a/src/database/PolicyHub.Migrations/Seeder/BatchUpdateSeeder.cs +++ b/src/database/PolicyHub.Migrations/Seeder/BatchUpdateSeeder.cs @@ -52,7 +52,7 @@ await SeedTable( await SeedTable( "policy_attributes", - x => new { x.PolicyId, x.Key, x.AttributeValue }, + x => new { x.Id, x.PolicyId, x.Key, x.AttributeValue }, x => x.dbEntity.IsActive != x.dataEntity.IsActive, (dbEntry, entry) => { diff --git a/src/database/PolicyHub.Migrations/Seeder/Data/policies.json b/src/database/PolicyHub.Migrations/Seeder/Data/policies.json index d76ebee..29c8a8a 100644 --- a/src/database/PolicyHub.Migrations/Seeder/Data/policies.json +++ b/src/database/PolicyHub.Migrations/Seeder/Data/policies.json @@ -15,30 +15,6 @@ "is_active": true, "attribute_key_id": 2 }, - { - "id": "01a0fba3-9b6e-435a-b045-e0e890c300b7", - "kind_id": 4, - "technical_key": "purpose.trace.v1.TraceBattery", - "description": "Facilitating compliance with mandatory regulatory requirements for tracking and reporting battery cells, modules & high-voltage batteries.", - "is_active": true, - "attribute_key_id": 2 - }, - { - "id": "01a0fba3-9b6e-435a-b045-e0e890c300b8", - "kind_id": 4, - "technical_key": "purpose.trace.v1.aspects", - "description": "Establishing a digital representation of the automotive supply chain to enable a component specific data exchange.", - "is_active": true, - "attribute_key_id": 2 - }, - { - "id": "01a0fba3-9b6e-435a-b045-e0e890c300b9", - "kind_id": 4, - "technical_key": "purpose.trace.v1.qualityanalysis", - "description": " The data can be used for quality analysis to identify and select affected components and to send quality notifications to affected customers or suppliers.", - "is_active": true, - "attribute_key_id": 2 - }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300c1", "kind_id": 5, @@ -58,7 +34,7 @@ }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300c9", - "kind_id": 4, + "kind_id": 3, "technical_key": "FrameworkAgreement", "description": "With the Framework Credential, only those participants which have signed the respective framework agreement (general or via a specific version) are allowed to view or negotiate the respective data offer. Generic: \"rightOperand\": \"active\"; specific \"rightOperand\": \"active:{version}\"", "is_active": true, diff --git a/src/database/PolicyHub.Migrations/Seeder/Data/policy_assigned_types.json b/src/database/PolicyHub.Migrations/Seeder/Data/policy_assigned_types.json index 45bbce7..ac3d875 100644 --- a/src/database/PolicyHub.Migrations/Seeder/Data/policy_assigned_types.json +++ b/src/database/PolicyHub.Migrations/Seeder/Data/policy_assigned_types.json @@ -2,12 +2,9 @@ { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b1", "policy_type_id": 1, "is_active": true }, { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b1", "policy_type_id": 2, "is_active": true }, { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b2", "policy_type_id": 1, "is_active": true }, - { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b2", "policy_type_id": 2, "is_active": true }, - { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b3", "policy_type_id": 2, "is_active": true }, - { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b4", "policy_type_id": 2, "is_active": true }, - { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b5", "policy_type_id": 2, "is_active": true }, - { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b6", "policy_type_id": 2, "is_active": true }, + { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b2", "policy_type_id": 2, "is_active": true }, { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c1", "policy_type_id": 1, "is_active": true }, { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c1", "policy_type_id": 2, "is_active": true }, - { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c2", "policy_type_id": 2, "is_active": true } + { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c2", "policy_type_id": 2, "is_active": true }, + { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9", "policy_type_id": 2, "is_active": true } ] diff --git a/src/database/PolicyHub.Migrations/Seeder/Data/policy_assigned_use_cases.json b/src/database/PolicyHub.Migrations/Seeder/Data/policy_assigned_use_cases.json index 0294aec..f2a5a33 100644 --- a/src/database/PolicyHub.Migrations/Seeder/Data/policy_assigned_use_cases.json +++ b/src/database/PolicyHub.Migrations/Seeder/Data/policy_assigned_use_cases.json @@ -8,11 +8,7 @@ { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b2", "use_case_id": 2, "is_active": true }, { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b2", "use_case_id": 3, "is_active": true }, { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b2", "use_case_id": 4, "is_active": true }, - { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b2", "use_case_id": 5, "is_active": true }, - { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b3", "use_case_id": 1, "is_active": true }, - { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b4", "use_case_id": 2, "is_active": true }, - { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b5", "use_case_id": 3, "is_active": true }, - { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b6", "use_case_id": 4, "is_active": true }, + { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b2", "use_case_id": 5, "is_active": true }, { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c1", "use_case_id": 1, "is_active": true }, { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c1", "use_case_id": 2, "is_active": true }, { "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c1", "use_case_id": 3, "is_active": true }, diff --git a/src/database/PolicyHub.Migrations/Seeder/Data/policy_attribute_assigned_use_cases.json b/src/database/PolicyHub.Migrations/Seeder/Data/policy_attribute_assigned_use_cases.json index 220d99c..09b6b12 100644 --- a/src/database/PolicyHub.Migrations/Seeder/Data/policy_attribute_assigned_use_cases.json +++ b/src/database/PolicyHub.Migrations/Seeder/Data/policy_attribute_assigned_use_cases.json @@ -1,82 +1,58 @@ [ - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d1", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d1", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d1", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d1", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d1", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d2", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d2", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d2", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d2", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d2", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d6", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d6", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d6", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d6", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d6", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d7", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d7", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d7", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d7", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d7", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d8", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d8", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d8", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d8", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d8", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d9", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d9", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d9", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d9", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d9", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e1", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e1", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e1", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e1", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e1", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e2", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e2", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e2", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e2", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e2", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e3", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e3", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e3", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e3", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e3", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e4", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e4", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e4", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e4", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e4", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e5", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e5", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e5", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e5", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e5", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e6", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e6", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e6", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e6", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e6", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e7", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e7", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e7", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e7", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e7", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e8", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e8", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e8", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e8", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e8", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e9", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e9", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e9", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e9", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e9", "use_case_id": 5, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300f1", "use_case_id": 1, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300f1", "use_case_id": 2, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300f1", "use_case_id": 3, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300f1", "use_case_id": 4, "is_active": true }, - { "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300f1", "use_case_id": 5, "is_active": true } + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d1", "use_case_id": 1, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d1", "use_case_id": 2, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d1", "use_case_id": 3, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d1", "use_case_id": 4, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d1", "use_case_id": 5, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d2", "use_case_id": 1, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d2", "use_case_id": 2, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d2", "use_case_id": 3, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d2", "use_case_id": 4, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d2", "use_case_id": 5, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d6", "use_case_id": 1, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d6", "use_case_id": 2, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d6", "use_case_id": 3, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d6", "use_case_id": 4, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d6", "use_case_id": 5, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d7", "use_case_id": 1, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d7", "use_case_id": 2, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d7", "use_case_id": 3, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d7", "use_case_id": 4, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d7", "use_case_id": 5, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d8", "use_case_id": 1, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d8", "use_case_id": 2, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d8", "use_case_id": 3, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d8", "use_case_id": 4, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d8", "use_case_id": 5, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d9", "use_case_id": 1, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e1", "use_case_id": 1, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e2", "use_case_id": 1, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e3", "use_case_id": 2, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e3", "use_case_id": 3, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e3", "use_case_id": 4, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e3", "use_case_id": 5, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e4", "use_case_id": 2, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e4", "use_case_id": 3, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e4", "use_case_id": 4, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e4", "use_case_id": 5, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e6", "use_case_id": 2, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e6", "use_case_id": 3, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e6", "use_case_id": 4, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e6", "use_case_id": 5, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e7", "use_case_id": 2, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e7", "use_case_id": 3, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e7", "use_case_id": 4, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e7", "use_case_id": 5, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e8", "use_case_id": 2, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e8", "use_case_id": 3, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e8", "use_case_id": 4, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e8", "use_case_id": 5, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e9", "use_case_id": 2, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e9", "use_case_id": 3, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e9", "use_case_id": 4, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e9", "use_case_id": 5, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300f1", "use_case_id": 2, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300f1", "use_case_id": 3, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300f1", "use_case_id": 4, "is_active": true }, + { "id": "01a0fba3-9b6e-435a-b045-e0e890c300f1", "use_case_id": 5, "is_active": true } ] \ No newline at end of file diff --git a/src/database/PolicyHub.Migrations/Seeder/Data/policy_attributes.json b/src/database/PolicyHub.Migrations/Seeder/Data/policy_attributes.json index 7618b87..c02ac53 100644 --- a/src/database/PolicyHub.Migrations/Seeder/Data/policy_attributes.json +++ b/src/database/PolicyHub.Migrations/Seeder/Data/policy_attributes.json @@ -15,21 +15,21 @@ }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d3", - "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b7", + "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c2", "key": 2, "attribute_value": "purpose.trace.v1.TraceBattery", "is_active": true }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d4", - "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b8", + "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c2", "key": 2, "attribute_value": "purpose.trace.v1.aspects", "is_active": true }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300d5", - "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300b9", + "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c2", "key": 2, "attribute_value": "purpose.trace.v1.qualityanalysis", "is_active": true @@ -59,77 +59,70 @@ "id": "01a0fba3-9b6e-435a-b045-e0e890c300d9", "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9", "key": 5, - "attribute_value": "traceability:1.0", + "attribute_value": "1.0", "is_active": true }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e1", "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9", "key": 5, - "attribute_value": "traceability:1.1", + "attribute_value": "1.1", "is_active": true }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e2", "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9", "key": 5, - "attribute_value": "traceability:1.2", + "attribute_value": "1.2", "is_active": true }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e3", "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9", "key": 5, - "attribute_value": "quality:1.0", + "attribute_value": "Quality:1.0", "is_active": true }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e4", "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9", "key": 5, - "attribute_value": "pcf:1.0", - "is_active": true - }, - { - "id": "01a0fba3-9b6e-435a-b045-e0e890c300e5", - "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9", - "key": 5, - "attribute_value": "pcf:1.0", + "attribute_value": "PCF:1.0", "is_active": true }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e6", "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9", "key": 5, - "attribute_value": "behavioraltwin:1.0", + "attribute_value": "Behavioraltwin:1.0", "is_active": true }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e7", "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9", "key": 5, - "attribute_value": "circulareconomy:1.0", + "attribute_value": "Circulareconomy:1.0", "is_active": true }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e8", "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9", "key": 5, - "attribute_value": "demandcapacity:1.0", + "attribute_value": "Demandcapacity:1.0", "is_active": true }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300e9", "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9", "key": 5, - "attribute_value": "puris:1.0", + "attribute_value": "Puris:1.0", "is_active": true }, { "id": "01a0fba3-9b6e-435a-b045-e0e890c300f1", "policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9", "key": 5, - "attribute_value": "businesspartner:1.0", + "attribute_value": "Businesspartner:1.0", "is_active": true } ] \ No newline at end of file diff --git a/src/hub/PolicyHub.Service/BusinessLogic/PolicyHubBusinessLogic.cs b/src/hub/PolicyHub.Service/BusinessLogic/PolicyHubBusinessLogic.cs index 344b16a..77f4001 100644 --- a/src/hub/PolicyHub.Service/BusinessLogic/PolicyHubBusinessLogic.cs +++ b/src/hub/PolicyHub.Service/BusinessLogic/PolicyHubBusinessLogic.cs @@ -20,6 +20,7 @@ using Org.Eclipse.TractusX.PolicyHub.DbAccess; using Org.Eclipse.TractusX.PolicyHub.DbAccess.Models; using Org.Eclipse.TractusX.PolicyHub.DbAccess.Repositories; +using Org.Eclipse.TractusX.PolicyHub.Entities.Entities; using Org.Eclipse.TractusX.PolicyHub.Entities.Enums; using Org.Eclipse.TractusX.PolicyHub.Service.Extensions; using Org.Eclipse.TractusX.PolicyHub.Service.Models; @@ -52,19 +53,19 @@ public async Task GetPolicyContentWithFiltersAsync(UseCaseId? us } var (rightOperand, additionalAttribute) = attributes.Key != null ? - GetRightOperand(operatorId, attributes, rightOperands, value, leftOperand) : + GetRightOperand(operatorId, attributes, rightOperands, value, leftOperand, useCase) : (rightOperandValue!, null); return new PolicyResponse(CreateFileContent(type, operatorId, "cx-policy:" + leftOperand, rightOperand), additionalAttribute == null ? null : Enumerable.Repeat(additionalAttribute, 1)); } - private static (object rightOperand, AdditionalAttributes? additionalAttribute) GetRightOperand(OperatorId operatorId, (AttributeKeyId? Key, IEnumerable Values) attributes, IEnumerable rightOperands, string? value, string leftOperand) => + private static (object rightOperand, AdditionalAttributes? additionalAttribute) GetRightOperand(OperatorId operatorId, (AttributeKeyId? Key, IEnumerable Values) attributes, IEnumerable rightOperands, string? value, string leftOperand, UseCaseId? useCase) => attributes.Key switch { AttributeKeyId.DynamicValue => (value ?? "{dynamicValue}", null), AttributeKeyId.Regex => (GetRegexValue(attributes, value), null), _ => operatorId == OperatorId.Equals - ? rightOperands.Count() > 1 ? ($"@{leftOperand}-{attributes.Key}", new AdditionalAttributes($"@{leftOperand}-{attributes.Key}", rightOperands)) : (rightOperands.Single(), null) + ? rightOperands.Count() > 1 ? ($"@{leftOperand}{(useCase != null ? useCase.ToString().Insert(0, ".") : string.Empty)}-{attributes.Key}", new AdditionalAttributes($"@{leftOperand}{(useCase != null ? useCase.ToString().Insert(0, ".") : string.Empty)}-{attributes.Key}", rightOperands)) : (rightOperands.Single(), null) : (rightOperands, null) }; @@ -163,7 +164,7 @@ public async Task GetPolicyContentAsync(PolicyContentRequest req } var (rightOperand, additionalAttribute) = policy.Attributes.Key != null ? - GetRightOperand(constraint.Operator, policy.Attributes, rightOperands, constraint.Value, policy.LeftOperand) : + GetRightOperand(constraint.Operator, policy.Attributes, rightOperands, constraint.Value, policy.LeftOperand, null) : (policy.RightOperandValue!, null); if (additionalAttribute != null) { diff --git a/tests/database/PolicyHub.DbAccess.Tests/PolicyRepositoryTests.cs b/tests/database/PolicyHub.DbAccess.Tests/PolicyRepositoryTests.cs index 373577d..0112256 100644 --- a/tests/database/PolicyHub.DbAccess.Tests/PolicyRepositoryTests.cs +++ b/tests/database/PolicyHub.DbAccess.Tests/PolicyRepositoryTests.cs @@ -72,13 +72,10 @@ public async Task GetPolicyTypes_ReturnsExpectedResult() var result = await sut.GetPolicyTypes(null, null).ToListAsync(); // Assert - result.Should().NotBeEmpty().And.HaveCount(8).And.Satisfy( + result.Should().NotBeEmpty().And.HaveCount(5).And.Satisfy( x => x.TechnicalKey == "BusinessPartnerNumber", x => x.TechnicalKey == "Membership", - x => x.TechnicalKey == "FrameworkAgreement.traceability", - x => x.TechnicalKey == "FrameworkAgreement.quality", - x => x.TechnicalKey == "FrameworkAgreement.pcf", - x => x.TechnicalKey == "FrameworkAgreement.behavioraltwin", + x => x.TechnicalKey == "FrameworkAgreement", x => x.TechnicalKey == "companyRole.dismantler", x => x.TechnicalKey == "purpose" ); @@ -108,13 +105,14 @@ public async Task GetPolicyTypes_WithUseCase_ReturnsExpectedResult() var sut = await CreateSut(); // Act - var result = await sut.GetPolicyTypes(null, UseCaseId.Sustainability).ToListAsync(); + var result = await sut.GetPolicyTypes(null, UseCaseId.Quality).ToListAsync(); // Assert - result.Should().NotBeEmpty().And.HaveCount(3).And.Satisfy( + result.Should().NotBeEmpty().And.HaveCount(4).And.Satisfy( x => x.TechnicalKey == "BusinessPartnerNumber" && x.Attribute.Count() == 1 && x.Type.Count() == 2 && x.UseCase.Count() == 5, x => x.TechnicalKey == "Membership" && x.Attribute.Count() == 1 && x.Type.Count() == 2 && x.UseCase.Count() == 5, - x => x.TechnicalKey == "companyRole.dismantler" && x.Attribute.Count() == 3 && x.Type.Count() == 2 && x.UseCase.Count() == 5 + x => x.TechnicalKey == "companyRole.dismantler" && x.Attribute.Count() == 3 && x.Type.Count() == 2 && x.UseCase.Count() == 5, + x => x.TechnicalKey == "FrameworkAgreement" && x.Attribute.Count() == 10 && x.Type.Count() == 1 && x.UseCase.Count() == 5 ); } @@ -147,14 +145,13 @@ public async Task GetPolicyContentAsync_WithRightOperand_ReturnsExpectedResult() var sut = await CreateSut(); // Act - var result = await sut.GetPolicyContentAsync(null, PolicyTypeId.Usage, "FrameworkAgreement.behavioraltwin"); + var result = await sut.GetPolicyContentAsync(null, PolicyTypeId.Usage, "FrameworkAgreement"); // Assert result.Exists.Should().BeTrue(); result.Attributes.Key.Should().Be(AttributeKeyId.Version); - result.Attributes.Values.Should().ContainSingle() - .And.Satisfy(x => x == "1.0"); - result.LeftOperand.Should().Be("FrameworkAgreement.behavioraltwin"); + result.Attributes.Values.Should().Contain("1.1"); + result.LeftOperand.Should().Be("FrameworkAgreement"); result.RightOperandValue.Should().Be("active:{0}"); } diff --git a/tests/hub/PolicyHub.Service.Tests/BusinessLogic/PolicyHubBusinessLogicTests.cs b/tests/hub/PolicyHub.Service.Tests/BusinessLogic/PolicyHubBusinessLogicTests.cs index 56fb3a3..1626f6d 100644 --- a/tests/hub/PolicyHub.Service.Tests/BusinessLogic/PolicyHubBusinessLogicTests.cs +++ b/tests/hub/PolicyHub.Service.Tests/BusinessLogic/PolicyHubBusinessLogicTests.cs @@ -181,7 +181,7 @@ public async Task GetPolicyContentWithFiltersAsync_WithMultipleValues_ReturnsExp x => x == "value2", x => x == "value3" ); - result.Content.Permission.Constraint.RightOperandValue.Should().Be("@multipleAdditionalValues-Static"); + result.Content.Permission.Constraint.RightOperandValue.Should().Be("@multipleAdditionalValues.Traceability-Static"); result.Content.Permission.Constraint.LeftOperand.Should().Be("cx-policy:multipleAdditionalValues"); result.Content.Permission.Constraint.Operator.Should().Be("eq"); result.Content.Permission.Constraint.AndOperands.Should().BeNull(); diff --git a/tests/hub/PolicyHub.Service.Tests/Controllers/PolicyHubControllerTests.cs b/tests/hub/PolicyHub.Service.Tests/Controllers/PolicyHubControllerTests.cs index 2e4c7ab..2174327 100644 --- a/tests/hub/PolicyHub.Service.Tests/Controllers/PolicyHubControllerTests.cs +++ b/tests/hub/PolicyHub.Service.Tests/Controllers/PolicyHubControllerTests.cs @@ -78,13 +78,10 @@ public async Task GetPolicyTypes_WithoutFilter_ReturnsExpected() // Assert policies.Should().NotBeNull() - .And.HaveCount(8).And.Satisfy( + .And.HaveCount(5).And.Satisfy( x => x.TechnicalKey == "BusinessPartnerNumber", x => x.TechnicalKey == "Membership", - x => x.TechnicalKey == "FrameworkAgreement.traceability", - x => x.TechnicalKey == "FrameworkAgreement.quality", - x => x.TechnicalKey == "FrameworkAgreement.pcf", - x => x.TechnicalKey == "FrameworkAgreement.behavioraltwin", + x => x.TechnicalKey == "FrameworkAgreement", x => x.TechnicalKey == "companyRole.dismantler", x => x.TechnicalKey == "purpose" ); @@ -116,7 +113,7 @@ public async Task GetPolicyTypes_WithUseCaseFilter_ReturnsExpected() .And.HaveCount(5).And.Satisfy( x => x.TechnicalKey == "BusinessPartnerNumber", x => x.TechnicalKey == "Membership", - x => x.TechnicalKey == "FrameworkAgreement.traceability", + x => x.TechnicalKey == "FrameworkAgreement", x => x.TechnicalKey == "companyRole.dismantler", x => x.TechnicalKey == "purpose" ); @@ -172,14 +169,14 @@ public async Task GetPolicyContent_BpnWithValue_ReturnsExpected() public async Task GetPolicyContent_UsageFrameworkEquals_ReturnsExpected() { // Act - var response = await _client.GetAsync($"{BaseUrl}/policy-content?type={PolicyTypeId.Usage}&policyName=FrameworkAgreement.traceability&operatorType={OperatorId.Equals}"); + var response = await _client.GetAsync($"{BaseUrl}/policy-content?useCase=Traceability&type={PolicyTypeId.Usage}&policyName=FrameworkAgreement&operatorType={OperatorId.Equals}"); // Assert response.Should().NotBeNull(); response.StatusCode.Should().Be(HttpStatusCode.OK); (await response.Content.ReadAsStringAsync()) .Should() - .Be("{\"content\":{\"@context\":[\"https://www.w3.org/ns/odrl.jsonld\",{\"cx\":\"https://w3id.org/catenax/v0.0.1/ns/\"}],\"@type\":\"Offer\",\"@id\":\"....\",\"permission\":{\"action\":\"use\",\"constraint\":{\"leftOperand\":\"cx-policy:FrameworkAgreement.traceability\",\"operator\":\"eq\",\"rightOperand\":\"@FrameworkAgreement.traceability-Version\"}}},\"attributes\":[{\"key\":\"@FrameworkAgreement.traceability-Version\",\"possibleValues\":[\"active:1.0\",\"active:1.1\",\"active:1.2\"]}]}"); + .Be("{\"content\":{\"@context\":[\"https://www.w3.org/ns/odrl.jsonld\",{\"cx\":\"https://w3id.org/catenax/v0.0.1/ns/\"}],\"@type\":\"Offer\",\"@id\":\"....\",\"permission\":{\"action\":\"use\",\"constraint\":{\"leftOperand\":\"cx-policy:FrameworkAgreement\",\"operator\":\"eq\",\"rightOperand\":\"@FrameworkAgreement.Traceability-Version\"}}},\"attributes\":[{\"key\":\"@FrameworkAgreement.Traceability-Version\",\"possibleValues\":[\"active:1.0\",\"active:1.1\",\"active:1.2\"]}]}"); } [Fact] @@ -207,7 +204,7 @@ public async Task GetPolicyContent_TraceabilityUsagePurposeEquals_ReturnsExpecte response.StatusCode.Should().Be(HttpStatusCode.OK); (await response.Content.ReadAsStringAsync()) .Should() - .Be("{\"content\":{\"@context\":[\"https://www.w3.org/ns/odrl.jsonld\",{\"cx\":\"https://w3id.org/catenax/v0.0.1/ns/\"}],\"@type\":\"Offer\",\"@id\":\"....\",\"permission\":{\"action\":\"use\",\"constraint\":{\"leftOperand\":\"Membership\",\"operator\":\"eq\",\"rightOperand\":\"active\"}}}}"); + .Be("{\"content\":{\"@context\":[\"https://www.w3.org/ns/odrl.jsonld\",{\"cx\":\"https://w3id.org/catenax/v0.0.1/ns/\"}],\"@type\":\"Offer\",\"@id\":\"....\",\"permission\":{\"action\":\"use\",\"constraint\":{\"leftOperand\":\"cx-policy:Membership\",\"operator\":\"eq\",\"rightOperand\":\"active\"}}}}"); } #endregion @@ -223,7 +220,7 @@ public async Task GetPolicyContentWithFiltersAsync_TwoEqualsConstraintsAndOperan ConstraintOperandId.And, new[] { - new Constraints("FrameworkAgreement.traceability", OperatorId.Equals, "1.0"), + new Constraints("FrameworkAgreement", OperatorId.Equals, "1.0"), new Constraints("companyRole.dismantler", OperatorId.In, "Audi") }); @@ -235,7 +232,7 @@ public async Task GetPolicyContentWithFiltersAsync_TwoEqualsConstraintsAndOperan response.StatusCode.Should().Be(HttpStatusCode.OK); (await response.Content.ReadAsStringAsync()) .Should() - .Be("{\"content\":{\"@context\":[\"https://www.w3.org/ns/odrl.jsonld\",{\"cx\":\"https://w3id.org/catenax/v0.0.1/ns/\"}],\"@type\":\"Offer\",\"@id\":\"....\",\"permission\":{\"action\":\"use\",\"constraint\":{\"odrl:and\":[{\"leftOperand\":\"FrameworkAgreement.traceability\",\"operator\":\"eq\",\"rightOperand\":\"@FrameworkAgreement.traceability-Version\"},{\"leftOperand\":\"Dismantler.activityType\",\"operator\":\"in\",\"rightOperand\":[\"Audi\",\"BMW\",\"VW\"]}]}}},\"attributes\":[{\"key\":\"@FrameworkAgreement.traceability-Version\",\"possibleValues\":[\"active:1.0\",\"active:1.1\",\"active:1.2\"]}]}"); + .Be("{\"content\":{\"@context\":[\"https://www.w3.org/ns/odrl.jsonld\",{\"cx\":\"https://w3id.org/catenax/v0.0.1/ns/\"}],\"@type\":\"Offer\",\"@id\":\"....\",\"permission\":{\"action\":\"use\",\"constraint\":{\"odrl:and\":[{\"leftOperand\":\"cx-policy:Dismantler.activityType\",\"operator\":\"in\",\"rightOperand\":[\"Audi\",\"BMW\",\"VW\"]},{\"leftOperand\":\"cx-policy:FrameworkAgreement\",\"operator\":\"eq\",\"rightOperand\":\"@FrameworkAgreement-Version\"}]}}},\"attributes\":[{\"key\":\"@FrameworkAgreement-Version\",\"possibleValues\":[\"active:1.0\",\"active:1.1\",\"active:1.2\",\"active:Behavioraltwin:1.0\",\"active:Businesspartner:1.0\",\"active:Circulareconomy:1.0\",\"active:Demandcapacity:1.0\",\"active:PCF:1.0\",\"active:Puris:1.0\",\"active:Quality:1.0\"]}]}"); } [Fact] @@ -268,7 +265,7 @@ public async Task GetPolicyContentWithFiltersAsync_MultipleConstraintsEqualsAndO ConstraintOperandId.And, new[] { - new Constraints("FrameworkAgreement.traceability", OperatorId.Equals, "1.0"), + new Constraints("FrameworkAgreement", OperatorId.Equals, "1.0"), new Constraints("companyRole.dismantler", OperatorId.In, "Audi"), new Constraints("BusinessPartnerNumber", OperatorId.Equals, "BPNL00000003CRHK") }); @@ -281,7 +278,7 @@ public async Task GetPolicyContentWithFiltersAsync_MultipleConstraintsEqualsAndO response.StatusCode.Should().Be(HttpStatusCode.OK); (await response.Content.ReadAsStringAsync()) .Should() - .Be("{\"content\":{\"@context\":[\"https://www.w3.org/ns/odrl.jsonld\",{\"cx\":\"https://w3id.org/catenax/v0.0.1/ns/\"}],\"@type\":\"Offer\",\"@id\":\"....\",\"permission\":{\"action\":\"use\",\"constraint\":{\"odrl:and\":[{\"leftOperand\":\"cx-policy:BusinessPartnerNumber\",\"operator\":\"eq\",\"rightOperand\":\"BPNL00000003CRHK\"},{\"leftOperand\":\"cx-policy:FrameworkAgreement.traceability\",\"operator\":\"eq\",\"rightOperand\":\"@FrameworkAgreement.traceability-Version\"},{\"leftOperand\":\"cx-policy:Dismantler.activityType\",\"operator\":\"in\",\"rightOperand\":[\"Audi\",\"BMW\",\"VW\"]}]}}},\"attributes\":[{\"key\":\"@FrameworkAgreement.traceability-Version\",\"possibleValues\":[\"active:1.0\",\"active:1.1\",\"active:1.2\"]}]}"); + .Be("{\"content\":{\"@context\":[\"https://www.w3.org/ns/odrl.jsonld\",{\"cx\":\"https://w3id.org/catenax/v0.0.1/ns/\"}],\"@type\":\"Offer\",\"@id\":\"....\",\"permission\":{\"action\":\"use\",\"constraint\":{\"odrl:and\":[{\"leftOperand\":\"cx-policy:BusinessPartnerNumber\",\"operator\":\"eq\",\"rightOperand\":\"BPNL00000003CRHK\"},{\"leftOperand\":\"cx-policy:Dismantler.activityType\",\"operator\":\"in\",\"rightOperand\":[\"Audi\",\"BMW\",\"VW\"]},{\"leftOperand\":\"cx-policy:FrameworkAgreement\",\"operator\":\"eq\",\"rightOperand\":\"@FrameworkAgreement-Version\"}]}}},\"attributes\":[{\"key\":\"@FrameworkAgreement-Version\",\"possibleValues\":[\"active:1.0\",\"active:1.1\",\"active:1.2\",\"active:Behavioraltwin:1.0\",\"active:Businesspartner:1.0\",\"active:Circulareconomy:1.0\",\"active:Demandcapacity:1.0\",\"active:PCF:1.0\",\"active:Puris:1.0\",\"active:Quality:1.0\"]}]}"); } // [Fact]