Search in sources :

Example 1 with CanceledInfo

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

the class OverviewFragmentTest method testUserCanSeeCanceledInfoAsUserName.

@Test
public void testUserCanSeeCanceledInfoAsUserName() throws Exception {
    // Prepare mocks
    when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild));
    mBuild.setCanceledInfo(new CanceledInfo(CANCELED_TIME_STAMP, new User("user.name", null)));
    // 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);
    // Checking Canceled by
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(1, R.id.itemHeader)).check(matches(withText(R.string.build_canceled_by_text)));
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(1, R.id.itemTitle)).check(matches(withText("user.name")));
}
Also used : User(com.github.vase4kin.teamcityapp.buildlist.api.User) Bundle(android.os.Bundle) CanceledInfo(com.github.vase4kin.teamcityapp.buildlist.api.CanceledInfo) Intent(android.content.Intent) Test(org.junit.Test)

Example 2 with CanceledInfo

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

the class OverviewFragmentTest method testUserCanSeeCanceledInfoAsTimeStampOfCancellation.

@Test
public void testUserCanSeeCanceledInfoAsTimeStampOfCancellation() throws Exception {
    // Prepare mocks
    when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild));
    mBuild.setCanceledInfo(new CanceledInfo(CANCELED_TIME_STAMP, new User("user.name", null)));
    // 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);
    // Checking time stamp
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(2, R.id.itemHeader)).check(matches(withText(R.string.build_cancellation_time_text)));
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(2, R.id.itemTitle)).check(matches(withText("23 Dec 16 15:11")));
}
Also used : User(com.github.vase4kin.teamcityapp.buildlist.api.User) Bundle(android.os.Bundle) CanceledInfo(com.github.vase4kin.teamcityapp.buildlist.api.CanceledInfo) Intent(android.content.Intent) Test(org.junit.Test)

Example 3 with CanceledInfo

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

the class OverviewFragmentTest method testUserCanSeeCanceledInfoAsUserRealName.

@Test
public void testUserCanSeeCanceledInfoAsUserRealName() throws Exception {
    // Prepare mocks
    when(mTeamCityService.build(anyString())).thenReturn(Observable.just(mBuild));
    mBuild.setCanceledInfo(new CanceledInfo(CANCELED_TIME_STAMP, new User("user.name", "User name")));
    // 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);
    // Checking Canceled by
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(1, R.id.itemHeader)).check(matches(withText(R.string.build_canceled_by_text)));
    onView(withRecyclerView(R.id.overview_recycler_view).atPositionOnView(1, R.id.itemTitle)).check(matches(withText("User name")));
}
Also used : User(com.github.vase4kin.teamcityapp.buildlist.api.User) Bundle(android.os.Bundle) CanceledInfo(com.github.vase4kin.teamcityapp.buildlist.api.CanceledInfo) Intent(android.content.Intent) Test(org.junit.Test)

Aggregations

Intent (android.content.Intent)3 Bundle (android.os.Bundle)3 CanceledInfo (com.github.vase4kin.teamcityapp.buildlist.api.CanceledInfo)3 User (com.github.vase4kin.teamcityapp.buildlist.api.User)3 Test (org.junit.Test)3