Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added metaDataUri to AppRegistrationResource #6098

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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"),
Expand Down
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")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We still need a test here for when there is no metadata sent on registration. I'll add it on merge.

.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
Loading