Skip to content

Commit 7808392

Browse files
chore: add test to presenationquery transformer (#4324)
1 parent 7abbdad commit 7808392

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

extensions/common/iam/identity-trust/identity-trust-transform/src/test/java/org/eclipse/edc/iam/identitytrust/transform/to/JsonObjectToPresentationQueryMessageTransformerTest.java

+45
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,51 @@ void transform_withScopes() throws JsonProcessingException {
7878
assertThat(query.getPresentationDefinition()).isNull();
7979
}
8080

81+
82+
@Test
83+
void transform_withEmptyScopes() throws JsonProcessingException {
84+
var obj = """
85+
{
86+
"@context": [
87+
"https://identity.foundation/presentation-exchange/submission/v1",
88+
"https://w3id.org/tractusx-trust/v0.8"
89+
],
90+
"@type": "PresentationQueryMessage",
91+
"scope": []
92+
}
93+
""";
94+
var json = mapper.readValue(obj, JsonObject.class);
95+
var jo = jsonLd.expand(json);
96+
assertThat(jo.succeeded()).withFailMessage(jo::getFailureDetail).isTrue();
97+
98+
var query = transformer.transform(jo.getContent(), context);
99+
assertThat(query).isNotNull();
100+
assertThat(query.getScopes()).isEmpty();
101+
assertThat(query.getPresentationDefinition()).isNull();
102+
}
103+
104+
@Test
105+
void transform_withNullScopes() throws JsonProcessingException {
106+
var obj = """
107+
{
108+
"@context": [
109+
"https://identity.foundation/presentation-exchange/submission/v1",
110+
"https://w3id.org/tractusx-trust/v0.8"
111+
],
112+
"@type": "PresentationQueryMessage"
113+
}
114+
""";
115+
var json = mapper.readValue(obj, JsonObject.class);
116+
var jo = jsonLd.expand(json);
117+
assertThat(jo.succeeded()).withFailMessage(jo::getFailureDetail).isTrue();
118+
119+
var query = transformer.transform(jo.getContent(), context);
120+
assertThat(query).isNotNull();
121+
assertThat(query.getScopes()).isEmpty();
122+
assertThat(query.getPresentationDefinition()).isNull();
123+
}
124+
125+
81126
@Test
82127
void transform_withScopes_separatedByWhitespace() throws JsonProcessingException {
83128
var obj = """

0 commit comments

Comments
 (0)