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