Search in sources :

Example 1 with IVA_ALPHANUMNOZERO_NOBLANK

use of org.jpos.iso.IVA_ALPHANUMNOZERO_NOBLANK 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 2 with IVA_ALPHANUMNOZERO_NOBLANK

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

the class ISOBaseValidatingPackagerTest method testValidateThrowsISOException5.

@Test
public void testValidateThrowsISOException5() throws Throwable {
    ISOValidator[] fvlds = new ISOValidator[1];
    fvlds[0] = new IVA_ALPHANUMNOZERO_NOBLANK();
    ISOBaseValidatingPackager iSOBaseValidatingPackager = new ISOBaseValidatingPackager();
    iSOBaseValidatingPackager.setFieldValidator(fvlds);
    ISOBaseValidator[] msgVlds = new ISOBaseValidator[2];
    msgVlds[1] = new TEST0100();
    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 : ISOException(org.jpos.iso.ISOException) ISOMsg(org.jpos.iso.ISOMsg) ISOValidator(org.jpos.iso.ISOValidator) ISOBaseValidator(org.jpos.iso.ISOBaseValidator) TEST0100(org.jpos.iso.validator.TEST0100) IVA_ALPHANUMNOZERO_NOBLANK(org.jpos.iso.IVA_ALPHANUMNOZERO_NOBLANK) Test(org.junit.Test)

Example 3 with IVA_ALPHANUMNOZERO_NOBLANK

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

the class GenericValidatingPackagerTest method testGenericValidatorContentHandlerMakeFieldValidatorArrayThrowsClassCastException1.

@SuppressWarnings("unchecked")
@Test
public void testGenericValidatorContentHandlerMakeFieldValidatorArrayThrowsClassCastException1() throws Throwable {
    GenericValidatingPackager.GenericValidatorContentHandler genericValidatorContentHandler = new GenericValidatingPackager().new GenericValidatorContentHandler();
    Map hashMap = new HashMap();
    hashMap.put("", "testString");
    Hashtable tab = new Hashtable(hashMap);
    tab.put(Integer.valueOf(100), new IVA_ALPHANUMNOZERO_NOBLANK(true, "testGenericValidatorContentHandlerDescription"));
    try {
        genericValidatorContentHandler.makeFieldValidatorArray(tab);
        fail("Expected ClassCastException to be thrown");
    } catch (ClassCastException ex) {
        assertEquals("ex.getClass()", ClassCastException.class, ex.getClass());
        assertEquals("tab.size()", 2, tab.size());
    }
}
Also used : HashMap(java.util.HashMap) Hashtable(java.util.Hashtable) HashMap(java.util.HashMap) Map(java.util.Map) IVA_ALPHANUMNOZERO_NOBLANK(org.jpos.iso.IVA_ALPHANUMNOZERO_NOBLANK) Test(org.junit.Test)

Aggregations

IVA_ALPHANUMNOZERO_NOBLANK (org.jpos.iso.IVA_ALPHANUMNOZERO_NOBLANK)3 Test (org.junit.Test)3 ISOBaseValidator (org.jpos.iso.ISOBaseValidator)2 ISOMsg (org.jpos.iso.ISOMsg)2 HashMap (java.util.HashMap)1 Hashtable (java.util.Hashtable)1 Map (java.util.Map)1 ISOException (org.jpos.iso.ISOException)1 ISOFieldValidator (org.jpos.iso.ISOFieldValidator)1 ISOVMsg (org.jpos.iso.ISOVMsg)1 ISOValidator (org.jpos.iso.ISOValidator)1 MSGTEST (org.jpos.iso.validator.MSGTEST)1 TEST0100 (org.jpos.iso.validator.TEST0100)1