Search in sources :

Example 1 with MSGTEST

use of org.jpos.iso.validator.MSGTEST in project jPOS by jpos.

the class GenericValidatingPackagerTest method testValidate6.

@Test
public void testValidate6() throws Throwable {
    ISOBaseValidator mSGTEST = new MSGTEST(false);
    GenericValidatingPackager genericValidatingPackager = new GenericValidatingPackager();
    ISOBaseValidator mSGTEST2 = new MSGTEST(false);
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[3];
    msgVlds[0] = mSGTEST2;
    msgVlds[1] = mSGTEST;
    msgVlds[2] = mSGTEST2;
    genericValidatingPackager.setMsgValidator(msgVlds);
    ISOFieldValidator[] fvlds = new ISOFieldValidator[1];
    fvlds[0] = new IVA_ALPHANUM("testGenericValidatingPackagerDescription");
    genericValidatingPackager.setFieldValidator(fvlds);
    ISOVMsg result = (ISOVMsg) genericValidatingPackager.validate(new ISOMsg(100));
    assertNotNull("result", result);
}
Also used : MSGTEST(org.jpos.iso.validator.MSGTEST) ISOMsg(org.jpos.iso.ISOMsg) IVA_ALPHANUM(org.jpos.iso.IVA_ALPHANUM) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) ISOVMsg(org.jpos.iso.ISOVMsg) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) Test(org.junit.Test)

Example 2 with MSGTEST

use of org.jpos.iso.validator.MSGTEST in project jPOS by jpos.

the class GenericValidatingPackagerTest method testValidate1.

@Test
public void testValidate1() throws Throwable {
    GenericValidatingPackager genericValidatingPackager = new GenericValidatingPackager();
    ISOFieldValidator[] fvlds = new ISOFieldValidator[2];
    fvlds[0] = new ISOFieldValidator();
    fvlds[1] = new IVA_ALPHANUMNOZERO_NOBLANK();
    genericValidatingPackager.setFieldValidator(fvlds);
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[2];
    msgVlds[0] = new MSGTEST();
    msgVlds[1] = new ISOBaseValidator();
    genericValidatingPackager.setMsgValidator(msgVlds);
    ISOMsg m = new ISOMsg("testGenericValidatingPackagerMti");
    m.setMTI("testGenericValidatingPackagerMti");
    ISOVMsg result = (ISOVMsg) genericValidatingPackager.validate(m);
    assertNotNull("result", result);
}
Also used : MSGTEST(org.jpos.iso.validator.MSGTEST) ISOMsg(org.jpos.iso.ISOMsg) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) ISOVMsg(org.jpos.iso.ISOVMsg) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) IVA_ALPHANUMNOZERO_NOBLANK(org.jpos.iso.IVA_ALPHANUMNOZERO_NOBLANK) Test(org.junit.Test)

Example 3 with MSGTEST

use of org.jpos.iso.validator.MSGTEST in project jPOS by jpos.

the class ISOBaseValidatingPackagerTest method testValidateThrowsNullPointerException2.

