-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Create an enum for IL location (#791)
- Loading branch information
Showing
9 changed files
with
96 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...ss/src/main/java/ch/srgssr/pillarbox/core/business/integrationlayer/service/IlLocation.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.core.business.integrationlayer.service | ||
|
||
/** | ||
* Represents the location from which requests to the integration layer are made. | ||
*/ | ||
enum class IlLocation { | ||
/** | ||
* Represents Switzerland. | ||
*/ | ||
CH, | ||
|
||
/** | ||
* Represents the rest of the world. | ||
*/ | ||
WW; | ||
|
||
@Suppress("UndocumentedPublicClass") | ||
companion object { | ||
/** | ||
* Retrieves an [IlLocation] associated with the given [name]. | ||
* | ||
* @param name The name to search for. | ||
* @return The [IlLocation] associated with the name, or `null` if not found. | ||
*/ | ||
fun fromName(name: String): IlLocation? { | ||
return entries.find { it.name.equals(name, ignoreCase = true) } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
...rc/test/java/ch/srgssr/pillarbox/core/business/integrationlayer/service/IlLocationTest.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
/* | ||
* Copyright (c) SRG SSR. All rights reserved. | ||
* License information is available from the LICENSE file. | ||
*/ | ||
package ch.srgssr.pillarbox.core.business.integrationlayer.service | ||
|
||
import kotlin.test.Test | ||
import kotlin.test.assertEquals | ||
import kotlin.test.assertNull | ||
|
||
class IlLocationTest { | ||
@Test | ||
fun `fromName CH`() { | ||
assertEquals(IlLocation.CH, IlLocation.fromName("ch")) | ||
assertEquals(IlLocation.CH, IlLocation.fromName("CH")) | ||
} | ||
|
||
@Test | ||
fun `fromName WW`() { | ||
assertEquals(IlLocation.WW, IlLocation.fromName("ww")) | ||
assertEquals(IlLocation.WW, IlLocation.fromName("WW")) | ||
} | ||
|
||
@Test | ||
fun `fromName invalid name`() { | ||
assertNull(IlLocation.fromName("INVALID")) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters