Search in sources :

Example 1 with ProjectsEnvelope

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

the class CreatorDashboardViewModelTest method testProjectName_whenMultipleProjects.

@Test
public void testProjectName_whenMultipleProjects() {
    final Project project1 = ProjectFactory.project().toBuilder().name("Best Project 2K19").build();
    final Project project2 = ProjectFactory.project();
    final List<Project> projects = Arrays.asList(project1, project2);
    final MockApiClient apiClient = new MockApiClient() {

        @Override
        @NonNull
        public Observable<ProjectsEnvelope> fetchProjects(final boolean member) {
            return Observable.just(ProjectsEnvelopeFactory.projectsEnvelope(projects));
        }
    };
    setUpEnvironment(environment().toBuilder().apiClient(apiClient).build());
    this.vm.intent(new Intent());
    this.projectName.assertValue("Best Project 2K19");
}
Also used : Project(com.kickstarter.models.Project) ProjectsEnvelope(com.kickstarter.services.apiresponses.ProjectsEnvelope) MockApiClient(com.kickstarter.mock.services.MockApiClient) Intent(android.content.Intent) Test(org.junit.Test)

Example 2 with ProjectsEnvelope

use of com.kickstarter.services.apiresponses.ProjectsEnvelope 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 ProjectsEnvelope

use of com.kickstarter.services.apiresponses.ProjectsEnvelope 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 4 with ProjectsEnvelope

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

the class CreatorDashboardViewModelTest method testProjectsForBottomSheet_With1Project.

@Test
public void testProjectsForBottomSheet_With1Project() {
    final List<Project> projects = Collections.singletonList(ProjectFactory.project());
    final MockApiClient apiClient = new MockApiClient() {

        @Override
        @NonNull
        public Observable<ProjectsEnvelope> fetchProjects(final boolean member) {
            return Observable.just(ProjectsEnvelopeFactory.projectsEnvelope(projects));
        }
    };
    setUpEnvironment(environment().toBuilder().apiClient(apiClient).build());
    this.projectsForBottomSheet.assertNoValues();
}
Also used : Project(com.kickstarter.models.Project) ProjectsEnvelope(com.kickstarter.services.apiresponses.ProjectsEnvelope) MockApiClient(com.kickstarter.mock.services.MockApiClient) Test(org.junit.Test)

Example 5 with ProjectsEnvelope

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

the class CreatorDashboardViewModelTest method testProjectsForBottomSheet_WithManyProjects.

@Test
public void testProjectsForBottomSheet_WithManyProjects() {
    final Project project1 = ProjectFactory.project();
    final Project project2 = ProjectFactory.project();
    final List<Project> projects = Arrays.asList(project1, project2);
    final MockApiClient apiClient = new MockApiClient() {

        @Override
        @NonNull
        public Observable<ProjectsEnvelope> fetchProjects(final boolean member) {
            return Observable.just(ProjectsEnvelopeFactory.projectsEnvelope(projects));
        }
    };
    setUpEnvironment(environment().toBuilder().apiClient(apiClient).build());
    this.vm.intent(new Intent());
    this.projectsForBottomSheet.assertValue(Collections.singletonList(project2));
}
Also used : Project(com.kickstarter.models.Project) ProjectsEnvelope(com.kickstarter.services.apiresponses.ProjectsEnvelope) MockApiClient(com.kickstarter.mock.services.MockApiClient) Intent(android.content.Intent) Test(org.junit.Test)

Aggregations

MockApiClient (com.kickstarter.mock.services.MockApiClient)6 Project (com.kickstarter.models.Project)6 ProjectsEnvelope (com.kickstarter.services.apiresponses.ProjectsEnvelope)6 Intent (android.content.Intent)5 Test (org.junit.Test)5 NonNull (androidx.annotation.NonNull)2 ProjectStatsEnvelope (com.kickstarter.services.apiresponses.ProjectStatsEnvelope)2 ProjectDashboardData (com.kickstarter.ui.adapters.data.ProjectDashboardData)2 DateTime (org.joda.time.DateTime)1