Search in sources :

Example 1 with Changes

use of com.github.vase4kin.teamcityapp.changes.api.Changes in project TeamCityApp by vase4kin.

the class Mocks method createBuildMock.

/**
 * MOCK
 *
 * @return parametrized build
 */
public static Build createBuildMock(String href, String number, String buildTypeId, String status, String state, String statusText, String waitReason, String branchName, String startDate, String startEstimate, String queuedDate, String finishDate) {
    Build build = new Build(href, number, buildTypeId, status, state, statusText, waitReason, branchName, startDate, startEstimate, queuedDate, finishDate, "http://www.google.com");
    build.setChanges(new Changes("/guestAuth/app/rest/changes?locator=build:(id:826073)"));
    build.setArtifacts(new Artifacts("/guestAuth/app/rest/builds/id:92912/artifacts/children/"));
    build.setAgent(new Agent("agent-love"));
    build.setTriggered(new Triggered("user", "details", new User("code-lover", null)));
    List<Properties.Property> propertyList = new ArrayList<>();
    propertyList.add(new Properties.Property("sdk", "24"));
    propertyList.add(new Properties.Property("userName", "Murdock"));
    build.setProperties(new Properties(propertyList));
    build.setTestOccurrences(new TestOccurrences(10, 2, 4, "/guestAuth/app/rest/testOccurrences?locator=build:(id:835695)"));
    return build;
}
Also used : Changes(com.github.vase4kin.teamcityapp.changes.api.Changes) Artifacts(com.github.vase4kin.teamcityapp.artifact.api.Artifacts) Agent(com.github.vase4kin.teamcityapp.agents.api.Agent) Triggered(com.github.vase4kin.teamcityapp.buildlist.api.Triggered) User(com.github.vase4kin.teamcityapp.buildlist.api.User) Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) TestOccurrences(com.github.vase4kin.teamcityapp.tests.api.TestOccurrences) ArrayList(java.util.ArrayList) Properties(com.github.vase4kin.teamcityapp.properties.api.Properties)

Example 2 with Changes

use of com.github.vase4kin.teamcityapp.changes.api.Changes in project TeamCityApp by vase4kin.

the class ChangesPresenterImplTest method testInitViews.

@Test
public void testInitViews() throws Exception {
    when(mDataManager.canLoadMore()).thenReturn(false);
    mPresenter.initViews();
    verify(mView).setLoadMoreListener(mOnLoadMoreListenerArgumentCaptor.capture());
    MugenCallbacks onLoadMoreListener = mOnLoadMoreListenerArgumentCaptor.getValue();
    assertThat(onLoadMoreListener.hasLoadedAllItems(), is(true));
    verify(mDataManager).canLoadMore();
    onLoadMoreListener.onLoadMore();
    verify(mView).addLoadMore();
    verify(mDataManager).loadMore(mOnChangesLoadingListener.capture());
    assertThat(mPresenter.mIsLoadMoreLoading, is(true));
    OnLoadingListener<List<Changes.Change>> onChangesLoadingListener = mOnChangesLoadingListener.getValue();
    List<Changes.Change> changes = Collections.emptyList();
    onChangesLoadingListener.onSuccess(changes);
    verify(mView).removeLoadMore();
    verify(mView).addMoreBuilds(any(ChangesDataModelImpl.class));
    assertThat(mPresenter.mIsLoadMoreLoading, is(false));
    onChangesLoadingListener.onFail("error");
    verify(mView, times(2)).removeLoadMore();
    verify(mView).showRetryLoadMoreSnackBar();
    assertThat(mPresenter.mIsLoadMoreLoading, is(false));
}
Also used : Changes(com.github.vase4kin.teamcityapp.changes.api.Changes) MugenCallbacks(com.mugen.MugenCallbacks) List(java.util.List) ChangesDataModelImpl(com.github.vase4kin.teamcityapp.changes.data.ChangesDataModelImpl) Test(org.junit.Test)

Aggregations

Changes (com.github.vase4kin.teamcityapp.changes.api.Changes)2 Agent (com.github.vase4kin.teamcityapp.agents.api.Agent)1 Artifacts (com.github.vase4kin.teamcityapp.artifact.api.Artifacts)1 Build (com.github.vase4kin.teamcityapp.buildlist.api.Build)1 Triggered (com.github.vase4kin.teamcityapp.buildlist.api.Triggered)1 User (com.github.vase4kin.teamcityapp.buildlist.api.User)1 ChangesDataModelImpl (com.github.vase4kin.teamcityapp.changes.data.ChangesDataModelImpl)1 Properties (com.github.vase4kin.teamcityapp.properties.api.Properties)1 TestOccurrences (com.github.vase4kin.teamcityapp.tests.api.TestOccurrences)1 MugenCallbacks (com.mugen.MugenCallbacks)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 Test (org.junit.Test)1