Search in sources :

Example 16 with Result

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

the class CheckFieldsTest method testInvalidTimestamp.

@Test
public void testInvalidTimestamp() {
    Date now = new Date();
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(7, ISODate.getDateTime(now));
    m.set(12, "*");
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "TRANSMISSION_TIMESTAMP TRANSACTION_TIMESTAMP");
    int action = cf.prepare(1L, ctx);
    // ctx.dump (System.out, "");
    assertEquals(ABORTED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertFalse(rc.hasInfo());
    assertFalse(rc.hasWarnings());
    assertTrue(rc.hasFailures());
    assertEquals(1, rc.failureList().size());
    assertEquals(CMF.INVALID_FIELD, rc.failure().getIrc());
    assertEquals("Invalid TRANSACTION_TIMESTAMP '*'", rc.failure().getMessage());
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) Date(java.util.Date) ISODate(org.jpos.iso.ISODate) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 17 with Result

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

the class CheckFieldsTest method testNoExtraFields.

@Test
public void testNoExtraFields() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(3, "000000");
    m.set(11, "000001");
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "11");
    cfg.put("optional", "3");
    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 18 with Result

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

the class CheckFieldsTest method testGenericFields.

@Test
public void testGenericFields() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(48, "Mandatory field 48");
    m.set(60, "Optional field");
    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 19 with Result

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

the class CheckFieldsTest method testCaptureDate.

@Test
public void testCaptureDate() {
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(17, "0101");
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "CAPTURE_DATE");
    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 20 with Result

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

the class CheckFieldsTest method testExtraFields.

@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("Action should be ABORTED|NO_JOIN|READONLY", ABORTED | NO_JOIN | READONLY, action);
    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());
}
Also used : Context(org.jpos.transaction.Context) ISOMsg(org.jpos.iso.ISOMsg) 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