Search in sources :

Example 1 with ExperimentData

use of com.kickstarter.libs.utils.ExperimentData in project android-oss by kickstarter.

the class DiscoveryFragmentViewModelTest method testShouldShowEditorial_featureDisabled.

@Test
public void testShouldShowEditorial_featureDisabled() {
    final MockCurrentUser user = new MockCurrentUser();
    final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {

        @Override
        public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature, @NotNull final ExperimentData experimentData) {
            return false;
        }
    };
    final Environment environment = environment().toBuilder().currentUser(user).optimizely(mockExperimentsClientType).build();
    setUpEnvironment(environment);
    setUpInitialHomeAllProjectsParams();
    this.shouldShowEditorial.assertValue(null);
}
Also used : Environment(com.kickstarter.libs.Environment) MockExperimentsClientType(com.kickstarter.mock.MockExperimentsClientType) NotNull(org.jetbrains.annotations.NotNull) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) ExperimentData(com.kickstarter.libs.utils.ExperimentData) Test(org.junit.Test)

Example 2 with ExperimentData

use of com.kickstarter.libs.utils.ExperimentData in project android-oss by kickstarter.

the class DiscoveryFragmentViewModelTest method testShouldShowEditorial_featureEnabled.

@Test
public void testShouldShowEditorial_featureEnabled() {
    final MockCurrentUser user = new MockCurrentUser();
    final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {

        @Override
        public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature, @NotNull final ExperimentData experimentData) {
            return true;
        }
    };
    final Environment environment = environment().toBuilder().currentUser(user).optimizely(mockExperimentsClientType).build();
    setUpEnvironment(environment);
    setUpInitialHomeAllProjectsParams();
    this.shouldShowEditorial.assertValue(Editorial.LIGHTS_ON);
}
Also used : Environment(com.kickstarter.libs.Environment) MockExperimentsClientType(com.kickstarter.mock.MockExperimentsClientType) NotNull(org.jetbrains.annotations.NotNull) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) ExperimentData(com.kickstarter.libs.utils.ExperimentData) Test(org.junit.Test)

Example 3 with ExperimentData

use of com.kickstarter.libs.utils.ExperimentData in project android-oss by kickstarter.

the class DiscoveryFragmentViewModelTest method testShouldShowEditorial_whenOptimizelyInitializationDelay.

@Test
public void testShouldShowEditorial_whenOptimizelyInitializationDelay() {
    final Environment environment = environment().toBuilder().currentUser(new MockCurrentUser()).optimizely(new MockExperimentsClientType() {

        int enabledCount;

        @Override
        public boolean isFeatureEnabled(@NonNull final OptimizelyFeature.Key feature, @NonNull final ExperimentData experimentData) {
            if (enabledCount == 0) {
                enabledCount += 1;
                return false;
            } else {
                return true;
            }
        }
    }).build();
    setUpEnvironment(environment);
    setUpInitialHomeAllProjectsParams();
    this.shouldShowEditorial.assertValue(null);
    this.vm.optimizelyReady();
    this.shouldShowEditorial.assertValues(null, Editorial.LIGHTS_ON);
}
Also used : NonNull(androidx.annotation.NonNull) Environment(com.kickstarter.libs.Environment) MockExperimentsClientType(com.kickstarter.mock.MockExperimentsClientType) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) ExperimentData(com.kickstarter.libs.utils.ExperimentData) Test(org.junit.Test)

Aggregations

Environment (com.kickstarter.libs.Environment)3 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)3 ExperimentData (com.kickstarter.libs.utils.ExperimentData)3 MockExperimentsClientType (com.kickstarter.mock.MockExperimentsClientType)3 Test (org.junit.Test)3 NotNull (org.jetbrains.annotations.NotNull)2 NonNull (androidx.annotation.NonNull)1