-
Notifications
You must be signed in to change notification settings - Fork 7
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Showing
57 changed files
with
1,685 additions
and
416 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
9 changes: 9 additions & 0 deletions
9
...c/main/java/io/appmetrica/analytics/impl/modules/client/ClientModuleServiceConfigModel.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,9 @@ | ||
package io.appmetrica.analytics.impl.modules.client | ||
|
||
import io.appmetrica.analytics.coreapi.internal.identifiers.SdkIdentifiers | ||
import io.appmetrica.analytics.modulesapi.internal.client.ModuleServiceConfig | ||
|
||
class ClientModuleServiceConfigModel<T>( | ||
override val identifiers: SdkIdentifiers, | ||
override val featuresConfig: T | ||
) : ModuleServiceConfig<T> |
22 changes: 22 additions & 0 deletions
22
...java/io/appmetrica/analytics/impl/modules/client/ClientModuleServiceConfigModelFactory.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,22 @@ | ||
package io.appmetrica.analytics.impl.modules.client | ||
|
||
import android.os.Bundle | ||
import io.appmetrica.analytics.coreapi.internal.identifiers.SdkIdentifiers | ||
import io.appmetrica.analytics.modulesapi.internal.client.ServiceConfigExtensionConfiguration | ||
|
||
class ClientModuleServiceConfigModelFactory { | ||
|
||
fun <T : Any> createClientModuleServiceConfigModel( | ||
bundle: Bundle, | ||
moduleIdentifier: String, | ||
identifiers: SdkIdentifiers, | ||
extensionConfiguration: ServiceConfigExtensionConfiguration<T> | ||
): ClientModuleServiceConfigModel<T?>? { | ||
return bundle.getBundle(moduleIdentifier)?.let { moduleConfig -> | ||
ClientModuleServiceConfigModel( | ||
identifiers = identifiers, | ||
featuresConfig = extensionConfiguration.getBundleConverter().fromBundle(moduleConfig) | ||
) | ||
} | ||
} | ||
} |
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
62 changes: 62 additions & 0 deletions
62
.../io/appmetrica/analytics/impl/modules/client/ClientModuleServiceConfigModelFactoryTest.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,62 @@ | ||
package io.appmetrica.analytics.impl.modules.client | ||
|
||
import android.os.Bundle | ||
import io.appmetrica.analytics.assertions.ObjectPropertyAssertions | ||
import io.appmetrica.analytics.coreapi.internal.identifiers.SdkIdentifiers | ||
import io.appmetrica.analytics.modulesapi.internal.client.BundleToServiceConfigConverter | ||
import io.appmetrica.analytics.modulesapi.internal.client.ServiceConfigExtensionConfiguration | ||
import io.appmetrica.analytics.testutils.CommonTest | ||
import org.assertj.core.api.Assertions.assertThat | ||
import org.junit.Test | ||
import org.junit.runner.RunWith | ||
import org.mockito.kotlin.doReturn | ||
import org.mockito.kotlin.mock | ||
import org.robolectric.RobolectricTestRunner | ||
|
||
@RunWith(RobolectricTestRunner::class) | ||
class ClientModuleServiceConfigModelFactoryTest : CommonTest() { | ||
|
||
private val moduleConfigBundle = Bundle() | ||
private val moduleIdentifier = "some_identifier" | ||
private val bundle = Bundle().also { | ||
it.putBundle(moduleIdentifier, moduleConfigBundle) | ||
} | ||
private val identifiers: SdkIdentifiers = mock() | ||
private val moduleConfig: TestModuleConfig = mock() | ||
private val bundleParser: BundleToServiceConfigConverter<TestModuleConfig> = mock { | ||
on { fromBundle(moduleConfigBundle) } doReturn moduleConfig | ||
} | ||
private val extension: ServiceConfigExtensionConfiguration<TestModuleConfig> = mock { | ||
on { getBundleConverter() } doReturn bundleParser | ||
} | ||
|
||
private val factory: ClientModuleServiceConfigModelFactory by setUp { ClientModuleServiceConfigModelFactory() } | ||
|
||
@Test | ||
fun createClientModuleServiceConfigModel() { | ||
val config = factory.createClientModuleServiceConfigModel( | ||
bundle, | ||
moduleIdentifier, | ||
identifiers, | ||
extension | ||
) | ||
ObjectPropertyAssertions(config) | ||
.checkField("identifiers", identifiers) | ||
.checkField("featuresConfig", moduleConfig) | ||
.checkAll() | ||
} | ||
|
||
@Test | ||
fun createClientModuleServiceConfigModelIfNoSuchModule() { | ||
val config = factory.createClientModuleServiceConfigModel( | ||
bundle, | ||
"another_module_identifier", | ||
identifiers, | ||
extension | ||
) | ||
|
||
assertThat(config).isNull() | ||
} | ||
} | ||
|
||
private class TestModuleConfig |
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
Oops, something went wrong.