@Test public void testExtraFields () { Context ctx = new Context(); ISOMsg m = new ISOMsg(); m.set(3, "000000"); m.set(11, "000001"); m.set(41, "29110001"); m.set(42, "000000000000001"); ctx.put(ContextConstants.REQUEST.toString(), m); cfg.put("mandatory", "11"); cfg.put("optional", "3"); int action = cf.prepare(1L, ctx); assertEquals (ABORTED | NO_JOIN | READONLY, action, "Action should be ABORTED|NO_JOIN|READONLY"); Result rc = ctx.getResult(); assertEquals(CMF.EXTRA_FIELD, rc.failure().getIrc()); assertFalse(rc.hasInfo()); assertFalse(rc.hasWarnings()); assertTrue(rc.hasFailures()); assertEquals("41 42", rc.failure().getMessage()); }
public int prepare (long id, Serializable context) { Context ctx = (Context) context; Result rc = ctx.getResult(); try { ISOMsg m = 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); if (!allowExtraFields) 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; }
CheckFields implements TransactionParticipant, Configurable { public int prepare (long id, Serializable context) { Context ctx = (Context) context; Result rc = ctx.getResult(); try { ISOMsg m = 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); if (!allowExtraFields) 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; } }
CheckFields implements TransactionParticipant, Configurable { public int prepare (long id, Serializable context) { Context ctx = (Context) context; Result rc = ctx.getResult(); try { ISOMsg m = 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); if (!allowExtraFields) 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; }  }
CheckFields implements TransactionParticipant, Configurable { public int prepare (long id, Serializable context) { Context ctx = (Context) context; Result rc = ctx.getResult(); try { ISOMsg m = 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); if (!allowExtraFields) 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; }  int prepare(long id, Serializable context); void setConfiguration(Configuration cfg); }
CheckFields implements TransactionParticipant, Configurable { public int prepare (long id, Serializable context) { Context ctx = (Context) context; Result rc = ctx.getResult(); try { ISOMsg m = 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); if (!allowExtraFields) 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; }  int prepare(long id, Serializable context); void setConfiguration(Configuration cfg);  }