Search in sources :

Example 6 with ProjectStatsEnvelope

use of com.kickstarter.services.apiresponses.ProjectStatsEnvelope in project android-oss by kickstarter.

the class CreatorDashboardHeaderHolderViewModelTest method testStartProjectActivity_whenFeatureFlagOn_shouldEmitProjectPage.

@Test
public void testStartProjectActivity_whenFeatureFlagOn_shouldEmitProjectPage() {
    final Project project = ProjectFactory.project();
    final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
    final CurrentUserType currentUser = new MockCurrentUser();
    final MockExperimentsClientType mockExperimentsClientType = new MockExperimentsClientType() {

        @Override
        public boolean isFeatureEnabled(@NotNull final OptimizelyFeature.Key feature) {
            return true;
        }
    };
    this.setUpEnvironment(environment().toBuilder().currentUser(currentUser).optimizely(mockExperimentsClientType).build());
    this.vm.inputs.configureWith(new ProjectDashboardData(project, projectStatsEnvelope, false));
    this.vm.inputs.projectButtonClicked();
    this.startProjectActivity.assertValueCount(1);
    assertEquals(this.startProjectActivity.getOnNextEvents().get(0).first, project);
    assertEquals(this.startProjectActivity.getOnNextEvents().get(0).second, RefTag.dashboard());
}
Also used : Project(com.kickstarter.models.Project) ProjectStatsEnvelope(com.kickstarter.services.apiresponses.ProjectStatsEnvelope) CurrentUserType(com.kickstarter.libs.CurrentUserType) MockExperimentsClientType(com.kickstarter.mock.MockExperimentsClientType) NotNull(org.jetbrains.annotations.NotNull) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData) Test(org.junit.Test)

Example 7 with ProjectStatsEnvelope

use of com.kickstarter.services.apiresponses.ProjectStatsEnvelope in project android-oss by kickstarter.

the class CreatorDashboardHeaderHolderViewModelTest method testTimeRemainingText.

@Test
public void testTimeRemainingText() {
    setUpEnvironment(environment());
    DateTimeUtils.setCurrentMillisFixed(new DateTime().getMillis());
    final Project project = ProjectFactory.project().toBuilder().deadline(new DateTime().plusDays(10)).build();
    final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
    final int deadlineVal = ProjectExt.deadlineCountdownValue(project);
    this.vm.inputs.configureWith(new ProjectDashboardData(project, projectStatsEnvelope, false));
    this.timeRemainingText.assertValue(NumberUtils.format(deadlineVal));
}
Also used : Project(com.kickstarter.models.Project) ProjectStatsEnvelope(com.kickstarter.services.apiresponses.ProjectStatsEnvelope) DateTime(org.joda.time.DateTime) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData) Test(org.junit.Test)

Example 8 with ProjectStatsEnvelope

use of com.kickstarter.services.apiresponses.ProjectStatsEnvelope in project android-oss by kickstarter.

the class CreatorDashboardReferrerBreakdownHolderViewModelTest method testProjectAndAveragePledge.

@Test
public void testProjectAndAveragePledge() {
    final Project project = ProjectFactory.project();
    final ProjectStatsEnvelope.CumulativeStats cumulativeStats = ProjectStatsEnvelopeFactory.CumulativeStatsFactory.cumulativeStats().toBuilder().averagePledge(10f).build();
    final ProjectStatsEnvelope statsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope().toBuilder().cumulative(cumulativeStats).build();
    setUpEnvironment(environment());
    this.vm.inputs.projectAndStatsInput(Pair.create(project, statsEnvelope));
    this.projectAndAveragePledge.assertValue(Pair.create(project, 10));
}
Also used : Project(com.kickstarter.models.Project) ProjectStatsEnvelope(com.kickstarter.services.apiresponses.ProjectStatsEnvelope) Test(org.junit.Test)

Example 9 with ProjectStatsEnvelope

use of com.kickstarter.services.apiresponses.ProjectStatsEnvelope in project android-oss by kickstarter.

the class CreatorDashboardReferrerBreakdownHolderViewModelTest method setUpEnvironmentAndInputProjectAndStats.

@NonNull
private Project setUpEnvironmentAndInputProjectAndStats() {
    final Project project = ProjectFactory.project();
    final ProjectStatsEnvelope projectStatsEnvelope = getProjectStatsEnvelope();
    setUpEnvironment(environment());
    this.vm.inputs.projectAndStatsInput(Pair.create(project, projectStatsEnvelope));
    return project;
}
Also used : Project(com.kickstarter.models.Project) ProjectStatsEnvelope(com.kickstarter.services.apiresponses.ProjectStatsEnvelope) NonNull(androidx.annotation.NonNull)

Example 10 with ProjectStatsEnvelope

use of com.kickstarter.services.apiresponses.ProjectStatsEnvelope in project android-oss by kickstarter.

the class CreatorDashboardViewModelTest method testProjectDashboardData_whenViewingAllProjects.

public void testProjectDashboardData_whenViewingAllProjects() {
    final List<Project> projects = Collections.singletonList(ProjectFactory.project());
    final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
    final MockApiClient apiClient = new MockApiClient() {

        @Override
        @NonNull
        public Observable<ProjectsEnvelope> fetchProjects(final boolean member) {
            return Observable.just(ProjectsEnvelopeFactory.projectsEnvelope(projects));
        }

        @Override
        @NonNull
        public Observable<ProjectStatsEnvelope> fetchProjectStats(@NonNull final Project project) {
            return Observable.just(projectStatsEnvelope);
        }
    };
    setUpEnvironment(environment().toBuilder().apiClient(apiClient).build());
    this.vm.intent(new Intent());
    this.projectDashboardData.assertValue(new ProjectDashboardData(Objects.requireNonNull(ListUtils.first(projects)), projectStatsEnvelope, false));
}
Also used : Project(com.kickstarter.models.Project) ProjectStatsEnvelope(com.kickstarter.services.apiresponses.ProjectStatsEnvelope) ProjectsEnvelope(com.kickstarter.services.apiresponses.ProjectsEnvelope) MockApiClient(com.kickstarter.mock.services.MockApiClient) NonNull(androidx.annotation.NonNull) Intent(android.content.Intent) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData)

Aggregations

Project (com.kickstarter.models.Project)16 ProjectStatsEnvelope (com.kickstarter.services.apiresponses.ProjectStatsEnvelope)16 ProjectDashboardData (com.kickstarter.ui.adapters.data.ProjectDashboardData)11 Test (org.junit.Test)10 NonNull (androidx.annotation.NonNull)5 Intent (android.content.Intent)3 MockApiClient (com.kickstarter.mock.services.MockApiClient)3 CurrentUserType (com.kickstarter.libs.CurrentUserType)2 MockCurrentUser (com.kickstarter.libs.MockCurrentUser)2 ProjectsEnvelope (com.kickstarter.services.apiresponses.ProjectsEnvelope)2 DateTime (org.joda.time.DateTime)2 MockExperimentsClientType (com.kickstarter.mock.MockExperimentsClientType)1 User (com.kickstarter.models.User)1 NotNull (org.jetbrains.annotations.NotNull)1