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);
}
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);
}
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);
}
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);
}
Aggregations