-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
tests: add tests for RemoteFeatureConfigCheckBuilder
- Loading branch information
Showing
1 changed file
with
53 additions
and
0 deletions.
There are no files selected for viewing
53 changes: 53 additions & 0 deletions
53
...rs/src/test/kotlin/org/wordpress/android/processor/RemoteFeatureConfigCheckBuilderTest.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,53 @@ | ||
package org.wordpress.android.processor | ||
|
||
import com.squareup.kotlinpoet.ClassName | ||
import org.assertj.core.api.Assertions | ||
import org.junit.Test | ||
|
||
class RemoteFeatureConfigCheckBuilderTest { | ||
|
||
@Test | ||
fun `given feature classes, when building config check, then generate the correct checks`() { | ||
// given | ||
val classA = "customClassA" | ||
val classB = "customClassB" | ||
val features = listOf( | ||
ClassName("org.wordpress", listOf(classA)), | ||
ClassName("org.wordpress", listOf(classB)) | ||
) | ||
|
||
// when | ||
val sut = RemoteFeatureConfigCheckBuilder(features) | ||
|
||
// then | ||
Assertions.assertThat(sut.getContent().toString()).isEqualTo( | ||
""" | ||
// Automatically generated file. DO NOT MODIFY | ||
package org.wordpress.android.util.config | ||
import org.wordpress.$classA | ||
import org.wordpress.$classB | ||
class RemoteFeatureConfigCheck( | ||
val appConfig: AppConfig | ||
) { | ||
val $classA: $classA = $classA(appConfig) | ||
val $classB: $classB = $classB(appConfig) | ||
fun checkRemoteFields() { | ||
if ($classA.remoteField == null) { | ||
throw IllegalArgumentException(""${'"'}org.wordpress.$classA needs to define | ||
remoteField""${'"'}) | ||
} | ||
if ($classB.remoteField == null) { | ||
throw IllegalArgumentException(""${'"'}org.wordpress.$classB needs to define | ||
remoteField""${'"'}) | ||
} | ||
} | ||
} | ||
""".trimIndent() | ||
) | ||
} | ||
} |