|
37 | 37 |
|
38 | 38 | import static org.assertj.core.api.Assertions.assertThat; |
39 | 39 | import static org.eclipse.edc.connector.controlplane.asset.spi.domain.DataplaneMetadata.EDC_DATAPLANE_METADATA_LABELS; |
| 40 | +import static org.eclipse.edc.connector.controlplane.asset.spi.domain.DataplaneMetadata.EDC_DATAPLANE_METADATA_PROFILES; |
40 | 41 | import static org.eclipse.edc.connector.controlplane.asset.spi.domain.DataplaneMetadata.EDC_DATAPLANE_METADATA_PROPERTIES; |
41 | 42 | import static org.eclipse.edc.connector.controlplane.asset.spi.domain.DataplaneMetadata.EDC_DATAPLANE_METADATA_SIMPLE_TYPE; |
42 | 43 | import static org.eclipse.edc.connector.controlplane.transform.TestInput.getExpanded; |
@@ -119,6 +120,36 @@ void shouldFail_whenLabelIsNotString(JsonValue context) { |
119 | 120 | assertThat(result).isFailed(); |
120 | 121 | } |
121 | 122 |
|
| 123 | + @ParameterizedTest |
| 124 | + @ArgumentsSource(Contexts.class) |
| 125 | + void shouldTransformProfiles(JsonValue context) { |
| 126 | + var jsonObj = jsonFactory.createObjectBuilder() |
| 127 | + .add(CONTEXT, context) |
| 128 | + .add(TYPE, EDC_DATAPLANE_METADATA_SIMPLE_TYPE) |
| 129 | + .add("profiles", jsonFactory.createArrayBuilder().add("profile1").add("profile2")) |
| 130 | + .build(); |
| 131 | + |
| 132 | + var result = typeTransformerRegistry.transform(getExpanded(jsonObj), DataplaneMetadata.class); |
| 133 | + |
| 134 | + assertThat(result).isSucceeded().satisfies(metadata -> { |
| 135 | + assertThat(metadata.getProfiles()).containsExactly("profile1", "profile2"); |
| 136 | + }); |
| 137 | + } |
| 138 | + |
| 139 | + @ParameterizedTest |
| 140 | + @ArgumentsSource(Contexts.class) |
| 141 | + void shouldFail_whenProfileIsNotString(JsonValue context) { |
| 142 | + var jsonObj = jsonFactory.createObjectBuilder() |
| 143 | + .add(CONTEXT, context) |
| 144 | + .add(TYPE, EDC_DATAPLANE_METADATA_SIMPLE_TYPE) |
| 145 | + .add(EDC_DATAPLANE_METADATA_PROFILES, jsonFactory.createArrayBuilder().add(1)) |
| 146 | + .build(); |
| 147 | + |
| 148 | + var result = typeTransformerRegistry.transform(getExpanded(jsonObj), DataplaneMetadata.class); |
| 149 | + |
| 150 | + assertThat(result).isFailed(); |
| 151 | + } |
| 152 | + |
122 | 153 | private static String prefix(JsonValue context) { |
123 | 154 | if (context instanceof JsonObject jsonObject && jsonObject.containsKey(VOCAB)) { |
124 | 155 | return jsonObject.getJsonString(VOCAB).getString(); |
|
0 commit comments