Search in sources :

Example 11 with Context

use of org.jpos.transaction.Context in project jPOS by jpos.

the class CheckFieldsTest method testInvalidTransaction.

@Test
public void testInvalidTransaction() {
    Context ctx = new Context();
    int action = cf.prepare(1L, ctx);
    assertEquals("Action should be ABORTED|NO_JOIN|READONLY", ABORTED | NO_JOIN | READONLY, action);
    Result rc = ctx.getResult();
    assertTrue("RC should have failures", rc.hasFailures());
    assertEquals("IRC should be INVALID_TRANSACTION", CMF.INVALID_TRANSACTION, rc.failure().getIrc());
}
Also used : Context(org.jpos.transaction.Context) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 12 with Context

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

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

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

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

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