Skip to content

Commit

Permalink
feat(attributes): align seeding for DateExchangeGovernance (#166)
Browse files Browse the repository at this point in the history
Refs: #165
  • Loading branch information
Phil91 authored Jul 10, 2024
1 parent 671aa3e commit 5b04040
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 94 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -25,26 +25,20 @@
{ "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-e0e890c300e7", "use_case_id": 6, "is_active": true },
{ "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e7", "use_case_id": 7, "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-e0e890c300d8", "use_case_id": 6, "is_active": true },
{ "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d8", "use_case_id": 7, "is_active": true },
{ "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300d9", "use_case_id": 1, "is_active": true },
{ "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e1", "use_case_id": 1, "is_active": true },
{ "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e2", "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-e0e890c300e4", "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-e0e890c300e8", "use_case_id": 7, "is_active": true },
{ "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300e9", "use_case_id": 7, "is_active": true },
{ "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300f1", "use_case_id": 5, "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": "d72611ad-b6e4-47cc-94d2-d3efdc02db17", "use_case_id": 1, "is_active": true },
{ "attribute_id": "d72611ad-b6e4-47cc-94d2-d3efdc02db17", "use_case_id": 2, "is_active": true },
{ "attribute_id": "d72611ad-b6e4-47cc-94d2-d3efdc02db17", "use_case_id": 3, "is_active": true },
{ "attribute_id": "d72611ad-b6e4-47cc-94d2-d3efdc02db17", "use_case_id": 4, "is_active": true },
{ "attribute_id": "d72611ad-b6e4-47cc-94d2-d3efdc02db17", "use_case_id": 5, "is_active": true },
{ "attribute_id": "d72611ad-b6e4-47cc-94d2-d3efdc02db17", "use_case_id": 6, "is_active": true },
{ "attribute_id": "d72611ad-b6e4-47cc-94d2-d3efdc02db17", "use_case_id": 7, "is_active": true },
{ "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300f2", "use_case_id": 1, "is_active": true },
{ "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300f2", "use_case_id": 2, "is_active": true },
{ "attribute_id": "01a0fba3-9b6e-435a-b045-e0e890c300f2", "use_case_id": 3, "is_active": true },
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -224,73 +224,10 @@
"is_active": true
},
{
"id": "01a0fba3-9b6e-435a-b045-e0e890c300d9",
"id": "d72611ad-b6e4-47cc-94d2-d3efdc02db17",
"policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9",
"key": 5,
"attribute_value": "Traceability:1.0",
"is_active": true
},
{
"id": "01a0fba3-9b6e-435a-b045-e0e890c300e1",
"policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9",
"key": 5,
"attribute_value": "Traceability:2.0",
"is_active": true
},
{
"id": "01a0fba3-9b6e-435a-b045-e0e890c300e2",
"policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9",
"key": 5,
"attribute_value": "Traceability:3.0",
"is_active": true
},
{
"id": "01a0fba3-9b6e-435a-b045-e0e890c300e3",
"policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9",
"key": 5,
"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-e0e890c300e6",
"policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9",
"key": 5,
"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",
"is_active": true
},
{
"id": "01a0fba3-9b6e-435a-b045-e0e890c300e8",
"policy_id": "01a0fba3-9b6e-435a-b045-e0e890c300c9",
"key": 5,
"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",
"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": "DataExchangeGovernance:1.0",
"is_active": true
},
{
Expand Down
13 changes: 2 additions & 11 deletions tests/database/PolicyHub.DbAccess.Tests/PolicyRepositoryTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public async Task GetPolicyTypes_WithUseCase_ReturnsExpectedResult()
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 == "Dismantler.allowedBrands" && 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,
x => x.TechnicalKey == "FrameworkAgreement" && x.Attribute.Count() == 1 && x.Type.Count() == 1 && x.UseCase.Count() == 5,
x => x.TechnicalKey == "Dismantler" && x.Attribute.Count() == 1 && x.Type.Count() == 2 && x.UseCase.Count() == 5
);
}
Expand Down Expand Up @@ -154,16 +154,7 @@ public async Task GetPolicyContentAsync_WithRightOperand_ReturnsExpectedResult()
result.Exists.Should().BeTrue();
result.Attributes.Key.Should().Be(AttributeKeyId.Version);
result.Attributes.Values.Should().Satisfy(
x => x == "Traceability:1.0",
x => x == "Traceability:2.0",
x => x == "Traceability:3.0",
x => x == "Quality:1.0",
x => x == "Pcf:1.0",
x => x == "BehavioralTwin:1.0",
x => x == "CircularEconomy:1.0",
x => x == "DemandCapacity:1.0",
x => x == "Puris:1.0",
x => x == "BusinessPartner:1.0"
x => x == "DataExchangeGovernance:1.0"
);
result.LeftOperand.Should().Be("FrameworkAgreement");
result.RightOperandValue.Should().BeNull();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public async Task GetPolicyContent_UsageFrameworkEquals_ReturnsExpected()
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\",\"operator\":\"eq\",\"rightOperand\":\"@FrameworkAgreement.Traceability-Version\"}}},\"attributes\":[{\"key\":\"@FrameworkAgreement.Traceability-Version\",\"possibleValues\":[\"Traceability:1.0\",\"Traceability:2.0\",\"Traceability:3.0\"]}]}");
.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\":\"DataExchangeGovernance:1.0\"}}}}");
}

