Search in sources :

Example 26 with Result

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()));
}
Also used : Context(org.jpos.transaction.Context) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 27 with Result

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;
}
Also used : Context(org.jpos.transaction.Context) Result(org.jpos.rc.Result) HashSet(java.util.HashSet)

Aggregations

Result (org.jpos.rc.Result)27 Context (org.jpos.transaction.Context)26 Test (org.junit.Test)24 ISOMsg (org.jpos.iso.ISOMsg)17 Date (java.util.Date)3 ISODate (org.jpos.iso.ISODate)3 BigDecimal (java.math.BigDecimal)1 HashSet (java.util.HashSet)1 ISOAmount (org.jpos.iso.ISOAmount)1 Chronometer (org.jpos.util.Chronometer)1