Search in sources :

Example 1 with Triggered

use of com.github.vase4kin.teamcityapp.buildlist.api.Triggered in project TeamCityApp by vase4kin.

the class OverviewFragmentTest method testUserCanSeePersonalInfoIfBuildIsPersonal.

@Test
public void testUserCanSeePersonalInfoIfBuildIsPersonal() {
    // Prepare mocks
    when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild));
    Triggered triggered = new Triggered(TRIGGER_TYPE_USER, null, new User(USER_NAME, null));
    mBuild.setTriggered(triggered);
    mBuild.setPersonal(true);
    // Prepare intent
    // <! ---------------------------------------------------------------------- !>
    // Passing build object to activity, had to create it for real, Can't pass mock object as serializable in bundle :(
    // <! ---------------------------------------------------------------------- !>
    Intent intent = new Intent();
    Bundle b = new Bundle();
    Build successBuild = Mocks.successBuild();
    successBuild.setPersonal(true);
    b.putSerializable(BundleExtractorValues.BUILD, Mocks.successBuild());
    b.putString(BundleExtractorValues.NAME, BUILD_TYPE_NAME);
    intent.putExtras(b);
    // Start activity
    mActivityRule.launchActivity(intent);
    // Scrolling to last item to make it visible
    onView(withId(R.id.overview_recycler_view)).perform(scrollToPosition(5));
    // Checking Personal of
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(5, R.id.itemHeader)).check(matches(withText(R.string.build_personal_text)));
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(5, R.id.itemTitle)).check(matches(withText(USER_NAME)));
}
Also used : Triggered(com.github.vase4kin.teamcityapp.buildlist.api.Triggered) User(com.github.vase4kin.teamcityapp.buildlist.api.User) Bundle(android.os.Bundle) Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) Intent(android.content.Intent) Test(org.junit.Test)

Example 2 with Triggered

use of com.github.vase4kin.teamcityapp.buildlist.api.Triggered in project TeamCityApp by vase4kin.

the class OverviewFragmentTest method testUserCanSeeWhatUserRestartedBuildIfUserHasName.

@Test
public void testUserCanSeeWhatUserRestartedBuildIfUserHasName() {
    // Prepare mocks
    when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild));
    Triggered triggered = new Triggered(TRIGGER_TYPE_RESTARTED, null, new User(USER_NAME, NAME));
    mBuild.setTriggered(triggered);
    // Prepare intent
    // <! ---------------------------------------------------------------------- !>
    // Passing build object to activity, had to create it for real, Can't pass mock object as serializable in bundle :(
    // <! ---------------------------------------------------------------------- !>
    Intent intent = new Intent();
    Bundle b = new Bundle();
    b.putSerializable(BundleExtractorValues.BUILD, Mocks.successBuild());
    b.putString(BundleExtractorValues.NAME, BUILD_TYPE_NAME);
    intent.putExtras(b);
    // Start activity
    mActivityRule.launchActivity(intent);
    // Scrolling to last item to make it visible
    onView(withId(R.id.overview_recycler_view)).perform(scrollToPosition(4));
    // Checking restarted by
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(4, R.id.itemHeader)).check(matches(withText(R.string.build_restarted_by_section_text)));
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(4, R.id.itemTitle)).check(matches(withText(NAME)));
}
Also used : Triggered(com.github.vase4kin.teamcityapp.buildlist.api.Triggered) User(com.github.vase4kin.teamcityapp.buildlist.api.User) Bundle(android.os.Bundle) Intent(android.content.Intent) Test(org.junit.Test)

Example 3 with Triggered

use of com.github.vase4kin.teamcityapp.buildlist.api.Triggered 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 4 with Triggered

use of com.github.vase4kin.teamcityapp.buildlist.api.Triggered in project TeamCityApp by vase4kin.

the class OverviewFragmentTest method testUserCanSeeUserWhatUserTriggeredBuildIfUserHasName.

