Search in sources :

Example 11 with Result

use of org.jpos.rc.Result in project jPOS by jpos.

the class SelectDestinationTest method testNetwork_V.

@Test
public void testNetwork_V() {
    cfg.put("ignore-luhn", "false");
    p.setConfiguration(cfg);
    Context ctx = new Context();
    ctx.put(ContextConstants.REQUEST.toString(), createISOMsg("4111111111111111"));
    int action = p.prepare(1L, ctx);
    assertEquals("Action should be PREPARED|NO_JOIN|READONLY", PREPARED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse("No failures", rc.hasFailures());
    assertEquals("Invalid Destination", "V", ctx.getString(DESTINATION.toString()));
}
Also used : Context(org.jpos.transaction.Context) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 12 with Result

use of org.jpos.rc.Result in project jPOS by jpos.

the class SelectDestinationTest method testNetwork7.

@Test
public void testNetwork7() {
    cfg.put("ignore-luhn", "true");
    p.setConfiguration(cfg);
    Context ctx = new Context();
    ctx.put(ContextConstants.REQUEST.toString(), createISOMsg("7111111111111111"));
    int action = p.prepare(1L, ctx);
    assertEquals("Action should be PREPARED|NO_JOIN|READONLY", PREPARED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse("No failures", rc.hasFailures());
    assertEquals("Invalid Destination", "N7", ctx.getString(DESTINATION.toString()));
}
Also used : Context(org.jpos.transaction.Context) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 13 with Result

use of org.jpos.rc.Result in project jPOS by jpos.

the class CheckFieldsTest method testAmounts.

@Test
public void testAmounts() throws ISOException {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    ISOAmount local = new ISOAmount(4, 858, new BigDecimal("290.00"));
    ISOAmount settlement = new ISOAmount(5, 840, new BigDecimal("10.00"));
    m.set(local);
    m.set(settlement);
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "AMOUNT");
    int action = cf.prepare(1L, ctx);
    assertEquals(PREPARED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse(rc.hasInfo());
    assertFalse(rc.hasWarnings());
    assertFalse(rc.hasFailures());
    assertEquals(local, ctx.get(ContextConstants.LOCAL_AMOUNT.toString()));
    assertEquals(settlement, ctx.get(ContextConstants.AMOUNT.toString()));
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) ISOAmount(org.jpos.iso.ISOAmount) BigDecimal(java.math.BigDecimal) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 14 with Result

use of org.jpos.rc.Result in project jPOS by jpos.

the class CheckFieldsTest method testInvalidMidAndTid.

@Test
public void testInvalidMidAndTid() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(41, "*1");
    m.set(42, "*2");
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "MID, TID");
    int action = cf.prepare(1L, ctx);
    assertEquals(ABORTED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertEquals(CMF.INVALID_FIELD, rc.failure().getIrc());
    assertFalse(rc.hasInfo());
    assertFalse(rc.hasWarnings());
    assertTrue(rc.hasFailures());
    assertEquals(2, rc.failureList().size());
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 15 with Result

use of org.jpos.rc.Result in project jPOS by jpos.

the class CheckFieldsTest method testOriginalDataElements.

@Test
public void testOriginalDataElements() throws ISOException {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    Date now = new Date();
    m.set(56, "0200000000000001" + ISODate.formatDate(now, "yyyyMMddHHmmss"));
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "ORIGINAL_DATA_ELEMENTS");
    int action = cf.prepare(1L, ctx);
    assertEquals(PREPARED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse(rc.hasInfo());
    assertFalse(rc.hasWarnings());
    assertFalse(rc.hasFailures());
    assertEquals("0200", ctx.get(ContextConstants.ORIGINAL_MTI.toString()));
    assertEquals("000000000001", ctx.get(ContextConstants.ORIGINAL_STAN.toString()));
    assertEquals(now.getTime() / 1000, ((Date) ctx.get(ContextConstants.ORIGINAL_TIMESTAMP.toString())).getTime() / 1000);
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Date(java.util.Date) ISODate(org.jpos.iso.ISODate) Result(org.jpos.rc.Result) Test(org.junit.Test)

Aggregations

Result (org.jpos.rc.Result)27 Context (org.jpos.transaction.Context)26 Test (org.junit.Test)24 ISOMsg (org.jpos.iso.ISOMsg)17 Date (java.util.Date)3 ISODate (org.jpos.iso.ISODate)3 BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1 ISOAmount (org.jpos.iso.ISOAmount)1 Chronometer (org.jpos.util.Chronometer)1