IdentifierValidator { public static boolean isValidParticipantIdentifier (@Nonnull final PeppolParticipantIdentifier aParticipantID) { ValueEnforcer.notNull (aParticipantID, "ParticipantID"); if (!aParticipantID.hasDefaultScheme ()) return true; boolean bAtLeastOneSupported = false; final String sIssuingAgencyID = aParticipantID.getIssuingAgencyID (); final String sLocal = aParticipantID.getLocalParticipantID (); for (final IParticipantIdentifierValidatorSPI aValidator : s_aParticipantIDValidators) if (aValidator.isSupportedIssuingAgency (sIssuingAgencyID)) { if (aValidator.isValueValid (sLocal)) { return true; } bAtLeastOneSupported = true; } if (bAtLeastOneSupported) return false; return true; } private  IdentifierValidator(); static boolean isValidParticipantIdentifier(@Nonnull final PeppolParticipantIdentifier aParticipantID);  }
@SuppressWarnings ("deprecation") @Test public void testNorwayOrgNumber () { assertFalse (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.NO_ORGNR.createParticipantIdentifier (""))); assertFalse (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.NO_ORGNR.createParticipantIdentifier ("123456789"))); assertTrue (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.NO_ORGNR.createParticipantIdentifier ("123456785"))); assertTrue (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.NO_ORGNR.createParticipantIdentifier ("968218743"))); assertTrue (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.NO_ORGNR.createParticipantIdentifier ("961329310"))); assertFalse (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.NO_VAT.createParticipantIdentifier (""))); assertFalse (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.NO_VAT.createParticipantIdentifier ("123456789"))); assertTrue (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.NO_VAT.createParticipantIdentifier ("123456785"))); assertTrue (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.NO_VAT.createParticipantIdentifier ("968218743"))); assertTrue (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.NO_VAT.createParticipantIdentifier ("961329310"))); }
@Test public void testWithoutRules () { assertTrue (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.AD_VAT.createParticipantIdentifier ("123456789"))); assertTrue (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.AD_VAT.createParticipantIdentifier ("123456785"))); assertTrue (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.AD_VAT.createParticipantIdentifier ("968218743"))); assertTrue (IdentifierValidator.isValidParticipantIdentifier (EPredefinedParticipantIdentifierScheme.AD_VAT.createParticipantIdentifier ("961329310"))); }