EG-1980 - Remove stale docs links from OS (#6251)

Remove hardcoded docs references, push docs link to gradle
This commit is contained in:
James Higgs
2020-05-14 12:57:59 +01:00
committed by GitHub
parent 8387e99535
commit 06467d04b1
20 changed files with 28 additions and 59 deletions

View File

@ -13,6 +13,7 @@ class CordaVersion {
val revision: String by lazy { manifestValue("Corda-Revision") ?: UNKNOWN }
val vendor: String by lazy { manifestValue("Corda-Vendor") ?: UNKNOWN }
val platformVersion: Int by lazy { manifestValue("Corda-Platform-Version")?.toInt() ?: 1 }
val docsLink: String by lazy { manifestValue("Corda-Docs-Link") ?: UNKNOWN }
internal val semanticVersion: String by lazy { if(releaseVersion == UNKNOWN) CURRENT_MAJOR_RELEASE else releaseVersion }
}

View File

@ -11,21 +11,10 @@ import java.util.*
class CordaErrorContextProvider : ErrorContextProvider {
companion object {
private const val BASE_URL = "https://docs.corda.net/docs"
private const val OS_PAGES = "corda-os"
private const val ENTERPRISE_PAGES = "corda-enterprise"
private const val ERROR_CODE_PAGE = "error-codes.html"
}
override fun getURL(locale: Locale): String {
val versionNumber = CordaVersion.releaseVersion
// This slightly strange block here allows the code to be merged across to Enterprise with no changes.
val productVersion = if (CordaVersion.platformEditionCode == "OS") {
OS_PAGES
} else {
ENTERPRISE_PAGES
}
return "$BASE_URL/$productVersion/$versionNumber/$ERROR_CODE_PAGE"
return "${CordaVersion.docsLink}/$ERROR_CODE_PAGE"
}
}

View File

@ -25,7 +25,7 @@ internal class ErrorReporterImpl(private val resourceLocation: String,
val resource = "$resourceLocation/$ERROR_INFO_RESOURCE"
val codeMessage = fetchAndFormat(resource, ERROR_CODE_MESSAGE, arrayOf(error.formatCode()))
val urlMessage = fetchAndFormat(resource, ERROR_CODE_URL, arrayOf(errorContextProvider.getURL(locale)))
return "[$codeMessage, $urlMessage]"
return "[$codeMessage $urlMessage]"
}
override fun report(error: ErrorCode<*>, logger: Logger) {

View File

@ -11,7 +11,8 @@ class CordaErrorContextProviderTest {
@Test(timeout = 300_000)
fun `check that correct URL is returned from context provider`() {
val context = CordaErrorContextProvider()
val expectedURL = "https://docs.corda.net/docs/corda-os/${CordaVersion.releaseVersion}/error-codes.html"
val version = CordaVersion.releaseVersion.substringBefore("-") // Remove SNAPSHOT if present
val expectedURL = "https://docs.corda.net/docs/corda-os/$version/error-codes.html"
// In this first release, there is only one localisation and the URL structure for future localisations is currently unknown. As
// a result, the same URL is expected for all locales.
assertEquals(expectedURL, context.getURL(Locale.getDefault()))

View File

@ -74,7 +74,7 @@ class ErrorReporterImplTest {
val error = TEST_ERROR_1
val testReporter = createReporterImpl("en-US")
testReporter.report(error, loggerMock)
assertEquals(listOf("This is a test message [Code: test-case1, URL: $TEST_URL/en-US]"), logs)
assertEquals(listOf("This is a test message [Code: test-case1 URL: $TEST_URL/en-US]"), logs)
}
@Test(timeout = 300_00)
@ -84,7 +84,7 @@ class ErrorReporterImplTest {
val testReporter = createReporterImpl("en-US")
testReporter.report(error, loggerMock)
val format = DateFormat.getDateInstance(DateFormat.LONG, Locale.forLanguageTag("en-US"))
assertEquals(listOf("This is the second case with string foo, number 1, date ${format.format(currentDate)} [Code: test-case2, URL: $TEST_URL/en-US]"), logs)
assertEquals(listOf("This is the second case with string foo, number 1, date ${format.format(currentDate)} [Code: test-case2 URL: $TEST_URL/en-US]"), logs)
}
@Test(timeout = 300_000)
@ -92,7 +92,7 @@ class ErrorReporterImplTest {
val error = TEST_ERROR_1
val testReporter = createReporterImpl("fr-FR")
testReporter.report(error, loggerMock)
assertEquals(listOf("This is a test message [Code: test-case1, URL: $TEST_URL/fr-FR]"), logs)
assertEquals(listOf("This is a test message [Code: test-case1 URL: $TEST_URL/fr-FR]"), logs)
}
@Test(timeout = 300_000)
@ -100,7 +100,7 @@ class ErrorReporterImplTest {
val error = TEST_ERROR_1
val testReporter = createReporterImpl("ga-IE")
testReporter.report(error, loggerMock)
assertEquals(listOf("Is teachtaireacht earráide é seo [Code: test-case1, URL: $TEST_URL/ga-IE]"), logs)
assertEquals(listOf("Is teachtaireacht earráide é seo [Code: test-case1 URL: $TEST_URL/ga-IE]"), logs)
}
@Test(timeout = 300_000)
@ -108,7 +108,7 @@ class ErrorReporterImplTest {
val error = TEST_ERROR_1
val testReporter = createReporterImpl("es-ES")
testReporter.report(error, loggerMock)
assertEquals(listOf("This is a test message [Code: test-case1, URL: $TEST_URL/es-ES]"), logs)
assertEquals(listOf("This is a test message [Code: test-case1 URL: $TEST_URL/es-ES]"), logs)
}
@Test(timeout = 300_000)
@ -116,6 +116,6 @@ class ErrorReporterImplTest {
val error = TEST_ERROR_3
val testReporter = createReporterImpl("en-US")
testReporter.report(error, loggerMock)
assertEquals(listOf("This is the third test message [Code: test-case-3, URL: $TEST_URL/en-US]"), logs)
assertEquals(listOf("This is the third test message [Code: test-case-3 URL: $TEST_URL/en-US]"), logs)
}
}