diff --git a/peppol-id/src/test/java/com/helger/peppolid/peppol/participant/PeppolParticipantIdentifierTest.java b/peppol-id/src/test/java/com/helger/peppolid/peppol/participant/PeppolParticipantIdentifierTest.java index 12c93e1f..e6ed35fd 100644 --- a/peppol-id/src/test/java/com/helger/peppolid/peppol/participant/PeppolParticipantIdentifierTest.java +++ b/peppol-id/src/test/java/com/helger/peppolid/peppol/participant/PeppolParticipantIdentifierTest.java @@ -45,16 +45,16 @@ public final class PeppolParticipantIdentifierTest private static final String VALUE_MAX_LENGTH = StringHelper.getRepeated ('a', PeppolIdentifierHelper.MAX_PARTICIPANT_VALUE_LENGTH); private static final String VALUE_MAX_LENGTH_PLUS_1 = VALUE_MAX_LENGTH + 'a'; - private static final IIdentifierFactory aIF = PeppolIdentifierFactory.INSTANCE; + private static final IIdentifierFactory IF = PeppolIdentifierFactory.INSTANCE; @Test public void testCtor () { - final PeppolParticipantIdentifier aID = new PeppolParticipantIdentifier (aIF, "scheme-actorid-test", "value"); + final PeppolParticipantIdentifier aID = new PeppolParticipantIdentifier (IF, "scheme-actorid-test", "value"); assertEquals ("scheme-actorid-test", aID.getScheme ()); assertEquals ("value", aID.getValue ()); - final PeppolParticipantIdentifier aID2 = new PeppolParticipantIdentifier (aIF, aID); + final PeppolParticipantIdentifier aID2 = new PeppolParticipantIdentifier (IF, aID); assertEquals ("scheme-actorid-test", aID2.getScheme ()); assertEquals ("value", aID2.getValue ()); @@ -65,9 +65,9 @@ public void testCtor () @Test public void testBasicMethods () { - final PeppolParticipantIdentifier aID1 = new PeppolParticipantIdentifier (aIF, "scheme-actorid-test", "value"); - final PeppolParticipantIdentifier aID2 = new PeppolParticipantIdentifier (aIF, "scheme-actorid-test", "value"); - final PeppolParticipantIdentifier aID3 = new PeppolParticipantIdentifier (aIF, "scheme2-actorid-test", "value"); + final PeppolParticipantIdentifier aID1 = new PeppolParticipantIdentifier (IF, "scheme-actorid-test", "value"); + final PeppolParticipantIdentifier aID2 = new PeppolParticipantIdentifier (IF, "scheme-actorid-test", "value"); + final PeppolParticipantIdentifier aID3 = new PeppolParticipantIdentifier (IF, "scheme2-actorid-test", "value"); CommonsTestHelper.testDefaultImplementationWithEqualContentObject (aID1, aID2); CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aID1, aID3); CommonsTestHelper.testDefaultImplementationWithDifferentContentObject (aID2, aID3); @@ -76,28 +76,28 @@ public void testBasicMethods () @Test public void testURIStuff () { - final IParticipantIdentifier aID1 = new PeppolParticipantIdentifier (aIF, "scheme-actorid-test", "value1"); + final IParticipantIdentifier aID1 = new PeppolParticipantIdentifier (IF, "scheme-actorid-test", "value1"); assertEquals ("scheme-actorid-test::value1", aID1.getURIEncoded ()); assertEquals ("scheme-actorid-test%3A%3Avalue1", aID1.getURIPercentEncoded ()); - final IParticipantIdentifier aID2 = aIF.parseParticipantIdentifier ("scheme-actorid-test::value1"); + final IParticipantIdentifier aID2 = IF.parseParticipantIdentifier ("scheme-actorid-test::value1"); assertTrue (aID1.hasSameContent (aID2)); - assertNull (aIF.parseParticipantIdentifier ("scheme1")); - assertNull (aIF.parseParticipantIdentifier (null)); - assertNull (aIF.parseParticipantIdentifier ("")); - - assertNotNull (aIF.parseParticipantIdentifier ("any-actorid-dummy::9908:976098897")); - assertNotNull (aIF.parseParticipantIdentifier ("any-actorid-dummy::9908:976098897 ")); - assertNotNull (aIF.parseParticipantIdentifier ("any-actorid-dummy::990:976098897")); - assertNotNull (aIF.parseParticipantIdentifier ("any-actorid-dummy::990976098897")); - assertNotNull (aIF.parseParticipantIdentifier ("any-actorid-dummy::9909:976098896")); - assertNotNull (aIF.parseParticipantIdentifier ("any-actorid-dummy::9908:976098896")); - - assertNull (aIF.parseParticipantIdentifier ("any-actorid-dummythatiswaytoolongforwhatisexpected::9908:976098896")); - assertNotNull (aIF.parseParticipantIdentifier ("any-actorid-dummy::" + VALUE_MAX_LENGTH)); - assertNull (aIF.parseParticipantIdentifier ("any-actorid-dummy::" + VALUE_MAX_LENGTH_PLUS_1)); - assertNull (aIF.parseParticipantIdentifier ("any-actorid-dummy:9908:976098896")); - assertNull (aIF.parseParticipantIdentifier ("any-actorid-dummy9908:976098896")); + assertNull (IF.parseParticipantIdentifier ("scheme1")); + assertNull (IF.parseParticipantIdentifier (null)); + assertNull (IF.parseParticipantIdentifier ("")); + + assertNotNull (IF.parseParticipantIdentifier ("any-actorid-dummy::9908:976098897")); + assertNotNull (IF.parseParticipantIdentifier ("any-actorid-dummy::9908:976098897 ")); + assertNotNull (IF.parseParticipantIdentifier ("any-actorid-dummy::990:976098897")); + assertNotNull (IF.parseParticipantIdentifier ("any-actorid-dummy::990976098897")); + assertNotNull (IF.parseParticipantIdentifier ("any-actorid-dummy::9909:976098896")); + assertNotNull (IF.parseParticipantIdentifier ("any-actorid-dummy::9908:976098896")); + + assertNull (IF.parseParticipantIdentifier ("any-actorid-dummythatiswaytoolongforwhatisexpected::9908:976098896")); + assertNotNull (IF.parseParticipantIdentifier ("any-actorid-dummy::" + VALUE_MAX_LENGTH)); + assertNull (IF.parseParticipantIdentifier ("any-actorid-dummy::" + VALUE_MAX_LENGTH_PLUS_1)); + assertNull (IF.parseParticipantIdentifier ("any-actorid-dummy:9908:976098896")); + assertNull (IF.parseParticipantIdentifier ("any-actorid-dummy9908:976098896")); } @Test @@ -107,7 +107,7 @@ public void testConstraints () try { // null key not allowed - new PeppolParticipantIdentifier (aIF, null, "value"); + new PeppolParticipantIdentifier (IF, null, "value"); fail (); } catch (final IllegalArgumentException ex) @@ -116,7 +116,7 @@ public void testConstraints () try { // invalid scheme - new PeppolParticipantIdentifier (aIF, "", "value"); + new PeppolParticipantIdentifier (IF, "", "value"); fail (); } catch (final IllegalArgumentException ex) @@ -125,7 +125,7 @@ public void testConstraints () try { // separator is forbidden - new PeppolParticipantIdentifier (aIF, "abc::def", "value"); + new PeppolParticipantIdentifier (IF, "abc::def", "value"); fail (); } catch (final IllegalArgumentException ex) @@ -134,7 +134,7 @@ public void testConstraints () try { // null value not allowed - new PeppolParticipantIdentifier (aIF, PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, null); + new PeppolParticipantIdentifier (IF, PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, null); fail (); } catch (final IllegalArgumentException ex) @@ -143,7 +143,7 @@ public void testConstraints () try { // Both null not allowed - new PeppolParticipantIdentifier (aIF, null, null); + new PeppolParticipantIdentifier (IF, null, null); fail (); } catch (final IllegalArgumentException ex) @@ -152,7 +152,7 @@ public void testConstraints () try { // Empty is not allowed - new PeppolParticipantIdentifier (aIF, PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, ""); + new PeppolParticipantIdentifier (IF, PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, ""); fail (); } catch (final IllegalArgumentException ex) @@ -161,7 +161,7 @@ public void testConstraints () try { // Cannot be mapped to ISO-8859-1: - new PeppolParticipantIdentifier (aIF, PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "Љ"); + new PeppolParticipantIdentifier (IF, PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, "Љ"); fail (); } catch (final IllegalArgumentException ex) @@ -170,7 +170,7 @@ public void testConstraints () try { // Scheme too long - new PeppolParticipantIdentifier (aIF, + new PeppolParticipantIdentifier (IF, PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME + VALUE_MAX_LENGTH_PLUS_1, "abc"); fail (); @@ -181,7 +181,7 @@ public void testConstraints () try { // Value too long - new PeppolParticipantIdentifier (aIF, PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, VALUE_MAX_LENGTH_PLUS_1); + new PeppolParticipantIdentifier (IF, PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME, VALUE_MAX_LENGTH_PLUS_1); fail (); } catch (final IllegalArgumentException ex) @@ -191,9 +191,8 @@ public void testConstraints () @Test public void testHasDefaultScheme () { - final IIdentifierFactory aIF = PeppolIdentifierFactory.INSTANCE; - assertTrue (aIF.createParticipantIdentifierWithDefaultScheme ("abc") - .hasScheme (PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME)); - assertFalse (new PeppolParticipantIdentifier (aIF, "dummy-actorid-upis", "abc").hasDefaultScheme ()); + assertTrue (IF.createParticipantIdentifierWithDefaultScheme ("abc") + .hasScheme (PeppolIdentifierHelper.DEFAULT_PARTICIPANT_SCHEME)); + assertFalse (new PeppolParticipantIdentifier (IF, "dummy-actorid-upis", "abc").hasDefaultScheme ()); } }