Search in sources :

Example 6 with Build

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

the class RunBuildActivityTest method testUserCanStartTheBuild.

@Test
public void testUserCanStartTheBuild() throws Exception {
    // Prepare intent
    Intent intent = new Intent();
    intent.putExtra(RunBuildInteractor.EXTRA_BUILD_TYPE_ID, "href");
    // Starting the activity
    mActivityRule.launchActivity(intent);
    // Starting the build
    onView(withId(R.id.fab_queue_build)).perform(click());
    // Checking triggered build
    verify(mTeamCityService).queueBuild(mBuildCaptor.capture());
    Build capturedBuild = mBuildCaptor.getValue();
    assertThat(capturedBuild.getBranchName(), is("master"));
    assertThat(capturedBuild.getAgent(), is(nullValue()));
    assertThat(capturedBuild.isPersonal(), is(equalTo(false)));
    assertThat(capturedBuild.isQueueAtTop(), is(equalTo(false)));
    assertThat(capturedBuild.isCleanSources(), is(equalTo(true)));
    // Checking activity is finishing
    assertThat(mActivityRule.getActivity().isFinishing(), is(true));
}
Also used : Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) Intent(android.content.Intent) Test(org.junit.Test)

Example 7 with Build

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

the class RunBuildActivityTest method testUserCanSeeErrorForbiddenSnackBarIfServerReturnsAnError.

@Test
public void testUserCanSeeErrorForbiddenSnackBarIfServerReturnsAnError() throws Exception {
    // Prepare mocks
    HttpException httpException = new HttpException(Response.<Build>error(CODE_FORBIDDEN, mResponseBody));
    when(mTeamCityService.queueBuild(any(Build.class))).thenReturn(Observable.<Build>error(httpException));
    // Prepare intent
    Intent intent = new Intent();
    intent.putExtra(RunBuildInteractor.EXTRA_BUILD_TYPE_ID, "href");
    // Starting the activity
    mActivityRule.launchActivity(intent);
    // Starting the build
    onView(withId(R.id.fab_queue_build)).perform(click());
    // Checking the error snackbar text
    onView(withText(R.string.error_forbidden_error)).check(matches(isDisplayed()));
}
Also used : Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) HttpException(retrofit2.adapter.rxjava.HttpException) Intent(android.content.Intent) Test(org.junit.Test)

Example 8 with Build

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

the class RunBuildActivityTest method testUserCanSeeChooseAgentIfAgentsAvailable.

@Test
public void testUserCanSeeChooseAgentIfAgentsAvailable() throws Exception {
    // Prepare mocks
    List<Agent> agents = new ArrayList<>();
    Agent agent = new Agent("agent 1");
    agents.add(agent);
    when(mTeamCityService.listAgents(false, null, null)).thenReturn(Observable.just(new Agents(1, agents)));
    // Prepare intent
    Intent intent = new Intent();
    intent.putExtra(RunBuildInteractor.EXTRA_BUILD_TYPE_ID, "href");
    // Starting the activity
    mActivityRule.launchActivity(intent);
    // Choose agent
    onView(withId(R.id.chooser_agent)).perform(click());
    onView(withText("agent 1")).perform(click());
    // Starting the build
    onView(withId(R.id.fab_queue_build)).perform(click());
    // Checking that build was triggered with agent
    verify(mTeamCityService).queueBuild(mBuildCaptor.capture());
    Build capturedBuild = mBuildCaptor.getValue();
    assertThat(capturedBuild.getAgent(), is(agent));
    // Checking activity is finishing
    assertThat(mActivityRule.getActivity().isFinishing(), is(true));
}
Also used : Agent(com.github.vase4kin.teamcityapp.agents.api.Agent) Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) ArrayList(java.util.ArrayList) Agents(com.github.vase4kin.teamcityapp.agents.api.Agents) Intent(android.content.Intent) Test(org.junit.Test)

Example 9 with Build

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

the class RunBuildActivityTest method testUserCanStartTheBuildWithCustomParams.