[Fact]
Expand Down Expand Up @@ -223,7 +223,7 @@ public async Task GetPolicyContentWithFiltersAsync_TwoEqualsConstraintsAndOperan
ConstraintOperandId.And,
new[]
{
new Constraints("FrameworkAgreement", OperatorId.Equals, "Traceability:1.0"),
new Constraints("FrameworkAgreement", OperatorId.Equals, "DataExchangeGovernance:1.0"),
new Constraints("Dismantler.allowedBrands", OperatorId.In, "Audi")
});

Expand All @@ -235,7 +235,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\":\"cx-policy:Dismantler.allowedBrands\",\"operator\":\"in\",\"rightOperand\":[\"BMW\",\"Audi\",\"VW\"]},{\"leftOperand\":\"cx-policy:FrameworkAgreement\",\"operator\":\"eq\",\"rightOperand\":\"@FrameworkAgreement-Version\"}]}}},\"attributes\":[{\"key\":\"@FrameworkAgreement-Version\",\"possibleValues\":[\"Traceability:1.0\",\"Traceability:2.0\",\"Traceability:3.0\",\"Quality:1.0\",\"Pcf:1.0\",\"BehavioralTwin:1.0\",\"CircularEconomy:1.0\",\"DemandCapacity:1.0\",\"Puris:1.0\",\"BusinessPartner:1.0\"]}]}");
.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.allowedBrands\",\"operator\":\"in\",\"rightOperand\":[\"BMW\",\"Audi\",\"VW\"]},{\"leftOperand\":\"cx-policy:FrameworkAgreement\",\"operator\":\"eq\",\"rightOperand\":\"DataExchangeGovernance:1.0\"}]}}}}");
}

[Fact]
Expand Down Expand Up @@ -268,7 +268,7 @@ public async Task GetPolicyContentWithFiltersAsync_MultipleConstraintsEqualsAndO
ConstraintOperandId.And,
new[]
{
new Constraints("FrameworkAgreement", OperatorId.Equals, "Traceability:1.0"),
new Constraints("FrameworkAgreement", OperatorId.Equals, "DataExchangeGovernance:1.0"),
new Constraints("Dismantler.allowedBrands", OperatorId.In, "Audi"),
new Constraints("BusinessPartnerNumber", OperatorId.Equals, "BPNL00000003CRHK")
});
Expand All @@ -281,7 +281,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:Dismantler.allowedBrands\",\"operator\":\"in\",\"rightOperand\":[\"BMW\",\"Audi\",\"VW\"]},{\"leftOperand\":\"cx-policy:FrameworkAgreement\",\"operator\":\"eq\",\"rightOperand\":\"@FrameworkAgreement-Version\"}]}}},\"attributes\":[{\"key\":\"@FrameworkAgreement-Version\",\"possibleValues\":[\"Traceability:1.0\",\"Traceability:2.0\",\"Traceability:3.0\",\"Quality:1.0\",\"Pcf:1.0\",\"BehavioralTwin:1.0\",\"CircularEconomy:1.0\",\"DemandCapacity:1.0\",\"Puris:1.0\",\"BusinessPartner:1.0\"]}]}");
.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.allowedBrands\",\"operator\":\"in\",\"rightOperand\":[\"BMW\",\"Audi\",\"VW\"]},{\"leftOperand\":\"cx-policy:FrameworkAgreement\",\"operator\":\"eq\",\"rightOperand\":\"DataExchangeGovernance:1.0\"}]}}}}");
}

#endregion
Expand Down

0 comments on commit 5b04040

Please sign in to comment.