@Test
public void testValidateThrowsNullPointerException2() throws Throwable {
    ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[3];
    msgVlds[0] = new TEST0100();
    msgVlds[1] = new MSGTEST();
    msgVlds[2] = new MSGTEST02();
    ISOValidator[] fvlds = new ISOValidator[0];
    iSOBaseValidatingPackager.setFieldValidator(fvlds);
    iSOBaseValidatingPackager.setMsgValidator(msgVlds);
    ISOMsg m = new ISOMsg();
    m.setMTI("testISOBaseValidatingPackagerMti");
    m.setRetransmissionMTI();
    try {
        iSOBaseValidatingPackager.validate(m);
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : MSGTEST(org.jpos.iso.validator.MSGTEST) ISOMsg(org.jpos.iso.ISOMsg) ISOValidator(org.jpos.iso.ISOValidator) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) TEST0100(org.jpos.iso.validator.TEST0100) MSGTEST02(org.jpos.iso.validator.MSGTEST02) Test(org.junit.Test)

Example 4 with MSGTEST

use of org.jpos.iso.validator.MSGTEST in project jPOS by jpos.

the class ISOBaseValidatingPackagerTest method testValidateThrowsISOException2.

@Test
public void testValidateThrowsISOException2() throws Throwable {
    ISOFieldValidator iVA_ALPHANUMNOBLANK = new IVA_ALPHANUMNOBLANK(true, "testISOBaseValidatingPackagerDescription");
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[3];
    msgVlds[0] = new MSGTEST(false);
    msgVlds[1] = new MSGTEST();
    msgVlds[2] = new TEST0100(true);
    ISOFieldValidator[] fvlds = new ISOFieldValidator[3];
    fvlds[0] = iVA_ALPHANUMNOBLANK;
    ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
    iSOBaseValidatingPackager.setFieldValidator(fvlds);
    iSOBaseValidatingPackager.setMsgValidator(msgVlds);
    try {
        iSOBaseValidatingPackager.validate(new ISOMsg());
        fail("Expected ISOException to be thrown");
    } catch (ISOException ex) {
        assertEquals("ex.getMessage()", "MTI not available", ex.getMessage());
        assertNull("ex.getNested()", ex.getNested());
    }
}
Also used : IVA_ALPHANUMNOBLANK(org.jpos.iso.IVA_ALPHANUMNOBLANK) MSGTEST(org.jpos.iso.validator.MSGTEST) ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) TEST0100(org.jpos.iso.validator.TEST0100) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) Test(org.junit.Test)

Example 5 with MSGTEST

use of org.jpos.iso.validator.MSGTEST in project jPOS by jpos.

the class GenericValidatingPackagerTest method testValidateThrowsISOVException.

@Test
public void testValidateThrowsISOVException() throws Throwable {
    GenericValidatingPackager genericValidatingPackager = new GenericValidatingPackager();
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[3];
    msgVlds[0] = new MSGTEST(false);
    msgVlds[1] = new MSGTEST(true);
    genericValidatingPackager.setMsgValidator(msgVlds);
    ISOFieldValidator[] fvlds = new ISOFieldValidator[1];
    fvlds[0] = new IVA_ALPHANUM("testGenericValidatingPackagerDescription");
    genericValidatingPackager.setFieldValidator(fvlds);
    try {
        genericValidatingPackager.validate(new ISOMsg(100));
        fail("Expected ISOVException to be thrown");
    } catch (ISOVException ex) {
        assertEquals("ex.getMessage()", "Error on msg. ", ex.getMessage());
        assertFalse("ex.treated()", ex.treated());
        assertNotNull("ex.getErrComponent()", ex.getErrComponent());
        assertNull("ex.getNested()", ex.getNested());
    }
}
Also used : MSGTEST(org.jpos.iso.validator.MSGTEST) ISOMsg(org.jpos.iso.ISOMsg) IVA_ALPHANUM(org.jpos.iso.IVA_ALPHANUM) ISOVException(org.jpos.iso.validator.ISOVException) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) Test(org.junit.Test)

Aggregations

ISOBaseValidator (org.jpos.iso.ISOBaseValidator)9 ISOMsg (org.jpos.iso.ISOMsg)9 MSGTEST (org.jpos.iso.validator.MSGTEST)9 Test (org.junit.Test)9 ISOFieldValidator (org.jpos.iso.ISOFieldValidator)8 ISOVMsg (org.jpos.iso.ISOVMsg)4 ISOValidator (org.jpos.iso.ISOValidator)4 TEST0100 (org.jpos.iso.validator.TEST0100)4 ISOException (org.jpos.iso.ISOException)3 IVA_ALPHANUMNOBLANK (org.jpos.iso.IVA_ALPHANUMNOBLANK)3 IVA_ALPHANUM (org.jpos.iso.IVA_ALPHANUM)2 ISOVException (org.jpos.iso.validator.ISOVException)2 IVA_ALPHANUMNOZERO_NOBLANK (org.jpos.iso.IVA_ALPHANUMNOZERO_NOBLANK)1 MSGTEST02 (org.jpos.iso.validator.MSGTEST02)1