From 7109dde30bf0af10541985fe3b90d1a91a0a6513 Mon Sep 17 00:00:00 2001 From: Corneil du Plessis Date: Tue, 31 Dec 2024 11:59:30 +0200 Subject: [PATCH 1/2] Added metaDataUri to AppRegistrationResource Added metaDataUri to AppRegistrationResource Added test for presence of metaDataUri Fixes #6092 --- .../resource/AppRegistrationResource.java | 21 +++++++++++++++---- .../DetailedAppRegistrationResource.java | 4 ++-- .../DefaultAppRegistrationAssembler.java | 2 ++ .../AppRegistryControllerTests.java | 5 ++++- 4 files changed, 25 insertions(+), 7 deletions(-) diff --git a/spring-cloud-dataflow-rest-resource/src/main/java/org/springframework/cloud/dataflow/rest/resource/AppRegistrationResource.java b/spring-cloud-dataflow-rest-resource/src/main/java/org/springframework/cloud/dataflow/rest/resource/AppRegistrationResource.java index 132322a5ee..b44406510d 100644 --- a/spring-cloud-dataflow-rest-resource/src/main/java/org/springframework/cloud/dataflow/rest/resource/AppRegistrationResource.java +++ b/spring-cloud-dataflow-rest-resource/src/main/java/org/springframework/cloud/dataflow/rest/resource/AppRegistrationResource.java @@ -47,6 +47,10 @@ public class AppRegistrationResource extends RepresentationModel versions) { + public AppRegistrationResource(String name, String type, String version, String uri, String metaDataUri, Boolean defaultVersion, Set versions) { this.name = name; this.type = type; this.version = version; this.uri = uri; + this.metaDataUri = metaDataUri; this.defaultVersion = defaultVersion; this.versions = versions; } @@ -120,15 +127,17 @@ public AppRegistrationResource(String name, String type, String version, String * @param type app type * @param version app version * @param uri uri for app resource + * @param metaDataUri uri for app metadata * @param defaultVersion is this application selected to the be default version in DSL * @param versions all the registered versions of this application * @param label the label name of the application */ - public AppRegistrationResource(String name, String type, String version, String uri, Boolean defaultVersion, Set versions, String label) { + public AppRegistrationResource(String name, String type, String version, String uri, String metaDataUri, Boolean defaultVersion, Set versions, String label) { this.name = name; this.type = type; this.version = version; this.uri = uri; + this.metaDataUri = metaDataUri; this.defaultVersion = defaultVersion; this.versions = versions; this.label = label; @@ -184,6 +193,10 @@ public void setLabel(String label) { this.label = label; } + public String getMetaDataUri() { + return metaDataUri; + } + /** * Dedicated subclass to workaround type erasure. */ diff --git a/spring-cloud-dataflow-rest-resource/src/main/java/org/springframework/cloud/dataflow/rest/resource/DetailedAppRegistrationResource.java b/spring-cloud-dataflow-rest-resource/src/main/java/org/springframework/cloud/dataflow/rest/resource/DetailedAppRegistrationResource.java index 930587cd2f..46d9d5dee3 100644 --- a/spring-cloud-dataflow-rest-resource/src/main/java/org/springframework/cloud/dataflow/rest/resource/DetailedAppRegistrationResource.java +++ b/spring-cloud-dataflow-rest-resource/src/main/java/org/springframework/cloud/dataflow/rest/resource/DetailedAppRegistrationResource.java @@ -78,7 +78,7 @@ protected DetailedAppRegistrationResource() { * @param isDefault is this the default app */ public DetailedAppRegistrationResource(String name, String type, String version, String coordinates, Boolean isDefault) { - super(name, type, version, coordinates, isDefault); + super(name, type, version, coordinates, null, isDefault); } /** @@ -89,7 +89,7 @@ public DetailedAppRegistrationResource(String name, String type, String version, * data */ public DetailedAppRegistrationResource(AppRegistrationResource resource) { - super(resource.getName(), resource.getType(), resource.getVersion(), resource.getUri(), resource.getDefaultVersion()); + super(resource.getName(), resource.getType(), resource.getVersion(), resource.getUri(), resource.getMetaDataUri(), resource.getDefaultVersion()); } /** diff --git a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/controller/assembler/DefaultAppRegistrationAssembler.java b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/controller/assembler/DefaultAppRegistrationAssembler.java index 6ec3495c8a..b9a8eba8ce 100644 --- a/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/controller/assembler/DefaultAppRegistrationAssembler.java +++ b/spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/controller/assembler/DefaultAppRegistrationAssembler.java @@ -44,12 +44,14 @@ protected R instantiateModel(AppRegistration registration) { registration.getType().name(), registration.getVersion(), registration.getUri().toString(), + registration.getMetadataUri() != null ? registration.getMetadataUri().toString() : null, registration.isDefaultVersion() ) : new AppRegistrationResource( registration.getName(), registration.getType().name(), registration.getVersion(), registration.getUri().toString(), + registration.getMetadataUri() != null ? registration.getMetadataUri().toString() : null, registration.isDefaultVersion(), registration.getVersions() ); diff --git a/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/AppRegistryControllerTests.java b/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/AppRegistryControllerTests.java index 9282e27183..91cec6db98 100644 --- a/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/AppRegistryControllerTests.java +++ b/spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/AppRegistryControllerTests.java @@ -129,12 +129,15 @@ void findRegisteredApp() throws Exception { mockMvc.perform( post("/apps/sink/log1/3.0.0") .queryParam("bootVersion", "3") - .param("uri", "maven://org.springframework.cloud.stream.app:log-sink-rabbit:3.0.0").accept(MediaType.APPLICATION_JSON) + .param("uri", "maven://org.springframework.cloud.stream.app:log-sink-rabbit:3.0.0") + .param("metadata-uri", "maven://org.springframework.cloud.stream.app:log-sink-rabbit:jar:metadata:3.0.0") + .accept(MediaType.APPLICATION_JSON) ).andExpect(status().isCreated()); // when AppRegistration registration = this.appRegistryService.find("log1", ApplicationType.sink); // then assertThat(registration.getUri()).hasToString("maven://org.springframework.cloud.stream.app:log-sink-rabbit:3.0.0"); + assertThat(registration.getMetadataUri()).hasToString("maven://org.springframework.cloud.stream.app:log-sink-rabbit:jar:metadata:3.0.0"); } @Test From 24950796c8623a96a5cbf7f4c4d3a75ee1974dc6 Mon Sep 17 00:00:00 2001 From: Corneil du Plessis Date: Tue, 31 Dec 2024 16:49:50 +0200 Subject: [PATCH 2/2] Fix AppRegistryDocumentation and StreamDefinitionsDocumentation for changed resource. Adds metaDataUri to AppRegistryDocumentation and StreamDefinitionsDocumentation --- .../server/rest/documentation/AppRegistryDocumentation.java | 1 + .../rest/documentation/StreamDefinitionsDocumentation.java | 1 + 2 files changed, 2 insertions(+) diff --git a/spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/AppRegistryDocumentation.java b/spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/AppRegistryDocumentation.java index 424ed36e47..22ada75374 100644 --- a/spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/AppRegistryDocumentation.java +++ b/spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/AppRegistryDocumentation.java @@ -176,6 +176,7 @@ void getSingleApplication() throws Exception { fieldWithPath("label").description("The label name of the application"), fieldWithPath("type").description("The type of the application. One of " + Arrays.asList(ApplicationType.values())), fieldWithPath("uri").description("The uri of the application"), + fieldWithPath("metaDataUri").description("The uri of the application metadata").optional(), fieldWithPath("version").description("The version of the application"), fieldWithPath("versions").description("All the registered versions of the application"), fieldWithPath("defaultVersion").description("If true, the application is the default version"), diff --git a/spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/StreamDefinitionsDocumentation.java b/spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/StreamDefinitionsDocumentation.java index 9671403c7d..5288fe3c5b 100644 --- a/spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/StreamDefinitionsDocumentation.java +++ b/spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/StreamDefinitionsDocumentation.java @@ -164,6 +164,7 @@ void getStreamApplications() throws Exception { fieldWithPath("[].type").description("The type of the application. One of " + Arrays .asList(ApplicationType.values())), fieldWithPath("[].uri").description("The uri of the application"), + fieldWithPath("[].metaDataUri").description("The uri of the application metadata"), fieldWithPath("[].version").description("The version of the application"), fieldWithPath("[].defaultVersion").description("If true, the application is the default version"), fieldWithPath("[].versions").description("All the registered versions of the application"),