CitizenId implements Identity { public static boolean isValid(String id) { CitizenId cid = new CitizenId(id); return cid.validate(); } CitizenId(String id); static boolean isValid(String id); @Override boolean validate(); @Override boolean isValidFormat(); @Override int hashCode(); @Override boolean equals(Object o); @Override String toString(); @Override String prettyPrint(); @Override String getId();  }
@Test public void testInvalidFormatCitizenId() { assertFalse("Not Only Digit citizen-id, must be invalid", CitizenId.isValid("1a3456789101b")); assertFalse("citizen-id length more than 13, must be invalid", CitizenId.isValid("12345678910124")); assertFalse("citizen-id length less than 13, must be invalid", CitizenId.isValid("00000")); }
@Test public void validId() { assertTrue("1610255800005 should be valid", CitizenId.isValid("1610255800005")); assertTrue("1610255811112 should be valid", CitizenId.isValid("1610255811112")); assertTrue("1610255822220 should be valid", CitizenId.isValid("1610255822220")); assertTrue("pretty format id should be valid", CitizenId.isValid("1-6102-55800-00-5")); }
@Test public void invalIdWithValidFormat() { assertFalse("0012300000000 should be invalid", CitizenId.isValid("0012300000000")); assertFalse("1345678981235 should be invalid", CitizenId.isValid("1345678981235")); }