Search in sources :

Example 1 with Build

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

the class TestBuildDetailsPresenter method testStartLoadingDataManyJobs.

@Test
public void testStartLoadingDataManyJobs() {
    final long buildId = 1L;
    final String slug = "test";
    final Build build = new Build();
    final Commit commit = new Commit();
    final List<Job> jobs = new ArrayList<>();
    final Job job1 = new Job();
    jobs.add(job1);
    final Job job2 = new Job();
    jobs.add(job2);
    BuildDetails buildDetails = new BuildDetails();
    buildDetails.setBuild(build);
    buildDetails.setCommit(commit);
    buildDetails.setJobs(jobs);
    when(mTravisRestClient.getApiService().getBuild(slug, buildId)).thenReturn(buildDetails);
    mBuildsDetailsPresenter.startLoadingData(null, slug, buildId);
    verify(mTaskManager).getBuildDetails(slug, buildId);
    verify(mBuildDetailsView).showProgress();
    verify(mBuildDetailsView).hideProgress();
    verify(mBuildDetailsView).updateBuildDetails(buildDetails);
    verify(mBuildDetailsView).showBuildJobs(jobs);
}
Also used : Commit(com.khmelenko.lab.varis.network.response.Commit) BuildDetails(com.khmelenko.lab.varis.network.response.BuildDetails) Build(com.khmelenko.lab.varis.network.response.Build) ArrayList(java.util.ArrayList) Job(com.khmelenko.lab.varis.network.response.Job) Test(org.junit.Test)

Example 2 with Build

use of com.khmelenko.lab.varis.network.response.Build 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 3 with Build

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

the class TestRepoDetailsPresenter method testLoadBuildsHistory.

@Test
public void testLoadBuildsHistory() {
    final String slug = "test";
    final List<Build> builds = new ArrayList<>();
    final List<Commit> commits = new ArrayList<>();
    final BuildHistory buildHistory = new BuildHistory();
    buildHistory.setBuilds(builds);
    buildHistory.setCommits(commits);
    when(mTravisRestClient.getApiService().getBuilds(slug)).thenReturn(buildHistory);
    mRepoDetailsPresenter.setRepoSlug(slug);
    mRepoDetailsPresenter.loadBuildsHistory();
    verify(mTaskManager).getBuildHistory(slug);
    verify(mRepoDetailsView).updateBuildHistory(buildHistory);
}
Also used : Commit(com.khmelenko.lab.varis.network.response.Commit) Build(com.khmelenko.lab.varis.network.response.Build) ArrayList(java.util.ArrayList) BuildHistory(com.khmelenko.lab.varis.network.response.BuildHistory) Test(org.junit.Test)

Example 4 with Build

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

the class TestBuildDetailsPresenter method testStartLoadingDataSingleJob.

@Test
public void testStartLoadingDataSingleJob() {
    final long buildId = 1L;
    final String slug = "test";
    final Build build = new Build();
    final Commit commit = new Commit();
    final List<Job> jobs = new ArrayList<>();
    final Job job = new Job();
    jobs.add(job);
    BuildDetails buildDetails = new BuildDetails();
    buildDetails.setBuild(build);
    buildDetails.setCommit(commit);
    buildDetails.setJobs(jobs);
    final String expectedUrl = "https://sample.org";
    Response response = new Response(expectedUrl, 200, "", Collections.<Header>emptyList(), null);
    final String accessToken = "test";
    final String authToken = "token " + accessToken;
    AppSettings.putAccessToken("test");
    when(mRawClient.getApiService().getLog(authToken, String.valueOf(job.getId()))).thenReturn(response);
    when(mTravisRestClient.getApiService().getBuild(slug, buildId)).thenReturn(buildDetails);
    mBuildsDetailsPresenter.startLoadingData(null, slug, buildId);
    verify(mTaskManager).getBuildDetails(slug, buildId);
    verify(mBuildDetailsView).showProgress();
    verify(mBuildDetailsView).hideProgress();
    verify(mBuildDetailsView).updateBuildDetails(buildDetails);
    verify(mBuildDetailsView).showBuildLogs();
    verify(mBuildDetailsView).showAdditionalActionsForBuild(buildDetails);
}
Also used : Response(retrofit.client.Response) Commit(com.khmelenko.lab.varis.network.response.Commit) BuildDetails(com.khmelenko.lab.varis.network.response.BuildDetails) Build(com.khmelenko.lab.varis.network.response.Build) ArrayList(java.util.ArrayList) Job(com.khmelenko.lab.varis.network.response.Job) Test(org.junit.Test)

Example 5 with Build

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

the class BuildHistoryFragment method onItemSelected.

@Override
public void onItemSelected(int position) {
    if (mListener != null) {
        Build build = mBuildHistory.getBuilds().get(position);
        mListener.onBuildSelected(build.getId());
    }
}
Also used : Build(com.khmelenko.lab.varis.network.response.Build)

Aggregations

Build (com.khmelenko.lab.varis.network.response.Build)9 Commit (com.khmelenko.lab.varis.network.response.Commit)8 ArrayList (java.util.ArrayList)5 Test (org.junit.Test)5 BuildHistory (com.khmelenko.lab.varis.network.response.BuildHistory)3 BuildDetails (com.khmelenko.lab.varis.network.response.BuildDetails)2 Job (com.khmelenko.lab.varis.network.response.Job)2 RequestData (com.khmelenko.lab.varis.network.response.RequestData)2 Requests (com.khmelenko.lab.varis.network.response.Requests)2 Branch (com.khmelenko.lab.varis.network.response.Branch)1 Branches (com.khmelenko.lab.varis.network.response.Branches)1 BuildView (com.khmelenko.lab.varis.widget.BuildView)1 Response (retrofit.client.Response)1