@Test
public void testUserCanSeeUserWhatUserTriggeredBuildIfUserHasName() {
    // Prepare mocks
    when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild));
    Triggered triggered = new Triggered(TRIGGER_TYPE_USER, null, new User(USER_NAME, NAME));
    mBuild.setTriggered(triggered);
    // Prepare intent
    // <! ---------------------------------------------------------------------- !>
    // Passing build object to activity, had to create it for real, Can't pass mock object as serializable in bundle :(
    // <! ---------------------------------------------------------------------- !>
    Intent intent = new Intent();
    Bundle b = new Bundle();
    b.putSerializable(BundleExtractorValues.BUILD, Mocks.successBuild());
    b.putString(BundleExtractorValues.NAME, BUILD_TYPE_NAME);
    intent.putExtras(b);
    // Start activity
    mActivityRule.launchActivity(intent);
    // Scrolling to last item to make it visible
    onView(withId(R.id.overview_recycler_view)).perform(scrollToPosition(4));
    // Checking restarted by
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(4, R.id.itemHeader)).check(matches(withText(R.string.build_triggered_by_section_text)));
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(4, R.id.itemTitle)).check(matches(withText(NAME)));
}
Also used : Triggered(com.github.vase4kin.teamcityapp.buildlist.api.Triggered) User(com.github.vase4kin.teamcityapp.buildlist.api.User) Bundle(android.os.Bundle) Intent(android.content.Intent) Test(org.junit.Test)

Example 5 with Triggered

use of com.github.vase4kin.teamcityapp.buildlist.api.Triggered in project TeamCityApp by vase4kin.

the class OverviewFragmentTest method testUserCanSeeUserWhatUserTriggeredBuildIfUserHasOnLyName.

@Test
public void testUserCanSeeUserWhatUserTriggeredBuildIfUserHasOnLyName() {
    // Prepare mocks
    when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild));
    Triggered triggered = new Triggered(TRIGGER_TYPE_USER, null, new User(USER_NAME, null));
    mBuild.setTriggered(triggered);
    // Prepare intent
    // <! ---------------------------------------------------------------------- !>
    // Passing build object to activity, had to create it for real, Can't pass mock object as serializable in bundle :(
    // <! ---------------------------------------------------------------------- !>
    Intent intent = new Intent();
    Bundle b = new Bundle();
    b.putSerializable(BundleExtractorValues.BUILD, Mocks.successBuild());
    b.putString(BundleExtractorValues.NAME, BUILD_TYPE_NAME);
    intent.putExtras(b);
    // Start activity
    mActivityRule.launchActivity(intent);
    // Scrolling to last item to make it visible
    onView(withId(R.id.overview_recycler_view)).perform(scrollToPosition(4));
    // Checking restarted by
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(4, R.id.itemHeader)).check(matches(withText(R.string.build_triggered_by_section_text)));
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(4, R.id.itemTitle)).check(matches(withText(USER_NAME)));
}
Also used : Triggered(com.github.vase4kin.teamcityapp.buildlist.api.Triggered) User(com.github.vase4kin.teamcityapp.buildlist.api.User) Bundle(android.os.Bundle) Intent(android.content.Intent) Test(org.junit.Test)

Aggregations

Triggered (com.github.vase4kin.teamcityapp.buildlist.api.Triggered)9 Intent (android.content.Intent)8 Bundle (android.os.Bundle)8 Test (org.junit.Test)8 User (com.github.vase4kin.teamcityapp.buildlist.api.User)6 Build (com.github.vase4kin.teamcityapp.buildlist.api.Build)2 Agent (com.github.vase4kin.teamcityapp.agents.api.Agent)1 Artifacts (com.github.vase4kin.teamcityapp.artifact.api.Artifacts)1 Changes (com.github.vase4kin.teamcityapp.changes.api.Changes)1 Properties (com.github.vase4kin.teamcityapp.properties.api.Properties)1 TestOccurrences (com.github.vase4kin.teamcityapp.tests.api.TestOccurrences)1 ArrayList (java.util.ArrayList)1