예제 #1
0
 public void testUnpack() throws Exception {
   byte[] raw = new byte[] {68, 48, 48, 49, 50, 51};
   IFE_AMOUNT packager = new IFE_AMOUNT(6, "Should be C4F0F0F1F2F3");
   ISOField field = new ISOField();
   packager.unpack(field, ISOUtil.hex2byte("C4F0F0F1F2F3"), 0);
   assertEquals("D00123", (String) field.getValue());
 }
예제 #2
0
 public void testUnpack() throws Exception {
   byte[] raw = new byte[] {0x00, 0x04, 0x12, 0x34};
   IFB_LLLNUM packager = new IFB_LLLNUM(10, "Should be 00041234", true);
   ISOField field = new ISOField(12);
   packager.unpack(field, raw, 0);
   assertEquals("1234", (String) field.getValue());
 }
예제 #3
0
  public void testReversability() throws Exception {
    String origin = "D0000123";
    ISOField f = new ISOField(12, origin);
    IFE_AMOUNT packager = new IFE_AMOUNT(8, "Should be C4F0F0F1F2F3");

    ISOField unpack = new ISOField();
    packager.unpack(unpack, packager.pack(f), 0);
    assertEquals(origin, (String) unpack.getValue());
  }
예제 #4
0
  public void testReversability() throws Exception {
    String origin = "1234567890";
    ISOField f = new ISOField(12, origin);
    IFB_LLLNUM packager = new IFB_LLLNUM(10, "Should be 1234567890", true);

    ISOField unpack = new ISOField(12);
    packager.unpack(unpack, packager.pack(f), 0);
    assertEquals(origin, (String) unpack.getValue());
  }
예제 #5
0
 public void testUnpack() throws Exception {
   byte[] raw =
       new byte[] {
         (byte) 0xF0,
         (byte) 0xF0,
         (byte) 0xF0,
         (byte) 0xF0,
         (byte) 0xF0,
         (byte) 0xF0,
         (byte) 0xF1,
         (byte) 0xF2,
         (byte) 0xF3,
         (byte) 0xF4
       };
   IFE_NUMERIC packager = new IFE_NUMERIC(10, "Should be 0000001234");
   ISOField field = new ISOField(12);
   packager.unpack(field, raw, 0);
   assertEquals("0000001234", (String) field.getValue());
 }
예제 #6
0
 /** Validate that the component is not blank-filled. */
 public ISOComponent validate(ISOComponent f) throws ISOException {
   ISOField c = (ISOField) f;
   try {
     /** no zero... * */
     c = (ISOField) super.validate(c);
     /** no blank * */
     if (ISOUtil.isBlank((String) c.getValue())) {
       ISOVError e =
           new ISOVError(
               "Invalid Value Error. It can not be blank-filled. (Current value: "
                   + c.getValue()
                   + ") ",
               getRejCode(ISOVError.ERR_INVALID_VALUE));
       if (c instanceof ISOVField) ((ISOVField) c).addISOVError(e);
       else c = new ISOVField(c, e);
       if (breakOnError) throw new ISOVException("Error on field " + c.getKey(), c);
     }
     return c;
   } catch (Exception ex) {
     if (ex instanceof ISOVException) throw (ISOVException) ex;
     return c;
   }
 }