use of org.jpos.transaction.Context 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.transaction.Context 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);
}
use of org.jpos.transaction.Context in project jPOS by jpos.
the class SelectDestinationTest method testNetwork_Default.
@Test
public void testNetwork_Default() {
cfg.put("ignore-luhn", "true");
p.setConfiguration(cfg);
Context ctx = new Context();
ctx.put(ContextConstants.REQUEST.toString(), createISOMsg("0000000000000001"));
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", "DEFAULT", ctx.getString(DESTINATION.toString()));
}
use of org.jpos.transaction.Context in project jPOS by jpos.
the class CheckFields method prepare.
public int prepare(long id, Serializable context) {
Context ctx = (Context) context;
Result rc = ctx.getResult();
try {
ISOMsg m = (ISOMsg) ctx.get(request);
if (m == null) {
ctx.getResult().fail(CMF.INVALID_TRANSACTION, Caller.info(), "'%s' not available in Context", request);
return ABORTED | NO_JOIN | READONLY;
}
Set<String> validFields = new HashSet<>();
assertFields(ctx, m, cfg.get("mandatory", ""), true, validFields, rc);
assertFields(ctx, m, cfg.get("optional", ""), false, validFields, rc);
assertNoExtraFields(m, validFields, rc);
} catch (Throwable t) {
rc.fail(CMF.SYSTEM_ERROR, Caller.info(), t.getMessage());
ctx.log(t);
}
return (rc.hasFailures() ? ABORTED : PREPARED) | NO_JOIN | READONLY;
}
use of org.jpos.transaction.Context in project jPOS by jpos.
the class QueryHost method responseReceived.
public void responseReceived(ISOMsg resp, Object handBack) {
Context ctx = (Context) handBack;
ctx.put(responseName, resp);
ctx.resume();
}
Aggregations