Search in sources :

Example 11 with TeamCityApplication

use of com.github.vase4kin.teamcityapp.TeamCityApplication in project TeamCityApp by vase4kin.

the class FilterBuildsActivityTest method setUp.

@Before
public void setUp() {
    TeamCityApplication app = (TeamCityApplication) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();
    app.getRestApiInjector().sharedUserStorage().clearAll();
    app.getRestApiInjector().sharedUserStorage().saveGuestUserAccountAndSetItAsActive(Mocks.URL);
    when(mTeamCityService.listBuilds(anyString(), anyString())).thenReturn(Observable.just(new Builds(0, Collections.<Build>emptyList())));
}
Also used : Builds(com.github.vase4kin.teamcityapp.buildlist.api.Builds) TeamCityApplication(com.github.vase4kin.teamcityapp.TeamCityApplication) Before(org.junit.Before)

Example 12 with TeamCityApplication

use of com.github.vase4kin.teamcityapp.TeamCityApplication in project TeamCityApp by vase4kin.

the class FilterBuildsBranchesAutoCompleteTest method setUp.

@Before
public void setUp() {
    TeamCityApplication app = (TeamCityApplication) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();
    app.getRestApiInjector().sharedUserStorage().clearAll();
    app.getRestApiInjector().sharedUserStorage().saveGuestUserAccountAndSetItAsActive(Mocks.URL);
}
Also used : TeamCityApplication(com.github.vase4kin.teamcityapp.TeamCityApplication) Before(org.junit.Before)

Example 13 with TeamCityApplication

use of com.github.vase4kin.teamcityapp.TeamCityApplication in project TeamCityApp by vase4kin.

the class FilterBuildsActivity method onCreate.

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_filter_builds);
    // Injecting presenter
    DaggerFilterBuildsComponent.builder().restApiComponent(((TeamCityApplication) getApplication()).getRestApiInjector()).filterBuildsModule(new FilterBuildsModule(this)).build().inject(this);
    mPresenter.onCreate();
}
Also used : FilterBuildsModule(com.github.vase4kin.teamcityapp.filter_builds.dagger.FilterBuildsModule) TeamCityApplication(com.github.vase4kin.teamcityapp.TeamCityApplication)

Example 14 with TeamCityApplication

use of com.github.vase4kin.teamcityapp.TeamCityApplication in project TeamCityApp by vase4kin.

the class CreateAccountActivityTest method setUp.

@Before
public void setUp() {
    TeamCityApplication app = (TeamCityApplication) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();
    app.getAppInjector().sharedUserStorage().clearAll();
    when(mClientBase.newCall(Matchers.any(Request.class))).thenReturn(mCall);
    mActivityRule.launchActivity(null);
}
Also used : Request(okhttp3.Request) TeamCityApplication(com.github.vase4kin.teamcityapp.TeamCityApplication) Before(org.junit.Before)

Example 15 with TeamCityApplication

use of com.github.vase4kin.teamcityapp.TeamCityApplication in project TeamCityApp by vase4kin.

the class CreateAccountActivityTest method testUserCanCreateUserAccountWithCorrectUrlAndCredentials.

/**
 * Verifies that user can be logged in with correct account url and credentials
 */
@Ignore
@Test
public void testUserCanCreateUserAccountWithCorrectUrlAndCredentials() throws Throwable {
    doAnswer(new Answer() {

        @Override
        public Object answer(InvocationOnMock invocation) throws Throwable {
            mCallbackArgumentCaptor.getValue().onResponse(mCall, new Response.Builder().request(new Request.Builder().url(URL).build()).protocol(Protocol.HTTP_1_0).code(200).build());
            return null;
        }
    }).when(mCall).enqueue(mCallbackArgumentCaptor.capture());
    onView(withId(R.id.teamcity_url)).perform(typeText(INPUT_URL), closeSoftKeyboard());
    onView(withId(R.id.user_name)).perform(typeText("user"), pressImeActionButton());
    onView(withId(R.id.password)).perform(typeText("pass"), pressImeActionButton());
    intended(allOf(hasComponent(RootProjectsActivity.class.getName()), hasExtras(hasEntry(equalTo(BundleExtractorValues.IS_NEW_ACCOUNT_CREATED), equalTo(true)))));
    TeamCityApplication app = (TeamCityApplication) InstrumentationRegistry.getInstrumentation().getTargetContext().getApplicationContext();
    SharedUserStorage storageUtils = app.getRestApiInjector().sharedUserStorage();
    assertThat(storageUtils.hasAccountWithUrl(URL, "user"), is(true));
    assertThat(storageUtils.getActiveUser().getTeamcityUrl(), is(URL));
}
Also used : Mockito.doAnswer(org.mockito.Mockito.doAnswer) Answer(org.mockito.stubbing.Answer) RootProjectsActivity(com.github.vase4kin.teamcityapp.root.view.RootProjectsActivity) SharedUserStorage(com.github.vase4kin.teamcityapp.storage.SharedUserStorage) InvocationOnMock(org.mockito.invocation.InvocationOnMock) TeamCityApplication(com.github.vase4kin.teamcityapp.TeamCityApplication) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

TeamCityApplication (com.github.vase4kin.teamcityapp.TeamCityApplication)18 Before (org.junit.Before)10 Test (org.junit.Test)7 RootProjectsActivity (com.github.vase4kin.teamcityapp.root.view.RootProjectsActivity)6 SharedUserStorage (com.github.vase4kin.teamcityapp.storage.SharedUserStorage)5 Request (okhttp3.Request)5 Mockito.doAnswer (org.mockito.Mockito.doAnswer)5 InvocationOnMock (org.mockito.invocation.InvocationOnMock)5 Answer (org.mockito.stubbing.Answer)5 Response (okhttp3.Response)3 Ignore (org.junit.Ignore)3 Builds (com.github.vase4kin.teamcityapp.buildlist.api.Builds)1 FilterBuildsModule (com.github.vase4kin.teamcityapp.filter_builds.dagger.FilterBuildsModule)1 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)1