Search in sources :

Example 21 with Result

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

the class CheckFieldsTest method testGenericFieldsExtraPresent.

@Test
public void testGenericFieldsExtraPresent() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(48, "Mandatory field 48");
    m.set(60, "Extra field 60");
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "48");
    int action = cf.prepare(1L, ctx);
    // ctx.dump (System.out, "");
    assertEquals(ABORTED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse(rc.hasInfo());
    assertFalse(rc.hasWarnings());
    assertTrue(rc.hasFailures());
    assertEquals(CMF.EXTRA_FIELD, rc.failure().getIrc());
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 22 with Result

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

the class CheckFieldsTest method testInvalidCard.

@Test
public void testInvalidCard() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(2, "4111111111111111");
    m.set(14, "2912");
    m.set(35, "4111111111111112=2912");
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "CARD");
    int action = cf.prepare(1L, ctx);
    assertEquals(ABORTED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertEquals(CMF.INVALID_CARD_NUMBER, rc.failure().getIrc());
    assertFalse(rc.hasInfo());
    assertFalse(rc.hasWarnings());
    assertTrue(rc.hasFailures());
    assertEquals("track2 PAN mismatch", rc.failure().getMessage());
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 23 with Result

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

the class CheckFieldsTest method testPDC.

@Test
public void testPDC() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(22, new byte[16]);
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "POS_DATA_CODE");
    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());
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 24 with Result

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

the class SelectDestinationTest method testNetwork_M.

@Test
public void testNetwork_M() {
    cfg.put("ignore-luhn", "false");
    p.setConfiguration(cfg);
    Context ctx = new Context();
    ctx.put(ContextConstants.REQUEST.toString(), createISOMsg("5111111111111118"));
    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", "M", ctx.getString(DESTINATION.toString()));
}
Also used : Context(org.jpos.transaction.Context) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 25 with Result

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

the class SelectDestinationTest method testInvalidLUHN.

@Test
public void testInvalidLUHN() {
    cfg.put("ignore-luhn", "false");
    p.setConfiguration(cfg);
    Context ctx = new Context();
    ctx.put(ContextConstants.REQUEST.toString(), createISOMsg("5111111111111111"));
    int action = p.prepare(1L, ctx);
    assertEquals("Action should be ABORTED|NO_JOIN|READONLY", ABORTED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertTrue("Has failures", rc.hasFailures());
    assertTrue("Should raise invalid card error", rc.failure().getIrc() == CMF.INVALID_CARD_OR_CARDHOLDER_NUMBER);
}
Also used : Context(org.jpos.transaction.Context) 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