Search in sources :

Example 91 with ISOMsg

use of org.jpos.iso.ISOMsg in project jPOS by jpos.

the class CheckFieldsTest method testValidTimestamps.

@Test
public void testValidTimestamps() {
    Date now = new Date();
    Context ctx = new Context();
    ISOMsg m = new ISOMsg();
    m.set(7, ISODate.getDateTime(now));
    m.set(12, ISODate.getDateTime(now));
    ctx.put(ContextConstants.REQUEST.toString(), m);
    cfg.put("mandatory", "7 12");
    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) Date(java.util.Date) ISODate(org.jpos.iso.ISODate) Result(org.jpos.rc.Result) Test(org.junit.Test)

Example 92 with ISOMsg

use of org.jpos.iso.ISOMsg 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 93 with ISOMsg

use of org.jpos.iso.ISOMsg 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 94 with ISOMsg

use of org.jpos.iso.ISOMsg 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 95 with ISOMsg

use of org.jpos.iso.ISOMsg 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

ISOMsg (org.jpos.iso.ISOMsg)223 Test (org.junit.Test)191 LogEvent (org.jpos.util.LogEvent)41 ISOBaseValidator (org.jpos.iso.ISOBaseValidator)30 ISOException (org.jpos.iso.ISOException)29 ISOComponent (org.jpos.iso.ISOComponent)25 ISOVMsg (org.jpos.iso.ISOVMsg)22 ISOFieldValidator (org.jpos.iso.ISOFieldValidator)21 Context (org.jpos.transaction.Context)20 ISOValidator (org.jpos.iso.ISOValidator)18 Result (org.jpos.rc.Result)17 SimpleConfiguration (org.jpos.core.SimpleConfiguration)15 ISOFieldPackager (org.jpos.iso.ISOFieldPackager)12 TEST0100 (org.jpos.iso.validator.TEST0100)12 FileInputStream (java.io.FileInputStream)9 Vector (java.util.Vector)9 PostChannel (org.jpos.iso.channel.PostChannel)9 MSGTEST (org.jpos.iso.validator.MSGTEST)9 MSGTEST02 (org.jpos.iso.validator.MSGTEST02)9 ISOFilter (org.jpos.iso.ISOFilter)8