Search in sources :

Example 1 with Branch

use of com.khmelenko.lab.varis.network.response.Branch in project Varis-Android by dkhmelenko.

the class TestRepoDetailsPresenter method testLoadData.

@Test
public void testLoadData() {
    final String slug = "test";
    final List<Build> builds = new ArrayList<>();
    final List<Commit> commits = new ArrayList<>();
    final List<RequestData> requestData = new ArrayList<>();
    final Requests requests = new Requests();
    requests.setCommits(commits);
    requests.setRequests(requestData);
    final BuildHistory buildHistory = new BuildHistory();
    buildHistory.setBuilds(builds);
    buildHistory.setCommits(commits);
    final List<Branch> branch = new ArrayList<>();
    final Branches branches = new Branches();
    branches.setBranches(branch);
    branches.setCommits(commits);
    when(mTravisRestClient.getApiService().getBuilds(slug)).thenReturn(buildHistory);
    when(mTravisRestClient.getApiService().getBranches(slug)).thenReturn(branches);
    when(mTravisRestClient.getApiService().getRequests(slug)).thenReturn(requests);
    when(mTravisRestClient.getApiService().getPullRequestBuilds(slug)).thenReturn(buildHistory);
    mRepoDetailsPresenter.setRepoSlug(slug);
    mRepoDetailsPresenter.loadData();
    verify(mRepoDetailsPresenter).loadBuildsHistory();
    verify(mRepoDetailsPresenter).loadBranches();
    verify(mRepoDetailsPresenter).loadRequests();
}
Also used : Branches(com.khmelenko.lab.varis.network.response.Branches) ArrayList(java.util.ArrayList) Requests(com.khmelenko.lab.varis.network.response.Requests) Commit(com.khmelenko.lab.varis.network.response.Commit) Build(com.khmelenko.lab.varis.network.response.Build) RequestData(com.khmelenko.lab.varis.network.response.RequestData) Branch(com.khmelenko.lab.varis.network.response.Branch) BuildHistory(com.khmelenko.lab.varis.network.response.BuildHistory) Test(org.junit.Test)

Example 2 with Branch

use of com.khmelenko.lab.varis.network.response.Branch in project Varis-Android by dkhmelenko.

the class TestRepoDetailsPresenter method testLoadBranches.

@Test
public void testLoadBranches() {
    final String slug = "test";
    final List<Branch> branch = new ArrayList<>();
    final List<Commit> commits = new ArrayList<>();
    final Branches branches = new Branches();
    branches.setBranches(branch);
    branches.setCommits(commits);
    when(mTravisRestClient.getApiService().getBranches(slug)).thenReturn(branches);
    mRepoDetailsPresenter.setRepoSlug(slug);
    mRepoDetailsPresenter.loadBranches();
    verify(mTaskManager).getBranches(slug);
    verify(mRepoDetailsView).updateBranches(branches);
}
Also used : Commit(com.khmelenko.lab.varis.network.response.Commit) Branch(com.khmelenko.lab.varis.network.response.Branch) Branches(com.khmelenko.lab.varis.network.response.Branches) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 3 with Branch

use of com.khmelenko.lab.varis.network.response.Branch in project Varis-Android by dkhmelenko.

the class BranchesFragment method onItemSelected.

@Override
public void onItemSelected(int position) {
    if (mListener != null) {
        Branch branch = mBranches.getBranches().get(position);
        mListener.onBranchSelected(branch.getId());
    }
}
Also used : Branch(com.khmelenko.lab.varis.network.response.Branch)

Example 4 with Branch

use of com.khmelenko.lab.varis.network.response.Branch in project Varis-Android by dkhmelenko.

the class BranchesListAdapter method onBindViewHolder.

@Override
public void onBindViewHolder(BuildViewHolder holder, int position) {
    if (mBranches != null) {
        Branch branch = mBranches.getBranches().get(position);
        Commit relatedCommit = null;
        for (Commit commit : mBranches.getCommits()) {
            if (branch.getCommitId() == commit.getId()) {
                relatedCommit = commit;
                break;
            }
        }
        holder.mBuildView.setState(branch);
        holder.mBuildView.setCommit(relatedCommit);
    }
}
Also used : Commit(com.khmelenko.lab.varis.network.response.Commit) Branch(com.khmelenko.lab.varis.network.response.Branch)

Aggregations

Branch (com.khmelenko.lab.varis.network.response.Branch)4 Commit (com.khmelenko.lab.varis.network.response.Commit)3 Branches (com.khmelenko.lab.varis.network.response.Branches)2 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 Build (com.khmelenko.lab.varis.network.response.Build)1 BuildHistory (com.khmelenko.lab.varis.network.response.BuildHistory)1 RequestData (com.khmelenko.lab.varis.network.response.RequestData)1 Requests (com.khmelenko.lab.varis.network.response.Requests)1