Search in sources :

Example 1 with IVA_ALPHANUMNOBLANK

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

the class GenericValidatingPackagerTest method testValidateThrowsNullPointerException3.

@Test
public void testValidateThrowsNullPointerException3() throws Throwable {
    GenericValidatingPackager genericValidatingPackager = new GenericValidatingPackager();
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[2];
    msgVlds[0] = new MSGTEST02();
    genericValidatingPackager.setMsgValidator(msgVlds);
    ISOFieldValidator[] fvlds = new ISOFieldValidator[2];
    fvlds[0] = new IVA_ALPHANUMNOBLANK(100, "testGenericValidatingPackagerDescription");
    genericValidatingPackager.setFieldValidator(fvlds);
    try {
        genericValidatingPackager.validate(new ISOMsg());
        fail("Expected NullPointerException to be thrown");
    } catch (NullPointerException ex) {
        assertNull("ex.getMessage()", ex.getMessage());
    }
}
Also used : IVA_ALPHANUMNOBLANK(org.jpos.iso.IVA_ALPHANUMNOBLANK) ISOMsg(org.jpos.iso.ISOMsg) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) MSGTEST02(org.jpos.iso.validator.MSGTEST02) Test(org.junit.Test)

Example 2 with IVA_ALPHANUMNOBLANK

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

the class GenericValidatingPackagerTest method testValidateThrowsISOException.

@Test
public void testValidateThrowsISOException() throws Throwable {
    GenericValidatingPackager genericValidatingPackager = new GenericValidatingPackager();
    ISOFieldValidator[] fvlds = new ISOFieldValidator[1];
    fvlds[0] = new IVA_ALPHANUMNOBLANK("testGenericValidatingPackagerDescription");
    genericValidatingPackager.setFieldValidator(fvlds);
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[3];
    msgVlds[0] = new TEST0100();
    genericValidatingPackager.setMsgValidator(msgVlds);
    try {
        genericValidatingPackager.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) 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 3 with IVA_ALPHANUMNOBLANK

use of org.jpos.iso.IVA_ALPHANUMNOBLANK 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 4 with IVA_ALPHANUMNOBLANK

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

the class ISOBaseValidatingPackagerTest method testValidate9.

@Test
public void testValidate9() throws Throwable {
    ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
    ISOValidator[] fvlds = new ISOValidator[2];
    fvlds[0] = new ISOFieldValidator(100, 1000, "testISOBaseValidatingPackagerDescription");
    fvlds[1] = new IVA_ALPHANUMNOBLANK(true, "testISOBaseValidatingPackagerDescription");
    iSOBaseValidatingPackager.setFieldValidator(fvlds);
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[2];
    msgVlds[0] = new ISOBaseValidator(true);
    iSOBaseValidatingPackager.setMsgValidator(msgVlds);
    ISOMsg result = (ISOMsg) iSOBaseValidatingPackager.validate(new ISOMsg(100));
    assertEquals("result.getDirection()", 0, result.getDirection());
}
Also used : IVA_ALPHANUMNOBLANK(org.jpos.iso.IVA_ALPHANUMNOBLANK) ISOMsg(org.jpos.iso.ISOMsg) ISOValidator(org.jpos.iso.ISOValidator) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) Test(org.junit.Test)

Example 5 with IVA_ALPHANUMNOBLANK

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

the class GenericValidatingPackagerTest method testGenericValidatorContentHandlerMakeFieldValidatorArray2.

@SuppressWarnings("unchecked")
@Test
public void testGenericValidatorContentHandlerMakeFieldValidatorArray2() throws Throwable {
    GenericValidatingPackager.GenericValidatorContentHandler genericValidatorContentHandler = new GenericValidatingPackager().new GenericValidatorContentHandler();
    Hashtable tab = new Hashtable(100);
    tab.put(Integer.valueOf(-2), new IVA_ALPHANUMNOBLANK("testGenericValidatorContentHandlerDescription"));
    tab.put(Integer.valueOf(-4), new IVA_ALPHANUMNOBLANK(100, 1000, "testGenericValidatorContentHandlerDescription"));
    ISOFieldValidator[] result = genericValidatorContentHandler.makeFieldValidatorArray(tab);
    assertEquals("result.length", 2, result.length);
}
Also used : IVA_ALPHANUMNOBLANK(org.jpos.iso.IVA_ALPHANUMNOBLANK) Hashtable(java.util.Hashtable) ISOFieldValidator(org.jpos.iso.ISOFieldValidator) Test(org.junit.Test)

Aggregations

ISOFieldValidator (org.jpos.iso.ISOFieldValidator)9 IVA_ALPHANUMNOBLANK (org.jpos.iso.IVA_ALPHANUMNOBLANK)9 Test (org.junit.Test)9 ISOBaseValidator (org.jpos.iso.ISOBaseValidator)7 ISOMsg (org.jpos.iso.ISOMsg)7 ISOException (org.jpos.iso.ISOException)4 MSGTEST (org.jpos.iso.validator.MSGTEST)3 TEST0100 (org.jpos.iso.validator.TEST0100)3 Hashtable (java.util.Hashtable)2 ISOValidator (org.jpos.iso.ISOValidator)2 Properties (java.util.Properties)1 ISOVMsg (org.jpos.iso.ISOVMsg)1 ISOVException (org.jpos.iso.validator.ISOVException)1 MSGTEST02 (org.jpos.iso.validator.MSGTEST02)1