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