Skip to content

Commit

Permalink
Added metaDataUri to AppRegistrationResource
Browse files Browse the repository at this point in the history
Added metaDataUri to AppRegistrationResource
Added test for presence of metaDataUri

Fixes spring-cloud#6092
  • Loading branch information
Corneil du Plessis committed Dec 31, 2024
1 parent 0931f1e commit 7109dde
Show file tree
Hide file tree
Showing 4 changed files with 25 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ public class AppRegistrationResource extends RepresentationModel<AppRegistration
*/
private String uri;

/**
* URI for app metaData
*/
private String metaDataUri;
/**
* App version.
*/
Expand Down Expand Up @@ -74,7 +78,7 @@ protected AppRegistrationResource() {
}

public AppRegistrationResource(String name, String type, String uri) {
this(name, type, null, uri, false);
this(name, type, null, uri, null, false);
}

/**
Expand All @@ -86,11 +90,12 @@ public AppRegistrationResource(String name, String type, String uri) {
* @param uri uri for app resource
* @param defaultVersion is this application selected to the be default version in DSL
*/
public AppRegistrationResource(String name, String type, String version, String uri, Boolean defaultVersion) {
public AppRegistrationResource(String name, String type, String version, String uri, String metaDataUri, Boolean defaultVersion) {
this.name = name;
this.type = type;
this.version = version;
this.uri = uri;
this.metaDataUri = metaDataUri;
this.defaultVersion = defaultVersion;
}

Expand All @@ -101,14 +106,16 @@ 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
*/
public AppRegistrationResource(String name, String type, String version, String uri, Boolean defaultVersion, Set<String> versions) {
public AppRegistrationResource(String name, String type, String version, String uri, String metaDataUri, Boolean defaultVersion, Set<String> versions) {
this.name = name;
this.type = type;
this.version = version;
this.uri = uri;
this.metaDataUri = metaDataUri;
this.defaultVersion = defaultVersion;
this.versions = versions;
}
Expand All @@ -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<String> versions, String label) {
public AppRegistrationResource(String name, String type, String version, String uri, String metaDataUri, Boolean defaultVersion, Set<String> 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;
Expand Down Expand Up @@ -184,6 +193,10 @@ public void setLabel(String label) {
this.label = label;
}

public String getMetaDataUri() {
return metaDataUri;
}

/**
* Dedicated subclass to workaround type erasure.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

/**
Expand All @@ -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());
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 7109dde

Please sign in to comment.