@@ -17,12 +17,66 @@ class CrowdinConfigTest {
1717 .withDistributionHash(distributionHash)
1818 .build()
1919 Assert .fail(" SDK initialization with empty `distribution hash` not valid." )
20- } catch (exception : IllegalArgumentException ) {
20+ } catch (_ : IllegalArgumentException ) {
2121 // Then
2222 // exception expected
2323 }
2424 }
2525
26+ @Test
27+ fun whenDistributionHashIsNull_shouldThrowException () {
28+ listOf (" null" , " NULL" , " Null" ).forEach { hash ->
29+ try {
30+ CrowdinConfig .Builder ().withDistributionHash(hash).build()
31+ Assert .fail(" SDK initialization with `distributionHash` = \" $hash \" should not be valid." )
32+ } catch (_: IllegalArgumentException ) {
33+ // expected
34+ }
35+ }
36+ }
37+
38+ @Test
39+ fun whenDistributionHashIsFalse_shouldThrowException () {
40+ listOf (" false" , " FALSE" , " False" ).forEach { hash ->
41+ try {
42+ CrowdinConfig .Builder ().withDistributionHash(hash).build()
43+ Assert .fail(" SDK initialization with `distributionHash` = \" $hash \" should not be valid." )
44+ } catch (_: IllegalArgumentException ) {
45+ // expected
46+ }
47+ }
48+ }
49+
50+ @Test
51+ fun whenDistributionHashIsUndefined_shouldThrowException () {
52+ listOf (" undefined" , " UNDEFINED" ).forEach { hash ->
53+ try {
54+ CrowdinConfig .Builder ().withDistributionHash(hash).build()
55+ Assert .fail(" SDK initialization with `distributionHash` = \" $hash \" should not be valid." )
56+ } catch (_: IllegalArgumentException ) {
57+ // expected
58+ }
59+ }
60+ }
61+
62+ @Test
63+ fun whenDistributionHashContainsSlash_shouldThrowException () {
64+ listOf (" /hash" , " hash/" , " /" ).forEach { hash ->
65+ try {
66+ CrowdinConfig .Builder ().withDistributionHash(hash).build()
67+ Assert .fail(" SDK initialization with `distributionHash` = \" $hash \" should not be valid." )
68+ } catch (_: IllegalArgumentException ) {
69+ // expected
70+ }
71+ }
72+ }
73+
74+ @Test
75+ fun whenDistributionHashIsValid_shouldBuildSuccessfully () {
76+ val config = CrowdinConfig .Builder ().withDistributionHash(" abc123-valid-hash" ).build()
77+ Assert .assertEquals(" abc123-valid-hash" , config.distributionHash)
78+ }
79+
2680 @Test
2781 fun whenSourceLanguageEmptyWithRealTimeEnabled_shouldThrowException () {
2882 // Given
@@ -37,7 +91,7 @@ class CrowdinConfigTest {
3791 .withSourceLanguage(sourceLanguage)
3892 .build()
3993 Assert .fail(" SDK initialization with empty `sourceLanguage` when realTime updates enabled - not valid." )
40- } catch (exception : IllegalArgumentException ) {
94+ } catch (_ : IllegalArgumentException ) {
4195 // Then
4296 // exception expected
4397 }
@@ -57,7 +111,7 @@ class CrowdinConfigTest {
57111 .withSourceLanguage(sourceLanguage)
58112 .build()
59113 Assert .fail(" SDK initialization with empty `sourceLanguage` when screenshots enabled - not valid." )
60- } catch (exception : IllegalArgumentException ) {
114+ } catch (_ : IllegalArgumentException ) {
61115 // Then
62116 // exception expected
63117 }
@@ -76,7 +130,7 @@ class CrowdinConfigTest {
76130 .withAuthConfig(authConfig)
77131 .build()
78132 Assert .fail(" SDK initialization with empty `AuthConfig` values - not valid." )
79- } catch (exception : IllegalArgumentException ) {
133+ } catch (_ : IllegalArgumentException ) {
80134 // Then
81135 // exception expected
82136 }
0 commit comments