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());
}
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());
}
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());
}
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());
}
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());
}
Aggregations