use of org.jpos.rc.Result 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.rc.Result 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;
}
Aggregations