Skip to content

Commit

Permalink
tests: add tests for RemoteFeatureConfigCheckBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
wzieba committed Feb 20, 2024
1 parent 18f368d commit 5d3a86d
Showing 1 changed file with 53 additions and 0 deletions.
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()
)
}
}

0 comments on commit 5d3a86d

Please sign in to comment.