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 #6092

Fix AppRegistryDocumentation and StreamDefinitionsDocumentation for changed resource.

Adds metaDataUri to AppRegistryDocumentation and StreamDefinitionsDocumentation

Polish: Add test to register app without metadata
  • Loading branch information
Corneil du Plessis authored and cppwfs committed Jan 2, 2025
1 parent ab299ac commit da1eec0
Show file tree
Hide file tree
Showing 6 changed files with 42 additions and 7 deletions.
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 @@ -123,18 +123,36 @@ void registerVersionedApp() throws Exception {
assertThat(this.appRegistryService.find("log1", ApplicationType.sink).getUri()).hasToString("maven://org.springframework.cloud.stream.app:log-sink-rabbit:1.2.0.RELEASE");
}

@Test
void findRegisteredAppNoMetadata() throws Exception {
// given
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)
).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");
}

@Test
void findRegisteredApp() throws Exception {
// given
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 da1eec0

Please sign in to comment.