Search in sources :

Example 1 with ShowcaseContext

use of com.yandex.money.api.model.showcase.ShowcaseContext in project yandex-money-sdk-java by yandex-money.

the class ShowcaseParserTest method testShowcase.

private void testShowcase(ApiClient client, long scid) throws Exception {
    ShowcaseContext showcaseContext = client.execute(new Showcase.Request(scid));
    assertNotNull(showcaseContext);
    assertNotNull(showcaseContext.getCurrentStep().showcase);
}
Also used : Showcase(com.yandex.money.api.model.showcase.Showcase) ShowcaseContext(com.yandex.money.api.model.showcase.ShowcaseContext)

Example 2 with ShowcaseContext

use of com.yandex.money.api.model.showcase.ShowcaseContext in project yandex-money-sdk-java by yandex-money.

the class ShowcaseProcessTest method testProceedFail.

/**
 * Tests that erroneous leads to
 * {@link ShowcaseContext.State#INVALID_PARAMS} state.
 */
// @Test see INC-21192
public void testProceedFail() throws Exception {
    Showcase showcase = loadFromResource();
    ShowcaseContext.Step currentStep = new ShowcaseContext.Step(showcase, BILLS_SECOND_STEP_URL);
    final ShowcaseContext showcaseContext = new ShowcaseContext(new Stack<ShowcaseContext.Step>(), DateTime.now(), currentStep, Collections.<String, String>emptyMap(), ShowcaseContext.State.UNKNOWN);
    final ShowcaseProcess showcaseProcess = new ShowcaseProcess(getClient(), showcaseContext);
    showcaseProcess.proceed();
    assertEquals(showcaseContext.getState(), ShowcaseContext.State.INVALID_PARAMS);
    assertEquals(showcaseContext.getHistorySize(), 0);
}
Also used : Showcase(com.yandex.money.api.model.showcase.Showcase) ShowcaseContext(com.yandex.money.api.model.showcase.ShowcaseContext)

Example 3 with ShowcaseContext

use of com.yandex.money.api.model.showcase.ShowcaseContext in project yandex-money-sdk-java by yandex-money.

the class ShowcaseProcessTest method initShowcaseProcess.

private static ShowcaseProcess initShowcaseProcess() throws Exception {
    final ApiRequest<ShowcaseContext> resReq = new Showcase.Request(5551);
    final ApiClient client = getClient();
    final ShowcaseContext showcaseContext = client.execute(resReq);
    return new ShowcaseProcess(client, showcaseContext);
}
Also used : ShowcaseContext(com.yandex.money.api.model.showcase.ShowcaseContext) ApiRequest(com.yandex.money.api.net.ApiRequest) ApiClient(com.yandex.money.api.net.clients.ApiClient)

Example 4 with ShowcaseContext

use of com.yandex.money.api.model.showcase.ShowcaseContext in project yandex-money-sdk-java by yandex-money.

the class ShowcaseProcessTest method testProceedSuccess.

/**
 * Tests that complex showcase successfully proceeds two steps asynchronously.
 *
 * @throws Exception if something goes wrong
 */
@Test
public void testProceedSuccess() throws Exception {
    final ShowcaseProcess showcaseProcess = initShowcaseProcess();
    final ShowcaseContext showcaseContext = showcaseProcess.showcaseContext;
    Showcase showcase = showcaseContext.getCurrentStep().showcase;
    final Text inn = (Text) showcase.form.items.get(0);
    inn.setValue(SAMPLE_INN);
    showcaseProcess.proceed();
    assertEquals(showcaseContext.getHistorySize(), 1);
    showcase = showcaseContext.getCurrentStep().showcase;
    ((Text) showcase.form.items.get(0)).setValue("Содружество Авангард");
    ((Select) showcase.form.items.get(1)).setValue("40702810055240000859");
    showcaseProcess.proceed();
    assertEquals(showcaseContext.getHistorySize(), 2);
    showcaseProcess.proceed();
    assertEquals(showcaseContext.getHistorySize(), 3);
}
Also used : Showcase(com.yandex.money.api.model.showcase.Showcase) ShowcaseContext(com.yandex.money.api.model.showcase.ShowcaseContext) Select(com.yandex.money.api.model.showcase.components.uicontrols.Select) Text(com.yandex.money.api.model.showcase.components.uicontrols.Text) Test(org.testng.annotations.Test)

Example 5 with ShowcaseContext

use of com.yandex.money.api.model.showcase.ShowcaseContext in project yandex-money-sdk-java by yandex-money.

the class ShowcaseProcessTest method testComplete.

/**
 * Tests that showcase process returns {@code true} in case of completed showcase context.
 */
@Test
public void testComplete() throws Exception {
    final ShowcaseContext completedShowcaseContext = new ShowcaseContext(new Stack<ShowcaseContext.Step>(), DateTime.now(), new ShowcaseContext.Step(getEmptyShowcase(), "http://foobar.foo"), Collections.<String, String>emptyMap(), ShowcaseContext.State.COMPLETED);
    final ShowcaseProcess showcaseProcess = new ShowcaseProcess(getClient(), completedShowcaseContext);
    assertTrue(showcaseProcess.proceed());
}
Also used : ShowcaseContext(com.yandex.money.api.model.showcase.ShowcaseContext) Test(org.testng.annotations.Test)

Aggregations

ShowcaseContext (com.yandex.money.api.model.showcase.ShowcaseContext)6 Showcase (com.yandex.money.api.model.showcase.Showcase)4 Text (com.yandex.money.api.model.showcase.components.uicontrols.Text)2 Test (org.testng.annotations.Test)2 Select (com.yandex.money.api.model.showcase.components.uicontrols.Select)1 ApiRequest (com.yandex.money.api.net.ApiRequest)1 ApiClient (com.yandex.money.api.net.clients.ApiClient)1