Search in sources :

Example 1 with ProjectStatsEnvelope

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

the class CreatorDashboardAdapter method takeProjectDashboardData.

public void takeProjectDashboardData(@NonNull final ProjectDashboardData projectDashboardData) {
    setSection(SECTION_FUNDING_VIEW, Collections.singletonList(projectDashboardData));
    // add reward stats sections
    final Project project = projectDashboardData.getProject();
    final ProjectStatsEnvelope projectStatsEnvelope = projectDashboardData.getProjectStatsEnvelope();
    setSection(SECTION_REWARD_STATS_VIEW, Collections.singletonList(Pair.create(project, projectStatsEnvelope.rewardDistribution())));
    setSection(SECTION_REFERRER_BREAKDOWN_LAYOUT, Collections.singletonList(Pair.create(project, projectStatsEnvelope)));
    setSection(SECTION_REFERRER_STATS_VIEW, Collections.singletonList(Pair.create(project, projectStatsEnvelope.referralDistribution())));
    notifyDataSetChanged();
}
Also used : Project(com.kickstarter.models.Project) ProjectStatsEnvelope(com.kickstarter.services.apiresponses.ProjectStatsEnvelope)

Example 2 with ProjectStatsEnvelope

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

the class CreatorDashboardViewModelTest method testProjectSwitcherProjectClickOutput.

@Test
public void testProjectSwitcherProjectClickOutput() {
    DateTimeUtils.setCurrentMillisFixed(new DateTime().getMillis());
    final Project project1 = ProjectFactory.project();
    final Project project2 = ProjectFactory.project();
    final List<Project> projects = Arrays.asList(project1, project2);
    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.vm.inputs.projectSelectionInput(project2);
    this.projectDashboardData.assertValues(new ProjectDashboardData(project1, ProjectStatsEnvelopeFactory.projectStatsEnvelope(), false), new ProjectDashboardData(project2, ProjectStatsEnvelopeFactory.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) DateTime(org.joda.time.DateTime) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData) Test(org.junit.Test)

Example 3 with ProjectStatsEnvelope

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

the class CreatorDashboardViewModelTest method testProjectDashboardData_whenViewingSingleProjects.

public void testProjectDashboardData_whenViewingSingleProjects() {
    final Project project = ProjectFactory.project();
    final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
    final MockApiClient apiClient = new MockApiClient() {

        @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().putExtra(IntentKey.PROJECT, project));
    this.projectDashboardData.assertValue(new ProjectDashboardData(project, projectStatsEnvelope, true));
}
Also used : Project(com.kickstarter.models.Project) ProjectStatsEnvelope(com.kickstarter.services.apiresponses.ProjectStatsEnvelope) MockApiClient(com.kickstarter.mock.services.MockApiClient) NonNull(androidx.annotation.NonNull) Intent(android.content.Intent) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData)

Example 4 with ProjectStatsEnvelope

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

the class CreatorDashboardHeaderHolderViewModelTest method testPercentageFunded.

@Test
public void testPercentageFunded() {
    setUpEnvironment(environment());
    final Project project = ProjectFactory.project();
    final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
    this.vm.inputs.configureWith(new ProjectDashboardData(project, projectStatsEnvelope, false));
    final String percentageFundedOutput = NumberUtils.flooredPercentage(project.percentageFunded());
    this.percentageFunded.assertValues(percentageFundedOutput);
    final int percentageFundedProgressOutput = ProgressBarUtils.progress(project.percentageFunded());
    this.percentageFundedProgress.assertValue(percentageFundedProgressOutput);
}
Also used : Project(com.kickstarter.models.Project) ProjectStatsEnvelope(com.kickstarter.services.apiresponses.ProjectStatsEnvelope) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData) Test(org.junit.Test)

Example 5 with ProjectStatsEnvelope

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

the class CreatorDashboardHeaderHolderViewModelTest method testProjectNameTextViewText.

@Test
public void testProjectNameTextViewText() {
    final Project project = ProjectFactory.project().toBuilder().name("somebody once told me").build();
    final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
    setUpEnvironment(environment());
    this.vm.inputs.configureWith(new ProjectDashboardData(project, projectStatsEnvelope, false));
    this.projectNameTextViewText.assertValue("somebody once told me");
}
Also used : Project(com.kickstarter.models.Project) ProjectStatsEnvelope(com.kickstarter.services.apiresponses.ProjectStatsEnvelope) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData) Test(org.junit.Test)

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