Search in sources :

Example 11 with ProjectDashboardData

use of com.kickstarter.ui.adapters.data.ProjectDashboardData 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)

Example 12 with ProjectDashboardData

use of com.kickstarter.ui.adapters.data.ProjectDashboardData in project android-oss by kickstarter.

the class CreatorDashboardHeaderHolderViewModelTest method testOtherProjectsButtonIsGone_whenCurrentUserIsMemberOfManyProjects_viewingAllProjects.

@Test
public void testOtherProjectsButtonIsGone_whenCurrentUserIsMemberOfManyProjects_viewingAllProjects() {
    final CurrentUserType collaborator = new MockCurrentUser(UserFactory.collaborator());
    setUpEnvironment(environment().toBuilder().currentUser(collaborator).build());
    this.vm.inputs.configureWith(new ProjectDashboardData(ProjectFactory.project(), ProjectStatsEnvelopeFactory.projectStatsEnvelope(), false));
    this.otherProjectsButtonIsGone.assertValue(false);
}
Also used : CurrentUserType(com.kickstarter.libs.CurrentUserType) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData) Test(org.junit.Test)

Example 13 with ProjectDashboardData

use of com.kickstarter.ui.adapters.data.ProjectDashboardData in project android-oss by kickstarter.

the class CreatorDashboardHeaderHolderViewModelTest method testProjectBackersCountText.

@Test
public void testProjectBackersCountText() {
    final Project project = ProjectFactory.project().toBuilder().backersCount(10).build();
    final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
    setUpEnvironment(environment());
    this.vm.inputs.configureWith(new ProjectDashboardData(project, projectStatsEnvelope, false));
    this.projectBackersCountText.assertValue("10");
}
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 14 with ProjectDashboardData

use of com.kickstarter.ui.adapters.data.ProjectDashboardData in project android-oss by kickstarter.

the class CreatorDashboardHeaderHolderViewModelTest method testMessagesButtonIsGone_whenCurrentUserIsProjectCreator.

@Test
public void testMessagesButtonIsGone_whenCurrentUserIsProjectCreator() {
    final User creator = UserFactory.creator();
    final CurrentUserType currentUser = new MockCurrentUser(creator);
    final Project project = ProjectFactory.project().toBuilder().creator(creator).build();
    setUpEnvironment(environment().toBuilder().currentUser(currentUser).build());
    this.vm.inputs.configureWith(new ProjectDashboardData(project, ProjectStatsEnvelopeFactory.projectStatsEnvelope(), false));
    // Messages button is shown to project creator.
    this.messagesButtonIsGone.assertValues(false);
}
Also used : Project(com.kickstarter.models.Project) User(com.kickstarter.models.User) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) CurrentUserType(com.kickstarter.libs.CurrentUserType) MockCurrentUser(com.kickstarter.libs.MockCurrentUser) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData) Test(org.junit.Test)

Example 15 with ProjectDashboardData

use of com.kickstarter.ui.adapters.data.ProjectDashboardData in project android-oss by kickstarter.

the class CreatorDashboardHeaderHolderViewModelTest method getDashboardDataForProjectState.

private ProjectDashboardData getDashboardDataForProjectState(@Project.State final String state) {
    final ProjectStatsEnvelope projectStatsEnvelope = ProjectStatsEnvelopeFactory.projectStatsEnvelope();
    final Project project = ProjectFactory.project().toBuilder().state(state).build();
    return new ProjectDashboardData(project, projectStatsEnvelope, false);
}
Also used : Project(com.kickstarter.models.Project) ProjectStatsEnvelope(com.kickstarter.services.apiresponses.ProjectStatsEnvelope) ProjectDashboardData(com.kickstarter.ui.adapters.data.ProjectDashboardData)

Aggregations

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