Skip to content
This repository was archived by the owner on May 14, 2025. It is now read-only.

Commit da1eec0

Browse files
Corneil du Plessiscppwfs
Corneil du Plessis
authored andcommitted
Added metaDataUri to AppRegistrationResource
Added metaDataUri to AppRegistrationResource Added test for presence of metaDataUri Fixes #6092 Fix AppRegistryDocumentation and StreamDefinitionsDocumentation for changed resource. Adds metaDataUri to AppRegistryDocumentation and StreamDefinitionsDocumentation Polish: Add test to register app without metadata
1 parent ab299ac commit da1eec0

File tree

6 files changed

+42
-7
lines changed

6 files changed

+42
-7
lines changed

spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/AppRegistryDocumentation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,6 +176,7 @@ void getSingleApplication() throws Exception {
176176
fieldWithPath("label").description("The label name of the application"),
177177
fieldWithPath("type").description("The type of the application. One of " + Arrays.asList(ApplicationType.values())),
178178
fieldWithPath("uri").description("The uri of the application"),
179+
fieldWithPath("metaDataUri").description("The uri of the application metadata").optional(),
179180
fieldWithPath("version").description("The version of the application"),
180181
fieldWithPath("versions").description("All the registered versions of the application"),
181182
fieldWithPath("defaultVersion").description("If true, the application is the default version"),

spring-cloud-dataflow-classic-docs/src/test/java/org/springframework/cloud/dataflow/server/rest/documentation/StreamDefinitionsDocumentation.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ void getStreamApplications() throws Exception {
164164
fieldWithPath("[].type").description("The type of the application. One of " + Arrays
165165
.asList(ApplicationType.values())),
166166
fieldWithPath("[].uri").description("The uri of the application"),
167+
fieldWithPath("[].metaDataUri").description("The uri of the application metadata"),
167168
fieldWithPath("[].version").description("The version of the application"),
168169
fieldWithPath("[].defaultVersion").description("If true, the application is the default version"),
169170
fieldWithPath("[].versions").description("All the registered versions of the application"),

spring-cloud-dataflow-rest-resource/src/main/java/org/springframework/cloud/dataflow/rest/resource/AppRegistrationResource.java

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public class AppRegistrationResource extends RepresentationModel<AppRegistration
4747
*/
4848
private String uri;
4949

50+
/**
51+
* URI for app metaData
52+
*/
53+
private String metaDataUri;
5054
/**
5155
* App version.
5256
*/
@@ -74,7 +78,7 @@ protected AppRegistrationResource() {
7478
}
7579

7680
public AppRegistrationResource(String name, String type, String uri) {
77-
this(name, type, null, uri, false);
81+
this(name, type, null, uri, null, false);
7882
}
7983

8084
/**
@@ -86,11 +90,12 @@ public AppRegistrationResource(String name, String type, String uri) {
8690
* @param uri uri for app resource
8791
* @param defaultVersion is this application selected to the be default version in DSL
8892
*/
89-
public AppRegistrationResource(String name, String type, String version, String uri, Boolean defaultVersion) {
93+
public AppRegistrationResource(String name, String type, String version, String uri, String metaDataUri, Boolean defaultVersion) {
9094
this.name = name;
9195
this.type = type;
9296
this.version = version;
9397
this.uri = uri;
98+
this.metaDataUri = metaDataUri;
9499
this.defaultVersion = defaultVersion;
95100
}
96101

@@ -101,14 +106,16 @@ public AppRegistrationResource(String name, String type, String version, String
101106
* @param type app type
102107
* @param version app version
103108
* @param uri uri for app resource
109+
* @param metaDataUri uri for app metadata
104110
* @param defaultVersion is this application selected to the be default version in DSL
105111
* @param versions all the registered versions of this application
106112
*/
107-
public AppRegistrationResource(String name, String type, String version, String uri, Boolean defaultVersion, Set<String> versions) {
113+
public AppRegistrationResource(String name, String type, String version, String uri, String metaDataUri, Boolean defaultVersion, Set<String> versions) {
108114
this.name = name;
109115
this.type = type;
110116
this.version = version;
111117
this.uri = uri;
118+
this.metaDataUri = metaDataUri;
112119
this.defaultVersion = defaultVersion;
113120
this.versions = versions;
114121
}
@@ -120,15 +127,17 @@ public AppRegistrationResource(String name, String type, String version, String
120127
* @param type app type
121128
* @param version app version
122129
* @param uri uri for app resource
130+
* @param metaDataUri uri for app metadata
123131
* @param defaultVersion is this application selected to the be default version in DSL
124132
* @param versions all the registered versions of this application
125133
* @param label the label name of the application
126134
*/
127-
public AppRegistrationResource(String name, String type, String version, String uri, Boolean defaultVersion, Set<String> versions, String label) {
135+
public AppRegistrationResource(String name, String type, String version, String uri, String metaDataUri, Boolean defaultVersion, Set<String> versions, String label) {
128136
this.name = name;
129137
this.type = type;
130138
this.version = version;
131139
this.uri = uri;
140+
this.metaDataUri = metaDataUri;
132141
this.defaultVersion = defaultVersion;
133142
this.versions = versions;
134143
this.label = label;
@@ -184,6 +193,10 @@ public void setLabel(String label) {
184193
this.label = label;
185194
}
186195

196+
public String getMetaDataUri() {
197+
return metaDataUri;
198+
}
199+
187200
/**
188201
* Dedicated subclass to workaround type erasure.
189202
*/

spring-cloud-dataflow-rest-resource/src/main/java/org/springframework/cloud/dataflow/rest/resource/DetailedAppRegistrationResource.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ protected DetailedAppRegistrationResource() {
7878
* @param isDefault is this the default app
7979
*/
8080
public DetailedAppRegistrationResource(String name, String type, String version, String coordinates, Boolean isDefault) {
81-
super(name, type, version, coordinates, isDefault);
81+
super(name, type, version, coordinates, null, isDefault);
8282
}
8383

8484
/**
@@ -89,7 +89,7 @@ public DetailedAppRegistrationResource(String name, String type, String version,
8989
* data
9090
*/
9191
public DetailedAppRegistrationResource(AppRegistrationResource resource) {
92-
super(resource.getName(), resource.getType(), resource.getVersion(), resource.getUri(), resource.getDefaultVersion());
92+
super(resource.getName(), resource.getType(), resource.getVersion(), resource.getUri(), resource.getMetaDataUri(), resource.getDefaultVersion());
9393
}
9494

9595
/**

spring-cloud-dataflow-server-core/src/main/java/org/springframework/cloud/dataflow/server/controller/assembler/DefaultAppRegistrationAssembler.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,12 +44,14 @@ protected R instantiateModel(AppRegistration registration) {
4444
registration.getType().name(),
4545
registration.getVersion(),
4646
registration.getUri().toString(),
47+
registration.getMetadataUri() != null ? registration.getMetadataUri().toString() : null,
4748
registration.isDefaultVersion()
4849
) : new AppRegistrationResource(
4950
registration.getName(),
5051
registration.getType().name(),
5152
registration.getVersion(),
5253
registration.getUri().toString(),
54+
registration.getMetadataUri() != null ? registration.getMetadataUri().toString() : null,
5355
registration.isDefaultVersion(),
5456
registration.getVersions()
5557
);

spring-cloud-dataflow-server-core/src/test/java/org/springframework/cloud/dataflow/server/controller/AppRegistryControllerTests.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,18 +123,36 @@ void registerVersionedApp() throws Exception {
123123
assertThat(this.appRegistryService.find("log1", ApplicationType.sink).getUri()).hasToString("maven://org.springframework.cloud.stream.app:log-sink-rabbit:1.2.0.RELEASE");
124124
}
125125

126+
@Test
127+
void findRegisteredAppNoMetadata() throws Exception {
128+
// given
129+
mockMvc.perform(
130+
post("/apps/sink/log1/3.0.0")
131+
.queryParam("bootVersion", "3")
132+
.param("uri", "maven://org.springframework.cloud.stream.app:log-sink-rabbit:3.0.0")
133+
.accept(MediaType.APPLICATION_JSON)
134+
).andExpect(status().isCreated());
135+
// when
136+
AppRegistration registration = this.appRegistryService.find("log1", ApplicationType.sink);
137+
// then
138+
assertThat(registration.getUri()).hasToString("maven://org.springframework.cloud.stream.app:log-sink-rabbit:3.0.0");
139+
}
140+
126141
@Test
127142
void findRegisteredApp() throws Exception {
128143
// given
129144
mockMvc.perform(
130145
post("/apps/sink/log1/3.0.0")
131146
.queryParam("bootVersion", "3")
132-
.param("uri", "maven://org.springframework.cloud.stream.app:log-sink-rabbit:3.0.0").accept(MediaType.APPLICATION_JSON)
147+
.param("uri", "maven://org.springframework.cloud.stream.app:log-sink-rabbit:3.0.0")
148+
.param("metadata-uri", "maven://org.springframework.cloud.stream.app:log-sink-rabbit:jar:metadata:3.0.0")
149+
.accept(MediaType.APPLICATION_JSON)
133150
).andExpect(status().isCreated());
134151
// when
135152
AppRegistration registration = this.appRegistryService.find("log1", ApplicationType.sink);
136153
// then
137154
assertThat(registration.getUri()).hasToString("maven://org.springframework.cloud.stream.app:log-sink-rabbit:3.0.0");
155+
assertThat(registration.getMetadataUri()).hasToString("maven://org.springframework.cloud.stream.app:log-sink-rabbit:jar:metadata:3.0.0");
138156
}
139157

140158
@Test

0 commit comments

Comments
 (0)