Search in sources :

Example 6 with Showcase

use of com.yandex.money.api.model.showcase.Showcase 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 7 with Showcase

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

the class ShowcaseProcessTest method testRepeat.

/**
 * Tests that recovery from erroneous input works as expected.
 */
// @Test see INC-21192
public void testRepeat() throws Exception {
    Showcase showcase = loadFromResource();
    final 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);
    Text inn = (Text) showcase.form.items.get(0);
    inn.setValue("erroneous input");
    showcaseProcess.proceed();
    assertEquals(showcaseContext.getHistorySize(), 0);
    // repeat proceed with allowed inn
    showcase = showcaseContext.getCurrentStep().showcase;
    inn = (Text) showcase.form.items.get(0);
    inn.setValue(SAMPLE_INN);
    showcaseProcess.proceed();
    assertEquals(showcaseContext.getHistorySize(), 1);
}
Also used : Showcase(com.yandex.money.api.model.showcase.Showcase) ShowcaseContext(com.yandex.money.api.model.showcase.ShowcaseContext) Text(com.yandex.money.api.model.showcase.components.uicontrols.Text)

Example 8 with Showcase

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

the class ShowcaseParserTest method testResourceShowcase.

@Test
public void testResourceShowcase() {
    InputStream inputStream = ShowcaseParserTest.class.getResourceAsStream("/showcase.json");
    if (inputStream == null) {
        return;
    }
    Showcase showcase = ShowcaseTypeAdapter.getInstance().fromJson(inputStream);
    checkShowcase(showcase);
}
Also used : Showcase(com.yandex.money.api.model.showcase.Showcase) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Test(org.testng.annotations.Test)

Example 9 with Showcase

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

the class ShowcaseParserTest method testShowcaseWithUndefinedType.

@Test
public void testShowcaseWithUndefinedType() {
    InputStream inputStream = ShowcaseParserTest.class.getResourceAsStream("/showcase/showcase_with_undefined_types.json");
    if (inputStream == null) {
        return;
    }
    Showcase showcase = ShowcaseTypeAdapter.getInstance().fromJson(inputStream);
    assertEquals(showcase.form.items.size(), 1);
    Component component = showcase.form.items.get(0);
    assertTrue(component instanceof Group);
    Group group = (Group) component;
    assertEquals(group.items.size(), 0);
}
Also used : Group(com.yandex.money.api.model.showcase.components.containers.Group) Showcase(com.yandex.money.api.model.showcase.Showcase) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) Component(com.yandex.money.api.model.showcase.components.Component) Test(org.testng.annotations.Test)

Aggregations

Showcase (com.yandex.money.api.model.showcase.Showcase)9 ShowcaseContext (com.yandex.money.api.model.showcase.ShowcaseContext)4 Test (org.testng.annotations.Test)4 Group (com.yandex.money.api.model.showcase.components.containers.Group)2 Text (com.yandex.money.api.model.showcase.components.uicontrols.Text)2 ByteArrayInputStream (java.io.ByteArrayInputStream)2 InputStream (java.io.InputStream)2 AllowedMoneySource (com.yandex.money.api.model.AllowedMoneySource)1 Component (com.yandex.money.api.model.showcase.components.Component)1 Select (com.yandex.money.api.model.showcase.components.uicontrols.Select)1 ShowcaseTypeAdapter (com.yandex.money.api.typeadapters.model.showcase.ShowcaseTypeAdapter)1 FileNotFoundException (java.io.FileNotFoundException)1 Map (java.util.Map)1