Search in sources :

Example 6 with Result

use of org.jpos.rc.Result in project jPOS by jpos.

the class CheckFieldsTest method testMandatoryPCodeNotPresent.

@Test
public void testMandatoryPCodeNotPresent() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "3");
    int action = cf.prepare(1L, ctx);
    assertEquals("Action should be ABORTED|NO_JOIN|READONLY", ABORTED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse("RC should have no info", rc.hasInfo());
    assertFalse("RC should have no warnings", rc.hasWarnings());
    assertTrue("RC should have failures", rc.hasFailures());
    assertEquals("IRC should be MISSING_FIELD", CMF.MISSING_FIELD, rc.failure().getIrc());
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 7 with Result

use of org.jpos.rc.Result in project jPOS by jpos.

the class CheckFieldsTest method testOptionalPCodeNotPresent.

@Test
public void testOptionalPCodeNotPresent() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    ctx.put(ContextConstants.REQUEST.toString(), m);
    int action = cf.prepare(1L, ctx);
    assertEquals("Action should be PREPARED|NO_JOIN|READONLY", PREPARED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse("RC should have no info", rc.hasInfo());
    assertFalse("RC should have no warnings", rc.hasWarnings());
    assertFalse("RC should have no failures", rc.hasFailures());
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 8 with Result

use of org.jpos.rc.Result in project jPOS by jpos.

the class CheckFieldsTest method testInvalidPCode.

@Test
public void testInvalidPCode() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(3, "*00000");
    m.set(11, "000001");
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("optional", "PCODE");
    int action = cf.prepare(1L, ctx);
    assertEquals("Action should be ABORTED|NO_JOIN|READONLY", 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());
    assertTrue(rc.failure().getMessage().startsWith("Invalid PCODE"));
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 9 with Result

use of org.jpos.rc.Result in project jPOS by jpos.

the class CheckFieldsTest method testGenericFieldsOptionalNotPresent.

@Test
public void testGenericFieldsOptionalNotPresent() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(48, "Mandatory field 48");
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "48");
    cfg.put("optional", "60");
    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());
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 10 with Result

use of org.jpos.rc.Result in project jPOS by jpos.

the class SelectDestinationTest method testNetwork6.

@Test
public void testNetwork6() {
    cfg.put("ignore-luhn", "true");
    p.setConfiguration(cfg);
    Context ctx = new Context();
    ctx.put(ContextConstants.REQUEST.toString(), createISOMsg("6111111111111111"));
    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", "N6", ctx.getString(DESTINATION.toString()));
}
Also used : Context(org.jpos.transaction.Context) Result(org.jpos.rc.Result) Test(org.junit.Test)

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