Skip to content

Commit

Permalink
OCTOPUS-345 Add end-point to get version names (#17)
Browse files Browse the repository at this point in the history
  • Loading branch information
ozonophore authored Sep 20, 2023
1 parent 02a14ed commit 0763230
Show file tree
Hide file tree
Showing 6 changed files with 37 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,9 @@ interface ComponentsRegistryServiceClient {
@RequestLine("GET rest/api/2/common/supported-groups")
fun getSupportedGroupIds(): Set<String>

@RequestLine("GET rest/api/2/common/version-names")
fun getVersionNames(): Map<String, String>

@RequestLine("GET rest/api/2/components-registry/service/status")
fun getServiceStatus(): ServiceStatusDTO

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ class ClassicComponentsRegistryServiceClient(
override fun getSupportedGroupIds(): Set<String> =
client.getSupportedGroupIds()

override fun getVersionNames(): Map<String, String> =
client.getVersionNames()

override fun getServiceStatus(): ServiceStatusDTO =
client.getServiceStatus()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ class ComponentRegistryServiceClientTest : BaseComponentsRegistryServiceTest() {

override fun getSupportedGroupIds(): Set<String> = componentsRegistryClient.getSupportedGroupIds()

override fun getVersionNames(): Map<String, String> = componentsRegistryClient.getVersionNames()

override fun getDependencyAliasToComponentMapping(): Map<String, String> =
componentsRegistryClient.getDependencyAliasToComponentMapping()

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,4 +34,13 @@ class CommonControllerV2(
fun getSupportedGroupIds(): Set<String> {
return configHelper.supportedGroupIds().toSet()
}

@GetMapping("version-names", produces = [MediaType.APPLICATION_JSON_VALUE])
fun getVersionNames(): Map<String, String> {
return mapOf(
"service-branch" to configHelper.serviceBranch(),
"service" to configHelper.service(),
"minor" to configHelper.minor(),
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,16 @@ class ComponentsRegistryServiceControllerTest : BaseComponentsRegistryServiceTes
.response
.toObject(object : TypeReference<Set<String>>() {})

override fun getVersionNames(): Map<String, String> =
mvc.perform(
MockMvcRequestBuilders.get(URI.create("/rest/api/2/common/version-names"))
.accept(APPLICATION_JSON)
)
.andExpect(status().isOk)
.andReturn()
.response
.toObject(object : TypeReference<Map<String, String>>() {})

override fun getDependencyAliasToComponentMapping() =
mvc.perform(
MockMvcRequestBuilders.get(URI.create("/rest/api/2/common/dependency-aliases"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,6 +87,7 @@ abstract class BaseComponentsRegistryServiceTest {
//common
protected abstract fun getAllJiraComponentVersionRanges(): Collection<JiraComponentVersionRangeDTO>
protected abstract fun getSupportedGroupIds(): Set<String>
abstract fun getVersionNames(): Map<String, String>
protected abstract fun getDependencyAliasToComponentMapping(): Map<String, String>

protected abstract fun getComponentV1(component: String): ComponentV1
Expand Down Expand Up @@ -133,6 +134,15 @@ abstract class BaseComponentsRegistryServiceTest {
Assertions.assertEquals(Arrays.asList("org.octopusden.octopus", "io.bcomponent").sorted(), getSupportedGroupIds().sorted())
}

@Test
fun testVersionNames() {
val map = getVersionNames()
Assertions.assertEquals(3, map.size)
Assertions.assertEquals("serviceCBranch", map["service-branch"])
Assertions.assertEquals("serviceC", map["service"])
Assertions.assertEquals("minorC", map["minor"])
}

@Test
fun testGetDependencyAliasToComponentMapping() {
Assertions.assertEquals(
Expand Down

0 comments on commit 0763230

Please sign in to comment.