Esempio n. 1
0
  @Test
  public void testIdentityFileDoBYearOnlyWithSpaces() throws Exception {
    // setup
    final byte[] idFile =
        new byte[] {12, 12, ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', '1', '9', '6', '2'};

    // operate
    final Identity identity = TlvParser.parse(idFile, Identity.class);

    // verify
    assertNotNull(identity.getDateOfBirth());
    LOG.debug("date of birth: " + identity.getDateOfBirth().getTime());
    assertEquals(1962, identity.getDateOfBirth().get(Calendar.YEAR));
    assertEquals(0, identity.getDateOfBirth().get(Calendar.MONTH));
    assertEquals(1, identity.getDateOfBirth().get(Calendar.DAY_OF_MONTH));
  }
Esempio n. 2
0
  @Test
  public void testExtendedMinority() throws Exception {
    // setup
    final byte[] idFile =
        IOUtils.toByteArray(TlvParserTest.class.getResourceAsStream("/extended-minority.tlv"));

    // operate
    final Identity identity = TlvParser.parse(idFile, Identity.class);

    // verify
    LOG.debug("special status: " + identity.specialStatus);
    assertEquals(SpecialStatus.EXTENDED_MINORITY, identity.specialStatus);
    assertFalse(identity.specialStatus.hasBadSight());
    assertTrue(identity.specialStatus.hasExtendedMinority());
    LOG.debug("special organisation: \"" + identity.getSpecialOrganisation() + "\"");
    assertNull(identity.getSpecialOrganisation());
  }
Esempio n. 3
0
  @Test
  public void parseIdentityFile() throws Exception {
    // setup
    final InputStream idInputStream = TlvParserTest.class.getResourceAsStream("/id-alice.tlv");
    final byte[] idFile = IOUtils.toByteArray(idInputStream);

    // operate
    final Identity identity = TlvParser.parse(idFile, Identity.class);

    // verify
    assertNotNull(identity);
    LOG.debug("name: " + identity.name);
    assertEquals("SPECIMEN", identity.name);
    LOG.debug("first name: " + identity.firstName);
    assertEquals("Alice Geldigekaart2266", identity.firstName);
    LOG.debug("card number: " + identity.cardNumber);
    assertEquals("000000226635", identity.cardNumber);
    LOG.debug("card validity date begin: " + identity.cardValidityDateBegin.getTime());
    assertEquals(new GregorianCalendar(2005, 7, 8), identity.cardValidityDateBegin);
    LOG.debug("card validity date end: " + identity.cardValidityDateEnd.getTime());
    assertEquals(new GregorianCalendar(2010, 7, 8), identity.cardValidityDateEnd);
    LOG.debug("Card Delivery Municipality: " + identity.cardDeliveryMunicipality);
    assertEquals("Certipost Specimen", identity.cardDeliveryMunicipality);
    LOG.debug("national number: " + identity.nationalNumber);
    assertEquals("71715100070", identity.nationalNumber);
    LOG.debug("middle name: " + identity.middleName);
    assertEquals("A", identity.middleName);
    LOG.debug("nationality: " + identity.nationality);
    assertEquals("Belg", identity.nationality);
    LOG.debug("place of birth: " + identity.placeOfBirth);
    assertEquals("Hamont-Achel", identity.placeOfBirth);
    LOG.debug("gender: " + identity.gender);
    assertEquals(Gender.FEMALE, identity.gender);
    assertNotNull(identity.dateOfBirth);
    LOG.debug("date of birth: " + identity.dateOfBirth.getTime());
    assertEquals(new GregorianCalendar(1971, 0, 1), identity.dateOfBirth);
    LOG.debug("special status: " + identity.specialStatus);
    assertEquals(SpecialStatus.NO_STATUS, identity.specialStatus);
    assertNull(identity.getSpecialOrganisation());

    assertNotNull(identity.getData());
  }
Esempio n. 4
0
  @Test
  public void testDuplicate02() throws Exception {
    // setup
    final InputStream inputStream = TlvParserTest.class.getResourceAsStream("/duplicate-02.tlv");
    final byte[] identityData = IOUtils.toByteArray(inputStream);

    // operate
    final Identity identity = TlvParser.parse(identityData, Identity.class);

    // verify
    LOG.debug("document type: " + identity.getDocumentType());
    assertEquals(DocumentType.FOREIGNER_A, identity.getDocumentType());
    LOG.debug("duplicate: " + identity.getDuplicate());
    assertEquals("02", identity.getDuplicate());
    LOG.debug("member of family: " + identity.isMemberOfFamily());
    assertTrue(identity.isMemberOfFamily());
    LOG.debug("special organisation: \"" + identity.getSpecialOrganisation() + "\"");
    assertEquals(SpecialOrganisation.RESEARCHER, identity.getSpecialOrganisation());
  }
Esempio n. 5
0
  @Test
  public void testForeignerIdentityFile() throws Exception {
    // setup
    final InputStream inputStream = TlvParserTest.class.getResourceAsStream("/id-foreigner.tlv");
    final byte[] identityData = IOUtils.toByteArray(inputStream);

    // operate
    final Identity identity = TlvParser.parse(identityData, Identity.class);

    // verify
    LOG.debug("name: " + identity.getName());
    LOG.debug("first name: " + identity.getFirstName());
    LOG.debug("document type: " + identity.getDocumentType());
    assertEquals(DocumentType.FOREIGNER_E_PLUS, identity.getDocumentType());
    assertNotNull(identity.getDuplicate());
    LOG.debug("duplicate: " + identity.getDuplicate());
    LOG.debug("special organisation: \"" + identity.getSpecialOrganisation() + "\"");
    assertEquals(SpecialOrganisation.UNSPECIFIED, identity.getSpecialOrganisation());
  }
Esempio n. 6
0
  @Test
  public void testHCard() throws Exception {
    // setup
    final InputStream inputStream = TlvParserTest.class.getResourceAsStream("/h-card.tlv");
    final byte[] identityData = IOUtils.toByteArray(inputStream);

    // operate
    final Identity identity = TlvParser.parse(identityData, Identity.class);

    // verify
    LOG.debug("document type: " + identity.getDocumentType());
    assertEquals(DocumentType.EUROPEAN_BLUE_CARD_H, identity.getDocumentType());
    LOG.debug("duplicate: " + identity.getDuplicate());
    assertEquals("01", identity.getDuplicate());
    assertTrue(identity.isMemberOfFamily());
    LOG.debug("special organisation: \"" + identity.getSpecialOrganisation() + "\"");
    assertEquals(SpecialOrganisation.UNSPECIFIED, identity.getSpecialOrganisation());
  }
Esempio n. 7
0
  @Test
  public void testParseNewIdentityFile() throws Exception {
    // setup
    final InputStream inputStream = TlvParserTest.class.getResourceAsStream("/new-eid.txt");
    final byte[] base64IdentityData = IOUtils.toByteArray(inputStream);
    final byte[] identityData = Base64.decodeBase64(base64IdentityData);

    // operate
    final Identity identity = TlvParser.parse(identityData, Identity.class);

    // verify
    LOG.debug("name: " + identity.getName());
    LOG.debug("first name: " + identity.getFirstName());
    LOG.debug("card validity date begin: " + identity.getCardValidityDateBegin().getTime());
    LOG.debug("document type: " + identity.getDocumentType());
    assertEquals(DocumentType.BELGIAN_CITIZEN, identity.getDocumentType());
    assertNull(identity.getDuplicate());
    assertFalse(identity.isMemberOfFamily());
  }
Esempio n. 8
0
  @Test
  public void testGermanIdentityFileDoB() throws Exception {
    // setup
    final byte[] idFileCaseInTheField =
        new byte[] {12, 12, '2', '3', '.', 'S', 'E', 'P', '.', ' ', '1', '9', '8', '2'};

    // operate
    final Identity identity = TlvParser.parse(idFileCaseInTheField, Identity.class);

    // verify
    assertNotNull(identity.getDateOfBirth());
    LOG.debug("date of birth: " + identity.getDateOfBirth().getTime());

    final byte[] idFile =
        new byte[] {12, 11, '2', '3', '.', 'S', 'E', 'P', '.', '1', '9', '8', '2'};
    final Identity identity2 = TlvParser.parse(idFile, Identity.class);
    assertEquals(identity.getDateOfBirth(), identity2.getDateOfBirth());
  }
Esempio n. 9
0
 @Test
 public void testYearOnlyDate() throws Exception {
   final byte[] yearOnlyTLV = new byte[] {12, 4, '1', '9', '8', '4'};
   final Identity identity = TlvParser.parse(yearOnlyTLV, Identity.class);
   assertEquals(1984, identity.getDateOfBirth().get(Calendar.YEAR));
 }