Skip to content

Commit b5f29ac

Browse files
authored
W-13157845: upgrade to AMF 5.3.0 (#442)
1 parent ca2f6ef commit b5f29ac

File tree

5 files changed

+92
-56
lines changed

5 files changed

+92
-56
lines changed

interface-impl-amf/pom.xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
<licensePath>../LICENSE_HEADER.txt</licensePath>
1818
<formatterConfigPath>../formatter.xml</formatterConfigPath>
1919
<sonar.jacoco.reportPaths>../target/jacoco.exec</sonar.jacoco.reportPaths>
20-
<amf.version>5.2.3</amf.version>
20+
<amf.version>5.3.0</amf.version>
2121
<amf.xml.extension.version>2.0.3</amf.xml.extension.version>
2222
<json-simple.version>1.1.1</json-simple.version>
2323
</properties>

interface-impl-amf/src/main/java/org/mule/amf/impl/model/ParameterImpl.java

Lines changed: 8 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@
3535
import java.util.Map;
3636
import java.util.Optional;
3737
import java.util.Set;
38+
import java.util.stream.Stream;
3839

3940
import static java.util.Arrays.asList;
4041
import static java.util.Collections.emptyList;
@@ -259,20 +260,16 @@ private static Boolean needsQuotes(Shape anyShape) {
259260
}
260261

261262
private static boolean hasAnArrayVariant(UnionShape unionShape) {
262-
boolean hasAnArrayVariant = false;
263-
for (Shape shape : unionShape.anyOf()) {
264-
if (shape instanceof ArrayShape) {
265-
hasAnArrayVariant = true;
266-
} else if (!(shape instanceof NilShape)) {
267-
return false;
268-
}
269-
}
270-
271-
return hasAnArrayVariant;
263+
return flatMapUnionShapes(unionShape).noneMatch(shape -> !(shape instanceof ArrayShape || shape instanceof NilShape));
272264
}
273265

274266
private static boolean hasNilShape(UnionShape unionShape) {
275-
return unionShape.anyOf().stream().anyMatch(NilShape.class::isInstance);
267+
return flatMapUnionShapes(unionShape).anyMatch(NilShape.class::isInstance);
268+
}
269+
270+
private static Stream<Shape> flatMapUnionShapes(UnionShape unionShape) {
271+
return unionShape.anyOf().stream()
272+
.flatMap(shape -> shape instanceof UnionShape ? flatMapUnionShapes((UnionShape) shape) : Stream.of(shape));
276273
}
277274

278275
public static List<String> getDefaultValuesFromSchema(AnyShape schema) {
Lines changed: 58 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,45 +1,63 @@
11
{
2-
"resourceType":"ActivityDefinition",
3-
"status":"active",
4-
"id": "28d9888a-e91b46a9-a84c-ab2d8e8af457",
5-
"title":"TELEMED",
6-
"description":"Telemedicine Visit",
7-
"subtitle":"1",
8-
"extension":[
9-
{
10-
"url":"http://hl7.org/fhir/StructureDefinition/timing-daysOfCycle",
11-
"extension":[
12-
{
13-
"url":"day",
14-
"valueInteger":0
15-
}
16-
]
17-
}
18-
],
19-
"timingRange":{
20-
"low":{
21-
"value":0,
22-
"unit":"day"
23-
},
24-
"high":{
25-
"value":0,
26-
"unit":"day"
27-
}
28-
},
29-
"dynamicValue":[
30-
{
31-
"path":"Questionnaire/62baa9b8-f3d2-11ea-adc1-0242ac120002",
32-
"expression":{
33-
"language":"text/fhirpath",
34-
"name":"Telemedicine Visit"
2+
"resource": {
3+
"resourceType": "ActivityDefinition",
4+
"status": "active",
5+
"id": "28d9888a-e91b46a9-a84c-ab2d8e8af457",
6+
"title": "TELEMED",
7+
"description": "Telemedicine Visit",
8+
"subtitle": "1",
9+
"observationRequirement": [
10+
{
11+
"test": "test"
12+
}
13+
],
14+
"observationResultRequirement": [
15+
{
16+
"test": "test"
17+
}
18+
],
19+
"transform": "test",
20+
"specimenRequirement": [
21+
{
22+
"test": "test"
23+
}
24+
],
25+
"extension": [
26+
{
27+
"url": "http://hl7.org/fhir/StructureDefinition/timing-daysOfCycle",
28+
"extension": [
29+
{
30+
"url": "day",
31+
"valueInteger": 0
32+
}
33+
]
34+
}
35+
],
36+
"timingRange": {
37+
"low": {
38+
"value": 0,
39+
"unit": "day"
40+
},
41+
"high": {
42+
"value": 0,
43+
"unit": "day"
3544
}
3645
},
37-
{
38-
"path":"Questionnaire/28d9888a-e91b46a9-a84c-ab2d8e8af457",
39-
"expression":{
40-
"language":"text/fhirpath",
41-
"name":"*Investigator - Telemedicine ProgressNote"
46+
"dynamicValue": [
47+
{
48+
"path": "Questionnaire/62baa9b8-f3d2-11ea-adc1-0242ac120002",
49+
"expression": {
50+
"language": "text/fhirpath",
51+
"name": "test"
52+
}
53+
},
54+
{
55+
"path": "Questionnaire/28d9888a-e91b46a9-a84c-ab2d8e8af457",
56+
"expression": {
57+
"language": "text/fhirpath",
58+
"name": "test"
59+
}
4260
}
43-
}
44-
]
61+
]
62+
}
4563
}

parser-service/src/test/java/org/mule/parser/service/QueryConsistencyTestCase.java

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ public class QueryConsistencyTestCase {
5353
private static final String NON_NULLABLE_UNION_OF_ARRAYS = "nonNullableUnionOfArraysParams";
5454
private static final String NULLABLE_UNION_OF_NULLABLE_ARRAYS = "nullableUnionOfNullableArraysParams";
5555
private static final String NON_NULLABLE_UNION_OF_NULLABLE_ARRAYS = "nonNullableUnionOfNullableArraysParams";
56+
private static final String REPEATABLE = "repeatableParams";
57+
private static final String NOT_REPEATABLE = "notRepeatableParams";
5658

5759
private Map<String, Parameter> queryParameters;
5860
private QueryString queryString;
@@ -211,10 +213,8 @@ public void testObjectArrayValidation() {
211213
}
212214

213215
/**
214-
* In terms of validation, when the parameter is nullable (for RAML this is a union between nil and something else), a null
215-
* value will be considered as a union's value instead of inner type's value. This is because the validator considers the weight
216-
* of the outer type to be greater than that of the inner types. Note that a value is considered as null when it is a: - null
217-
* Object - "null" String - null Object or "null" String as part of a single element in an array
216+
* Note that a value is considered as null when it is a: - null Object - "null" String - null Object or "null" String as part of
217+
* a single element in an array.
218218
*/
219219

220220
@Test
@@ -273,6 +273,14 @@ public void testNonNullableUnionOfNullableArraysValidation() {
273273
}
274274
}
275275

276+
@Test
277+
public void testRepeatable() {
278+
if (parserMode.equals(ParserMode.AMF)) {
279+
validateArrayConsistency(true, REPEATABLE, asList("123", "456"));
280+
validateArrayConsistency(false, NOT_REPEATABLE, asList("123", "456"));
281+
}
282+
}
283+
276284
@Test
277285
public void testDefaultValues() {
278286
// Java RAML parser is not returning default values

parser-service/src/test/resources/query-validation-consistency/api.raml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -91,6 +91,11 @@ types:
9191
type: booleanItems | integerItems
9292
nonNullableUnionOfNullableArrays:
9393
type: nullableStringItems | nullableIntegerItems
94+
repeatable:
95+
type: integerItems | booleanItems | nil
96+
notRepeatable:
97+
type: integerItems | nullableString
98+
9499
query:
95100
type: object
96101
additionalProperties: false
@@ -137,6 +142,10 @@ types:
137142
type: nonNullableUnionOfNullableArrays
138143
nullableScalarParams?:
139144
type: nullableStringItems
145+
repeatableParams?:
146+
type: repeatable
147+
notRepeatableParams?:
148+
type: notRepeatable
140149

141150
/testQueryParams:
142151
get:
@@ -183,6 +192,10 @@ types:
183192
type: nonNullableUnionOfNullableArrays
184193
nullableScalarParams?:
185194
type: nullableStringItems
195+
repeatableParams?:
196+
type: repeatable
197+
notRepeatableParams?:
198+
type: notRepeatable
186199
responses:
187200
200:
188201
/testQueryString:

0 commit comments

Comments
 (0)