Search in sources :

Example 1 with Showcase

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

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

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

the class ShowcaseProcessTest method getEmptyShowcase.

private static Showcase getEmptyShowcase() {
    Group.Builder builder = new Group.Builder();
    Group group = builder.create();
    return new Showcase.Builder().setTitle("foo").setErrors(Collections.<Showcase.Error>emptyList()).setForm(group).setHiddenFields(Collections.<String, String>emptyMap()).setMoneySources(Collections.<AllowedMoneySource>emptyList()).create();
}
Also used : Group(com.yandex.money.api.model.showcase.components.containers.Group) Showcase(com.yandex.money.api.model.showcase.Showcase) AllowedMoneySource(com.yandex.money.api.model.AllowedMoneySource)

Example 4 with Showcase

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

the class ShowcaseTypeAdapterTest method testShowcase.

private static void testShowcase(String fileName) {
    ShowcaseTypeAdapter adapter = ShowcaseTypeAdapter.getInstance();
    check(fileName, adapter);
    try {
        Showcase showcase = adapter.fromJson(Resources.load(getPath(fileName)));
        Object allowedMoneySource = showcase.moneySources.get(0);
        assertEquals(allowedMoneySource.getClass(), AllowedMoneySource.class);
    } catch (FileNotFoundException e) {
        fail();
    }
}
Also used : ShowcaseTypeAdapter(com.yandex.money.api.typeadapters.model.showcase.ShowcaseTypeAdapter) Showcase(com.yandex.money.api.model.showcase.Showcase) FileNotFoundException(java.io.FileNotFoundException)

Example 5 with Showcase

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

the class ShowcaseTest method testShowcaseParameters.

@Test
public void testShowcaseParameters() throws FileNotFoundException {
    Showcase showcase = ShowcaseTypeAdapter.getInstance().fromJson(Resources.load("/model/showcase.json"));
    assertNotNull(showcase);
    Map<String, String> parameters = showcase.getPaymentParameters();
    assertNotNull(parameters);
    assertFalse(parameters.isEmpty());
    assertNotNull(showcase.hiddenFields);
    assertFalse(showcase.hiddenFields.isEmpty());
    for (Map.Entry<String, String> field : showcase.hiddenFields.entrySet()) {
        String key = field.getKey();
        String value = parameters.get(key);
        assertNotNull(value);
        assertTrue(value.equals(field.getValue()));
    }
}
Also used : Showcase(com.yandex.money.api.model.showcase.Showcase) Map(java.util.Map) 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