Skip to content

Commit

Permalink
Fixed warning
Browse files Browse the repository at this point in the history
  • Loading branch information
phax committed Jul 2, 2024
1 parent b341086 commit 25706cd
Showing 1 changed file with 36 additions and 37 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 ());

Expand All @@ -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);
Expand All @@ -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
Expand All @@ -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)
Expand All @@ -116,7 +116,7 @@ public void testConstraints ()
try
{
// invalid scheme
new PeppolParticipantIdentifier (aIF, "", "value");
new PeppolParticipantIdentifier (IF, "", "value");
fail ();
}
catch (final IllegalArgumentException ex)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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)
Expand All @@ -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 ();
Expand All @@ -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)
Expand All @@ -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 ());
}
}

0 comments on commit 25706cd

Please sign in to comment.