@Test public void should_be_able_to_acquire_token_and_then_acquire_silent() { //clear cache givenThat(james).wasAbleTo(clearCache, clickDone, readCache); then(james).should(seeThat(TokenCacheItemCount.displayed(), is(0))); givenThat(james).wasAbleTo( clickDone, acquireToken, clickDone, readCache); int expectedCacheCountToken = james.asksFor(ExpectedCacheItemCount.displayed()); then(james).should(seeThat(TokenCacheItemCount.displayed(), is(expectedCacheCountToken))); when(james).attemptsTo( clickDone, acquireTokenSilent, clickDone, readCache ); then(james).should(seeThat(TokenCacheItemCount.displayed(), is(expectedCacheCountToken))); }
public static <T> Consequence<T>[] seeThat(Question<? extends T> actual, Matcher<T>... expectedMatchers) { if (thereAreNo(expectedMatchers)) { return consequenceGroupFor(actual); } else { return consequencesForEachMatcher(actual, expectedMatchers); } }
@Test public void should_be_able_to_new_access_token_after_expiry_on_silent() { //clear cache givenThat(james).wasAbleTo(clearCache, clickDone, readCache); then(james).should(seeThat(TokenCacheItemCount.displayed(), is(0))); givenThat(james).wasAbleTo( clickDone, acquireToken, clickDone, readCache); int expectedCacheCount = james.asksFor(ExpectedCacheItemCount.displayed()); then(james).should(seeThat(TokenCacheItemCount.displayed(), is(expectedCacheCount))); String accessToken1 = james.asksFor(AccessToken.displayed()); TokenCacheItemReadResult result = james.asksFor(TokenCacheItemFromResult.displayed()); givenThat(james).wasAbleTo( clickDone, expireAccessToken.withTokenCacheItem(result), clickDone, acquireTokenSilent.withUniqueId(result.uniqueUserId), clickDone, readCache); then(james).should(seeThat(AccessToken.displayed(), not(accessToken1))); }
public static <T> Task seeIf(Question<T> question, Matcher<T> matcher) { Consequence<T> consequence = seeThat(question, matcher); return Task.where("See if " + question.toString() + " " + matcher.toString(), (Performable) consequence::evaluateFor ); }
@Test public void should_be_able_to_acquire_token_with_broker() { givenThat(james).wasAbleTo( acquireToken.withBroker(), WaitUntil.the(Results.RESULT_FIELD, isVisible()).forNoMoreThan(10).seconds() ); then(james).should(seeThat(AccessTokenFromAuthenticationResult.displayed(), notNullValue())); james.attemptsTo(workplaceLeave); }
@Override public <A extends Actor> void performAs(A actor) { actor.should(eventually(seeThat(WebElementQuestion.the(target), expectedState)).withNoReporting()); }
@Test public void should_be_able_to_acquire_token_and_then_acquire_silent_with_different_resource() { //clear cache givenThat(james).wasAbleTo(clearCache, clickDone, readCache); then(james).should(seeThat(TokenCacheItemCount.displayed(), is(0))); givenThat(james).wasAbleTo( clickDone, acquireToken, clickDone, readCache); int expectedCacheCountToken = james.asksFor(ExpectedCacheItemCount.displayed()); then(james).should(seeThat(TokenCacheItemCount.displayed(), is(expectedCacheCountToken))); when(james).attemptsTo( clickDone, acquireTokenSilent.withResourceId(mSecondaryResource), clickDone, readCache ); expectedCacheCountToken += expectedCacheCountToken/2; then(james).should(seeThat(TokenCacheItemCount.displayed(), is(expectedCacheCountToken))); }
@Test public void should_be_able_to_acquire_token_with_broker_with_prompt_always() { givenThat(james).wasAbleTo( acquireToken .withBroker() .withPrompt("Always"), WaitUntil.the(Results.RESULT_FIELD, isVisible()).forNoMoreThan(10).seconds() ); then(james).should(seeThat(AccessTokenFromAuthenticationResult.displayed(), notNullValue())); james.attemptsTo(workplaceLeave); }
@Test public void should_be_able_to_acquire_token_prompt_always() { james.attemptsTo( clearCache, clickDone, acquireToken.withPrompt("Always"), clickDone, readCache); int expectedCacheCount = james.asksFor(ExpectedCacheItemCount.displayed()); then(james).should(seeThat(TokenCacheItemCount.displayed(), is(expectedCacheCount))); }
@Override public <T extends Actor> void performAs(T actor) { actor.should(eventually(seeThat(the(target), expectedState)) .withNoReporting() .waitingForNoLongerThan(amount).milliseconds()); } };
@Test public void should_be_able_to_acquire_token_and_then_acquire_silent_with_login_hint() { //clear cache givenThat(james).wasAbleTo(clearCache, clickDone, readCache); then(james).should(seeThat(TokenCacheItemCount.displayed(), is(0))); givenThat(james).wasAbleTo( clickDone, acquireToken, clickDone, readCache); int expectedCacheCount = james.asksFor(ExpectedCacheItemCount.displayed()); then(james).should(seeThat(TokenCacheItemCount.displayed(), is(expectedCacheCount))); String accessToken1 = james.asksFor(AccessToken.displayed()); james.attemptsTo(clickDone); when(james).attemptsTo( acquireTokenSilent.withUserIdentifier(james.getCredential().userName), clickDone, readCache); then(james).should(seeThat(AccessToken.displayed(), is(accessToken1))); }
@Test public void should_be_able_to_acquire_token_with_broker_with_prompt_null() { givenThat(james).wasAbleTo( acquireToken .withBroker() .withPrompt(null), WaitUntil.the(Results.RESULT_FIELD, isVisible()).forNoMoreThan(10).seconds() ); then(james).should(seeThat(AccessTokenFromAuthenticationResult.displayed(), notNullValue())); james.attemptsTo(workplaceLeave); }
@Test public void should_be_able_to_acquire_token_prompt_null() { james.attemptsTo( clearCache, clickDone, acquireToken.withPrompt(null), clickDone, readCache); int expectedCacheCount = james.asksFor(ExpectedCacheItemCount.displayed()); then(james).should(seeThat(TokenCacheItemCount.displayed(), is(expectedCacheCount))); }
@Override public <T extends Actor> void performAs(T actor) { actor.should(eventually(seeThat(the(target), expectedState)) .withNoReporting() .waitingForNoLongerThan(amount).seconds()); } };
@Test public void should_be_able_to_acquire_token_and_then_acquire_silent_with_force_refresh() { givenThat(james).wasAbleTo( acquireToken ); String accessToken1 = james.asksFor(AccessTokenFromAuthenticationResult.displayed()); james.attemptsTo(clickDone); when(james).attemptsTo( acquireTokenSilent.withUserIdentifier(james.getCredential().userName).withForceRefresh() ); then(james).should(seeThat(AccessTokenFromAuthenticationResult.displayed(), not(accessToken1))); }
@Test public void should_be_able_to_acquire_token_with_broker_with_prompt_auto() { givenThat(james).wasAbleTo( acquireToken .withBroker() .withPrompt("Auto"), WaitUntil.the(Results.RESULT_FIELD, isVisible()).forNoMoreThan(10).seconds() ); then(james).should(seeThat(AccessTokenFromAuthenticationResult.displayed(), notNullValue())); james.attemptsTo(workplaceLeave); }
@Test public void should_be_able_to_acquire_token_prompt_auto() { james.attemptsTo( clearCache, clickDone, acquireToken.withPrompt("Auto"), clickDone, readCache); int expectedCacheCount = james.asksFor(ExpectedCacheItemCount.displayed()); then(james).should(seeThat(TokenCacheItemCount.displayed(), is(expectedCacheCount))); }
@Then("I should pay \\$(\\d+)") public void shouldPay(int totalPrice) { john.should(seeThat(TheTotalPrice.ofTheGizmos(billedPrice), equalTo(totalPrice))); }