Search in sources :

Example 26 with Context

use of org.jpos.transaction.Context 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 27 with Context

use of org.jpos.transaction.Context 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 28 with Context

use of org.jpos.transaction.Context 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 29 with Context

use of org.jpos.transaction.Context 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 30 with Context

use of org.jpos.transaction.Context 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

Context (org.jpos.transaction.Context)45 Test (org.junit.Test)29 Result (org.jpos.rc.Result)26 ISOMsg (org.jpos.iso.ISOMsg)20 Date (java.util.Date)5 ISODate (org.jpos.iso.ISODate)3 SpaceSource (org.jpos.space.SpaceSource)2 BigDecimal (java.math.BigDecimal)1 HashMap (java.util.HashMap)1 HashSet (java.util.HashSet)1 Map (java.util.Map)1 Element (org.jdom2.Element)1 Configurable (org.jpos.core.Configurable)1 Configuration (org.jpos.core.Configuration)1 ConfigurationException (org.jpos.core.ConfigurationException)1 ISOAmount (org.jpos.iso.ISOAmount)1 ISOSource (org.jpos.iso.ISOSource)1 LocalSpace (org.jpos.space.LocalSpace)1 Space (org.jpos.space.Space)1 SpaceFactory (org.jpos.space.SpaceFactory)1