diff --git a/src/main/kotlin/com/github/chriskn/structurizrextension/plantuml/IconRegistry.kt b/src/main/kotlin/com/github/chriskn/structurizrextension/plantuml/IconRegistry.kt index 8e71ab6..77da291 100644 --- a/src/main/kotlin/com/github/chriskn/structurizrextension/plantuml/IconRegistry.kt +++ b/src/main/kotlin/com/github/chriskn/structurizrextension/plantuml/IconRegistry.kt @@ -53,6 +53,12 @@ object IconRegistry { iconNameToIconUrl[name.lowercase()] = URL(url) } + internal fun reset() { + iconNameToIconUrl.clear() + iconNameToIconUrl.putAll(commonIcons.mapValues { URL(it.value) }) + iconNameToIconUrl.putAll(awsIcons.mapValues { URL(it.value) }) + } + /** * @return True if an icon with the given name (case-insensitive) exists, false otherwise. */ @@ -412,7 +418,6 @@ object IconRegistry { ) init { - iconNameToIconUrl.putAll(commonIcons.mapValues { URL(it.value) }) - iconNameToIconUrl.putAll(awsIcons.mapValues { URL(it.value) }) + reset() } } diff --git a/src/test/kotlin/com/github/chriskn/structurizrextension/plantuml/IconRegistryTest.kt b/src/test/kotlin/com/github/chriskn/structurizrextension/plantuml/IconRegistryTest.kt index daea2f3..b0b2f2a 100644 --- a/src/test/kotlin/com/github/chriskn/structurizrextension/plantuml/IconRegistryTest.kt +++ b/src/test/kotlin/com/github/chriskn/structurizrextension/plantuml/IconRegistryTest.kt @@ -1,6 +1,7 @@ package com.github.chriskn.structurizrextension.plantuml import org.assertj.core.api.Assertions.assertThat +import org.junit.jupiter.api.AfterEach import org.junit.jupiter.api.Test import org.junit.jupiter.api.assertThrows import java.net.MalformedURLException @@ -46,4 +47,9 @@ class IconRegistryTest { fun `iconFileNameFor return null if no icon file exists for name`() { assertThat(IconRegistry.iconFileNameFor("iDoNotExist")).isNull() } + + @AfterEach + fun resetIconRegistry() { + IconRegistry.reset() + } }