Search in sources :

Example 1 with BuildType

use of com.github.vase4kin.teamcityapp.navigation.api.BuildType in project TeamCityApp by vase4kin.

the class RunBuildInteractorImpl method loadAgents.

/**
 * {@inheritDoc}
 */
@Override
public void loadAgents(final OnLoadingListener<List<Agent>> loadingListener) {
    Subscription queueBuildSubscription = mRepository.buildType(mBuildTypeId, false).flatMap(new Func1<BuildType, Observable<Agents>>() {

        @Override
        public Observable<Agents> call(BuildType buildType) {
            boolean isCompatibleAgentsSupported = buildType.getCompatibleAgents() != null;
            if (isCompatibleAgentsSupported) {
                // TODO: No hardcode
                String locator = String.format("compatible:(buildType:(id:%s))", mBuildTypeId);
                return mRepository.listAgents(null, null, locator, false);
            } else {
                return mRepository.listAgents(false, null, null, false);
            }
        }
    }).subscribeOn(Schedulers.io()).observeOn(AndroidSchedulers.mainThread()).subscribe(new Observer<Agents>() {

        @Override
        public void onCompleted() {
        }

        @Override
        public void onError(Throwable e) {
            loadingListener.onFail(e.getMessage());
        }

        @Override
        public void onNext(Agents agents) {
            loadingListener.onSuccess(agents.getObjects());
        }
    });
    mSubscription.add(queueBuildSubscription);
}
Also used : Agents(com.github.vase4kin.teamcityapp.agents.api.Agents) BuildType(com.github.vase4kin.teamcityapp.navigation.api.BuildType) CompositeSubscription(rx.subscriptions.CompositeSubscription) Subscription(rx.Subscription) Func1(rx.functions.Func1)

Example 2 with BuildType

use of com.github.vase4kin.teamcityapp.navigation.api.BuildType in project TeamCityApp by vase4kin.

the class Mocks method navigationNode.

/**
 * MOCK
 *
 * @return projects and build type
 */
public static NavigationNode navigationNode() {
    Project project = new Project();
    project.setName("Project");
    project.setDescription("Description");
    BuildType buildType = new BuildType();
    buildType.setId("build_type_id");
    buildType.setName("build type");
    return new NavigationNode(new Projects(Collections.singletonList(project)), new BuildTypes(Collections.singletonList(buildType)));
}
Also used : NavigationNode(com.github.vase4kin.teamcityapp.navigation.api.NavigationNode) Project(com.github.vase4kin.teamcityapp.navigation.api.Project) BuildTypes(com.github.vase4kin.teamcityapp.navigation.api.BuildTypes) BuildType(com.github.vase4kin.teamcityapp.navigation.api.BuildType) Projects(com.github.vase4kin.teamcityapp.navigation.api.Projects)

Example 3 with BuildType

use of com.github.vase4kin.teamcityapp.navigation.api.BuildType in project TeamCityApp by vase4kin.

the class RootProjectsActivityTest method testUserCanSeeProjectsData.

@Test
public void testUserCanSeeProjectsData() throws Exception {
    // Prepare data
    Project project = new Project();
    project.setName("New project");
    project.setDescription("Contains a lof of projects");
    BuildType buildType = new BuildType();
    buildType.setId("build_type_id");
    buildType.setName("Build and run tests");
    NavigationNode navigationNode = new NavigationNode(new Projects(Collections.singletonList(project)), new BuildTypes(Collections.singletonList(buildType)));
    when(mTeamCityService.listBuildTypes(anyString())).thenCallRealMethod().thenReturn(Observable.just(navigationNode));
    mActivityRule.launchActivity(null);
    // Checking toolbar title
    matchToolbarTitle("Projects");
    // Checking projects data
    onView(withId(R.id.navigation_recycler_view)).check(hasItemsCount(2));
    onView(withRecyclerView(R.id.navigation_recycler_view).atPositionOnView(0, R.id.itemTitle)).check(matches(withText("Project")));
    onView(withRecyclerView(R.id.navigation_recycler_view).atPositionOnView(0, R.id.itemSubTitle)).check(matches(withText("Description")));
    onView(withRecyclerView(R.id.navigation_recycler_view).atPositionOnView(1, R.id.itemTitle)).check(matches(withText("build type")));
    // Click on projects
    onView(withText("Project")).perform(click());
    // Check toolbar
    matchToolbarTitle("Project");
    // Check Project data
    onView(withId(R.id.navigation_recycler_view)).check(hasItemsCount(2));
    onView(withRecyclerView(R.id.navigation_recycler_view).atPositionOnView(0, R.id.itemTitle)).check(matches(withText("New project")));
    onView(withRecyclerView(R.id.navigation_recycler_view).atPositionOnView(0, R.id.itemSubTitle)).check(matches(withText("Contains a lof of projects")));
    onView(withRecyclerView(R.id.navigation_recycler_view).atPositionOnView(1, R.id.itemTitle)).check(matches(withText("Build and run tests")));
}
Also used : NavigationNode(com.github.vase4kin.teamcityapp.navigation.api.NavigationNode) Project(com.github.vase4kin.teamcityapp.navigation.api.Project) BuildTypes(com.github.vase4kin.teamcityapp.navigation.api.BuildTypes) BuildType(com.github.vase4kin.teamcityapp.navigation.api.BuildType) Projects(com.github.vase4kin.teamcityapp.navigation.api.Projects) Test(org.junit.Test)

Example 4 with BuildType

use of com.github.vase4kin.teamcityapp.navigation.api.BuildType in project TeamCityApp by vase4kin.

the class Build method setBuildTypeId.

public void setBuildTypeId(String buildTypeId) {
    this.buildType = new BuildType();
    this.buildType.setId(buildTypeId);
}
Also used : BuildType(com.github.vase4kin.teamcityapp.navigation.api.BuildType)

Aggregations

BuildType (com.github.vase4kin.teamcityapp.navigation.api.BuildType)4 BuildTypes (com.github.vase4kin.teamcityapp.navigation.api.BuildTypes)2 NavigationNode (com.github.vase4kin.teamcityapp.navigation.api.NavigationNode)2 Project (com.github.vase4kin.teamcityapp.navigation.api.Project)2 Projects (com.github.vase4kin.teamcityapp.navigation.api.Projects)2 Agents (com.github.vase4kin.teamcityapp.agents.api.Agents)1 Test (org.junit.Test)1 Subscription (rx.Subscription)1 Func1 (rx.functions.Func1)1 CompositeSubscription (rx.subscriptions.CompositeSubscription)1