Mrz { public DocumentData getPrettyData() { DocumentData data = new DocumentData(); if (mrz.startsWith("P")) { data.setDocumentNumber(mrz.split("\n")[1].substring(PASSPORT_DOCNO_INDICES[0], PASSPORT_DOCNO_INDICES[1])); data.setDateOfBirth(mrz.split("\n")[1].substring(PASSPORT_DOB_INDICES[0], PASSPORT_DOB_INDICES[1])); data.setExpiryDate(mrz.split("\n")[1].substring(PASSPORT_EXP_INDICES[0],PASSPORT_EXP_INDICES[1])); } else if (mrz.startsWith("I")) { data.setDocumentNumber(mrz.split("\n")[0].substring(ID_DOCNO_INDICES[0],ID_DOCNO_INDICES[1])); data.setDateOfBirth(mrz.split("\n")[1].substring(ID_DOB_INDICES[0],ID_DOB_INDICES[1])); data.setExpiryDate(mrz.split("\n")[1].substring(ID_EXP_INDICES[0],ID_EXP_INDICES[1])); } return data; } Mrz(String mrz); DocumentData getPrettyData(); boolean valid(); String getText();  }
@Test public void get_pretty_data_test() throws Exception { Mrz valid = new Mrz(valid_id_mrz); assertEquals(valid_id_doc_num, valid.getPrettyData().getDocumentNumber()); assertEquals(valid_id_data_of_birth, valid.getPrettyData().getDateOfBirth()); assertEquals(valid_id_expiry_data, valid.getPrettyData().getExpiryDate()); assertTrue(valid.getPrettyData().isValid()); }
@Test public void get_pretty_data_test2() throws Exception { Mrz valid = new Mrz(valid_passport_mrz); DocumentData data = valid.getPrettyData(); assertEquals(valid_pass_doc_num, data.getDocumentNumber()); assertEquals(valid_pass_data_of_birth, data.getDateOfBirth()); assertEquals(valid_pass_expiry_data, data.getExpiryDate()); assertTrue(data.isValid()); }