Search in sources :

Example 1 with BuildListFilter

use of com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilter in project TeamCityApp by vase4kin.

the class BuildListActivityTest method testUserCanSeeSnackBarIfBuildFiltersHaveBeenApplied.

@Test
public void testUserCanSeeSnackBarIfBuildFiltersHaveBeenApplied() throws Exception {
    when(mTeamCityService.listBuilds(anyString(), anyString())).thenReturn(Observable.just(new Builds(0, Collections.<Build>emptyList())));
    // Preparing stubbing intent
    Intent resultData = new Intent();
    BuildListFilter filter = new BuildListFilterImpl();
    filter.setFilter(FilterBuildsView.FILTER_CANCELLED);
    filter.setBranch("branch");
    filter.setPersonal(true);
    filter.setPinned(true);
    resultData.putExtra(FilterBuildsRouter.EXTRA_FILTER, filter);
    Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData);
    mActivityRule.launchActivity(null);
    // Open build type
    onView(withText("build type")).perform(click());
    // Set up result stubbing
    intending(hasComponent(FilterBuildsActivity.class.getName())).respondWith(result);
    // Pressing filter builds toolbar item
    onView(withId(R.id.filter_builds)).perform(click());
    // Check snack bar text
    onView(withText(R.string.text_filters_applied)).check(matches(isDisplayed()));
    // Check data was loaded with new filter
    verify(mTeamCityService).listBuilds(eq("build_type_id"), eq("canceled:true,branch:name:branch,personal:true,pinned:true,count:10"));
}
Also used : Builds(com.github.vase4kin.teamcityapp.buildlist.api.Builds) BuildListFilterImpl(com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilterImpl) Instrumentation(android.app.Instrumentation) FilterBuildsActivity(com.github.vase4kin.teamcityapp.filter_builds.view.FilterBuildsActivity) Intent(android.content.Intent) BuildListFilter(com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilter) Test(org.junit.Test)

Example 2 with BuildListFilter

use of com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilter in project TeamCityApp by vase4kin.

the class FilterBuildsPresenterImpl method onFilterFabClick.

@Override
public void onFilterFabClick(int filterType, boolean isPersonal, boolean isPinned) {
    BuildListFilter filter = new BuildListFilterImpl();
    filter.setFilter(filterType);
    filter.setBranch(mBranchesComponentView.getBranchName());
    filter.setPersonal(isPersonal);
    filter.setPinned(isPinned);
    mTracker.trackUserFilteredBuilds();
    mRouter.closeOnSuccess(filter);
}
Also used : BuildListFilterImpl(com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilterImpl) BuildListFilter(com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilter)

Example 3 with BuildListFilter

use of com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilter in project TeamCityApp by vase4kin.

the class BuildListPresenterImpl method loadData.

/**
 * {@inheritDoc}
 */
@Override
protected void loadData(@NonNull OnLoadingListener<List<BuildDetails>> loadingListener, boolean update) {
    String buildTypeId = mValueExtractor.getId();
    BuildListFilter filter = mValueExtractor.getBuildListFilter();
    if (filter != null) {
        mDataManager.load(buildTypeId, filter, loadingListener, update);
    } else {
        mDataManager.load(buildTypeId, loadingListener, update);
    }
}
Also used : BuildListFilter(com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilter)

Example 4 with BuildListFilter

use of com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilter in project TeamCityApp by vase4kin.

the class BuildDetailsPresenterImpl method onStartBuildListActivityFilteredByBranchEventTriggered.

/**
 * {@inheritDoc}
 */
@Override
public void onStartBuildListActivityFilteredByBranchEventTriggered(String branchName) {
    String name = mInteractor.getBuildTypeName();
    String id = mInteractor.getBuildDetails().getBuildTypeId();
    BuildListFilter filter = new BuildListFilterImpl();
    filter.setFilter(FilterBuildsView.FILTER_NONE);
    filter.setBranch(branchName);
    mRouter.startBuildListActivity(name, id, filter);
}
Also used : BuildListFilterImpl(com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilterImpl) BuildListFilter(com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilter)

Example 5 with BuildListFilter

use of com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilter in project TeamCityApp by vase4kin.

the class FilterBuildsPresenterImplTest method onFilterFabClick.

@Test
public void onFilterFabClick() throws Exception {
    when(mBranchesComponentView.getBranchName()).thenReturn("branch");
    mPresenter.onFilterFabClick(FilterBuildsView.FILTER_CANCELLED, true, true);
    verify(mBranchesComponentView).getBranchName();
    verify(mTracker).trackUserFilteredBuilds();
    verify(mRouter).closeOnSuccess(mBuildListFilterCaptor.capture());
    BuildListFilter capturedFilter = mBuildListFilterCaptor.getValue();
    assertThat(capturedFilter.toLocator(), is(equalTo("canceled:true,branch:name:branch,personal:true,pinned:true,count:10")));
}
Also used : BuildListFilter(com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilter) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

BuildListFilter (com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilter)5 BuildListFilterImpl (com.github.vase4kin.teamcityapp.buildlist.filter.BuildListFilterImpl)3 Test (org.junit.Test)2 Instrumentation (android.app.Instrumentation)1 Intent (android.content.Intent)1 Builds (com.github.vase4kin.teamcityapp.buildlist.api.Builds)1 FilterBuildsActivity (com.github.vase4kin.teamcityapp.filter_builds.view.FilterBuildsActivity)1 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)1