@Test
public void testUserCanStartTheBuildWithCustomParams() throws Exception {
    // Prepare intent
    Intent intent = new Intent();
    intent.putExtra(RunBuildInteractor.EXTRA_BUILD_TYPE_ID, "href");
    // Starting the activity
    mActivityRule.launchActivity(intent);
    // Scroll to
    onView(withId(android.R.id.content)).perform(swipeUp());
    // Add new param
    onView(withId(R.id.button_add_parameter)).perform(click());
    // Fill params
    onView(withId(R.id.parameter_name)).perform(typeText(PARAMETER_NAME));
    onView(withId(R.id.parameter_value)).perform(typeText(PARAMETER_VALUE), closeSoftKeyboard());
    // Add param
    onView(withText(R.string.text_add_parameter_button)).perform(click());
    // Scroll to
    onView(withId(android.R.id.content)).perform(swipeUp());
    // Check params on view
    onView(allOf(withId(R.id.parameter_name), isDisplayed())).check(matches(withText(PARAMETER_NAME)));
    onView(allOf(withId(R.id.parameter_value), isDisplayed())).check(matches(withText(PARAMETER_VALUE)));
    // Starting the build
    onView(withId(R.id.fab_queue_build)).perform(click());
    // Checking triggered build
    verify(mTeamCityService).queueBuild(mBuildCaptor.capture());
    Build capturedBuild = mBuildCaptor.getValue();
    assertThat(capturedBuild.getProperties().getObjects().size(), is(equalTo(1)));
    Properties.Property capturedProperty = capturedBuild.getProperties().getObjects().get(0);
    assertThat(capturedProperty.getName(), is(equalTo(PARAMETER_NAME)));
    assertThat(capturedProperty.getValue(), is(equalTo(PARAMETER_VALUE)));
    // Checking activity is finishing
    assertThat(mActivityRule.getActivity().isFinishing(), is(true));
}
Also used : Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) Intent(android.content.Intent) Properties(com.github.vase4kin.teamcityapp.properties.api.Properties) Test(org.junit.Test)

Example 10 with Build

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

the class BuildListActivityTest method testUserCanSeeBuildListIsRefreshedIfBuildIsAddedToQueue.

@Test
public void testUserCanSeeBuildListIsRefreshedIfBuildIsAddedToQueue() throws Exception {
    when(mTeamCityService.listBuilds(anyString(), anyString())).thenReturn(Observable.just(new Builds(0, Collections.<Build>emptyList()))).thenCallRealMethod();
    // Preparing stubbing intent
    Intent resultData = new Intent();
    resultData.putExtra(RunBuildRouter.EXTRA_HREF, "href");
    Instrumentation.ActivityResult result = new Instrumentation.ActivityResult(Activity.RESULT_OK, resultData);
    mActivityRule.launchActivity(null);
    // Open build type
    onView(withText("build type")).perform(click());
    // Check the list is empty
    onView(withId(android.R.id.empty)).check(matches(isDisplayed())).check(matches(withText(R.string.empty_list_message_builds)));
    // Set up result stubbing
    intending(hasComponent(RunBuildActivity.class.getName())).respondWith(result);
    // Pressing run build fab
    onView(withId(R.id.floating_action_button)).perform(click());
    // Check new items appeared
    onView(withRecyclerView(R.id.build_recycler_view).atPositionOnView(1, R.id.itemTitle)).check(matches(withText("Running tests")));
}
Also used : RunBuildActivity(com.github.vase4kin.teamcityapp.runbuild.view.RunBuildActivity) Builds(com.github.vase4kin.teamcityapp.buildlist.api.Builds) Build(com.github.vase4kin.teamcityapp.buildlist.api.Build) Instrumentation(android.app.Instrumentation) Intent(android.content.Intent) Test(org.junit.Test)

Aggregations

Build (com.github.vase4kin.teamcityapp.buildlist.api.Build)27 Intent (android.content.Intent)14 Test (org.junit.Test)14 Builds (com.github.vase4kin.teamcityapp.buildlist.api.Builds)6 HttpException (retrofit2.adapter.rxjava.HttpException)6 Bundle (android.os.Bundle)5 ArrayList (java.util.ArrayList)5 Subscription (rx.Subscription)5 Properties (com.github.vase4kin.teamcityapp.properties.api.Properties)4 CompositeSubscription (rx.subscriptions.CompositeSubscription)3 Instrumentation (android.app.Instrumentation)2 Agent (com.github.vase4kin.teamcityapp.agents.api.Agent)2 BuildDetailsActivity (com.github.vase4kin.teamcityapp.build_details.view.BuildDetailsActivity)2 Triggered (com.github.vase4kin.teamcityapp.buildlist.api.Triggered)2 User (com.github.vase4kin.teamcityapp.buildlist.api.User)2 RunBuildActivity (com.github.vase4kin.teamcityapp.runbuild.view.RunBuildActivity)2 Agents (com.github.vase4kin.teamcityapp.agents.api.Agents)1 Artifacts (com.github.vase4kin.teamcityapp.artifact.api.Artifacts)1 BuildCancelRequest (com.github.vase4kin.teamcityapp.build_details.api.BuildCancelRequest)1 Changes (com.github.vase4kin.teamcityapp.changes.api.Changes)1