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());
}
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));
}
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));
}
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;
}
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));
}
Aggregations