diff --git a/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/DatastoreUtilsIndexCalculatorTest.java b/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/DatastoreUtilsIndexCalculatorTest.java index 7139d7afd0d..2dfbc7fabc6 100644 --- a/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/DatastoreUtilsIndexCalculatorTest.java +++ b/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/DatastoreUtilsIndexCalculatorTest.java @@ -35,8 +35,9 @@ import java.util.List; import java.util.TimeZone; + @Category(JUnitTests.class) -public class DatastoreUtilsIndexCalculatorTest extends Assert { +public class DatastoreUtilsIndexCalculatorTest { private static final Logger LOG = LoggerFactory.getLogger(DatastoreUtilsIndexCalculatorTest.class); @@ -105,7 +106,7 @@ public void testIndex() throws KapuaException, ParseException { @Test public void dataIndexNameByScopeId() { - assertEquals("1-data-message-*", DatastoreUtils.getDataIndexName(KapuaId.ONE)); + Assert.assertEquals("1-data-message-*", DatastoreUtils.getDataIndexName(KapuaId.ONE)); } @Test @@ -113,30 +114,30 @@ public void dataIndexNameByScopeIdAndTimestamp() throws KapuaException, ParseExc // Index by Week String weekIndexName = DatastoreUtils.getDataIndexName(KapuaId.ONE, sdf.parse("02/01/2017 13:12 +0100").getTime(), DatastoreUtils.INDEXING_WINDOW_OPTION_WEEK); - assertEquals("1-data-message-2017-01", weekIndexName); + Assert.assertEquals("1-data-message-2017-01", weekIndexName); // Index by Day String dayIndexName = DatastoreUtils.getDataIndexName(KapuaId.ONE, sdf.parse("02/01/2017 13:12 +0100").getTime(), DatastoreUtils.INDEXING_WINDOW_OPTION_DAY); - assertEquals("1-data-message-2017-01-02", dayIndexName); + Assert.assertEquals("1-data-message-2017-01-02", dayIndexName); // Index by Hour String hourIndexName = DatastoreUtils.getDataIndexName(KapuaId.ONE, sdf.parse("02/01/2017 13:12 +0100").getTime(), DatastoreUtils.INDEXING_WINDOW_OPTION_HOUR); - assertEquals("1-data-message-2017-01-02-12", hourIndexName); // Index Hour is UTC! + Assert.assertEquals("1-data-message-2017-01-02-12", hourIndexName); // Index Hour is UTC! } @Test public void channelIndexNameByScopeId() { - assertEquals("1-data-channel", DatastoreUtils.getChannelIndexName(KapuaId.ONE)); + Assert.assertEquals("1-data-channel", DatastoreUtils.getChannelIndexName(KapuaId.ONE)); } @Test public void clientIndexNameByScopeId() { - assertEquals("1-data-client", DatastoreUtils.getClientIndexName(KapuaId.ONE)); + Assert.assertEquals("1-data-client", DatastoreUtils.getClientIndexName(KapuaId.ONE)); } @Test public void metricIndexNameByScopeId() { - assertEquals("1-data-metric", DatastoreUtils.getMetricIndexName(KapuaId.ONE)); + Assert.assertEquals("1-data-metric", DatastoreUtils.getMetricIndexName(KapuaId.ONE)); } private void performTest(Date startDate, Date endDate, String[] expectedIndexes) throws DatastoreException { @@ -203,12 +204,12 @@ private String[] buildExpectedResult(String scopeId, int startWeek, int startYea private void compareResult(String[] expected, String[] result) { if (result != null) { - assertEquals("Wrong result size!", (expected != null ? expected.length : 0), result.length); + Assert.assertEquals("Wrong result size!", (expected != null ? expected.length : 0), result.length); for (int i = 0; i < result.length; i++) { - assertEquals(String.format("Wrong result at position {0}!", i), expected[i], result[i]); + Assert.assertEquals(String.format("Wrong result at position {0}!", i), expected[i], result[i]); } } else { - assertTrue("Wrong result size!", expected == null || expected.length <= 0); + Assert.assertTrue("Wrong result size!", expected == null || expected.length <= 0); } } diff --git a/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/utils/DatastoreUtilsConvertDateTest.java b/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/utils/DatastoreUtilsConvertDateTest.java index 16a951f7c60..7ec5e7e2bbd 100644 --- a/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/utils/DatastoreUtilsConvertDateTest.java +++ b/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/utils/DatastoreUtilsConvertDateTest.java @@ -15,7 +15,6 @@ import org.assertj.core.api.Assertions; import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.eclipse.kapua.service.datastore.internal.mediator.DatastoreUtils; -import org.junit.Assert; import org.junit.Test; import org.junit.experimental.categories.Category; @@ -23,8 +22,9 @@ import java.time.ZonedDateTime; import java.util.Date; + @Category(JUnitTests.class) -public class DatastoreUtilsConvertDateTest extends Assert { +public class DatastoreUtilsConvertDateTest { @Test(expected = java.lang.IllegalArgumentException.class) public void convertNullString() { diff --git a/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/utils/DatastoreUtilsIndexNameTest.java b/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/utils/DatastoreUtilsIndexNameTest.java index 37cc431a74b..fc4eca65cc1 100644 --- a/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/utils/DatastoreUtilsIndexNameTest.java +++ b/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/utils/DatastoreUtilsIndexNameTest.java @@ -29,8 +29,9 @@ import java.time.ZoneOffset; import java.time.ZonedDateTime; + @Category(JUnitTests.class) -public class DatastoreUtilsIndexNameTest extends Assert { +public class DatastoreUtilsIndexNameTest { private static final KapuaId ONE = new KapuaEid(BigInteger.ONE); diff --git a/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/utils/MessageStoreConfigurationTest.java b/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/utils/MessageStoreConfigurationTest.java index fc5debd9d9c..b3c1f575dbb 100644 --- a/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/utils/MessageStoreConfigurationTest.java +++ b/service/datastore/test/src/test/java/org/eclipse/kapua/service/datastore/test/junit/utils/MessageStoreConfigurationTest.java @@ -25,8 +25,9 @@ import java.util.HashMap; import java.util.Map; + @Category(JUnitTests.class) -public class MessageStoreConfigurationTest extends Assert { +public class MessageStoreConfigurationTest { @Test public void test1() { diff --git a/service/device/commons/src/test/java/org/eclipse/kapua/service/device/management/commons/message/notification/KapuaNotifyMessageTest.java b/service/device/commons/src/test/java/org/eclipse/kapua/service/device/management/commons/message/notification/KapuaNotifyMessageTest.java index 88fc48d7ae8..38f45a8cc52 100644 --- a/service/device/commons/src/test/java/org/eclipse/kapua/service/device/management/commons/message/notification/KapuaNotifyMessageTest.java +++ b/service/device/commons/src/test/java/org/eclipse/kapua/service/device/management/commons/message/notification/KapuaNotifyMessageTest.java @@ -18,8 +18,9 @@ import org.eclipse.kapua.qa.markers.junit.JUnitTests; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class KapuaNotifyMessageTest extends Assert { +public class KapuaNotifyMessageTest { private static final String NOTIFY_MSG_STR = "Client id 'clientId-1' - semantic topic 'part1/part2/part3'"; diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorImplTest.java index a3fae569b80..a01311390be 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionCreatorImplTest.java @@ -19,8 +19,9 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class MfaOptionCreatorImplTest extends Assert { +public class MfaOptionCreatorImplTest { KapuaId[] scopeIds; KapuaId[] userIds; @@ -47,9 +48,9 @@ public void mfaOptionCreatorImplScopeIdUserIdSecretKeyParametersTest() { for (KapuaId userId : userIds) { for (String mfaSecretKey : mfaSecretKeys) { MfaOptionCreatorImpl mfaOptionCreatorImpl = new MfaOptionCreatorImpl(scopeId, userId, mfaSecretKey); - assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionCreatorImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", userId, mfaOptionCreatorImpl.getUserId()); - assertEquals("Expected and actual values should be the same.", mfaSecretKey, mfaOptionCreatorImpl.getMfaSecretKey()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionCreatorImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", userId, mfaOptionCreatorImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", mfaSecretKey, mfaOptionCreatorImpl.getMfaSecretKey()); } } } @@ -59,9 +60,9 @@ public void mfaOptionCreatorImplScopeIdUserIdSecretKeyParametersTest() { public void mfaOptionCreatorImplScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { MfaOptionCreatorImpl mfaOptionCreatorImpl = new MfaOptionCreatorImpl(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionCreatorImpl.getScopeId()); - assertNull("Null expected.", mfaOptionCreatorImpl.getUserId()); - assertNull("Null expected.", mfaOptionCreatorImpl.getMfaSecretKey()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionCreatorImpl.getScopeId()); + Assert.assertNull("Null expected.", mfaOptionCreatorImpl.getUserId()); + Assert.assertNull("Null expected.", mfaOptionCreatorImpl.getMfaSecretKey()); } } @@ -69,10 +70,10 @@ public void mfaOptionCreatorImplScopeIdParameterTest() { public void setAndGetUserIdTest() { for (KapuaId newUserId : newUserIds) { mfaOptionCreatorImpl1.setUserId(newUserId); - assertEquals("Expected and actual values should be the same.", newUserId, mfaOptionCreatorImpl1.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, mfaOptionCreatorImpl1.getUserId()); mfaOptionCreatorImpl2.setUserId(newUserId); - assertEquals("Expected and actual values should be the same.", newUserId, mfaOptionCreatorImpl2.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, mfaOptionCreatorImpl2.getUserId()); } } @@ -80,10 +81,10 @@ public void setAndGetUserIdTest() { public void setAndGetMfaSecretKeyTest() { for (String newMfaSecretKey : newMfaSecretKeys) { mfaOptionCreatorImpl1.setMfaSecretKey(newMfaSecretKey); - assertEquals("Expected and actual values should be the same.", newMfaSecretKey, mfaOptionCreatorImpl1.getMfaSecretKey()); + Assert.assertEquals("Expected and actual values should be the same.", newMfaSecretKey, mfaOptionCreatorImpl1.getMfaSecretKey()); mfaOptionCreatorImpl2.setMfaSecretKey(newMfaSecretKey); - assertEquals("Expected and actual values should be the same.", newMfaSecretKey, mfaOptionCreatorImpl2.getMfaSecretKey()); + Assert.assertEquals("Expected and actual values should be the same.", newMfaSecretKey, mfaOptionCreatorImpl2.getMfaSecretKey()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java index c0b2be9ae77..eab01466eaf 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionFactoryImplTest.java @@ -28,8 +28,9 @@ import java.util.Date; + @Category(JUnitTests.class) -public class MfaOptionFactoryImplTest extends Assert { +public class MfaOptionFactoryImplTest { MfaOptionFactoryImpl mfaOptionFactoryImpl; KapuaId[] scopeIds; @@ -56,9 +57,9 @@ public void newCreatorScopeIdUserIdMfaSecretKeyParametersTest() { for (KapuaEid userId : userIds) { for (String mfaSecretKey : mfaSecretKeys) { MfaOptionCreatorImpl mfaOptionCreatorImpl = mfaOptionFactoryImpl.newCreator(scopeId, userId, mfaSecretKey); - assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionCreatorImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", userId, mfaOptionCreatorImpl.getUserId()); - assertEquals("Expected and actual values should be the same.", mfaSecretKey, mfaOptionCreatorImpl.getMfaSecretKey()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionCreatorImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", userId, mfaOptionCreatorImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", mfaSecretKey, mfaOptionCreatorImpl.getMfaSecretKey()); } } } @@ -66,14 +67,14 @@ public void newCreatorScopeIdUserIdMfaSecretKeyParametersTest() { @Test public void newListResultTest() { - assertTrue("Instance of MfaOptionListResult expected.", mfaOptionFactoryImpl.newListResult() instanceof MfaOptionListResult); + Assert.assertTrue("Instance of MfaOptionListResult expected.", mfaOptionFactoryImpl.newListResult() instanceof MfaOptionListResult); } @Test public void newEntityTest() { for (KapuaId scopeId : scopeIds) { MfaOption mfaOption = mfaOptionFactoryImpl.newEntity(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, mfaOption.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOption.getScopeId()); } } @@ -83,9 +84,9 @@ public void newMfaOptionTest() { for (KapuaId userId : userIds) { for (String mfaSecretKey : mfaSecretKeys) { MfaOption mfaOption = mfaOptionFactoryImpl.newMfaOption(scopeId, userId, mfaSecretKey); - assertEquals("Expected and actual values should be the same.", scopeId, mfaOption.getScopeId()); - assertEquals("Expected and actual values should be the same.", userId, mfaOption.getUserId()); - assertEquals("Expected and actual values should be the same.", mfaSecretKey, mfaOption.getMfaSecretKey()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOption.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", userId, mfaOption.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", mfaSecretKey, mfaOption.getMfaSecretKey()); } } } @@ -95,7 +96,7 @@ public void newMfaOptionTest() { public void newQueryTest() { for (KapuaId scopeId : scopeIds) { MfaOptionQuery mfaOptionQuery = mfaOptionFactoryImpl.newQuery(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionQuery.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionQuery.getScopeId()); } } @@ -103,7 +104,7 @@ public void newQueryTest() { public void newCreatorScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { MfaOptionCreator mfaOptionCreator = mfaOptionFactoryImpl.newCreator(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionCreator.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionCreator.getScopeId()); } } @@ -120,14 +121,14 @@ public void cloneTest() { MfaOption mfaOptionResult = mfaOptionFactoryImpl.clone(mfaOption); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, mfaOptionResult.getScopeId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, mfaOptionResult.getUserId()); - assertEquals("Expected and actual values should be the same.", "mfa secret key", mfaOptionResult.getMfaSecretKey()); - assertEquals("Expected and actual values should be the same.", "thrust key", mfaOptionResult.getTrustKey()); - assertEquals("Expected and actual values should be the same.", trustExpirationDate, mfaOptionResult.getTrustExpirationDate()); - assertEquals("Expected and actual values should be the same.", modifiedOn, mfaOptionResult.getModifiedOn()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, mfaOptionResult.getModifiedBy()); - assertEquals("Expected and actual values should be the same.", 10, mfaOptionResult.getOptlock()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, mfaOptionResult.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, mfaOptionResult.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", "mfa secret key", mfaOptionResult.getMfaSecretKey()); + Assert.assertEquals("Expected and actual values should be the same.", "thrust key", mfaOptionResult.getTrustKey()); + Assert.assertEquals("Expected and actual values should be the same.", trustExpirationDate, mfaOptionResult.getTrustExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", modifiedOn, mfaOptionResult.getModifiedOn()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, mfaOptionResult.getModifiedBy()); + Assert.assertEquals("Expected and actual values should be the same.", 10, mfaOptionResult.getOptlock()); } @Test(expected = KapuaEntityCloneException.class) diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionImplTest.java index 959a0765550..99edfc9ccbc 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionImplTest.java @@ -28,8 +28,9 @@ import java.util.LinkedList; import java.util.List; + @Category(JUnitTests.class) -public class MfaOptionImplTest extends Assert { +public class MfaOptionImplTest { KapuaId[] scopeIds; KapuaEid[] userIds; @@ -50,22 +51,22 @@ public void initialize() { @Test public void mfaOptionImplWithoutParametersTest() { MfaOptionImpl mfaOptionImpl = new MfaOptionImpl(); - assertNull("Null expected.", mfaOptionImpl.getScopeId()); - assertNull("Null expected.", mfaOptionImpl.getUserId()); - assertNull("Null expected.", mfaOptionImpl.getMfaSecretKey()); - assertNull("Null expected.", mfaOptionImpl.getTrustKey()); - assertNull("Null expected.", mfaOptionImpl.getTrustExpirationDate()); + Assert.assertNull("Null expected.", mfaOptionImpl.getScopeId()); + Assert.assertNull("Null expected.", mfaOptionImpl.getUserId()); + Assert.assertNull("Null expected.", mfaOptionImpl.getMfaSecretKey()); + Assert.assertNull("Null expected.", mfaOptionImpl.getTrustKey()); + Assert.assertNull("Null expected.", mfaOptionImpl.getTrustExpirationDate()); } @Test public void mfaOptionImplScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { MfaOptionImpl mfaOptionImpl = new MfaOptionImpl(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionImpl.getScopeId()); - assertNull("Null expected.", mfaOptionImpl.getUserId()); - assertNull("Null expected.", mfaOptionImpl.getMfaSecretKey()); - assertNull("Null expected.", mfaOptionImpl.getTrustKey()); - assertNull("Null expected.", mfaOptionImpl.getTrustExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionImpl.getScopeId()); + Assert.assertNull("Null expected.", mfaOptionImpl.getUserId()); + Assert.assertNull("Null expected.", mfaOptionImpl.getMfaSecretKey()); + Assert.assertNull("Null expected.", mfaOptionImpl.getTrustKey()); + Assert.assertNull("Null expected.", mfaOptionImpl.getTrustExpirationDate()); } } @@ -75,11 +76,11 @@ public void mfaOptionImplScopeIdUserIdMfaSecretKeyParametersTest() { for (KapuaId userId : userIds) { for (String mfaSecretKey : mfaSecretKeys) { MfaOptionImpl mfaOptionImpl = new MfaOptionImpl(scopeId, userId, mfaSecretKey); - assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", userId, mfaOptionImpl.getUserId()); - assertEquals("Expected and actual values should be the same.", mfaSecretKey, mfaOptionImpl.getMfaSecretKey()); - assertNull("Null expected.", mfaOptionImpl.getTrustKey()); - assertNull("Null expected.", mfaOptionImpl.getTrustExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", userId, mfaOptionImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", mfaSecretKey, mfaOptionImpl.getMfaSecretKey()); + Assert.assertNull("Null expected.", mfaOptionImpl.getTrustKey()); + Assert.assertNull("Null expected.", mfaOptionImpl.getTrustExpirationDate()); } } } @@ -98,14 +99,14 @@ public void mfaOptionImplMfaOptionParameterTest() throws KapuaException { MfaOptionImpl mfaOptionImpl = new MfaOptionImpl(mfaOption); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, mfaOptionImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, mfaOptionImpl.getUserId()); - assertEquals("Expected and actual values should be the same.", "mfa secret key", mfaOptionImpl.getMfaSecretKey()); - assertEquals("Expected and actual values should be the same.", "trust key", mfaOptionImpl.getTrustKey()); - assertEquals("Expected and actual values should be the same.", trustExpirationDate, mfaOptionImpl.getTrustExpirationDate()); - assertEquals("Expected and actual values should be the same.", modifiedOn, mfaOptionImpl.getModifiedOn()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, mfaOptionImpl.getModifiedBy()); - assertEquals("Expected and actual values should be the same.", 10, mfaOptionImpl.getOptlock()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, mfaOptionImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, mfaOptionImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", "mfa secret key", mfaOptionImpl.getMfaSecretKey()); + Assert.assertEquals("Expected and actual values should be the same.", "trust key", mfaOptionImpl.getTrustKey()); + Assert.assertEquals("Expected and actual values should be the same.", trustExpirationDate, mfaOptionImpl.getTrustExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", modifiedOn, mfaOptionImpl.getModifiedOn()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, mfaOptionImpl.getModifiedBy()); + Assert.assertEquals("Expected and actual values should be the same.", 10, mfaOptionImpl.getOptlock()); } @Test(expected = NullPointerException.class) @@ -120,25 +121,25 @@ public void setAndGetUserIdTest() throws KapuaException { MfaOptionImpl mfaOptionImpl1 = new MfaOptionImpl(); for (KapuaId newUserId : newUserIds) { mfaOptionImpl1.setUserId(newUserId); - assertEquals("Expected and actual values should be the same.", newUserId, mfaOptionImpl1.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, mfaOptionImpl1.getUserId()); } MfaOptionImpl mfaOptionImpl2 = new MfaOptionImpl(KapuaId.ONE); for (KapuaId newUserId : newUserIds) { mfaOptionImpl2.setUserId(newUserId); - assertEquals("Expected and actual values should be the same.", newUserId, mfaOptionImpl2.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, mfaOptionImpl2.getUserId()); } MfaOptionImpl mfaOptionImpl3 = new MfaOptionImpl(KapuaId.ONE, new KapuaEid(), "mfa secret key"); for (KapuaId newUserId : newUserIds) { mfaOptionImpl3.setUserId(newUserId); - assertEquals("Expected and actual values should be the same.", newUserId, mfaOptionImpl3.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, mfaOptionImpl3.getUserId()); } MfaOptionImpl mfaOptionImpl4 = new MfaOptionImpl(mfaOption); for (KapuaId newUserId : newUserIds) { mfaOptionImpl4.setUserId(newUserId); - assertEquals("Expected and actual values should be the same.", newUserId, mfaOptionImpl4.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, mfaOptionImpl4.getUserId()); } } @@ -149,25 +150,25 @@ public void setAndGetMfaSecretKeyTest() throws KapuaException { MfaOptionImpl mfaOptionImpl1 = new MfaOptionImpl(); for (String newSecretKey : newSecretKeys) { mfaOptionImpl1.setMfaSecretKey(newSecretKey); - assertEquals("Expected and actual values should be the same.", newSecretKey, mfaOptionImpl1.getMfaSecretKey()); + Assert.assertEquals("Expected and actual values should be the same.", newSecretKey, mfaOptionImpl1.getMfaSecretKey()); } MfaOptionImpl mfaOptionImpl2 = new MfaOptionImpl(KapuaId.ONE); for (String newSecretKey : newSecretKeys) { mfaOptionImpl2.setMfaSecretKey(newSecretKey); - assertEquals("Expected and actual values should be the same.", newSecretKey, mfaOptionImpl2.getMfaSecretKey()); + Assert.assertEquals("Expected and actual values should be the same.", newSecretKey, mfaOptionImpl2.getMfaSecretKey()); } MfaOptionImpl mfaOptionImpl3 = new MfaOptionImpl(KapuaId.ONE, new KapuaEid(), "mfa secret key"); for (String newSecretKey : newSecretKeys) { mfaOptionImpl3.setMfaSecretKey(newSecretKey); - assertEquals("Expected and actual values should be the same.", newSecretKey, mfaOptionImpl3.getMfaSecretKey()); + Assert.assertEquals("Expected and actual values should be the same.", newSecretKey, mfaOptionImpl3.getMfaSecretKey()); } MfaOptionImpl mfaOptionImpl4 = new MfaOptionImpl(mfaOption); for (String newSecretKey : newSecretKeys) { mfaOptionImpl4.setMfaSecretKey(newSecretKey); - assertEquals("Expected and actual values should be the same.", newSecretKey, mfaOptionImpl4.getMfaSecretKey()); + Assert.assertEquals("Expected and actual values should be the same.", newSecretKey, mfaOptionImpl4.getMfaSecretKey()); } } @@ -178,25 +179,25 @@ public void setAndGetTrustKeyTest() throws KapuaException { MfaOptionImpl mfaOptionImpl1 = new MfaOptionImpl(); for (String newTrustKey : newTrustKeys) { mfaOptionImpl1.setTrustKey(newTrustKey); - assertEquals("Expected and actual values should be the same.", newTrustKey, mfaOptionImpl1.getTrustKey()); + Assert.assertEquals("Expected and actual values should be the same.", newTrustKey, mfaOptionImpl1.getTrustKey()); } MfaOptionImpl mfaOptionImpl2 = new MfaOptionImpl(KapuaId.ONE); for (String newTrustKey : newTrustKeys) { mfaOptionImpl2.setTrustKey(newTrustKey); - assertEquals("Expected and actual values should be the same.", newTrustKey, mfaOptionImpl2.getTrustKey()); + Assert.assertEquals("Expected and actual values should be the same.", newTrustKey, mfaOptionImpl2.getTrustKey()); } MfaOptionImpl mfaOptionImpl3 = new MfaOptionImpl(KapuaId.ONE, new KapuaEid(), "mfa secret key"); for (String newTrustKey : newTrustKeys) { mfaOptionImpl3.setTrustKey(newTrustKey); - assertEquals("Expected and actual values should be the same.", newTrustKey, mfaOptionImpl3.getTrustKey()); + Assert.assertEquals("Expected and actual values should be the same.", newTrustKey, mfaOptionImpl3.getTrustKey()); } MfaOptionImpl mfaOptionImpl4 = new MfaOptionImpl(mfaOption); for (String newTrustKey : newTrustKeys) { mfaOptionImpl4.setTrustKey(newTrustKey); - assertEquals("Expected and actual values should be the same.", newTrustKey, mfaOptionImpl4.getTrustKey()); + Assert.assertEquals("Expected and actual values should be the same.", newTrustKey, mfaOptionImpl4.getTrustKey()); } } @@ -207,25 +208,25 @@ public void setAndGetTrustExpirationDateTest() throws KapuaException { MfaOptionImpl mfaOptionImpl1 = new MfaOptionImpl(); for (Date newTrustExpirationDate : newTrustExpirationDates) { mfaOptionImpl1.setTrustExpirationDate(newTrustExpirationDate); - assertEquals("Expected and actual values should be the same.", newTrustExpirationDate, mfaOptionImpl1.getTrustExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", newTrustExpirationDate, mfaOptionImpl1.getTrustExpirationDate()); } MfaOptionImpl mfaOptionImpl2 = new MfaOptionImpl(KapuaId.ONE); for (Date newTrustExpirationDate : newTrustExpirationDates) { mfaOptionImpl2.setTrustExpirationDate(newTrustExpirationDate); - assertEquals("Expected and actual values should be the same.", newTrustExpirationDate, mfaOptionImpl2.getTrustExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", newTrustExpirationDate, mfaOptionImpl2.getTrustExpirationDate()); } MfaOptionImpl mfaOptionImpl3 = new MfaOptionImpl(KapuaId.ONE, new KapuaEid(), "mfa secret key"); for (Date newTrustExpirationDate : newTrustExpirationDates) { mfaOptionImpl3.setTrustExpirationDate(newTrustExpirationDate); - assertEquals("Expected and actual values should be the same.", newTrustExpirationDate, mfaOptionImpl3.getTrustExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", newTrustExpirationDate, mfaOptionImpl3.getTrustExpirationDate()); } MfaOptionImpl mfaOptionImpl4 = new MfaOptionImpl(mfaOption); for (Date newTrustExpirationDate : newTrustExpirationDates) { mfaOptionImpl4.setTrustExpirationDate(newTrustExpirationDate); - assertEquals("Expected and actual values should be the same.", newTrustExpirationDate, mfaOptionImpl4.getTrustExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", newTrustExpirationDate, mfaOptionImpl4.getTrustExpirationDate()); } } @@ -236,25 +237,25 @@ public void setAndGetQRCodeImageTest() throws KapuaException { MfaOptionImpl mfaOptionImpl1 = new MfaOptionImpl(); for (String newQrCodeImage : newQrCodeImages) { mfaOptionImpl1.setQRCodeImage(newQrCodeImage); - assertEquals("Expected and actual values should be the same.", newQrCodeImage, mfaOptionImpl1.getQRCodeImage()); + Assert.assertEquals("Expected and actual values should be the same.", newQrCodeImage, mfaOptionImpl1.getQRCodeImage()); } MfaOptionImpl mfaOptionImpl2 = new MfaOptionImpl(KapuaId.ONE); for (String newQrCodeImage : newQrCodeImages) { mfaOptionImpl2.setQRCodeImage(newQrCodeImage); - assertEquals("Expected and actual values should be the same.", newQrCodeImage, mfaOptionImpl2.getQRCodeImage()); + Assert.assertEquals("Expected and actual values should be the same.", newQrCodeImage, mfaOptionImpl2.getQRCodeImage()); } MfaOptionImpl mfaOptionImpl3 = new MfaOptionImpl(KapuaId.ONE, new KapuaEid(), "mfa secret key"); for (String newQrCodeImage : newQrCodeImages) { mfaOptionImpl3.setQRCodeImage(newQrCodeImage); - assertEquals("Expected and actual values should be the same.", newQrCodeImage, mfaOptionImpl3.getQRCodeImage()); + Assert.assertEquals("Expected and actual values should be the same.", newQrCodeImage, mfaOptionImpl3.getQRCodeImage()); } MfaOptionImpl mfaOptionImpl4 = new MfaOptionImpl(mfaOption); for (String newQrCodeImage : newQrCodeImages) { mfaOptionImpl4.setQRCodeImage(newQrCodeImage); - assertEquals("Expected and actual values should be the same.", newQrCodeImage, mfaOptionImpl4.getQRCodeImage()); + Assert.assertEquals("Expected and actual values should be the same.", newQrCodeImage, mfaOptionImpl4.getQRCodeImage()); } } @@ -264,23 +265,23 @@ public void setAndGetScratchCodesEmptyListTest() throws KapuaException { MfaOptionImpl mfaOptionImpl1 = new MfaOptionImpl(); mfaOptionImpl1.setScratchCodes(scratchCodeList); - assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl1.getScratchCodes()); - assertTrue("True expected.", mfaOptionImpl1.getScratchCodes().isEmpty()); + Assert.assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl1.getScratchCodes()); + Assert.assertTrue("True expected.", mfaOptionImpl1.getScratchCodes().isEmpty()); MfaOptionImpl mfaOptionImpl2 = new MfaOptionImpl(KapuaId.ONE); mfaOptionImpl2.setScratchCodes(scratchCodeList); - assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl2.getScratchCodes()); - assertTrue("True expected.", mfaOptionImpl2.getScratchCodes().isEmpty()); + Assert.assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl2.getScratchCodes()); + Assert.assertTrue("True expected.", mfaOptionImpl2.getScratchCodes().isEmpty()); MfaOptionImpl mfaOptionImpl3 = new MfaOptionImpl(KapuaId.ONE, new KapuaEid(), "mfa secret key"); mfaOptionImpl3.setScratchCodes(scratchCodeList); - assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl3.getScratchCodes()); - assertTrue("True expected.", mfaOptionImpl3.getScratchCodes().isEmpty()); + Assert.assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl3.getScratchCodes()); + Assert.assertTrue("True expected.", mfaOptionImpl3.getScratchCodes().isEmpty()); MfaOptionImpl mfaOptionImpl4 = new MfaOptionImpl(mfaOption); mfaOptionImpl4.setScratchCodes(scratchCodeList); - assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl4.getScratchCodes()); - assertTrue("True expected.", mfaOptionImpl4.getScratchCodes().isEmpty()); + Assert.assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl4.getScratchCodes()); + Assert.assertTrue("True expected.", mfaOptionImpl4.getScratchCodes().isEmpty()); } @Test @@ -294,22 +295,22 @@ public void setAndGetScratchCodesTest() throws KapuaException { MfaOptionImpl mfaOptionImpl1 = new MfaOptionImpl(); mfaOptionImpl1.setScratchCodes(scratchCodeList); - assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl1.getScratchCodes()); - assertFalse("False expected.", mfaOptionImpl1.getScratchCodes().isEmpty()); + Assert.assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl1.getScratchCodes()); + Assert.assertFalse("False expected.", mfaOptionImpl1.getScratchCodes().isEmpty()); MfaOptionImpl mfaOptionImpl2 = new MfaOptionImpl(KapuaId.ONE); mfaOptionImpl2.setScratchCodes(scratchCodeList); - assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl2.getScratchCodes()); - assertFalse("False expected.", mfaOptionImpl2.getScratchCodes().isEmpty()); + Assert.assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl2.getScratchCodes()); + Assert.assertFalse("False expected.", mfaOptionImpl2.getScratchCodes().isEmpty()); MfaOptionImpl mfaOptionImpl3 = new MfaOptionImpl(KapuaId.ONE, new KapuaEid(), "mfa secret key"); mfaOptionImpl3.setScratchCodes(scratchCodeList); - assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl3.getScratchCodes()); - assertFalse("False expected.", mfaOptionImpl3.getScratchCodes().isEmpty()); + Assert.assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl3.getScratchCodes()); + Assert.assertFalse("False expected.", mfaOptionImpl3.getScratchCodes().isEmpty()); MfaOptionImpl mfaOptionImpl4 = new MfaOptionImpl(mfaOption); mfaOptionImpl4.setScratchCodes(scratchCodeList); - assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl4.getScratchCodes()); - assertFalse("False expected.", mfaOptionImpl4.getScratchCodes().isEmpty()); + Assert.assertEquals("Expected and actual values should be the same.", scratchCodeList, mfaOptionImpl4.getScratchCodes()); + Assert.assertFalse("False expected.", mfaOptionImpl4.getScratchCodes().isEmpty()); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionQueryImplTest.java index 364f53f2276..51f23ca3f59 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionQueryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/MfaOptionQueryImplTest.java @@ -18,15 +18,16 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class MfaOptionQueryImplTest extends Assert { +public class MfaOptionQueryImplTest { @Test public void mfaOptionQueryImplTest() { MfaOptionQueryImpl mfaOptionQueryImpl = new MfaOptionQueryImpl(); - assertNull("Null expected.", mfaOptionQueryImpl.getScopeId()); - assertNull("mfaOptionQueryImpl.sortCriteria", mfaOptionQueryImpl.getSortCriteria()); - assertNotNull("mfaOptionQueryImpl.defaultSortCriteria", mfaOptionQueryImpl.getDefaultSortCriteria()); + Assert.assertNull("Null expected.", mfaOptionQueryImpl.getScopeId()); + Assert.assertNull("mfaOptionQueryImpl.sortCriteria", mfaOptionQueryImpl.getSortCriteria()); + Assert.assertNotNull("mfaOptionQueryImpl.defaultSortCriteria", mfaOptionQueryImpl.getDefaultSortCriteria()); } @Test @@ -35,9 +36,9 @@ public void mfaOptionQueryImplScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { MfaOptionQueryImpl mfaOptionQueryImpl = new MfaOptionQueryImpl(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionQueryImpl.getScopeId()); - assertNull("mfaOptionQueryImpl.sortCriteria", mfaOptionQueryImpl.getSortCriteria()); - assertNotNull("mfaOptionQueryImpl.defaultSortCriteria", mfaOptionQueryImpl.getDefaultSortCriteria()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, mfaOptionQueryImpl.getScopeId()); + Assert.assertNull("mfaOptionQueryImpl.sortCriteria", mfaOptionQueryImpl.getSortCriteria()); + Assert.assertNotNull("mfaOptionQueryImpl.defaultSortCriteria", mfaOptionQueryImpl.getDefaultSortCriteria()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeCreatorImplTest.java index 16f89639bc5..571d01381fd 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeCreatorImplTest.java @@ -19,8 +19,9 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class ScratchCodeCreatorImplTest extends Assert { +public class ScratchCodeCreatorImplTest { KapuaId[] scopeIds, mfaOptionIds; String[] codes; @@ -38,9 +39,9 @@ public void scratchCodeCreatorImplScopeIdMfaOptionIdCodeParametersTest() { for (KapuaId mfaOptionId : mfaOptionIds) { for (String code : codes) { ScratchCodeCreatorImpl scratchCodeCreatorImpl = new ScratchCodeCreatorImpl(scopeId, mfaOptionId, code); - assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeCreatorImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", mfaOptionId, scratchCodeCreatorImpl.getMfaOptionId()); - assertEquals("Expected and actual values should be the same.", code, scratchCodeCreatorImpl.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeCreatorImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", mfaOptionId, scratchCodeCreatorImpl.getMfaOptionId()); + Assert.assertEquals("Expected and actual values should be the same.", code, scratchCodeCreatorImpl.getCode()); } } } @@ -50,9 +51,9 @@ public void scratchCodeCreatorImplScopeIdMfaOptionIdCodeParametersTest() { public void scratchCodeCreatorImplScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { ScratchCodeCreatorImpl scratchCodeCreatorImpl = new ScratchCodeCreatorImpl(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeCreatorImpl.getScopeId()); - assertNull("Null expected.", scratchCodeCreatorImpl.getMfaOptionId()); - assertNull("Null expected.", scratchCodeCreatorImpl.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeCreatorImpl.getScopeId()); + Assert.assertNull("Null expected.", scratchCodeCreatorImpl.getMfaOptionId()); + Assert.assertNull("Null expected.", scratchCodeCreatorImpl.getCode()); } } @@ -63,13 +64,13 @@ public void setAndGetMfaOptionIdTest() { ScratchCodeCreatorImpl scratchCodeCreatorImpl1 = new ScratchCodeCreatorImpl(KapuaId.ONE); for (KapuaId newMfaOptionId : newMfaOptionIds) { scratchCodeCreatorImpl1.setMfaOptionId(newMfaOptionId); - assertEquals("Expected and actual values should be the same.", newMfaOptionId, scratchCodeCreatorImpl1.getMfaOptionId()); + Assert.assertEquals("Expected and actual values should be the same.", newMfaOptionId, scratchCodeCreatorImpl1.getMfaOptionId()); } ScratchCodeCreatorImpl scratchCodeCreatorImpl2 = new ScratchCodeCreatorImpl(KapuaId.ONE, KapuaId.ANY, "code"); for (KapuaId newMfaOptionId : newMfaOptionIds) { scratchCodeCreatorImpl2.setMfaOptionId(newMfaOptionId); - assertEquals("Expected and actual values should be the same.", newMfaOptionId, scratchCodeCreatorImpl2.getMfaOptionId()); + Assert.assertEquals("Expected and actual values should be the same.", newMfaOptionId, scratchCodeCreatorImpl2.getMfaOptionId()); } } @@ -80,13 +81,13 @@ public void setAndGetCodeTest() { ScratchCodeCreatorImpl scratchCodeCreatorImpl1 = new ScratchCodeCreatorImpl(KapuaId.ONE); for (String newCode : newCodes) { scratchCodeCreatorImpl1.setCode(newCode); - assertEquals("Expected and actual values should be the same.", newCode, scratchCodeCreatorImpl1.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", newCode, scratchCodeCreatorImpl1.getCode()); } ScratchCodeCreatorImpl scratchCodeCreatorImpl2 = new ScratchCodeCreatorImpl(KapuaId.ONE, KapuaId.ANY, "code"); for (String newCode : newCodes) { scratchCodeCreatorImpl2.setCode(newCode); - assertEquals("Expected and actual values should be the same.", newCode, scratchCodeCreatorImpl2.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", newCode, scratchCodeCreatorImpl2.getCode()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeFactoryImplTest.java index 48a22f023ac..b99058b8d01 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeFactoryImplTest.java @@ -29,8 +29,9 @@ import java.util.Date; + @Category(JUnitTests.class) -public class ScratchCodeFactoryImplTest extends Assert { +public class ScratchCodeFactoryImplTest { ScratchCodeFactoryImpl scratchCodeFactoryImpl; KapuaId[] scopeIds; @@ -56,9 +57,9 @@ public void newCreatorScopeIdMfaOptionIdCodeParametersTest() { for (KapuaEid mfaOptionId : mfaOptionIds) { for (String code : codes) { ScratchCodeCreatorImpl scratchCodeCreatorImpl = scratchCodeFactoryImpl.newCreator(scopeId, mfaOptionId, code); - assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeCreatorImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", mfaOptionId, scratchCodeCreatorImpl.getMfaOptionId()); - assertEquals("Expected and actual values should be the same.", code, scratchCodeCreatorImpl.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeCreatorImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", mfaOptionId, scratchCodeCreatorImpl.getMfaOptionId()); + Assert.assertEquals("Expected and actual values should be the same.", code, scratchCodeCreatorImpl.getCode()); } } } @@ -66,14 +67,14 @@ public void newCreatorScopeIdMfaOptionIdCodeParametersTest() { @Test public void newListResultTest() { - assertTrue("True expected.", scratchCodeFactoryImpl.newListResult() instanceof ScratchCodeListResult); + Assert.assertTrue("True expected.", scratchCodeFactoryImpl.newListResult() instanceof ScratchCodeListResult); } @Test public void newEntityTest() { for (KapuaId scopeId : scopeIds) { ScratchCode scratchCode = scratchCodeFactoryImpl.newEntity(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, scratchCode.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, scratchCode.getScopeId()); } } @@ -83,9 +84,9 @@ public void newScratchCodeTest() { for (KapuaId mfaOptionId : mfaOptionIds) { for (String code : codes) { ScratchCode scratchCode = scratchCodeFactoryImpl.newScratchCode(scopeId, mfaOptionId, code); - assertEquals("Expected and actual values should be the same.", scopeId, scratchCode.getScopeId()); - assertEquals("Expected and actual values should be the same.", mfaOptionId, scratchCode.getMfaOptionId()); - assertEquals("Expected and actual values should be the same.", code, scratchCode.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, scratchCode.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", mfaOptionId, scratchCode.getMfaOptionId()); + Assert.assertEquals("Expected and actual values should be the same.", code, scratchCode.getCode()); } } } @@ -95,7 +96,7 @@ public void newScratchCodeTest() { public void newQueryTest() { for (KapuaId scopeId : scopeIds) { ScratchCodeQuery scratchCodeQuery = scratchCodeFactoryImpl.newQuery(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeQuery.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeQuery.getScopeId()); } } @@ -103,7 +104,7 @@ public void newQueryTest() { public void newCreatorScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { ScratchCodeCreator scratchCodeCreator = scratchCodeFactoryImpl.newCreator(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeCreator.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeCreator.getScopeId()); } } @@ -118,12 +119,12 @@ public void cloneTest() { ScratchCode scratchCodeResult = scratchCodeFactoryImpl.clone(scratchCode); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, scratchCodeResult.getScopeId()); - assertEquals("Expected and actual values should be the same.", "code", scratchCodeResult.getCode()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, scratchCodeResult.getMfaOptionId()); - assertEquals("Expected and actual values should be the same.", modifiedOn, scratchCodeResult.getModifiedOn()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, scratchCodeResult.getModifiedBy()); - assertEquals("Expected and actual values should be the same.", 10, scratchCodeResult.getOptlock()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, scratchCodeResult.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", "code", scratchCodeResult.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, scratchCodeResult.getMfaOptionId()); + Assert.assertEquals("Expected and actual values should be the same.", modifiedOn, scratchCodeResult.getModifiedOn()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, scratchCodeResult.getModifiedBy()); + Assert.assertEquals("Expected and actual values should be the same.", 10, scratchCodeResult.getOptlock()); } @Test(expected = KapuaEntityCloneException.class) diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeImplTest.java index cd8fbf952c4..b2664dcab79 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeImplTest.java @@ -25,8 +25,9 @@ import java.util.Date; + @Category(JUnitTests.class) -public class ScratchCodeImplTest extends Assert { +public class ScratchCodeImplTest { KapuaId[] scopeIds; KapuaEid[] mfaOptionIds, newMfaOptionIds; @@ -48,18 +49,18 @@ public void initialize() { @Test public void scratchCodeImplWithoutParametersTest() { ScratchCodeImpl scratchCodeImpl = new ScratchCodeImpl(); - assertNull("Null expected.", scratchCodeImpl.getScopeId()); - assertNull("Null expected.", scratchCodeImpl.getMfaOptionId()); - assertNull("Null expected.", scratchCodeImpl.getCode()); + Assert.assertNull("Null expected.", scratchCodeImpl.getScopeId()); + Assert.assertNull("Null expected.", scratchCodeImpl.getMfaOptionId()); + Assert.assertNull("Null expected.", scratchCodeImpl.getCode()); } @Test public void scratchCodeImplScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { ScratchCodeImpl scratchCodeImpl = new ScratchCodeImpl(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeImpl.getScopeId()); - assertNull("Null expected.", scratchCodeImpl.getMfaOptionId()); - assertNull("Null expected.", scratchCodeImpl.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeImpl.getScopeId()); + Assert.assertNull("Null expected.", scratchCodeImpl.getMfaOptionId()); + Assert.assertNull("Null expected.", scratchCodeImpl.getCode()); } } @@ -69,9 +70,9 @@ public void scratchCodeImplScopeIdMfaOptionIdCodeParametersTest() { for (KapuaId mfaOptionId : mfaOptionIds) { for (String code : codes) { ScratchCodeImpl scratchCodeImpl = new ScratchCodeImpl(scopeId, mfaOptionId, code); - assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", mfaOptionId, scratchCodeImpl.getMfaOptionId()); - assertEquals("Expected and actual values should be the same.", code, scratchCodeImpl.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", mfaOptionId, scratchCodeImpl.getMfaOptionId()); + Assert.assertEquals("Expected and actual values should be the same.", code, scratchCodeImpl.getCode()); } } } @@ -87,12 +88,12 @@ public void scratchCodeImplScratchCodeParameterTest() throws KapuaException { ScratchCodeImpl scratchCodeImpl = new ScratchCodeImpl(scratchCode); - assertNull("Null expected.", scratchCodeImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, scratchCodeImpl.getMfaOptionId()); - assertEquals("Expected and actual values should be the same.", "code", scratchCodeImpl.getCode()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, scratchCodeImpl.getModifiedBy()); - assertEquals("Expected and actual values should be the same.", modifiedOn, scratchCodeImpl.getModifiedOn()); - assertEquals("Expected and actual values should be the same.", 10, scratchCodeImpl.getOptlock()); + Assert.assertNull("Null expected.", scratchCodeImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, scratchCodeImpl.getMfaOptionId()); + Assert.assertEquals("Expected and actual values should be the same.", "code", scratchCodeImpl.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, scratchCodeImpl.getModifiedBy()); + Assert.assertEquals("Expected and actual values should be the same.", modifiedOn, scratchCodeImpl.getModifiedOn()); + Assert.assertEquals("Expected and actual values should be the same.", 10, scratchCodeImpl.getOptlock()); } @@ -101,25 +102,25 @@ public void setAndGetMfaOptionIdTest() throws KapuaException { ScratchCodeImpl scratchCodeImpl1 = new ScratchCodeImpl(); for (KapuaId newMfaOptionId : newMfaOptionIds) { scratchCodeImpl1.setMfaOptionId(newMfaOptionId); - assertEquals("Expected and actual values should be the same.", newMfaOptionId, scratchCodeImpl1.getMfaOptionId()); + Assert.assertEquals("Expected and actual values should be the same.", newMfaOptionId, scratchCodeImpl1.getMfaOptionId()); } ScratchCodeImpl scratchCodeImpl2 = new ScratchCodeImpl(KapuaId.ONE); for (KapuaId newMfaOptionId : newMfaOptionIds) { scratchCodeImpl2.setMfaOptionId(newMfaOptionId); - assertEquals("Expected and actual values should be the same.", newMfaOptionId, scratchCodeImpl2.getMfaOptionId()); + Assert.assertEquals("Expected and actual values should be the same.", newMfaOptionId, scratchCodeImpl2.getMfaOptionId()); } ScratchCodeImpl scratchCodeImpl3 = new ScratchCodeImpl(KapuaId.ONE, new KapuaEid(), "code"); for (KapuaId newMfaOptionId : newMfaOptionIds) { scratchCodeImpl3.setMfaOptionId(newMfaOptionId); - assertEquals("Expected and actual values should be the same.", newMfaOptionId, scratchCodeImpl3.getMfaOptionId()); + Assert.assertEquals("Expected and actual values should be the same.", newMfaOptionId, scratchCodeImpl3.getMfaOptionId()); } ScratchCodeImpl scratchCodeImpl4 = new ScratchCodeImpl(scratchCode); for (KapuaId newMfaOptionId : newMfaOptionIds) { scratchCodeImpl4.setMfaOptionId(newMfaOptionId); - assertEquals("Expected and actual values should be the same.", newMfaOptionId, scratchCodeImpl4.getMfaOptionId()); + Assert.assertEquals("Expected and actual values should be the same.", newMfaOptionId, scratchCodeImpl4.getMfaOptionId()); } } @@ -128,25 +129,25 @@ public void setAndGetCodeTest() throws KapuaException { ScratchCodeImpl scratchCodeImpl1 = new ScratchCodeImpl(); for (String code : newCodes) { scratchCodeImpl1.setCode(code); - assertEquals("Expected and actual values should be the same.", code, scratchCodeImpl1.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", code, scratchCodeImpl1.getCode()); } ScratchCodeImpl scratchCodeImpl2 = new ScratchCodeImpl(KapuaId.ONE); for (String code : newCodes) { scratchCodeImpl2.setCode(code); - assertEquals("Expected and actual values should be the same.", code, scratchCodeImpl2.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", code, scratchCodeImpl2.getCode()); } ScratchCodeImpl scratchCodeImpl3 = new ScratchCodeImpl(KapuaId.ONE, new KapuaEid(), "code"); for (String code : newCodes) { scratchCodeImpl3.setCode(code); - assertEquals("Expected and actual values should be the same.", code, scratchCodeImpl3.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", code, scratchCodeImpl3.getCode()); } ScratchCodeImpl scratchCodeImpl4 = new ScratchCodeImpl(scratchCode); for (String code : newCodes) { scratchCodeImpl4.setCode(code); - assertEquals("Expected and actual values should be the same.", code, scratchCodeImpl4.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", code, scratchCodeImpl4.getCode()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeQueryImplTest.java index 183330226d7..f6a3f23b29c 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeQueryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeQueryImplTest.java @@ -18,15 +18,16 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class ScratchCodeQueryImplTest extends Assert { +public class ScratchCodeQueryImplTest { @Test public void scratchCodeQueryImplWithoutParameterTest() { ScratchCodeQueryImpl scratchCodeQueryImpl = new ScratchCodeQueryImpl(); - assertNull("Null expected.", scratchCodeQueryImpl.getScopeId()); - assertNull("scratchCodeQueryImpl.sortCriteria", scratchCodeQueryImpl.getSortCriteria()); - assertNotNull("scratchCodeQueryImpl.defaultSortCriteria", scratchCodeQueryImpl.getDefaultSortCriteria()); + Assert.assertNull("Null expected.", scratchCodeQueryImpl.getScopeId()); + Assert.assertNull("scratchCodeQueryImpl.sortCriteria", scratchCodeQueryImpl.getSortCriteria()); + Assert.assertNotNull("scratchCodeQueryImpl.defaultSortCriteria", scratchCodeQueryImpl.getDefaultSortCriteria()); } @Test @@ -34,9 +35,9 @@ public void scratchCodeQueryImplScopeIdParameterTest() { KapuaId[] scopeIds = {null, KapuaId.ONE}; for (KapuaId scopeId : scopeIds) { ScratchCodeQueryImpl scratchCodeQueryImpl = new ScratchCodeQueryImpl(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeQueryImpl.getScopeId()); - assertNull("scratchCodeQueryImpl.sortCriteria", scratchCodeQueryImpl.getSortCriteria()); - assertNotNull("scratchCodeQueryImpl.defaultSortCriteria", scratchCodeQueryImpl.getDefaultSortCriteria()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, scratchCodeQueryImpl.getScopeId()); + Assert.assertNull("scratchCodeQueryImpl.sortCriteria", scratchCodeQueryImpl.getSortCriteria()); + Assert.assertNotNull("scratchCodeQueryImpl.defaultSortCriteria", scratchCodeQueryImpl.getDefaultSortCriteria()); } } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeServiceImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeServiceImplTest.java index 69fc09a6a41..2db9c19d053 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeServiceImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/mfa/shiro/ScratchCodeServiceImplTest.java @@ -17,12 +17,13 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class ScratchCodeServiceImplTest extends Assert { +public class ScratchCodeServiceImplTest { @Test public void scratchCodeServiceImplTest() { ScratchCodeServiceImpl scratchCodeServiceImpl = new ScratchCodeServiceImpl(); - assertNotNull("Null not expected.", scratchCodeServiceImpl.getEntityManagerSession()); + Assert.assertNotNull("Null not expected.", scratchCodeServiceImpl.getEntityManagerSession()); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorImplTest.java index 6064dbde774..b31105a5de0 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialCreatorImplTest.java @@ -23,8 +23,9 @@ import java.util.Date; + @Category(JUnitTests.class) -public class CredentialCreatorImplTest extends Assert { +public class CredentialCreatorImplTest { CredentialCreatorImpl credentialCreatorImpl1, credentialCreatorImpl2; @@ -50,12 +51,12 @@ public void credentialCreatorImplMultipleParametersTest() { for (CredentialStatus credentialStatus : credentialStatuses) { for (Date date : dates) { CredentialCreatorImpl credentialCreatorImpl = new CredentialCreatorImpl(scopeId, userId, credentialType, credentialKey, credentialStatus, date); - assertEquals("Expected and actual values should be the same.", scopeId, credentialCreatorImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", userId, credentialCreatorImpl.getUserId()); - assertEquals("Expected and actual values should be the same.", credentialType, credentialCreatorImpl.getCredentialType()); - assertEquals("Expected and actual values should be the same.", credentialKey, credentialCreatorImpl.getCredentialPlainKey()); - assertEquals("Expected and actual values should be the same.", credentialStatus, credentialCreatorImpl.getCredentialStatus()); - assertEquals("Expected and actual values should be the same.", date, credentialCreatorImpl.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialCreatorImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", userId, credentialCreatorImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", credentialType, credentialCreatorImpl.getCredentialType()); + Assert.assertEquals("Expected and actual values should be the same.", credentialKey, credentialCreatorImpl.getCredentialPlainKey()); + Assert.assertEquals("Expected and actual values should be the same.", credentialStatus, credentialCreatorImpl.getCredentialStatus()); + Assert.assertEquals("Expected and actual values should be the same.", date, credentialCreatorImpl.getExpirationDate()); } } } @@ -69,12 +70,12 @@ public void credentialCreatorImplScopeIdParameterTest() { KapuaId[] scopeIds = {null, KapuaId.ONE}; for (KapuaId scopeId : scopeIds) { CredentialCreatorImpl credentialCreatorImpl = new CredentialCreatorImpl(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, credentialCreatorImpl.getScopeId()); - assertNull("Null expected.", credentialCreatorImpl.getUserId()); - assertNull("Null expected.", credentialCreatorImpl.getCredentialType()); - assertNull("Null expected.", credentialCreatorImpl.getCredentialPlainKey()); - assertNull("Null expected.", credentialCreatorImpl.getCredentialStatus()); - assertNull("Null expected.", credentialCreatorImpl.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialCreatorImpl.getScopeId()); + Assert.assertNull("Null expected.", credentialCreatorImpl.getUserId()); + Assert.assertNull("Null expected.", credentialCreatorImpl.getCredentialType()); + Assert.assertNull("Null expected.", credentialCreatorImpl.getCredentialPlainKey()); + Assert.assertNull("Null expected.", credentialCreatorImpl.getCredentialStatus()); + Assert.assertNull("Null expected.", credentialCreatorImpl.getExpirationDate()); } } @@ -84,8 +85,8 @@ public void setAndGetUserIdTest() { for (KapuaId newUserId : newUserIds) { credentialCreatorImpl1.setUserId(newUserId); credentialCreatorImpl2.setUserId(newUserId); - assertEquals("Expected and actual values should be the same.", newUserId, credentialCreatorImpl1.getUserId()); - assertEquals("Expected and actual values should be the same.", newUserId, credentialCreatorImpl2.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, credentialCreatorImpl1.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, credentialCreatorImpl2.getUserId()); } } @@ -95,8 +96,8 @@ public void setAndGetCredentialTypeTest() { for (CredentialType newCredentialType : newCredentialTypes) { credentialCreatorImpl1.setCredentialType(newCredentialType); credentialCreatorImpl2.setCredentialType(newCredentialType); - assertEquals("Expected and actual values should be the same.", newCredentialType, credentialCreatorImpl1.getCredentialType()); - assertEquals("Expected and actual values should be the same.", newCredentialType, credentialCreatorImpl2.getCredentialType()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialType, credentialCreatorImpl1.getCredentialType()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialType, credentialCreatorImpl2.getCredentialType()); } } @@ -106,8 +107,8 @@ public void setAndGetCredentialPlainKeyTest() { for (String newCredentialKey : newCredentialKeys) { credentialCreatorImpl1.setCredentialPlainKey(newCredentialKey); credentialCreatorImpl2.setCredentialPlainKey(newCredentialKey); - assertEquals("Expected and actual values should be the same.", newCredentialKey, credentialCreatorImpl1.getCredentialPlainKey()); - assertEquals("Expected and actual values should be the same.", newCredentialKey, credentialCreatorImpl2.getCredentialPlainKey()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialKey, credentialCreatorImpl1.getCredentialPlainKey()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialKey, credentialCreatorImpl2.getCredentialPlainKey()); } } @@ -117,8 +118,8 @@ public void setAndGetExpirationDateTest() { for (Date newDate : newDates) { credentialCreatorImpl1.setExpirationDate(newDate); credentialCreatorImpl2.setExpirationDate(newDate); - assertEquals("Expected and actual values should be the same.", newDate, credentialCreatorImpl1.getExpirationDate()); - assertEquals("Expected and actual values should be the same.", newDate, credentialCreatorImpl2.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", newDate, credentialCreatorImpl1.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", newDate, credentialCreatorImpl2.getExpirationDate()); } } @@ -128,8 +129,8 @@ public void setAndGetCredentialStatusTest() { for (CredentialStatus newCredentialStatus : newCredentialStatuses) { credentialCreatorImpl1.setCredentialStatus(newCredentialStatus); credentialCreatorImpl2.setCredentialStatus(newCredentialStatus); - assertEquals("Expected and actual values should be the same.", newCredentialStatus, credentialCreatorImpl1.getCredentialStatus()); - assertEquals("Expected and actual values should be the same.", newCredentialStatus, credentialCreatorImpl2.getCredentialStatus()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialStatus, credentialCreatorImpl1.getCredentialStatus()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialStatus, credentialCreatorImpl2.getCredentialStatus()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java index a80ad93b280..a4e7ba28aeb 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialFactoryImplTest.java @@ -30,8 +30,9 @@ import java.util.Date; + @Category(JUnitTests.class) -public class CredentialFactoryImplTest extends Assert { +public class CredentialFactoryImplTest { CredentialFactoryImpl credentialFactoryImpl; KapuaId[] scopeIds; @@ -66,12 +67,12 @@ public void newCreatorScopeIdUserIdMfaSecretKeyParametersTest() { for (CredentialStatus credentialStatus : credentialStatuses) { for (Date date : dates) { CredentialCreatorImpl credentialCreatorImpl = credentialFactoryImpl.newCreator(scopeId, userId, credentialType, credentialKey, credentialStatus, date); - assertEquals("Expected and actual values should be the same.", scopeId, credentialCreatorImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", userId, credentialCreatorImpl.getUserId()); - assertEquals("Expected and actual values should be the same.", credentialType, credentialCreatorImpl.getCredentialType()); - assertEquals("Expected and actual values should be the same.", credentialKey, credentialCreatorImpl.getCredentialPlainKey()); - assertEquals("Expected and actual values should be the same.", credentialStatus, credentialCreatorImpl.getCredentialStatus()); - assertEquals("Expected and actual values should be the same.", date, credentialCreatorImpl.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialCreatorImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", userId, credentialCreatorImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", credentialType, credentialCreatorImpl.getCredentialType()); + Assert.assertEquals("Expected and actual values should be the same.", credentialKey, credentialCreatorImpl.getCredentialPlainKey()); + Assert.assertEquals("Expected and actual values should be the same.", credentialStatus, credentialCreatorImpl.getCredentialStatus()); + Assert.assertEquals("Expected and actual values should be the same.", date, credentialCreatorImpl.getExpirationDate()); } } } @@ -82,14 +83,14 @@ public void newCreatorScopeIdUserIdMfaSecretKeyParametersTest() { @Test public void newListResultTest() { - assertTrue("True expected.", credentialFactoryImpl.newListResult() instanceof CredentialListResult); + Assert.assertTrue("True expected.", credentialFactoryImpl.newListResult() instanceof CredentialListResult); } @Test public void newEntityTest() { for (KapuaId scopeId : scopeIds) { Credential credential = credentialFactoryImpl.newEntity(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, credential.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, credential.getScopeId()); } } @@ -102,12 +103,12 @@ public void newMfaOptionTest() { for (CredentialStatus credentialStatus : credentialStatuses) { for (Date date : dates) { Credential credential = credentialFactoryImpl.newCredential(scopeId, userId, credentialType, credentialKey, credentialStatus, date); - assertEquals("Expected and actual values should be the same.", scopeId, credential.getScopeId()); - assertEquals("Expected and actual values should be the same.", userId, credential.getUserId()); - assertEquals("Expected and actual values should be the same.", credentialType, credential.getCredentialType()); - assertEquals("Expected and actual values should be the same.", credentialKey, credential.getCredentialKey()); - assertEquals("Expected and actual values should be the same.", credentialStatus, credential.getStatus()); - assertEquals("Expected and actual values should be the same.", date, credential.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, credential.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", userId, credential.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", credentialType, credential.getCredentialType()); + Assert.assertEquals("Expected and actual values should be the same.", credentialKey, credential.getCredentialKey()); + Assert.assertEquals("Expected and actual values should be the same.", credentialStatus, credential.getStatus()); + Assert.assertEquals("Expected and actual values should be the same.", date, credential.getExpirationDate()); } } @@ -121,7 +122,7 @@ public void newMfaOptionTest() { public void newQueryTest() { for (KapuaId scopeId : scopeIds) { CredentialQuery credentialQuery = credentialFactoryImpl.newQuery(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, credentialQuery.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialQuery.getScopeId()); } } @@ -129,7 +130,7 @@ public void newQueryTest() { public void newCreatorScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { CredentialCreator credentialCreator = credentialFactoryImpl.newCreator(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, credentialCreator.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialCreator.getScopeId()); } } @@ -146,14 +147,14 @@ public void cloneTest() { Credential credentialResult = credentialFactoryImpl.clone(credential); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, credentialResult.getScopeId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, credentialResult.getUserId()); - assertEquals("Expected and actual values should be the same.", CredentialType.JWT, credentialResult.getCredentialType()); - assertEquals("Expected and actual values should be the same.", "key", credentialResult.getCredentialKey()); - assertEquals("Expected and actual values should be the same.", expirationDate, credentialResult.getExpirationDate()); - assertEquals("Expected and actual values should be the same.", modifiedOn, credentialResult.getModifiedOn()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, credentialResult.getModifiedBy()); - assertEquals("Expected and actual values should be the same.", 10, credentialResult.getOptlock()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, credentialResult.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, credentialResult.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", CredentialType.JWT, credentialResult.getCredentialType()); + Assert.assertEquals("Expected and actual values should be the same.", "key", credentialResult.getCredentialKey()); + Assert.assertEquals("Expected and actual values should be the same.", expirationDate, credentialResult.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", modifiedOn, credentialResult.getModifiedOn()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, credentialResult.getModifiedBy()); + Assert.assertEquals("Expected and actual values should be the same.", 10, credentialResult.getOptlock()); } @Test(expected = KapuaEntityCloneException.class) diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialImplTest.java index 44a475cc284..4d6ea9d0978 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialImplTest.java @@ -27,8 +27,9 @@ import java.util.Date; + @Category(JUnitTests.class) -public class CredentialImplTest extends Assert { +public class CredentialImplTest { KapuaId[] scopeIds; KapuaEid[] userIds; @@ -76,24 +77,24 @@ public void initialize() throws KapuaException { @Test public void credentialImplWithoutParametersTest() { CredentialImpl credentialImpl = new CredentialImpl(); - assertNull("Null expected.", credentialImpl.getScopeId()); - assertNull("Null expected.", credentialImpl.getUserId()); - assertNull("Null expected.", credentialImpl.getCredentialType()); - assertNull("Null expected.", credentialImpl.getCredentialKey()); - assertNull("Null expected.", credentialImpl.getStatus()); - assertNull("Null expected.", credentialImpl.getExpirationDate()); + Assert.assertNull("Null expected.", credentialImpl.getScopeId()); + Assert.assertNull("Null expected.", credentialImpl.getUserId()); + Assert.assertNull("Null expected.", credentialImpl.getCredentialType()); + Assert.assertNull("Null expected.", credentialImpl.getCredentialKey()); + Assert.assertNull("Null expected.", credentialImpl.getStatus()); + Assert.assertNull("Null expected.", credentialImpl.getExpirationDate()); } @Test public void credentialImplScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { CredentialImpl credentialImpl = new CredentialImpl(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, credentialImpl.getScopeId()); - assertNull("Null expected.", credentialImpl.getUserId()); - assertNull("Null expected.", credentialImpl.getCredentialType()); - assertNull("Null expected.", credentialImpl.getCredentialKey()); - assertNull("Null expected.", credentialImpl.getStatus()); - assertNull("Null expected.", credentialImpl.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialImpl.getScopeId()); + Assert.assertNull("Null expected.", credentialImpl.getUserId()); + Assert.assertNull("Null expected.", credentialImpl.getCredentialType()); + Assert.assertNull("Null expected.", credentialImpl.getCredentialKey()); + Assert.assertNull("Null expected.", credentialImpl.getStatus()); + Assert.assertNull("Null expected.", credentialImpl.getExpirationDate()); } } @@ -106,12 +107,12 @@ public void credentialImplMultipleParametersTest() { for (CredentialStatus credentialStatus : credentialStatuses) { for (Date date : dates) { CredentialImpl credentialImpl = new CredentialImpl(scopeId, userId, credentialType, credentialKey, credentialStatus, date); - assertEquals("Expected and actual values should be the same.", scopeId, credentialImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", userId, credentialImpl.getUserId()); - assertEquals("Expected and actual values should be the same.", credentialType, credentialImpl.getCredentialType()); - assertEquals("Expected and actual values should be the same.", credentialKey, credentialImpl.getCredentialKey()); - assertEquals("Expected and actual values should be the same.", credentialStatus, credentialImpl.getStatus()); - assertEquals("Expected and actual values should be the same.", date, credentialImpl.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", userId, credentialImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", credentialType, credentialImpl.getCredentialType()); + Assert.assertEquals("Expected and actual values should be the same.", credentialKey, credentialImpl.getCredentialKey()); + Assert.assertEquals("Expected and actual values should be the same.", credentialStatus, credentialImpl.getStatus()); + Assert.assertEquals("Expected and actual values should be the same.", date, credentialImpl.getExpirationDate()); } } } @@ -123,18 +124,18 @@ public void credentialImplMultipleParametersTest() { @Test public void credentialImplCredentialParameterTest() throws KapuaException { CredentialImpl credentialImpl = new CredentialImpl(credential); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, credentialImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", modifiedOn, credentialImpl.getModifiedOn()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, credentialImpl.getModifiedBy()); - assertEquals("Expected and actual values should be the same.", 10, credentialImpl.getOptlock()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, credentialImpl.getUserId()); - assertEquals("Expected and actual values should be the same.", CredentialType.PASSWORD, credentialImpl.getCredentialType()); - assertEquals("Expected and actual values should be the same.", "key", credentialImpl.getCredentialKey()); - assertEquals("Expected and actual values should be the same.", expirationDate, credentialImpl.getExpirationDate()); - assertEquals("Expected and actual values should be the same.", CredentialStatus.ENABLED, credentialImpl.getStatus()); - assertEquals("Expected and actual values should be the same.", 2, credentialImpl.getLoginFailures()); - assertEquals("Expected and actual values should be the same.", loginFailuresReset, credentialImpl.getLoginFailuresReset()); - assertEquals("Expected and actual values should be the same.", lockoutReset, credentialImpl.getLockoutReset()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, credentialImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", modifiedOn, credentialImpl.getModifiedOn()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, credentialImpl.getModifiedBy()); + Assert.assertEquals("Expected and actual values should be the same.", 10, credentialImpl.getOptlock()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, credentialImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", CredentialType.PASSWORD, credentialImpl.getCredentialType()); + Assert.assertEquals("Expected and actual values should be the same.", "key", credentialImpl.getCredentialKey()); + Assert.assertEquals("Expected and actual values should be the same.", expirationDate, credentialImpl.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", CredentialStatus.ENABLED, credentialImpl.getStatus()); + Assert.assertEquals("Expected and actual values should be the same.", 2, credentialImpl.getLoginFailures()); + Assert.assertEquals("Expected and actual values should be the same.", loginFailuresReset, credentialImpl.getLoginFailuresReset()); + Assert.assertEquals("Expected and actual values should be the same.", lockoutReset, credentialImpl.getLockoutReset()); } @Test @@ -148,10 +149,10 @@ public void setAndGetUserIdTest() { credentialImpl3.setUserId(newUserId); credentialImpl4.setUserId(newUserId); - assertEquals("Expected and actual values should be the same.", newUserId, credentialImpl1.getUserId()); - assertEquals("Expected and actual values should be the same.", newUserId, credentialImpl2.getUserId()); - assertEquals("Expected and actual values should be the same.", newUserId, credentialImpl3.getUserId()); - assertEquals("Expected and actual values should be the same.", newUserId, credentialImpl4.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, credentialImpl1.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, credentialImpl2.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, credentialImpl3.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, credentialImpl4.getUserId()); } for (KapuaEid newUserEid : newUserEids) { @@ -160,10 +161,10 @@ public void setAndGetUserIdTest() { credentialImpl3.setUserId(newUserEid); credentialImpl4.setUserId(newUserEid); - assertEquals("Expected and actual values should be the same.", newUserEid, credentialImpl1.getUserId()); - assertEquals("Expected and actual values should be the same.", newUserEid, credentialImpl2.getUserId()); - assertEquals("Expected and actual values should be the same.", newUserEid, credentialImpl3.getUserId()); - assertEquals("Expected and actual values should be the same.", newUserEid, credentialImpl4.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserEid, credentialImpl1.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserEid, credentialImpl2.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserEid, credentialImpl3.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserEid, credentialImpl4.getUserId()); } } @@ -177,10 +178,10 @@ public void setAndGetCredentialTypeTest() { credentialImpl3.setCredentialType(newCredentialType); credentialImpl4.setCredentialType(newCredentialType); - assertEquals("Expected and actual values should be the same.", newCredentialType, credentialImpl1.getCredentialType()); - assertEquals("Expected and actual values should be the same.", newCredentialType, credentialImpl2.getCredentialType()); - assertEquals("Expected and actual values should be the same.", newCredentialType, credentialImpl3.getCredentialType()); - assertEquals("Expected and actual values should be the same.", newCredentialType, credentialImpl4.getCredentialType()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialType, credentialImpl1.getCredentialType()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialType, credentialImpl2.getCredentialType()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialType, credentialImpl3.getCredentialType()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialType, credentialImpl4.getCredentialType()); } } @@ -194,10 +195,10 @@ public void setAndGetCredentialKeyTest() { credentialImpl3.setCredentialKey(newCredentialKey); credentialImpl4.setCredentialKey(newCredentialKey); - assertEquals("Expected and actual values should be the same.", newCredentialKey, credentialImpl1.getCredentialKey()); - assertEquals("Expected and actual values should be the same.", newCredentialKey, credentialImpl2.getCredentialKey()); - assertEquals("Expected and actual values should be the same.", newCredentialKey, credentialImpl3.getCredentialKey()); - assertEquals("Expected and actual values should be the same.", newCredentialKey, credentialImpl4.getCredentialKey()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialKey, credentialImpl1.getCredentialKey()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialKey, credentialImpl2.getCredentialKey()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialKey, credentialImpl3.getCredentialKey()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialKey, credentialImpl4.getCredentialKey()); } } @@ -211,10 +212,10 @@ public void setAndGetStatusTest() { credentialImpl3.setStatus(newCredentialStatus); credentialImpl4.setStatus(newCredentialStatus); - assertEquals("Expected and actual values should be the same.", newCredentialStatus, credentialImpl1.getStatus()); - assertEquals("Expected and actual values should be the same.", newCredentialStatus, credentialImpl2.getStatus()); - assertEquals("Expected and actual values should be the same.", newCredentialStatus, credentialImpl3.getStatus()); - assertEquals("Expected and actual values should be the same.", newCredentialStatus, credentialImpl4.getStatus()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialStatus, credentialImpl1.getStatus()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialStatus, credentialImpl2.getStatus()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialStatus, credentialImpl3.getStatus()); + Assert.assertEquals("Expected and actual values should be the same.", newCredentialStatus, credentialImpl4.getStatus()); } } @@ -228,10 +229,10 @@ public void setAndGetExpirationDateTest() { credentialImpl3.setExpirationDate(newExpirationDate); credentialImpl4.setExpirationDate(newExpirationDate); - assertEquals("Expected and actual values should be the same.", newExpirationDate, credentialImpl1.getExpirationDate()); - assertEquals("Expected and actual values should be the same.", newExpirationDate, credentialImpl2.getExpirationDate()); - assertEquals("Expected and actual values should be the same.", newExpirationDate, credentialImpl3.getExpirationDate()); - assertEquals("Expected and actual values should be the same.", newExpirationDate, credentialImpl4.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", newExpirationDate, credentialImpl1.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", newExpirationDate, credentialImpl2.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", newExpirationDate, credentialImpl3.getExpirationDate()); + Assert.assertEquals("Expected and actual values should be the same.", newExpirationDate, credentialImpl4.getExpirationDate()); } } @@ -245,10 +246,10 @@ public void setAndGetLoginFailuresTest() { credentialImpl3.setLoginFailures(newLoginFailure); credentialImpl4.setLoginFailures(newLoginFailure); - assertEquals("Expected and actual values should be the same.", newLoginFailure, credentialImpl1.getLoginFailures()); - assertEquals("Expected and actual values should be the same.", newLoginFailure, credentialImpl2.getLoginFailures()); - assertEquals("Expected and actual values should be the same.", newLoginFailure, credentialImpl3.getLoginFailures()); - assertEquals("Expected and actual values should be the same.", newLoginFailure, credentialImpl4.getLoginFailures()); + Assert.assertEquals("Expected and actual values should be the same.", newLoginFailure, credentialImpl1.getLoginFailures()); + Assert.assertEquals("Expected and actual values should be the same.", newLoginFailure, credentialImpl2.getLoginFailures()); + Assert.assertEquals("Expected and actual values should be the same.", newLoginFailure, credentialImpl3.getLoginFailures()); + Assert.assertEquals("Expected and actual values should be the same.", newLoginFailure, credentialImpl4.getLoginFailures()); } } @@ -262,10 +263,10 @@ public void setAndGetFirstLoginFailureTest() { credentialImpl3.setFirstLoginFailure(newFirstLoginFailure); credentialImpl4.setFirstLoginFailure(newFirstLoginFailure); - assertEquals("Expected and actual values should be the same.", newFirstLoginFailure, credentialImpl1.getFirstLoginFailure()); - assertEquals("Expected and actual values should be the same.", newFirstLoginFailure, credentialImpl2.getFirstLoginFailure()); - assertEquals("Expected and actual values should be the same.", newFirstLoginFailure, credentialImpl3.getFirstLoginFailure()); - assertEquals("Expected and actual values should be the same.", newFirstLoginFailure, credentialImpl4.getFirstLoginFailure()); + Assert.assertEquals("Expected and actual values should be the same.", newFirstLoginFailure, credentialImpl1.getFirstLoginFailure()); + Assert.assertEquals("Expected and actual values should be the same.", newFirstLoginFailure, credentialImpl2.getFirstLoginFailure()); + Assert.assertEquals("Expected and actual values should be the same.", newFirstLoginFailure, credentialImpl3.getFirstLoginFailure()); + Assert.assertEquals("Expected and actual values should be the same.", newFirstLoginFailure, credentialImpl4.getFirstLoginFailure()); } } @@ -279,10 +280,10 @@ public void setAndLoginFailuresResetTest() { credentialImpl3.setLoginFailuresReset(newLoginFailuresReset); credentialImpl4.setLoginFailuresReset(newLoginFailuresReset); - assertEquals("Expected and actual values should be the same.", newLoginFailuresReset, credentialImpl1.getLoginFailuresReset()); - assertEquals("Expected and actual values should be the same.", newLoginFailuresReset, credentialImpl2.getLoginFailuresReset()); - assertEquals("Expected and actual values should be the same.", newLoginFailuresReset, credentialImpl3.getLoginFailuresReset()); - assertEquals("Expected and actual values should be the same.", newLoginFailuresReset, credentialImpl4.getLoginFailuresReset()); + Assert.assertEquals("Expected and actual values should be the same.", newLoginFailuresReset, credentialImpl1.getLoginFailuresReset()); + Assert.assertEquals("Expected and actual values should be the same.", newLoginFailuresReset, credentialImpl2.getLoginFailuresReset()); + Assert.assertEquals("Expected and actual values should be the same.", newLoginFailuresReset, credentialImpl3.getLoginFailuresReset()); + Assert.assertEquals("Expected and actual values should be the same.", newLoginFailuresReset, credentialImpl4.getLoginFailuresReset()); } } @@ -296,10 +297,10 @@ public void setAndGetLockoutResetTest() { credentialImpl3.setLockoutReset(newLockoutReset); credentialImpl4.setLockoutReset(newLockoutReset); - assertEquals("Expected and actual values should be the same.", newLockoutReset, credentialImpl1.getLockoutReset()); - assertEquals("Expected and actual values should be the same.", newLockoutReset, credentialImpl2.getLockoutReset()); - assertEquals("Expected and actual values should be the same.", newLockoutReset, credentialImpl3.getLockoutReset()); - assertEquals("Expected and actual values should be the same.", newLockoutReset, credentialImpl4.getLockoutReset()); + Assert.assertEquals("Expected and actual values should be the same.", newLockoutReset, credentialImpl1.getLockoutReset()); + Assert.assertEquals("Expected and actual values should be the same.", newLockoutReset, credentialImpl2.getLockoutReset()); + Assert.assertEquals("Expected and actual values should be the same.", newLockoutReset, credentialImpl3.getLockoutReset()); + Assert.assertEquals("Expected and actual values should be the same.", newLockoutReset, credentialImpl4.getLockoutReset()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialQueryImplTest.java index fa0d1b7dbeb..7192854baa1 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialQueryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialQueryImplTest.java @@ -18,15 +18,16 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class CredentialQueryImplTest extends Assert { +public class CredentialQueryImplTest { @Test public void credentialQueryImplWithoutParameterTest() { CredentialQueryImpl credentialQueryImpl = new CredentialQueryImpl(); - assertNull("Null expected.", credentialQueryImpl.getScopeId()); - assertNull("credentialQueryImpl.sortCriteria", credentialQueryImpl.getSortCriteria()); - assertNotNull("credentialQueryImpl.defaultSortCriteria", credentialQueryImpl.getDefaultSortCriteria()); + Assert.assertNull("Null expected.", credentialQueryImpl.getScopeId()); + Assert.assertNull("credentialQueryImpl.sortCriteria", credentialQueryImpl.getSortCriteria()); + Assert.assertNotNull("credentialQueryImpl.defaultSortCriteria", credentialQueryImpl.getDefaultSortCriteria()); } @Test @@ -34,9 +35,9 @@ public void credentialQueryImplScopeIdTest() { KapuaId[] scopeIds = {null, KapuaId.ONE}; for (KapuaId scopeId : scopeIds) { CredentialQueryImpl credentialQueryImpl = new CredentialQueryImpl(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, credentialQueryImpl.getScopeId()); - assertNull("credentialQueryImpl.sortCriteria", credentialQueryImpl.getSortCriteria()); - assertNotNull("credentialQueryImpl.defaultSortCriteria", credentialQueryImpl.getDefaultSortCriteria()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, credentialQueryImpl.getScopeId()); + Assert.assertNull("credentialQueryImpl.sortCriteria", credentialQueryImpl.getSortCriteria()); + Assert.assertNotNull("credentialQueryImpl.defaultSortCriteria", credentialQueryImpl.getDefaultSortCriteria()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialServiceImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialServiceImplTest.java index 9855c60c438..4f36ef46d98 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialServiceImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/credential/shiro/CredentialServiceImplTest.java @@ -17,8 +17,9 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class CredentialServiceImplTest extends Assert { +public class CredentialServiceImplTest { @Test public void credentialServiceImplMinimumPasswordLengthTest() { @@ -26,7 +27,7 @@ public void credentialServiceImplMinimumPasswordLengthTest() { try { new CredentialServiceImpl(); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } @@ -36,7 +37,7 @@ public void credentialServiceImplTooShortPasswordLengthTest() { try { new CredentialServiceImpl(); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } @@ -46,7 +47,7 @@ public void credentialServiceNegativePasswordLengthTest() { try { new CredentialServiceImpl(); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } @@ -56,7 +57,7 @@ public void credentialServiceZeroPasswordLengthTest() { try { new CredentialServiceImpl(); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } @@ -66,7 +67,7 @@ public void credentialServiceImplTest() { try { new CredentialServiceImpl(); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } @@ -76,7 +77,7 @@ public void credentialServiceLongPasswordLengthTest() { try { new CredentialServiceImpl(); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } @@ -86,7 +87,7 @@ public void credentialServiceTooLongPasswordLengthTest() { try { new CredentialServiceImpl(); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/AccessTokenCredentialsImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/AccessTokenCredentialsImplTest.java index 4f8ef4607ed..58731a6b519 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/AccessTokenCredentialsImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/AccessTokenCredentialsImplTest.java @@ -18,8 +18,9 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class AccessTokenCredentialsImplTest extends Assert { +public class AccessTokenCredentialsImplTest { @Test(expected = NullPointerException.class) public void accessTokenCredentialsImplCloneConstructorNullTest() { @@ -32,8 +33,8 @@ public void accessTokenCredentialsImplCloneConstructorImplTest() { AccessTokenCredentialsImpl second = new AccessTokenCredentialsImpl(first); - assertNotEquals("AccessTokenCredentialImpl", first, second); - assertEquals("AccessTokenCredential.tokenId", first.getTokenId(), second.getTokenId()); + Assert.assertNotEquals("AccessTokenCredentialImpl", first, second); + Assert.assertEquals("AccessTokenCredential.tokenId", first.getTokenId(), second.getTokenId()); } @Test @@ -42,8 +43,8 @@ public void accessTokenCredentialsImplCloneConstructorAnotherTest() { AccessTokenCredentialsImpl second = new AccessTokenCredentialsImpl(first); - assertNotEquals("AccessTokenCredentialImpl", first, second); - assertEquals("AccessTokenCredential.tokenId", first.getTokenId(), second.getTokenId()); + Assert.assertNotEquals("AccessTokenCredentialImpl", first, second); + Assert.assertEquals("AccessTokenCredential.tokenId", first.getTokenId(), second.getTokenId()); } @Test @@ -52,8 +53,8 @@ public void accessTokenCredentialsImplParseNullTest() { AccessTokenCredentialsImpl second = AccessTokenCredentialsImpl.parse(null); - assertNull("Parsed AccessTokenCredentialsImpl", second); - assertEquals("AccessTokenCredentialImpl", first, second); + Assert.assertNull("Parsed AccessTokenCredentialsImpl", second); + Assert.assertEquals("AccessTokenCredentialImpl", first, second); } @Test @@ -62,8 +63,8 @@ public void accessTokenCredentialsImplParseImplTest() { AccessTokenCredentialsImpl second = AccessTokenCredentialsImpl.parse(first); - assertEquals("AccessTokenCredentialImpl", first, second); - assertEquals("AccessTokenCredential.tokenId", first.getTokenId(), second.getTokenId()); + Assert.assertEquals("AccessTokenCredentialImpl", first, second); + Assert.assertEquals("AccessTokenCredential.tokenId", first.getTokenId(), second.getTokenId()); } @Test @@ -72,8 +73,8 @@ public void accessTokenCredentialsImplParseAnotherTest() { AccessTokenCredentialsImpl second = AccessTokenCredentialsImpl.parse(first); - assertNotEquals("AccessTokenCredentialImpl", first, second); - assertEquals("AccessTokenCredential.tokenId", first.getTokenId(), second.getTokenId()); + Assert.assertNotEquals("AccessTokenCredentialImpl", first, second); + Assert.assertEquals("AccessTokenCredential.tokenId", first.getTokenId(), second.getTokenId()); } @@ -83,9 +84,9 @@ public void accessTokenCredentialsImplTokenIdParameterTest() { for (String tokenId : tokenIds) { AccessTokenCredentialsImpl accessTokenCredentialsImpl = new AccessTokenCredentialsImpl(tokenId); - assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCredentialsImpl.getTokenId()); - assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCredentialsImpl.getPrincipal()); - assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCredentialsImpl.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCredentialsImpl.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCredentialsImpl.getPrincipal()); + Assert.assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCredentialsImpl.getCredentials()); } } @@ -96,9 +97,9 @@ public void setAndGetTokenIdPrincipalAndCredentialsTest() { for (String newTokenId : newTokenIds) { accessTokenCredentialsImpl.setTokenId(newTokenId); - assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenCredentialsImpl.getTokenId()); - assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenCredentialsImpl.getPrincipal()); - assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenCredentialsImpl.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenCredentialsImpl.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenCredentialsImpl.getPrincipal()); + Assert.assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenCredentialsImpl.getCredentials()); } } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/ApiKeyCredentialsImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/ApiKeyCredentialsImplTest.java index 815d81fa1db..cbe21eb1241 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/ApiKeyCredentialsImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/ApiKeyCredentialsImplTest.java @@ -18,8 +18,9 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class ApiKeyCredentialsImplTest extends Assert { +public class ApiKeyCredentialsImplTest { @Test(expected = NullPointerException.class) public void apiKeyCredentialsImplCloneConstructorNullTest() { @@ -32,8 +33,8 @@ public void apiKeyCredentialsImplCloneConstructorImplTest() { ApiKeyCredentialsImpl second = new ApiKeyCredentialsImpl(first); - assertNotEquals("ApiKeyCredentialImpl", first, second); - assertEquals("ApiKeyCredential.apiKey", first.getApiKey(), second.getApiKey()); + Assert.assertNotEquals("ApiKeyCredentialImpl", first, second); + Assert.assertEquals("ApiKeyCredential.apiKey", first.getApiKey(), second.getApiKey()); } @Test @@ -42,8 +43,8 @@ public void apiKeyCredentialsImplCloneConstructorAnotherTest() { ApiKeyCredentialsImpl second = new ApiKeyCredentialsImpl(first); - assertNotEquals("ApiKeyCredentialImpl", first, second); - assertEquals("ApiKeyCredential.apiKey", first.getApiKey(), second.getApiKey()); + Assert.assertNotEquals("ApiKeyCredentialImpl", first, second); + Assert.assertEquals("ApiKeyCredential.apiKey", first.getApiKey(), second.getApiKey()); } @Test @@ -52,8 +53,8 @@ public void apiKeyCredentialsImplParseNullTest() { ApiKeyCredentialsImpl second = ApiKeyCredentialsImpl.parse(null); - assertNull("Parsed ApiKeyCredentialsImpl", second); - assertEquals("ApiKeyCredentialImpl", first, second); + Assert.assertNull("Parsed ApiKeyCredentialsImpl", second); + Assert.assertEquals("ApiKeyCredentialImpl", first, second); } @Test @@ -62,8 +63,8 @@ public void apiKeyCredentialsImplParseImplTest() { ApiKeyCredentialsImpl second = ApiKeyCredentialsImpl.parse(first); - assertEquals("ApiKeyCredentialImpl", first, second); - assertEquals("ApiKeyCredential.apiKey", first.getApiKey(), second.getApiKey()); + Assert.assertEquals("ApiKeyCredentialImpl", first, second); + Assert.assertEquals("ApiKeyCredential.apiKey", first.getApiKey(), second.getApiKey()); } @Test @@ -72,8 +73,8 @@ public void apiKeyCredentialsImplParseAnotherTest() { ApiKeyCredentialsImpl second = ApiKeyCredentialsImpl.parse(first); - assertNotEquals("ApiKeyCredentialImpl", first, second); - assertEquals("ApiKeyCredential.apiKey", first.getApiKey(), second.getApiKey()); + Assert.assertNotEquals("ApiKeyCredentialImpl", first, second); + Assert.assertEquals("ApiKeyCredential.apiKey", first.getApiKey(), second.getApiKey()); } @Test @@ -82,9 +83,9 @@ public void apiKeyCredentialsImplTest() { for (String apiKey : apiKeys) { ApiKeyCredentialsImpl apiKeyCredentialsImpl = new ApiKeyCredentialsImpl(apiKey); - assertEquals("Expected and actual values should be the same.", apiKey, apiKeyCredentialsImpl.getApiKey()); - assertEquals("Expected and actual values should be the same.", apiKey, apiKeyCredentialsImpl.getPrincipal()); - assertEquals("Expected and actual values should be the same.", apiKey, apiKeyCredentialsImpl.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", apiKey, apiKeyCredentialsImpl.getApiKey()); + Assert.assertEquals("Expected and actual values should be the same.", apiKey, apiKeyCredentialsImpl.getPrincipal()); + Assert.assertEquals("Expected and actual values should be the same.", apiKey, apiKeyCredentialsImpl.getCredentials()); } } @@ -95,9 +96,9 @@ public void setAndGetApiKeyPrincipalAndCredentialsTest() { for (String newApiKey : newApiKeys) { apiKeyCredentialsImpl.setApiKey(newApiKey); - assertEquals("Expected and actual values should be the same.", newApiKey, apiKeyCredentialsImpl.getApiKey()); - assertEquals("Expected and actual values should be the same.", newApiKey, apiKeyCredentialsImpl.getPrincipal()); - assertEquals("Expected and actual values should be the same.", newApiKey, apiKeyCredentialsImpl.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", newApiKey, apiKeyCredentialsImpl.getApiKey()); + Assert.assertEquals("Expected and actual values should be the same.", newApiKey, apiKeyCredentialsImpl.getPrincipal()); + Assert.assertEquals("Expected and actual values should be the same.", newApiKey, apiKeyCredentialsImpl.getCredentials()); } } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/CredentialsFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/CredentialsFactoryImplTest.java index ba820800ed5..25c28463c56 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/CredentialsFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/CredentialsFactoryImplTest.java @@ -24,8 +24,9 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class CredentialsFactoryImplTest extends Assert { +public class CredentialsFactoryImplTest { CredentialsFactoryImpl credentialsFactoryImpl; String[] usernames, passwords, apiKeys, idTokens, accessTokens, refreshTokens; @@ -46,8 +47,8 @@ public void newUsernamePasswordCredentialsTest() { for (String username : usernames) { for (String password : passwords) { UsernamePasswordCredentials usernamePasswordCredentials = credentialsFactoryImpl.newUsernamePasswordCredentials(username, password); - assertEquals("Expected and actual values should be the same.", username, usernamePasswordCredentials.getUsername()); - assertEquals("Expected and actual values should be the same.", password, usernamePasswordCredentials.getPassword()); + Assert.assertEquals("Expected and actual values should be the same.", username, usernamePasswordCredentials.getUsername()); + Assert.assertEquals("Expected and actual values should be the same.", password, usernamePasswordCredentials.getPassword()); } } } @@ -56,7 +57,7 @@ public void newUsernamePasswordCredentialsTest() { public void newApiKeyCredentialsTest() { for (String apiKey : apiKeys) { ApiKeyCredentials apiKeyCredentials = credentialsFactoryImpl.newApiKeyCredentials(apiKey); - assertEquals("Expected and actual values should be the same.", apiKey, apiKeyCredentials.getApiKey()); + Assert.assertEquals("Expected and actual values should be the same.", apiKey, apiKeyCredentials.getApiKey()); } } @@ -65,8 +66,8 @@ public void newJwtCredentialsTest() { for (String accessToken : accessTokens) { for (String idToken : idTokens) { JwtCredentials jwtCredentials = credentialsFactoryImpl.newJwtCredentials(accessToken, idToken); - assertEquals("Expected and actual values should be the same.", accessToken, jwtCredentials.getAccessToken()); - assertEquals("Expected and actual values should be the same.", idToken, jwtCredentials.getIdToken()); + Assert.assertEquals("Expected and actual values should be the same.", accessToken, jwtCredentials.getAccessToken()); + Assert.assertEquals("Expected and actual values should be the same.", idToken, jwtCredentials.getIdToken()); } } } @@ -75,7 +76,7 @@ public void newJwtCredentialsTest() { public void newAccessTokenCredentialsTest() { for (String idToken : idTokens) { AccessTokenCredentials accessTokenCredentials = credentialsFactoryImpl.newAccessTokenCredentials(idToken); - assertEquals("Expected and actual values should be the same.", idToken, accessTokenCredentials.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", idToken, accessTokenCredentials.getTokenId()); } } @@ -84,8 +85,8 @@ public void newRefreshTokenCredentialsTest() { for (String idToken : idTokens) { for (String refreshToken : refreshTokens) { RefreshTokenCredentials refreshTokenCredentials = credentialsFactoryImpl.newRefreshTokenCredentials(idToken, refreshToken); - assertEquals("Expected and actual values should be the same.", idToken, refreshTokenCredentials.getTokenId()); - assertEquals("Expected and actual values should be the same.", refreshToken, refreshTokenCredentials.getRefreshToken()); + Assert.assertEquals("Expected and actual values should be the same.", idToken, refreshTokenCredentials.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", refreshToken, refreshTokenCredentials.getRefreshToken()); } } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/JwtCredentialsTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/JwtCredentialsTest.java index 82dbc85ffcf..c991bc4d020 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/JwtCredentialsTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/JwtCredentialsTest.java @@ -19,8 +19,9 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class JwtCredentialsTest extends Assert { +public class JwtCredentialsTest { JwtCredentialsImpl jwtCredentialsImpl; String[] accessTokens, idsToken, newAccessTokens, newIdsToken; @@ -45,9 +46,9 @@ public void jwtCredentialsImplCloneConstructorImplTest() { JwtCredentialsImpl second = new JwtCredentialsImpl(first); - assertNotEquals("JwtCredentialImpl", first, second); - assertEquals("JwtCredential.accessToken", first.getAccessToken(), second.getAccessToken()); - assertEquals("JwtCredential.idToken", first.getIdToken(), second.getIdToken()); + Assert.assertNotEquals("JwtCredentialImpl", first, second); + Assert.assertEquals("JwtCredential.accessToken", first.getAccessToken(), second.getAccessToken()); + Assert.assertEquals("JwtCredential.idToken", first.getIdToken(), second.getIdToken()); } @Test @@ -56,9 +57,9 @@ public void jwtCredentialsImplCloneConstructorAnotherTest() { JwtCredentialsImpl second = new JwtCredentialsImpl(first); - assertNotEquals("JwtCredentialImpl", first, second); - assertEquals("JwtCredential.accessToken", first.getAccessToken(), second.getAccessToken()); - assertEquals("JwtCredential.idToken", first.getIdToken(), second.getIdToken()); + Assert.assertNotEquals("JwtCredentialImpl", first, second); + Assert.assertEquals("JwtCredential.accessToken", first.getAccessToken(), second.getAccessToken()); + Assert.assertEquals("JwtCredential.idToken", first.getIdToken(), second.getIdToken()); } @Test @@ -67,8 +68,8 @@ public void jwtCredentialsImplParseNullTest() { JwtCredentialsImpl second = JwtCredentialsImpl.parse(null); - assertNull("Parsed JwtCredentialsImpl", second); - assertEquals("JwtCredentialImpl", first, second); + Assert.assertNull("Parsed JwtCredentialsImpl", second); + Assert.assertEquals("JwtCredentialImpl", first, second); } @Test @@ -77,9 +78,9 @@ public void jwtCredentialsImplParseImplTest() { JwtCredentialsImpl second = JwtCredentialsImpl.parse(first); - assertEquals("JwtCredentialImpl", first, second); - assertEquals("JwtCredential.accessToken", first.getAccessToken(), second.getAccessToken()); - assertEquals("JwtCredential.idToken", first.getIdToken(), second.getIdToken()); + Assert.assertEquals("JwtCredentialImpl", first, second); + Assert.assertEquals("JwtCredential.accessToken", first.getAccessToken(), second.getAccessToken()); + Assert.assertEquals("JwtCredential.idToken", first.getIdToken(), second.getIdToken()); } @Test @@ -88,9 +89,9 @@ public void jwtCredentialsImplParseAnotherTest() { JwtCredentialsImpl second = JwtCredentialsImpl.parse(first); - assertNotEquals("JwtCredentialImpl", first, second); - assertEquals("JwtCredential.accessToken", first.getAccessToken(), second.getAccessToken()); - assertEquals("JwtCredential.idToken", first.getIdToken(), second.getIdToken()); + Assert.assertNotEquals("JwtCredentialImpl", first, second); + Assert.assertEquals("JwtCredential.accessToken", first.getAccessToken(), second.getAccessToken()); + Assert.assertEquals("JwtCredential.idToken", first.getIdToken(), second.getIdToken()); } @@ -99,10 +100,10 @@ public void jwtCredentialsImplTest() { for (String accessToken : accessTokens) { for (String idToken : idsToken) { JwtCredentialsImpl jwtCredentialsImpl = new JwtCredentialsImpl(accessToken, idToken); - assertEquals("Expected and actual values should be the same.", accessToken, jwtCredentialsImpl.getAccessToken()); - assertEquals("Expected and actual values should be the same.", idToken, jwtCredentialsImpl.getIdToken()); - assertEquals("Expected and actual values should be the same.", accessToken, jwtCredentialsImpl.getPrincipal()); - assertEquals("Expected and actual values should be the same.", accessToken, jwtCredentialsImpl.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", accessToken, jwtCredentialsImpl.getAccessToken()); + Assert.assertEquals("Expected and actual values should be the same.", idToken, jwtCredentialsImpl.getIdToken()); + Assert.assertEquals("Expected and actual values should be the same.", accessToken, jwtCredentialsImpl.getPrincipal()); + Assert.assertEquals("Expected and actual values should be the same.", accessToken, jwtCredentialsImpl.getCredentials()); } } } @@ -111,9 +112,9 @@ public void jwtCredentialsImplTest() { public void setAndGetJwtPrincipalAndCredentialTest() { for (String newAccessToken : newAccessTokens) { jwtCredentialsImpl.setAccessToken(newAccessToken); - assertEquals("Expected and actual values should be the same.", newAccessToken, jwtCredentialsImpl.getAccessToken()); - assertEquals("Expected and actual values should be the same.", newAccessToken, jwtCredentialsImpl.getPrincipal()); - assertEquals("Expected and actual values should be the same.", newAccessToken, jwtCredentialsImpl.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", newAccessToken, jwtCredentialsImpl.getAccessToken()); + Assert.assertEquals("Expected and actual values should be the same.", newAccessToken, jwtCredentialsImpl.getPrincipal()); + Assert.assertEquals("Expected and actual values should be the same.", newAccessToken, jwtCredentialsImpl.getCredentials()); } } @@ -121,7 +122,7 @@ public void setAndGetJwtPrincipalAndCredentialTest() { public void setAndGetIdTokenTest() { for (String newIdToken : newIdsToken) { jwtCredentialsImpl.setIdToken(newIdToken); - assertEquals("Expected and actual values should be the same.", newIdToken, jwtCredentialsImpl.getIdToken()); + Assert.assertEquals("Expected and actual values should be the same.", newIdToken, jwtCredentialsImpl.getIdToken()); } } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/KapuaAuthenticationExceptionTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/KapuaAuthenticationExceptionTest.java index 4c1c1b54d20..f706ceb23e1 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/KapuaAuthenticationExceptionTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/KapuaAuthenticationExceptionTest.java @@ -19,8 +19,9 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class KapuaAuthenticationExceptionTest extends Assert { +public class KapuaAuthenticationExceptionTest { KapuaAuthenticationErrorCodes[] kapuaAuthenticationErrorCodes; String kapuaErrorMessage, expectedMessageWithoutArguments, expectedMessageWithArguments; @@ -47,10 +48,10 @@ public void initialize() { public void kapuaAuthenticationExceptionCodeParameterTest() { for (KapuaAuthenticationErrorCodes kapuaAuthenticationErrorCode : kapuaAuthenticationErrorCodes) { KapuaAuthenticationException kapuaAuthenticationException = new KapuaAuthenticationException(kapuaAuthenticationErrorCode); - assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, kapuaAuthenticationException.getCode()); - assertEquals("Expected and actual values should be the same.", expectedMessageWithoutArguments, kapuaAuthenticationException.getMessage()); - assertNull("Null expected.", kapuaAuthenticationException.getCause()); - assertEquals("Expected and actual values should be the same.", kapuaErrorMessage, kapuaAuthenticationException.getKapuaErrorMessagesBundle()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, kapuaAuthenticationException.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", expectedMessageWithoutArguments, kapuaAuthenticationException.getMessage()); + Assert.assertNull("Null expected.", kapuaAuthenticationException.getCause()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaErrorMessage, kapuaAuthenticationException.getKapuaErrorMessagesBundle()); } } @@ -58,10 +59,10 @@ public void kapuaAuthenticationExceptionCodeParameterTest() { public void kapuaAuthenticationExceptionCodeArgumentsParametersTest() { for (KapuaAuthenticationErrorCodes kapuaAuthenticationErrorCode : kapuaAuthenticationErrorCodes) { KapuaAuthenticationException kapuaAuthenticationException = new KapuaAuthenticationException(kapuaAuthenticationErrorCode, stringObject, intObject, charObject); - assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, kapuaAuthenticationException.getCode()); - assertEquals("Expected and actual values should be the same.", expectedMessageWithArguments, kapuaAuthenticationException.getMessage()); - assertNull("Null expected.", kapuaAuthenticationException.getCause()); - assertEquals("Expected and actual values should be the same.", kapuaErrorMessage, kapuaAuthenticationException.getKapuaErrorMessagesBundle()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, kapuaAuthenticationException.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", expectedMessageWithArguments, kapuaAuthenticationException.getMessage()); + Assert.assertNull("Null expected.", kapuaAuthenticationException.getCause()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaErrorMessage, kapuaAuthenticationException.getKapuaErrorMessagesBundle()); } } @@ -69,10 +70,10 @@ public void kapuaAuthenticationExceptionCodeArgumentsParametersTest() { public void kapuaAuthenticationExceptionCodeNullArgumentsParametersTest() { for (KapuaAuthenticationErrorCodes kapuaAuthenticationErrorCode : kapuaAuthenticationErrorCodes) { KapuaAuthenticationException kapuaAuthenticationException = new KapuaAuthenticationException(kapuaAuthenticationErrorCode, null); - assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, kapuaAuthenticationException.getCode()); - assertEquals("Expected and actual values should be the same.", expectedMessageWithoutArguments, kapuaAuthenticationException.getMessage()); - assertNull("Null expected.", kapuaAuthenticationException.getCause()); - assertEquals("Expected and actual values should be the same.", kapuaErrorMessage, kapuaAuthenticationException.getKapuaErrorMessagesBundle()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, kapuaAuthenticationException.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", expectedMessageWithoutArguments, kapuaAuthenticationException.getMessage()); + Assert.assertNull("Null expected.", kapuaAuthenticationException.getCause()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaErrorMessage, kapuaAuthenticationException.getKapuaErrorMessagesBundle()); } } @@ -81,10 +82,10 @@ public void kapuaAuthenticationExceptionCodeCauseArgumentsParametersTest() { for (KapuaAuthenticationErrorCodes kapuaAuthenticationErrorCode : kapuaAuthenticationErrorCodes) { for (Throwable throwable : throwables) { KapuaAuthenticationException kapuaAuthenticationException = new KapuaAuthenticationException(kapuaAuthenticationErrorCode, throwable, stringObject, intObject, charObject); - assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, kapuaAuthenticationException.getCode()); - assertEquals("Expected and actual values should be the same.", expectedMessageWithArguments, kapuaAuthenticationException.getMessage()); - assertEquals("Expected and actual values should be the same.", throwable, kapuaAuthenticationException.getCause()); - assertEquals("Expected and actual values should be the same.", kapuaErrorMessage, kapuaAuthenticationException.getKapuaErrorMessagesBundle()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, kapuaAuthenticationException.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", expectedMessageWithArguments, kapuaAuthenticationException.getMessage()); + Assert.assertEquals("Expected and actual values should be the same.", throwable, kapuaAuthenticationException.getCause()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaErrorMessage, kapuaAuthenticationException.getKapuaErrorMessagesBundle()); } } } @@ -94,10 +95,10 @@ public void kapuaAuthenticationExceptionCodeCauseNullArgumentsParametersTest() { for (KapuaAuthenticationErrorCodes kapuaAuthenticationErrorCode : kapuaAuthenticationErrorCodes) { for (Throwable throwable : throwables) { KapuaAuthenticationException kapuaAuthenticationException = new KapuaAuthenticationException(kapuaAuthenticationErrorCode, throwable, null); - assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, kapuaAuthenticationException.getCode()); - assertEquals("Expected and actual values should be the same.", expectedMessageWithoutArguments, kapuaAuthenticationException.getMessage()); - assertEquals("Expected and actual values should be the same.", throwable, kapuaAuthenticationException.getCause()); - assertEquals("Expected and actual values should be the same.", kapuaErrorMessage, kapuaAuthenticationException.getKapuaErrorMessagesBundle()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, kapuaAuthenticationException.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", expectedMessageWithoutArguments, kapuaAuthenticationException.getMessage()); + Assert.assertEquals("Expected and actual values should be the same.", throwable, kapuaAuthenticationException.getCause()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaErrorMessage, kapuaAuthenticationException.getKapuaErrorMessagesBundle()); } } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/RefreshTokenCredentialsImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/RefreshTokenCredentialsImplTest.java index 5636d3d33b4..03f494db645 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/RefreshTokenCredentialsImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/RefreshTokenCredentialsImplTest.java @@ -18,8 +18,9 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class RefreshTokenCredentialsImplTest extends Assert { +public class RefreshTokenCredentialsImplTest { String[] idsToken, refreshTokens, newIdsToken, newRefreshTokens; RefreshTokenCredentialsImpl refreshTokenCredentialsImpl; @@ -37,8 +38,8 @@ public void refreshTokenCredentialsImplTest() { for (String idToken : idsToken) { for (String refreshToken : refreshTokens) { refreshTokenCredentialsImpl = new RefreshTokenCredentialsImpl(idToken, refreshToken); - assertEquals("Expected and actual values should be the same.", idToken, refreshTokenCredentialsImpl.getTokenId()); - assertEquals("Expected and actual values should be the same.", refreshToken, refreshTokenCredentialsImpl.getRefreshToken()); + Assert.assertEquals("Expected and actual values should be the same.", idToken, refreshTokenCredentialsImpl.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", refreshToken, refreshTokenCredentialsImpl.getRefreshToken()); } } } @@ -48,7 +49,7 @@ public void setAndGetTokenIdTest() { refreshTokenCredentialsImpl = new RefreshTokenCredentialsImpl("token id", "refresh token"); for (String newIdToken : newIdsToken) { refreshTokenCredentialsImpl.setTokenId(newIdToken); - assertEquals("Expected and actual values should be the same.", newIdToken, refreshTokenCredentialsImpl.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", newIdToken, refreshTokenCredentialsImpl.getTokenId()); } } @@ -57,7 +58,7 @@ public void setAndGetRefreshTokenTest() { refreshTokenCredentialsImpl = new RefreshTokenCredentialsImpl("token id", "refresh token"); for (String newRefreshToken : newRefreshTokens) { refreshTokenCredentialsImpl.setRefreshToken(newRefreshToken); - assertEquals("Expected and actual values should be the same.", newRefreshToken, refreshTokenCredentialsImpl.getRefreshToken()); + Assert.assertEquals("Expected and actual values should be the same.", newRefreshToken, refreshTokenCredentialsImpl.getRefreshToken()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/UsernamePasswordCredentialsImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/UsernamePasswordCredentialsImplTest.java index af3d55a8bc1..3f203b974bf 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/UsernamePasswordCredentialsImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/UsernamePasswordCredentialsImplTest.java @@ -19,8 +19,9 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class UsernamePasswordCredentialsImplTest extends Assert { +public class UsernamePasswordCredentialsImplTest { String[] usernames, passwords, newUsernames, newPasswords, trustKeys, authenticationCodes; UsernamePasswordCredentialsImpl usernamePasswordCredentialsImpl; @@ -49,11 +50,11 @@ public void usernamePasswordCredentialsImplCloneConstructorImplTest() { UsernamePasswordCredentialsImpl second = new UsernamePasswordCredentialsImpl(first); - assertNotEquals("UsernamePasswordCredentialImpl", first, second); - assertEquals("UsernamePasswordCredential.username", first.getUsername(), second.getUsername()); - assertEquals("UsernamePasswordCredential.password", first.getPassword(), second.getPassword()); - assertEquals("UsernamePasswordCredential.trustKey", first.getTrustKey(), second.getTrustKey()); - assertEquals("UsernamePasswordCredential.authenticationCode", first.getAuthenticationCode(), second.getAuthenticationCode()); + Assert.assertNotEquals("UsernamePasswordCredentialImpl", first, second); + Assert.assertEquals("UsernamePasswordCredential.username", first.getUsername(), second.getUsername()); + Assert.assertEquals("UsernamePasswordCredential.password", first.getPassword(), second.getPassword()); + Assert.assertEquals("UsernamePasswordCredential.trustKey", first.getTrustKey(), second.getTrustKey()); + Assert.assertEquals("UsernamePasswordCredential.authenticationCode", first.getAuthenticationCode(), second.getAuthenticationCode()); } @@ -65,11 +66,11 @@ public void usernamePasswordCredentialsImplCloneConstructorAnotherTest() { UsernamePasswordCredentialsImpl second = new UsernamePasswordCredentialsImpl(first); - assertNotEquals("UsernamePasswordCredentialImpl", first, second); - assertEquals("UsernamePasswordCredential.username", first.getUsername(), second.getUsername()); - assertEquals("UsernamePasswordCredential.password", first.getPassword(), second.getPassword()); - assertEquals("UsernamePasswordCredential.trustKey", first.getTrustKey(), second.getTrustKey()); - assertEquals("UsernamePasswordCredential.authenticationCode", first.getAuthenticationCode(), second.getAuthenticationCode()); + Assert.assertNotEquals("UsernamePasswordCredentialImpl", first, second); + Assert.assertEquals("UsernamePasswordCredential.username", first.getUsername(), second.getUsername()); + Assert.assertEquals("UsernamePasswordCredential.password", first.getPassword(), second.getPassword()); + Assert.assertEquals("UsernamePasswordCredential.trustKey", first.getTrustKey(), second.getTrustKey()); + Assert.assertEquals("UsernamePasswordCredential.authenticationCode", first.getAuthenticationCode(), second.getAuthenticationCode()); } @Test @@ -78,8 +79,8 @@ public void usernamePasswordCredentialsImplParseNullTest() { UsernamePasswordCredentialsImpl second = UsernamePasswordCredentialsImpl.parse(null); - assertNull("Parsed UsernamePasswordCredentialsImpl", second); - assertEquals("UsernamePasswordCredentialImpl", first, second); + Assert.assertNull("Parsed UsernamePasswordCredentialsImpl", second); + Assert.assertEquals("UsernamePasswordCredentialImpl", first, second); } @Test @@ -90,11 +91,11 @@ public void usernamePasswordCredentialsImplParseImplTest() { UsernamePasswordCredentialsImpl second = UsernamePasswordCredentialsImpl.parse(first); - assertEquals("UsernamePasswordCredentialImpl", first, second); - assertEquals("UsernamePasswordCredential.username", first.getUsername(), second.getUsername()); - assertEquals("UsernamePasswordCredential.password", first.getPassword(), second.getPassword()); - assertEquals("UsernamePasswordCredential.trustKey", first.getTrustKey(), second.getTrustKey()); - assertEquals("UsernamePasswordCredential.authenticationCode", first.getAuthenticationCode(), second.getAuthenticationCode()); + Assert.assertEquals("UsernamePasswordCredentialImpl", first, second); + Assert.assertEquals("UsernamePasswordCredential.username", first.getUsername(), second.getUsername()); + Assert.assertEquals("UsernamePasswordCredential.password", first.getPassword(), second.getPassword()); + Assert.assertEquals("UsernamePasswordCredential.trustKey", first.getTrustKey(), second.getTrustKey()); + Assert.assertEquals("UsernamePasswordCredential.authenticationCode", first.getAuthenticationCode(), second.getAuthenticationCode()); } @Test @@ -105,11 +106,11 @@ public void usernamePasswordCredentiaslImplParseAnotherTest() { UsernamePasswordCredentialsImpl second = UsernamePasswordCredentialsImpl.parse(first); - assertNotEquals("UsernamePasswordCredentialImpl", first, second); - assertEquals("UsernamePasswordCredential.username", first.getUsername(), second.getUsername()); - assertEquals("UsernamePasswordCredential.password", first.getPassword(), second.getPassword()); - assertEquals("UsernamePasswordCredential.trustKey", first.getTrustKey(), second.getTrustKey()); - assertEquals("UsernamePasswordCredential.authenticationCode", first.getAuthenticationCode(), second.getAuthenticationCode()); + Assert.assertNotEquals("UsernamePasswordCredentialImpl", first, second); + Assert.assertEquals("UsernamePasswordCredential.username", first.getUsername(), second.getUsername()); + Assert.assertEquals("UsernamePasswordCredential.password", first.getPassword(), second.getPassword()); + Assert.assertEquals("UsernamePasswordCredential.trustKey", first.getTrustKey(), second.getTrustKey()); + Assert.assertEquals("UsernamePasswordCredential.authenticationCode", first.getAuthenticationCode(), second.getAuthenticationCode()); } @Test @@ -117,12 +118,12 @@ public void usernamePasswordCredentialsImplTest() { for (String username : usernames) { for (String password : passwords) { UsernamePasswordCredentialsImpl usernamePasswordCredentialsImpl = new UsernamePasswordCredentialsImpl(username, password); - assertEquals("Expected and actual values should be the same.", username, usernamePasswordCredentialsImpl.getUsername()); - assertEquals("Expected and actual values should be the same.", username, usernamePasswordCredentialsImpl.getPrincipal()); - assertEquals("Expected and actual values should be the same.", password, usernamePasswordCredentialsImpl.getPassword()); - assertEquals("Expected and actual values should be the same.", password, usernamePasswordCredentialsImpl.getCredentials()); - assertNull("Null expected.", usernamePasswordCredentialsImpl.getAuthenticationCode()); - assertNull("Null expected.", usernamePasswordCredentialsImpl.getTrustKey()); + Assert.assertEquals("Expected and actual values should be the same.", username, usernamePasswordCredentialsImpl.getUsername()); + Assert.assertEquals("Expected and actual values should be the same.", username, usernamePasswordCredentialsImpl.getPrincipal()); + Assert.assertEquals("Expected and actual values should be the same.", password, usernamePasswordCredentialsImpl.getPassword()); + Assert.assertEquals("Expected and actual values should be the same.", password, usernamePasswordCredentialsImpl.getCredentials()); + Assert.assertNull("Null expected.", usernamePasswordCredentialsImpl.getAuthenticationCode()); + Assert.assertNull("Null expected.", usernamePasswordCredentialsImpl.getTrustKey()); } } } @@ -131,8 +132,8 @@ public void usernamePasswordCredentialsImplTest() { public void setAndGetUsernameAndPrincipalTest() { for (String newUsername : newUsernames) { usernamePasswordCredentialsImpl.setUsername(newUsername); - assertEquals("Expected and actual values should be the same.", newUsername, usernamePasswordCredentialsImpl.getUsername()); - assertEquals("Expected and actual values should be the same.", newUsername, usernamePasswordCredentialsImpl.getPrincipal()); + Assert.assertEquals("Expected and actual values should be the same.", newUsername, usernamePasswordCredentialsImpl.getUsername()); + Assert.assertEquals("Expected and actual values should be the same.", newUsername, usernamePasswordCredentialsImpl.getPrincipal()); } } @@ -140,8 +141,8 @@ public void setAndGetUsernameAndPrincipalTest() { public void setAndGetPasswordAndCredentialsTest() { for (String newPassword : newPasswords) { usernamePasswordCredentialsImpl.setPassword(newPassword); - assertEquals("Expected and actual values should be the same.", newPassword, usernamePasswordCredentialsImpl.getPassword()); - assertEquals("Expected and actual values should be the same.", newPassword, usernamePasswordCredentialsImpl.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", newPassword, usernamePasswordCredentialsImpl.getPassword()); + Assert.assertEquals("Expected and actual values should be the same.", newPassword, usernamePasswordCredentialsImpl.getCredentials()); } } @@ -149,7 +150,7 @@ public void setAndGetPasswordAndCredentialsTest() { public void setAndGetAuthenticationCodeTest() { for (String authenticationCode : authenticationCodes) { usernamePasswordCredentialsImpl.setAuthenticationCode(authenticationCode); - assertEquals("Expected and actual values should be the same.", authenticationCode, usernamePasswordCredentialsImpl.getAuthenticationCode()); + Assert.assertEquals("Expected and actual values should be the same.", authenticationCode, usernamePasswordCredentialsImpl.getAuthenticationCode()); } } @@ -157,7 +158,7 @@ public void setAndGetAuthenticationCodeTest() { public void setAndGetTrustKeyTest() { for (String trustKey : trustKeys) { usernamePasswordCredentialsImpl.setTrustKey(trustKey); - assertEquals("Expected and actual values should be the same.", trustKey, usernamePasswordCredentialsImpl.getTrustKey()); + Assert.assertEquals("Expected and actual values should be the same.", trustKey, usernamePasswordCredentialsImpl.getTrustKey()); } } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/AuthenticationRuntimeExceptionTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/AuthenticationRuntimeExceptionTest.java index de53a565625..3747298aad7 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/AuthenticationRuntimeExceptionTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/AuthenticationRuntimeExceptionTest.java @@ -19,8 +19,9 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class AuthenticationRuntimeExceptionTest extends Assert { +public class AuthenticationRuntimeExceptionTest { KapuaAuthenticationErrorCodes[] kapuaAuthenticationErrorCodes; Object stringArgument, intArgument, booleanArgument; @@ -47,21 +48,21 @@ public void initialize() { public void authenticationRuntimeExceptionCodeParameterTest() { for (KapuaAuthenticationErrorCodes kapuaAuthenticationErrorCode : kapuaAuthenticationErrorCodes) { AuthenticationRuntimeException authenticationRuntimeException = new AuthenticationRuntimeException(kapuaAuthenticationErrorCode); - assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, authenticationRuntimeException.getCode()); - assertEquals("Expected and actual values should be the same.", errorMessageWithoutArguments, authenticationRuntimeException.getMessage()); - assertNull("Null expected.", authenticationRuntimeException.getCause()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, authenticationRuntimeException.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", errorMessageWithoutArguments, authenticationRuntimeException.getMessage()); + Assert.assertNull("Null expected.", authenticationRuntimeException.getCause()); } } @Test public void authenticationRuntimeExceptionNullCodeParameterTest() { AuthenticationRuntimeException authenticationRuntimeException = new AuthenticationRuntimeException(null); - assertNull("Null expected.", authenticationRuntimeException.getCode()); - assertNull("Null expected.", authenticationRuntimeException.getCause()); + Assert.assertNull("Null expected.", authenticationRuntimeException.getCode()); + Assert.assertNull("Null expected.", authenticationRuntimeException.getCause()); try { authenticationRuntimeException.getMessage(); } catch (Exception e) { - assertEquals("Expected and actual values should be the same.", new NullPointerException().toString(), e.toString()); + Assert.assertEquals("Expected and actual values should be the same.", new NullPointerException().toString(), e.toString()); } } @@ -69,21 +70,21 @@ public void authenticationRuntimeExceptionNullCodeParameterTest() { public void authenticationRuntimeExceptionCodeArgumentParametersTest() { for (KapuaAuthenticationErrorCodes kapuaAuthenticationErrorCode : kapuaAuthenticationErrorCodes) { AuthenticationRuntimeException authenticationRuntimeException = new AuthenticationRuntimeException(kapuaAuthenticationErrorCode, stringArgument, intArgument, booleanArgument); - assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, authenticationRuntimeException.getCode()); - assertEquals("Expected and actual values should be the same.", errorMessageWithArguments, authenticationRuntimeException.getMessage()); - assertNull("Null expected.", authenticationRuntimeException.getCause()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, authenticationRuntimeException.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", errorMessageWithArguments, authenticationRuntimeException.getMessage()); + Assert.assertNull("Null expected.", authenticationRuntimeException.getCause()); } } @Test public void authenticationRuntimeExceptionNullCodeArgumentParametersTest() { AuthenticationRuntimeException authenticationRuntimeException = new AuthenticationRuntimeException(null, stringArgument, intArgument, booleanArgument); - assertNull("Null expected.", authenticationRuntimeException.getCode()); - assertNull("Null expected.", authenticationRuntimeException.getCause()); + Assert.assertNull("Null expected.", authenticationRuntimeException.getCode()); + Assert.assertNull("Null expected.", authenticationRuntimeException.getCause()); try { authenticationRuntimeException.getMessage(); } catch (Exception e) { - assertEquals("Expected and actual values should be the same.", new NullPointerException().toString(), e.toString()); + Assert.assertEquals("Expected and actual values should be the same.", new NullPointerException().toString(), e.toString()); } } @@ -91,9 +92,9 @@ public void authenticationRuntimeExceptionNullCodeArgumentParametersTest() { public void authenticationRuntimeExceptionCodeNullArgumentParametersTest() { for (KapuaAuthenticationErrorCodes kapuaAuthenticationErrorCode : kapuaAuthenticationErrorCodes) { AuthenticationRuntimeException authenticationRuntimeException = new AuthenticationRuntimeException(kapuaAuthenticationErrorCode, null); - assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, authenticationRuntimeException.getCode()); - assertEquals("Expected and actual values should be the same.", errorMessageWithoutArguments, authenticationRuntimeException.getMessage()); - assertNull("Null expected.", authenticationRuntimeException.getCause()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, authenticationRuntimeException.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", errorMessageWithoutArguments, authenticationRuntimeException.getMessage()); + Assert.assertNull("Null expected.", authenticationRuntimeException.getCause()); } } @@ -102,9 +103,9 @@ public void authenticationRuntimeExceptionCodeCauseArgumentsParametersTest() { for (KapuaAuthenticationErrorCodes kapuaAuthenticationErrorCode : kapuaAuthenticationErrorCodes) { for (Throwable throwable : throwables) { AuthenticationRuntimeException authenticationRuntimeException = new AuthenticationRuntimeException(kapuaAuthenticationErrorCode, throwable, stringArgument, intArgument, booleanArgument); - assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, authenticationRuntimeException.getCode()); - assertEquals("Expected and actual values should be the same.", errorMessageWithArguments, authenticationRuntimeException.getMessage()); - assertEquals("Expected and actual values should be the same.", throwable, authenticationRuntimeException.getCause()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, authenticationRuntimeException.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", errorMessageWithArguments, authenticationRuntimeException.getMessage()); + Assert.assertEquals("Expected and actual values should be the same.", throwable, authenticationRuntimeException.getCause()); } } } @@ -113,12 +114,12 @@ public void authenticationRuntimeExceptionCodeCauseArgumentsParametersTest() { public void authenticationRuntimeExceptionNullCodeCauseArgumentsParametersTest() { for (Throwable throwable : throwables) { AuthenticationRuntimeException authenticationRuntimeException = new AuthenticationRuntimeException(null, throwable, stringArgument, intArgument, booleanArgument); - assertNull("Null expected.", authenticationRuntimeException.getCode()); - assertEquals("Expected and actual values should be the same.", throwable, authenticationRuntimeException.getCause()); + Assert.assertNull("Null expected.", authenticationRuntimeException.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", throwable, authenticationRuntimeException.getCause()); try { authenticationRuntimeException.getMessage(); } catch (Exception e) { - assertEquals("Expected and actual values should be the same.", new NullPointerException().toString(), e.toString()); + Assert.assertEquals("Expected and actual values should be the same.", new NullPointerException().toString(), e.toString()); } } } @@ -128,9 +129,9 @@ public void authenticationRuntimeExceptionCodeCauseNullArgumentsParametersTest() for (KapuaAuthenticationErrorCodes kapuaAuthenticationErrorCode : kapuaAuthenticationErrorCodes) { for (Throwable throwable : throwables) { AuthenticationRuntimeException authenticationRuntimeException = new AuthenticationRuntimeException(kapuaAuthenticationErrorCode, throwable, null); - assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, authenticationRuntimeException.getCode()); - assertEquals("Expected and actual values should be the same.", errorMessageWithoutArguments, authenticationRuntimeException.getMessage()); - assertEquals("Expected and actual values should be the same.", throwable, authenticationRuntimeException.getCause()); + Assert.assertEquals("Expected and actual values should be the same.", kapuaAuthenticationErrorCode, authenticationRuntimeException.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", errorMessageWithoutArguments, authenticationRuntimeException.getMessage()); + Assert.assertEquals("Expected and actual values should be the same.", throwable, authenticationRuntimeException.getCause()); } } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/ExpiredAccountExceptionTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/ExpiredAccountExceptionTest.java index bb1e6e8b70a..9928e9346c5 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/ExpiredAccountExceptionTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/ExpiredAccountExceptionTest.java @@ -20,8 +20,9 @@ import java.time.format.DateTimeFormatter; import java.util.Date; + @Category(JUnitTests.class) -public class ExpiredAccountExceptionTest extends Assert { +public class ExpiredAccountExceptionTest { @Test public void expiredAccountExceptionTest() { @@ -30,13 +31,13 @@ public void expiredAccountExceptionTest() { for (int i = 0; i < dates.length; i++) { ExpiredAccountException expiredAccountException = new ExpiredAccountException(dates[i]); - assertEquals("Expected and actual values should be the same.", expectedMessages[i], expiredAccountException.getMessage()); + Assert.assertEquals("Expected and actual values should be the same.", expectedMessages[i], expiredAccountException.getMessage()); } } @Test public void expiredAccountExceptionNullTest() { ExpiredAccountException expiredAccountException = new ExpiredAccountException(null); - assertEquals("Expected and actual values should be the same.", "This credential has been locked out until ", expiredAccountException.getMessage()); + Assert.assertEquals("Expected and actual values should be the same.", "This credential has been locked out until ", expiredAccountException.getMessage()); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/JwtCertificateNotFoundExceptionTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/JwtCertificateNotFoundExceptionTest.java index e3f7a7eff28..e293d476654 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/JwtCertificateNotFoundExceptionTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/JwtCertificateNotFoundExceptionTest.java @@ -18,14 +18,15 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class JwtCertificateNotFoundExceptionTest extends Assert { +public class JwtCertificateNotFoundExceptionTest { @Test public void jwtCertificateNotFoundExceptionTest() { JwtCertificateNotFoundException jwtCertificateNotFoundException = new JwtCertificateNotFoundException(); - assertEquals("Expected and actual values should be the same.", KapuaAuthenticationErrorCodes.JWT_CERTIFICATE_NOT_FOUND, jwtCertificateNotFoundException.getCode()); - assertEquals("Expected and actual values should be the same.", "Error: ", jwtCertificateNotFoundException.getMessage()); - assertNull("Null expected.", jwtCertificateNotFoundException.getCause()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaAuthenticationErrorCodes.JWT_CERTIFICATE_NOT_FOUND, jwtCertificateNotFoundException.getCode()); + Assert.assertEquals("Expected and actual values should be the same.", "Error: ", jwtCertificateNotFoundException.getMessage()); + Assert.assertNull("Null expected.", jwtCertificateNotFoundException.getCause()); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/MfaRequiredExceptionTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/MfaRequiredExceptionTest.java index 9e4279f2349..b1be29e3656 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/MfaRequiredExceptionTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/MfaRequiredExceptionTest.java @@ -17,12 +17,13 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class MfaRequiredExceptionTest extends Assert { +public class MfaRequiredExceptionTest { @Test public void mfaRequiredExceptionTest() { MfaRequiredException mfaRequiredException = new MfaRequiredException(); - assertEquals("Expected and actual values should be the same.", "This user requires Multi Factor Authentication.", mfaRequiredException.getMessage()); + Assert.assertEquals("Expected and actual values should be the same.", "This user requires Multi Factor Authentication.", mfaRequiredException.getMessage()); } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/TemporaryLockedAccountExceptionTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/TemporaryLockedAccountExceptionTest.java index cb510cda294..ec0bb9d9b33 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/TemporaryLockedAccountExceptionTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/exceptions/TemporaryLockedAccountExceptionTest.java @@ -20,8 +20,9 @@ import java.time.format.DateTimeFormatter; import java.util.Date; + @Category(JUnitTests.class) -public class TemporaryLockedAccountExceptionTest extends Assert { +public class TemporaryLockedAccountExceptionTest { @Test public void temporaryLockedAccountExceptionTest() { @@ -30,13 +31,13 @@ public void temporaryLockedAccountExceptionTest() { for (int i = 0; i < dates.length; i++) { TemporaryLockedAccountException temporaryLockedAccountException = new TemporaryLockedAccountException(dates[i]); - assertEquals("Expected and actual values should be the same.", expectedMessages[i], temporaryLockedAccountException.getMessage()); + Assert.assertEquals("Expected and actual values should be the same.", expectedMessages[i], temporaryLockedAccountException.getMessage()); } } @Test public void temporaryLockedAccountExceptionNullTest() { TemporaryLockedAccountException temporaryLockedAccountException = new TemporaryLockedAccountException(null); - assertEquals("Expected and actual values should be the same.", "This credential has been locked out until ", temporaryLockedAccountException.getMessage()); + Assert.assertEquals("Expected and actual values should be the same.", "This credential has been locked out until ", temporaryLockedAccountException.getMessage()); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/mfa/MfaAuthenticatorServiceLocatorTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/mfa/MfaAuthenticatorServiceLocatorTest.java index 1d76e12f0bf..81eb9295c07 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/mfa/MfaAuthenticatorServiceLocatorTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/mfa/MfaAuthenticatorServiceLocatorTest.java @@ -21,30 +21,31 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; + @Category(JUnitTests.class) -public class MfaAuthenticatorServiceLocatorTest extends Assert { +public class MfaAuthenticatorServiceLocatorTest { @Test public void mfaAuthenticatorServiceLocatorTest() throws Exception { Constructor mfaAuthenticatorServiceLocator = MfaAuthenticatorServiceLocator.class.getDeclaredConstructor(); mfaAuthenticatorServiceLocator.setAccessible(true); mfaAuthenticatorServiceLocator.newInstance(); - assertTrue("True expected.", Modifier.isPrivate(mfaAuthenticatorServiceLocator.getModifiers())); + Assert.assertTrue("True expected.", Modifier.isPrivate(mfaAuthenticatorServiceLocator.getModifiers())); } @Test public void getInstanceNullLocatorTest() { - assertTrue("True expected.", MfaAuthenticatorServiceLocator.getInstance() instanceof MfaAuthenticatorServiceLocator); + Assert.assertTrue("True expected.", MfaAuthenticatorServiceLocator.getInstance() instanceof MfaAuthenticatorServiceLocator); } @Test public void getInstanceTest() { MfaAuthenticatorServiceLocator.getInstance(); - assertTrue("True expected.", MfaAuthenticatorServiceLocator.getInstance() instanceof MfaAuthenticatorServiceLocator); + Assert.assertTrue("True expected.", MfaAuthenticatorServiceLocator.getInstance() instanceof MfaAuthenticatorServiceLocator); } @Test public void getMfaAuthenticatorTest() { - assertTrue("True expected.", MfaAuthenticatorServiceLocator.getInstance().getMfaAuthenticator() instanceof MfaAuthenticator); + Assert.assertTrue("True expected.", MfaAuthenticatorServiceLocator.getInstance().getMfaAuthenticator() instanceof MfaAuthenticator); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/ApiKeyCredentialsMatcherTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/ApiKeyCredentialsMatcherTest.java index 31c6789e263..0b5b3b24976 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/ApiKeyCredentialsMatcherTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/ApiKeyCredentialsMatcherTest.java @@ -22,8 +22,9 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; + @Category(JUnitTests.class) -public class ApiKeyCredentialsMatcherTest extends Assert { +public class ApiKeyCredentialsMatcherTest { ApiKeyCredentialsMatcher apiKeyCredentialsMatcher; JwtCredentialsImpl authenticationToken; @@ -56,7 +57,7 @@ public void doCredentialsMatchDifferentCredentialTypesTest() { Mockito.when(authenticationInfo.getCredentials()).thenReturn(credential); Mockito.when(credential.getCredentialType()).thenReturn(CredentialType.PASSWORD); - assertFalse("False expected.", apiKeyCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); + Assert.assertFalse("False expected.", apiKeyCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); } @Test @@ -66,7 +67,7 @@ public void doCredentialsMatchDifferentTokenAndInfoPreTest() { Mockito.when(credential.getCredentialType()).thenReturn(CredentialType.API_KEY); Mockito.when(credential.getCredentialKey()).thenReturn("FullApiK:Credential"); - assertFalse("False expected.", apiKeyCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); + Assert.assertFalse("False expected.", apiKeyCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); } @Test @@ -76,7 +77,7 @@ public void doCredentialsMatchEqualTokenAndInfoPreFalseCheckPwTest() { Mockito.when(credential.getCredentialType()).thenReturn(CredentialType.API_KEY); Mockito.when(credential.getCredentialKey()).thenReturn("FullApiK:$2a$12$2AZYOAvilJyNvG8b6rBDaOSIcM3mKc6iyNQUYIXOF4ZFEAYdzM7Jm"); - assertFalse("False expected.", apiKeyCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); + Assert.assertFalse("False expected.", apiKeyCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); } @Test @@ -86,6 +87,6 @@ public void doCredentialsMatchTest() { Mockito.when(credential.getCredentialType()).thenReturn(CredentialType.API_KEY); Mockito.when(credential.getCredentialKey()).thenReturn("FullApiK:$2a$12$2AZYOAvilJyNvG8b6rBDaOSIcM3mKc6iyNQUYIXOF4ZFEAYdzM7Jm"); - assertTrue("True expected.", apiKeyCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); + Assert.assertTrue("True expected.", apiKeyCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/JwtCredentialsMatcherTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/JwtCredentialsMatcherTest.java index 741168574d7..00e72137095 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/JwtCredentialsMatcherTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/JwtCredentialsMatcherTest.java @@ -24,8 +24,9 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; + @Category(JUnitTests.class) -public class JwtCredentialsMatcherTest extends Assert { +public class JwtCredentialsMatcherTest { JwtProcessor jwtProcessor; JwtCredentialsImpl authenticationToken; @@ -47,7 +48,7 @@ public void jwtCredentialsMatcherNullTest() { try { new JwtCredentialsMatcher(null); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } @@ -59,7 +60,7 @@ public void doCredentialsMatchNullAuthenticationTokenTest() { @Test public void doCredentialsMatchNullAuthenticationInfoNullJwtTest() { Mockito.when(authenticationToken.getIdToken()).thenReturn(null); - assertFalse("False expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, null)); + Assert.assertFalse("False expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, null)); } @Test(expected = NullPointerException.class) @@ -72,7 +73,7 @@ public void doCredentialsMatchNullAuthenticationInfoTest() { public void doCredentialsMatchNullJwtTest() { Mockito.when(authenticationToken.getIdToken()).thenReturn(null); - assertFalse("False expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); + Assert.assertFalse("False expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); } @Test @@ -80,7 +81,7 @@ public void doCredentialsMatchStringCredentialTest() { Mockito.when(authenticationToken.getIdToken()).thenReturn("idToken"); Mockito.when(authenticationInfo.getCredentials()).thenReturn("credential"); - assertFalse("False expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); + Assert.assertFalse("False expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); } @Test @@ -89,7 +90,7 @@ public void doCredentialsMatchDifferentKeysTest() { Mockito.when(authenticationInfo.getCredentials()).thenReturn(credential); Mockito.when(credential.getCredentialKey()).thenReturn("credential key"); - assertFalse("False expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); + Assert.assertFalse("False expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); } @Test @@ -99,7 +100,7 @@ public void doCredentialsMatchEqualKeysFalseTest() throws OpenIDException { Mockito.when(credential.getCredentialKey()).thenReturn("idToken"); Mockito.when(jwtProcessor.validate("idToken")).thenReturn(false); - assertFalse("False expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); + Assert.assertFalse("False expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); } @Test @@ -109,7 +110,7 @@ public void doCredentialsMatchEqualKeysTrueTest() throws OpenIDException { Mockito.when(credential.getCredentialKey()).thenReturn("idToken"); Mockito.when(jwtProcessor.validate("idToken")).thenReturn(true); - assertTrue("True expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); + Assert.assertTrue("True expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); } @Test @@ -120,6 +121,6 @@ public void doCredentialsMatchEqualKeysOpenIDExceptionTest() throws OpenIDExcept Mockito.when(credential.getCredentialKey()).thenReturn("idToken"); Mockito.when(jwtProcessor.validate("idToken")).thenThrow(Mockito.mock(OpenIDException.class)); - assertFalse("False expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); + Assert.assertFalse("False expected.", jwtCredentialsMatcher.doCredentialsMatch(authenticationToken, authenticationInfo)); } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/LoginAuthenticationInfoTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/LoginAuthenticationInfoTest.java index 231eefc2642..dc234af99ad 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/LoginAuthenticationInfoTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/LoginAuthenticationInfoTest.java @@ -25,8 +25,9 @@ import java.util.HashMap; import java.util.Map; + @Category(JUnitTests.class) -public class LoginAuthenticationInfoTest extends Assert { +public class LoginAuthenticationInfoTest { String[] realmNames; Account account; @@ -47,28 +48,28 @@ public void initialize() { public void loginAuthenticationInfoTest() { for (String realmName : realmNames) { LoginAuthenticationInfo loginAuthenticationInfo = new LoginAuthenticationInfo(realmName, account, user, credentials, credentialServiceConfig); - assertEquals("Expected and actual values should be the same.", user, loginAuthenticationInfo.getUser()); - assertEquals("Expected and actual values should be the same.", account, loginAuthenticationInfo.getAccount()); - assertEquals("Expected and actual values should be the same.", realmName, loginAuthenticationInfo.getRealmName()); - assertFalse("False expected.", loginAuthenticationInfo.getPrincipals().isEmpty()); - assertEquals("Expected and actual values should be the same.", credentials, loginAuthenticationInfo.getCredentials()); - assertEquals("Expected and actual values should be the same.", credentialServiceConfig, loginAuthenticationInfo.getCredentialServiceConfig()); + Assert.assertEquals("Expected and actual values should be the same.", user, loginAuthenticationInfo.getUser()); + Assert.assertEquals("Expected and actual values should be the same.", account, loginAuthenticationInfo.getAccount()); + Assert.assertEquals("Expected and actual values should be the same.", realmName, loginAuthenticationInfo.getRealmName()); + Assert.assertFalse("False expected.", loginAuthenticationInfo.getPrincipals().isEmpty()); + Assert.assertEquals("Expected and actual values should be the same.", credentials, loginAuthenticationInfo.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", credentialServiceConfig, loginAuthenticationInfo.getCredentialServiceConfig()); } } @Test public void loginAuthenticationInfoNullNameTest() { LoginAuthenticationInfo loginAuthenticationInfo = new LoginAuthenticationInfo(null, account, user, credentials, credentialServiceConfig); - assertEquals("Expected and actual values should be the same.", user, loginAuthenticationInfo.getUser()); - assertEquals("Expected and actual values should be the same.", account, loginAuthenticationInfo.getAccount()); - assertNull("Null expected.", loginAuthenticationInfo.getRealmName()); - assertEquals("Expected and actual values should be the same.", credentials, loginAuthenticationInfo.getCredentials()); - assertEquals("Expected and actual values should be the same.", credentialServiceConfig, loginAuthenticationInfo.getCredentialServiceConfig()); + Assert.assertEquals("Expected and actual values should be the same.", user, loginAuthenticationInfo.getUser()); + Assert.assertEquals("Expected and actual values should be the same.", account, loginAuthenticationInfo.getAccount()); + Assert.assertNull("Null expected.", loginAuthenticationInfo.getRealmName()); + Assert.assertEquals("Expected and actual values should be the same.", credentials, loginAuthenticationInfo.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", credentialServiceConfig, loginAuthenticationInfo.getCredentialServiceConfig()); try { loginAuthenticationInfo.getPrincipals(); - fail("IllegalArgumentException expected."); + Assert.fail("IllegalArgumentException expected."); } catch (Exception e) { - assertEquals("Expected and actual values should be the same.", new NullPointerException("realmName argument cannot be null.").toString(), e.toString()); + Assert.assertEquals("Expected and actual values should be the same.", new NullPointerException("realmName argument cannot be null.").toString(), e.toString()); } } @@ -76,12 +77,12 @@ public void loginAuthenticationInfoNullNameTest() { public void loginAuthenticationInfoNullAccountTest() { for (String realmName : realmNames) { LoginAuthenticationInfo loginAuthenticationInfo = new LoginAuthenticationInfo(realmName, null, user, credentials, credentialServiceConfig); - assertEquals("Expected and actual values should be the same.", user, loginAuthenticationInfo.getUser()); - assertEquals("Expected and actual values should be the same.", realmName, loginAuthenticationInfo.getRealmName()); - assertNull("Null expected.", loginAuthenticationInfo.getAccount()); - assertFalse("False expected.", loginAuthenticationInfo.getPrincipals().isEmpty()); - assertEquals("Expected and actual values should be the same.", credentials, loginAuthenticationInfo.getCredentials()); - assertEquals("Expected and actual values should be the same.", credentialServiceConfig, loginAuthenticationInfo.getCredentialServiceConfig()); + Assert.assertEquals("Expected and actual values should be the same.", user, loginAuthenticationInfo.getUser()); + Assert.assertEquals("Expected and actual values should be the same.", realmName, loginAuthenticationInfo.getRealmName()); + Assert.assertNull("Null expected.", loginAuthenticationInfo.getAccount()); + Assert.assertFalse("False expected.", loginAuthenticationInfo.getPrincipals().isEmpty()); + Assert.assertEquals("Expected and actual values should be the same.", credentials, loginAuthenticationInfo.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", credentialServiceConfig, loginAuthenticationInfo.getCredentialServiceConfig()); } } @@ -89,16 +90,16 @@ public void loginAuthenticationInfoNullAccountTest() { public void loginAuthenticationInfoNullUserTest() { for (String realmName : realmNames) { LoginAuthenticationInfo loginAuthenticationInfo = new LoginAuthenticationInfo(realmName, account, null, credentials, credentialServiceConfig); - assertNull("Null expected.", loginAuthenticationInfo.getUser()); - assertEquals("Expected and actual values should be the same.", account, loginAuthenticationInfo.getAccount()); - assertEquals("Expected and actual values should be the same.", realmName, loginAuthenticationInfo.getRealmName()); - assertEquals("Expected and actual values should be the same.", credentials, loginAuthenticationInfo.getCredentials()); - assertEquals("Expected and actual values should be the same.", credentialServiceConfig, loginAuthenticationInfo.getCredentialServiceConfig()); + Assert.assertNull("Null expected.", loginAuthenticationInfo.getUser()); + Assert.assertEquals("Expected and actual values should be the same.", account, loginAuthenticationInfo.getAccount()); + Assert.assertEquals("Expected and actual values should be the same.", realmName, loginAuthenticationInfo.getRealmName()); + Assert.assertEquals("Expected and actual values should be the same.", credentials, loginAuthenticationInfo.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", credentialServiceConfig, loginAuthenticationInfo.getCredentialServiceConfig()); try { loginAuthenticationInfo.getPrincipals(); - fail("IllegalArgumentException expected."); + Assert.fail("IllegalArgumentException expected."); } catch (Exception e) { - assertEquals("Expected and actual values should be the same.", new NullPointerException("principal argument cannot be null.").toString(), e.toString()); + Assert.assertEquals("Expected and actual values should be the same.", new NullPointerException("principal argument cannot be null.").toString(), e.toString()); } } } @@ -107,12 +108,12 @@ public void loginAuthenticationInfoNullUserTest() { public void loginAuthenticationInfoNullCredentialsTest() { for (String realmName : realmNames) { LoginAuthenticationInfo loginAuthenticationInfo = new LoginAuthenticationInfo(realmName, account, user, null, credentialServiceConfig); - assertEquals("Expected and actual values should be the same.", user, loginAuthenticationInfo.getUser()); - assertEquals("Expected and actual values should be the same.", account, loginAuthenticationInfo.getAccount()); - assertEquals("Expected and actual values should be the same.", realmName, loginAuthenticationInfo.getRealmName()); - assertFalse("False expected.", loginAuthenticationInfo.getPrincipals().isEmpty()); - assertNull("Null expected.", loginAuthenticationInfo.getCredentials()); - assertEquals("Expected and actual values should be the same.", credentialServiceConfig, loginAuthenticationInfo.getCredentialServiceConfig()); + Assert.assertEquals("Expected and actual values should be the same.", user, loginAuthenticationInfo.getUser()); + Assert.assertEquals("Expected and actual values should be the same.", account, loginAuthenticationInfo.getAccount()); + Assert.assertEquals("Expected and actual values should be the same.", realmName, loginAuthenticationInfo.getRealmName()); + Assert.assertFalse("False expected.", loginAuthenticationInfo.getPrincipals().isEmpty()); + Assert.assertNull("Null expected.", loginAuthenticationInfo.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", credentialServiceConfig, loginAuthenticationInfo.getCredentialServiceConfig()); } } @@ -120,12 +121,12 @@ public void loginAuthenticationInfoNullCredentialsTest() { public void loginAuthenticationInfoNullCredentialServiceConfigTest() { for (String realmName : realmNames) { LoginAuthenticationInfo loginAuthenticationInfo = new LoginAuthenticationInfo(realmName, account, user, credentials, null); - assertEquals("Expected and actual values should be the same.", user, loginAuthenticationInfo.getUser()); - assertEquals("Expected and actual values should be the same.", account, loginAuthenticationInfo.getAccount()); - assertEquals("Expected and actual values should be the same.", realmName, loginAuthenticationInfo.getRealmName()); - assertFalse("False expected.", loginAuthenticationInfo.getPrincipals().isEmpty()); - assertEquals("Expected and actual values should be the same.", credentials, loginAuthenticationInfo.getCredentials()); - assertNull("Null expected.", loginAuthenticationInfo.getCredentialServiceConfig()); + Assert.assertEquals("Expected and actual values should be the same.", user, loginAuthenticationInfo.getUser()); + Assert.assertEquals("Expected and actual values should be the same.", account, loginAuthenticationInfo.getAccount()); + Assert.assertEquals("Expected and actual values should be the same.", realmName, loginAuthenticationInfo.getRealmName()); + Assert.assertFalse("False expected.", loginAuthenticationInfo.getPrincipals().isEmpty()); + Assert.assertEquals("Expected and actual values should be the same.", credentials, loginAuthenticationInfo.getCredentials()); + Assert.assertNull("Null expected.", loginAuthenticationInfo.getCredentialServiceConfig()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/SessionAuthenticationInfoTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/SessionAuthenticationInfoTest.java index b3b12bad8f7..8918232aab8 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/SessionAuthenticationInfoTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/realm/SessionAuthenticationInfoTest.java @@ -22,8 +22,9 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; + @Category(JUnitTests.class) -public class SessionAuthenticationInfoTest extends Assert { +public class SessionAuthenticationInfoTest { String[] realmNames; Account account; @@ -42,28 +43,28 @@ public void initialize() { public void sessionAuthenticationInfoTest() { for (String realmName : realmNames) { SessionAuthenticationInfo sessionAuthenticationInfo = new SessionAuthenticationInfo(realmName, account, user, accessToken); - assertEquals("Expected and actual values should be the same.", user, sessionAuthenticationInfo.getUser()); - assertEquals("Expected and actual values should be the same.", account, sessionAuthenticationInfo.getAccount()); - assertEquals("Expected and actual values should be the same.", realmName, sessionAuthenticationInfo.getRealmName()); - assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getAccessToken()); - assertFalse("False expected.", sessionAuthenticationInfo.getPrincipals().isEmpty()); - assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", user, sessionAuthenticationInfo.getUser()); + Assert.assertEquals("Expected and actual values should be the same.", account, sessionAuthenticationInfo.getAccount()); + Assert.assertEquals("Expected and actual values should be the same.", realmName, sessionAuthenticationInfo.getRealmName()); + Assert.assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getAccessToken()); + Assert.assertFalse("False expected.", sessionAuthenticationInfo.getPrincipals().isEmpty()); + Assert.assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getCredentials()); } } @Test public void sessionAuthenticationInfoNullNameTest() { SessionAuthenticationInfo sessionAuthenticationInfo = new SessionAuthenticationInfo(null, account, user, accessToken); - assertEquals("Expected and actual values should be the same.", user, sessionAuthenticationInfo.getUser()); - assertEquals("Expected and actual values should be the same.", account, sessionAuthenticationInfo.getAccount()); - assertNull("Null expected.", sessionAuthenticationInfo.getRealmName()); - assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getAccessToken()); - assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", user, sessionAuthenticationInfo.getUser()); + Assert.assertEquals("Expected and actual values should be the same.", account, sessionAuthenticationInfo.getAccount()); + Assert.assertNull("Null expected.", sessionAuthenticationInfo.getRealmName()); + Assert.assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getAccessToken()); + Assert.assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getCredentials()); try { sessionAuthenticationInfo.getPrincipals(); - fail("IllegalArgumentException expected."); + Assert.fail("IllegalArgumentException expected."); } catch (Exception e) { - assertEquals("Expected and actual values should be the same.", new NullPointerException("realmName argument cannot be null.").toString(), e.toString()); + Assert.assertEquals("Expected and actual values should be the same.", new NullPointerException("realmName argument cannot be null.").toString(), e.toString()); } } @@ -71,12 +72,12 @@ public void sessionAuthenticationInfoNullNameTest() { public void sessionAuthenticationInfoNullAccountTest() { for (String realmName : realmNames) { SessionAuthenticationInfo sessionAuthenticationInfo = new SessionAuthenticationInfo(realmName, null, user, accessToken); - assertEquals("Expected and actual values should be the same.", user, sessionAuthenticationInfo.getUser()); - assertNull("Null expected.", sessionAuthenticationInfo.getAccount()); - assertEquals("Expected and actual values should be the same.", realmName, sessionAuthenticationInfo.getRealmName()); - assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getAccessToken()); - assertFalse("False expected.", sessionAuthenticationInfo.getPrincipals().isEmpty()); - assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", user, sessionAuthenticationInfo.getUser()); + Assert.assertNull("Null expected.", sessionAuthenticationInfo.getAccount()); + Assert.assertEquals("Expected and actual values should be the same.", realmName, sessionAuthenticationInfo.getRealmName()); + Assert.assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getAccessToken()); + Assert.assertFalse("False expected.", sessionAuthenticationInfo.getPrincipals().isEmpty()); + Assert.assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getCredentials()); } } @@ -84,16 +85,16 @@ public void sessionAuthenticationInfoNullAccountTest() { public void sessionAuthenticationInfoNullUserTest() { for (String realmName : realmNames) { SessionAuthenticationInfo sessionAuthenticationInfo = new SessionAuthenticationInfo(realmName, account, null, accessToken); - assertNull("Null expected.", sessionAuthenticationInfo.getUser()); - assertEquals("Expected and actual values should be the same.", account, sessionAuthenticationInfo.getAccount()); - assertEquals("Expected and actual values should be the same.", realmName, sessionAuthenticationInfo.getRealmName()); - assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getAccessToken()); - assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getCredentials()); + Assert.assertNull("Null expected.", sessionAuthenticationInfo.getUser()); + Assert.assertEquals("Expected and actual values should be the same.", account, sessionAuthenticationInfo.getAccount()); + Assert.assertEquals("Expected and actual values should be the same.", realmName, sessionAuthenticationInfo.getRealmName()); + Assert.assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getAccessToken()); + Assert.assertEquals("Expected and actual values should be the same.", accessToken, sessionAuthenticationInfo.getCredentials()); try { sessionAuthenticationInfo.getPrincipals(); - fail("IllegalArgumentException expected."); + Assert.fail("IllegalArgumentException expected."); } catch (Exception e) { - assertEquals("Expected and actual values should be the same.", new NullPointerException("principal argument cannot be null.").toString(), e.toString()); + Assert.assertEquals("Expected and actual values should be the same.", new NullPointerException("principal argument cannot be null.").toString(), e.toString()); } } } @@ -102,12 +103,12 @@ public void sessionAuthenticationInfoNullUserTest() { public void sessionAuthenticationInfoNullAccessTokenTest() { for (String realmName : realmNames) { SessionAuthenticationInfo sessionAuthenticationInfo = new SessionAuthenticationInfo(realmName, account, user, null); - assertEquals("Expected and actual values should be the same.", user, sessionAuthenticationInfo.getUser()); - assertEquals("Expected and actual values should be the same.", account, sessionAuthenticationInfo.getAccount()); - assertEquals("Expected and actual values should be the same.", realmName, sessionAuthenticationInfo.getRealmName()); - assertNull("Null expected.", sessionAuthenticationInfo.getAccessToken()); - assertFalse("False expected.", sessionAuthenticationInfo.getPrincipals().isEmpty()); - assertNull("Null expected.", sessionAuthenticationInfo.getCredentials()); + Assert.assertEquals("Expected and actual values should be the same.", user, sessionAuthenticationInfo.getUser()); + Assert.assertEquals("Expected and actual values should be the same.", account, sessionAuthenticationInfo.getAccount()); + Assert.assertEquals("Expected and actual values should be the same.", realmName, sessionAuthenticationInfo.getRealmName()); + Assert.assertNull("Null expected.", sessionAuthenticationInfo.getAccessToken()); + Assert.assertFalse("False expected.", sessionAuthenticationInfo.getPrincipals().isEmpty()); + Assert.assertNull("Null expected.", sessionAuthenticationInfo.getCredentials()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/registration/RegistrationServiceImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/registration/RegistrationServiceImplTest.java index a95c1b8c594..9895a5611b4 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/registration/RegistrationServiceImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/registration/RegistrationServiceImplTest.java @@ -20,15 +20,16 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; + @Category(JUnitTests.class) -public class RegistrationServiceImplTest extends Assert { +public class RegistrationServiceImplTest { @Test public void registrationServiceImplTest() { try { new RegistrationServiceImpl(); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } @@ -38,7 +39,7 @@ public void closeTest() throws Exception { try { registrationServiceImpl.close(); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } @@ -46,24 +47,24 @@ public void closeTest() throws Exception { public void isAccountCreationEnabledTrueEmptyProcessorsTest() throws KapuaException { System.setProperty("authentication.registration.service.enabled", "true"); RegistrationServiceImpl registrationService = new RegistrationServiceImpl(); - assertFalse("False expected.", registrationService.isAccountCreationEnabled()); + Assert.assertFalse("False expected.", registrationService.isAccountCreationEnabled()); } @Test public void isAccountCreationEnabledFalseTest() throws KapuaException { System.setProperty("authentication.registration.service.enabled", "false"); RegistrationServiceImpl registrationService = new RegistrationServiceImpl(); - assertFalse("False expected.", registrationService.isAccountCreationEnabled()); + Assert.assertFalse("False expected.", registrationService.isAccountCreationEnabled()); } @Test public void createAccountCreationNotEnabledTest() throws KapuaException { JwtCredentials jwtCredentials = Mockito.mock(JwtCredentials.class); - assertFalse("False expected.", new RegistrationServiceImpl().createAccount(jwtCredentials)); + Assert.assertFalse("False expected.", new RegistrationServiceImpl().createAccount(jwtCredentials)); } @Test public void createAccountNullTest() throws KapuaException { - assertFalse("False expected.", new RegistrationServiceImpl().createAccount(null)); + Assert.assertFalse("False expected.", new RegistrationServiceImpl().createAccount(null)); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaAuthenticationSettingKeysTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaAuthenticationSettingKeysTest.java index d2b9db5e072..f542f18f0f3 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaAuthenticationSettingKeysTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaAuthenticationSettingKeysTest.java @@ -17,34 +17,35 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class KapuaAuthenticationSettingKeysTest extends Assert { +public class KapuaAuthenticationSettingKeysTest { @Test public void keyTest() { - assertEquals("Expected and actual values should be the same.", "authentication.key", KapuaAuthenticationSettingKeys.AUTHENTICATION_KEY.key()); - assertEquals("Expected and actual values should be the same.", "authentication.token.expire.after", KapuaAuthenticationSettingKeys.AUTHENTICATION_TOKEN_EXPIRE_AFTER.key()); - assertEquals("Expected and actual values should be the same.", "authentication.refresh.token.expire.after", KapuaAuthenticationSettingKeys.AUTHENTICATION_REFRESH_TOKEN_EXPIRE_AFTER.key()); - assertEquals("Expected and actual values should be the same.", "authentication.session.jwt.issuer", KapuaAuthenticationSettingKeys.AUTHENTICATION_SESSION_JWT_ISSUER.key()); - assertEquals("Expected and actual values should be the same.", "authentication.session.jwt.cache.enabled", KapuaAuthenticationSettingKeys.AUTHENTICATION_SESSION_JWT_CACHE_ENABLE.key()); - assertEquals("Expected and actual values should be the same.", "authentication.session.jwt.cache.ttl", KapuaAuthenticationSettingKeys.AUTHENTICATION_SESSION_JWT_CACHE_CACHE_TTL.key()); - assertEquals("Expected and actual values should be the same.", "authentication.credential.userpass.cache.enabled", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_USERPASS_CACHE_ENABLE.key()); - assertEquals("Expected and actual values should be the same.", "authentication.credential.userpass.cache.ttl", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_USERPASS_CACHE_CACHE_TTL.key()); - assertEquals("Expected and actual values should be the same.", "authentication.credential.userpass.password.minlength", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_USERPASS_PASSWORD_MINLENGTH.key()); - assertEquals("Expected and actual values should be the same.", "authentication.credential.jwt.audience.allowed", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_AUDIENCE_ALLOWED.key()); - assertEquals("Expected and actual values should be the same.", "authentication.credential.jwt.cache.enabled", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_JWT_CACHE_ENABLE.key()); - assertEquals("Expected and actual values should be the same.", "authentication.credential.jwt.cache.ttl", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_JWT_CACHE_CACHE_TTL.key()); - assertEquals("Expected and actual values should be the same.", "authentication.credential.jwt.issuer.allowed", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_ISSUER_ALLOWED.key()); - assertEquals("Expected and actual values should be the same.", "authentication.credential.apiKey.pre.length", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_APIKEY_PRE_LENGTH.key()); - assertEquals("Expected and actual values should be the same.", "authentication.credential.apiKey.pre.separator", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_APIKEY_PRE_SEPARATOR.key()); - assertEquals("Expected and actual values should be the same.", "authentication.credential.apiKey.key.length", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_APIKEY_KEY_LENGTH.key()); - assertEquals("Expected and actual values should be the same.", "authentication.credential.apiKey.cache.enabled", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_APIKEY_CACHE_ENABLE.key()); - assertEquals("Expected and actual values should be the same.", "authentication.credential.apiKey.cache.ttl", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_APIKEY_CACHE_TTL.key()); - assertEquals("Expected and actual values should be the same.", "authentication.eventAddress", KapuaAuthenticationSettingKeys.AUTHENTICATION_EVENT_ADDRESS.key()); - assertEquals("Expected and actual values should be the same.", "authentication.registration.service.enabled", KapuaAuthenticationSettingKeys.AUTHENTICATION_REGISTRATION_SERVICE_ENABLED.key()); - assertEquals("Expected and actual values should be the same.", "authentication.mfa.time.step.size", KapuaAuthenticationSettingKeys.AUTHENTICATION_MFA_TIME_STEP_SIZE.key()); - assertEquals("Expected and actual values should be the same.", "authentication.mfa.window.size", KapuaAuthenticationSettingKeys.AUTHENTICATION_MFA_WINDOW_SIZE.key()); - assertEquals("Expected and actual values should be the same.", "authentication.mfa.scratch.codes.number", KapuaAuthenticationSettingKeys.AUTHENTICATION_MFA_SCRATCH_CODES_NUMBER.key()); - assertEquals("Expected and actual values should be the same.", "authentication.mfa.code.digits.number", KapuaAuthenticationSettingKeys.AUTHENTICATION_MFA_CODE_DIGITS_NUMBER.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.key", KapuaAuthenticationSettingKeys.AUTHENTICATION_KEY.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.token.expire.after", KapuaAuthenticationSettingKeys.AUTHENTICATION_TOKEN_EXPIRE_AFTER.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.refresh.token.expire.after", KapuaAuthenticationSettingKeys.AUTHENTICATION_REFRESH_TOKEN_EXPIRE_AFTER.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.session.jwt.issuer", KapuaAuthenticationSettingKeys.AUTHENTICATION_SESSION_JWT_ISSUER.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.session.jwt.cache.enabled", KapuaAuthenticationSettingKeys.AUTHENTICATION_SESSION_JWT_CACHE_ENABLE.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.session.jwt.cache.ttl", KapuaAuthenticationSettingKeys.AUTHENTICATION_SESSION_JWT_CACHE_CACHE_TTL.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.credential.userpass.cache.enabled", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_USERPASS_CACHE_ENABLE.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.credential.userpass.cache.ttl", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_USERPASS_CACHE_CACHE_TTL.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.credential.userpass.password.minlength", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_USERPASS_PASSWORD_MINLENGTH.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.credential.jwt.audience.allowed", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_AUDIENCE_ALLOWED.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.credential.jwt.cache.enabled", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_JWT_CACHE_ENABLE.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.credential.jwt.cache.ttl", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_JWT_CACHE_CACHE_TTL.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.credential.jwt.issuer.allowed", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_ISSUER_ALLOWED.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.credential.apiKey.pre.length", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_APIKEY_PRE_LENGTH.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.credential.apiKey.pre.separator", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_APIKEY_PRE_SEPARATOR.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.credential.apiKey.key.length", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_APIKEY_KEY_LENGTH.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.credential.apiKey.cache.enabled", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_APIKEY_CACHE_ENABLE.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.credential.apiKey.cache.ttl", KapuaAuthenticationSettingKeys.AUTHENTICATION_CREDENTIAL_APIKEY_CACHE_TTL.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.eventAddress", KapuaAuthenticationSettingKeys.AUTHENTICATION_EVENT_ADDRESS.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.registration.service.enabled", KapuaAuthenticationSettingKeys.AUTHENTICATION_REGISTRATION_SERVICE_ENABLED.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.mfa.time.step.size", KapuaAuthenticationSettingKeys.AUTHENTICATION_MFA_TIME_STEP_SIZE.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.mfa.window.size", KapuaAuthenticationSettingKeys.AUTHENTICATION_MFA_WINDOW_SIZE.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.mfa.scratch.codes.number", KapuaAuthenticationSettingKeys.AUTHENTICATION_MFA_SCRATCH_CODES_NUMBER.key()); + Assert.assertEquals("Expected and actual values should be the same.", "authentication.mfa.code.digits.number", KapuaAuthenticationSettingKeys.AUTHENTICATION_MFA_CODE_DIGITS_NUMBER.key()); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaAuthenticationSettingTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaAuthenticationSettingTest.java index bcfb1e2f0a5..5fa4c377209 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaAuthenticationSettingTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaAuthenticationSettingTest.java @@ -20,19 +20,20 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; + @Category(JUnitTests.class) -public class KapuaAuthenticationSettingTest extends Assert { +public class KapuaAuthenticationSettingTest { @Test public void kapuaAuthenticationSettingTest() throws Exception { Constructor kapuaAuthenticationSetting = KapuaAuthenticationSetting.class.getDeclaredConstructor(); kapuaAuthenticationSetting.setAccessible(true); kapuaAuthenticationSetting.newInstance(); - assertTrue("True expected.", Modifier.isPrivate(kapuaAuthenticationSetting.getModifiers())); + Assert.assertTrue("True expected.", Modifier.isPrivate(kapuaAuthenticationSetting.getModifiers())); } @Test public void getInstanceTest() { - assertTrue("True expected.", KapuaAuthenticationSetting.getInstance() instanceof KapuaAuthenticationSetting); + Assert.assertTrue("True expected.", KapuaAuthenticationSetting.getInstance() instanceof KapuaAuthenticationSetting); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaCryptoSettingKeysTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaCryptoSettingKeysTest.java index 47b6222da17..91337f01743 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaCryptoSettingKeysTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaCryptoSettingKeysTest.java @@ -17,15 +17,16 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class KapuaCryptoSettingKeysTest extends Assert { +public class KapuaCryptoSettingKeysTest { @Test public void keyTest() { - assertEquals("Expected and actual values should be the same.", "crypto.key", KapuaCryptoSettingKeys.CRYPTO_KEY.key()); - assertEquals("Expected and actual values should be the same.", "crypto.bCrypt.logRounds", KapuaCryptoSettingKeys.CRYPTO_BCRYPT_LOG_ROUNDS.key()); - assertEquals("Expected and actual values should be the same.", "crypto.sha.algorithm", KapuaCryptoSettingKeys.CRYPTO_SHA_ALGORITHM.key()); - assertEquals("Expected and actual values should be the same.", "crypto.sha.salt.length", KapuaCryptoSettingKeys.CRYPTO_SHA_SALT_LENGTH.key()); - assertEquals("Expected and actual values should be the same.", "cipher.key", KapuaCryptoSettingKeys.CIPHER_KEY.key()); + Assert.assertEquals("Expected and actual values should be the same.", "crypto.key", KapuaCryptoSettingKeys.CRYPTO_KEY.key()); + Assert.assertEquals("Expected and actual values should be the same.", "crypto.bCrypt.logRounds", KapuaCryptoSettingKeys.CRYPTO_BCRYPT_LOG_ROUNDS.key()); + Assert.assertEquals("Expected and actual values should be the same.", "crypto.sha.algorithm", KapuaCryptoSettingKeys.CRYPTO_SHA_ALGORITHM.key()); + Assert.assertEquals("Expected and actual values should be the same.", "crypto.sha.salt.length", KapuaCryptoSettingKeys.CRYPTO_SHA_SALT_LENGTH.key()); + Assert.assertEquals("Expected and actual values should be the same.", "cipher.key", KapuaCryptoSettingKeys.CIPHER_KEY.key()); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaCryptoSettingTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaCryptoSettingTest.java index 75cd7a3302d..916052f655a 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaCryptoSettingTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/setting/KapuaCryptoSettingTest.java @@ -20,19 +20,20 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; + @Category(JUnitTests.class) -public class KapuaCryptoSettingTest extends Assert { +public class KapuaCryptoSettingTest { @Test public void kapuaCryptoSettingTest() throws Exception { Constructor kapuaCryptoSetting = KapuaCryptoSetting.class.getDeclaredConstructor(); kapuaCryptoSetting.setAccessible(true); kapuaCryptoSetting.newInstance(); - assertTrue("True expected.", Modifier.isPrivate(kapuaCryptoSetting.getModifiers())); + Assert.assertTrue("True expected.", Modifier.isPrivate(kapuaCryptoSetting.getModifiers())); } @Test public void getInstanceTest() { - assertTrue("True expected.", KapuaCryptoSetting.getInstance() instanceof KapuaCryptoSetting); + Assert.assertTrue("True expected.", KapuaCryptoSetting.getInstance() instanceof KapuaCryptoSetting); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/utils/AuthenticationUtilsTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/utils/AuthenticationUtilsTest.java index 649a9d9cee3..7dda3f9de83 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/utils/AuthenticationUtilsTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/utils/AuthenticationUtilsTest.java @@ -26,8 +26,9 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; + @Category(JUnitTests.class) -public class AuthenticationUtilsTest extends Assert { +public class AuthenticationUtilsTest { String[] plainValues, encryptedValues; private String cypherKeyPropKey = KapuaCryptoSettingKeys.CIPHER_KEY.key(); @@ -51,14 +52,14 @@ public void authenticationUtilsTest() throws Exception { Constructor authenticationUtils = AuthenticationUtils.class.getDeclaredConstructor(); authenticationUtils.setAccessible(true); authenticationUtils.newInstance(); - assertTrue("True expected.", Modifier.isPrivate(authenticationUtils.getModifiers())); + Assert.assertTrue("True expected.", Modifier.isPrivate(authenticationUtils.getModifiers())); } @Test public void cryptCredentialBCRYPTAlgorithmTest() throws KapuaException { for (String plainValue : plainValues) { - assertTrue("True expected.", AuthenticationUtils.cryptCredential(CryptAlgorithm.BCRYPT, plainValue).startsWith("$2a$12$")); - assertEquals("Expected and actual values should be the same.", 60, AuthenticationUtils.cryptCredential(CryptAlgorithm.BCRYPT, "plain value").length()); + Assert.assertTrue("True expected.", AuthenticationUtils.cryptCredential(CryptAlgorithm.BCRYPT, plainValue).startsWith("$2a$12$")); + Assert.assertEquals("Expected and actual values should be the same.", 60, AuthenticationUtils.cryptCredential(CryptAlgorithm.BCRYPT, "plain value").length()); } } @@ -70,8 +71,8 @@ public void cryptCredentialSHAAlgorithmTest() throws KapuaException { for (int i = 0; i < shaAlgorithm.length; i++) { System.setProperty(cryptoShaAlgorithmPropKey, shaAlgorithm[i]); for (String plainValue : plainValues) { - assertTrue("True expected.", AuthenticationUtils.cryptCredential(CryptAlgorithm.SHA, plainValue).contains("=:")); - assertEquals("Expected and actual values should be the same.", expectedLength[i], AuthenticationUtils.cryptCredential(CryptAlgorithm.SHA, plainValue).length()); + Assert.assertTrue("True expected.", AuthenticationUtils.cryptCredential(CryptAlgorithm.SHA, plainValue).contains("=:")); + Assert.assertEquals("Expected and actual values should be the same.", expectedLength[i], AuthenticationUtils.cryptCredential(CryptAlgorithm.SHA, plainValue).length()); } } } @@ -98,7 +99,7 @@ public void encryptAesTest() { try { AuthenticationUtils.encryptAes(plainValue); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } } @@ -123,7 +124,7 @@ public void encryptAesEmptyValueTest() { try { AuthenticationUtils.encryptAes(""); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } @@ -140,7 +141,7 @@ public void decryptAesTest() { try { AuthenticationUtils.decryptAes(encryptedValue); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } } @@ -171,7 +172,7 @@ public void decryptAesEmptyValueTest() { try { AuthenticationUtils.decryptAes(""); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/utils/JwtProcessorsTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/utils/JwtProcessorsTest.java index 77559d52af4..21e0a2531bd 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/utils/JwtProcessorsTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/shiro/utils/JwtProcessorsTest.java @@ -22,19 +22,20 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; + @Category(JUnitTests.class) -public class JwtProcessorsTest extends Assert { +public class JwtProcessorsTest { @Test public void jwtProcessorsTest() throws Exception { Constructor jwtProcessors = JwtProcessors.class.getDeclaredConstructor(); jwtProcessors.setAccessible(true); jwtProcessors.newInstance(); - assertTrue("True expected.", Modifier.isPrivate(jwtProcessors.getModifiers())); + Assert.assertTrue("True expected.", Modifier.isPrivate(jwtProcessors.getModifiers())); } @Test public void createDefaultTest() throws OpenIDException { - assertTrue("True expected.", JwtProcessors.createDefault() instanceof JwtProcessor); + Assert.assertTrue("True expected.", JwtProcessors.createDefault() instanceof JwtProcessor); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenCreatorImplTest.java index 1cd68167975..0d73bf4acce 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenCreatorImplTest.java @@ -21,8 +21,9 @@ import java.util.Date; + @Category(JUnitTests.class) -public class AccessTokenCreatorImplTest extends Assert { +public class AccessTokenCreatorImplTest { AccessTokenCreatorImpl accessTokenCreatorImpl; @@ -33,23 +34,23 @@ public void initialize() { @Test public void accessTokenCreatorImplTest() { - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenCreatorImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenCreatorImpl.getScopeId()); } @Test public void accessTokenCreatorImplNullTest() { AccessTokenCreatorImpl accessTokenCreatorImpl = new AccessTokenCreatorImpl(null); - assertNull("Null expected.", accessTokenCreatorImpl.getScopeId()); + Assert.assertNull("Null expected.", accessTokenCreatorImpl.getScopeId()); } @Test public void setAndGetTokenIdTest() { String[] tokenIds = {null, "", "!!tokenID-1", "#1(TOKEN.,/token id)9--99", "!$$ 1-2 ID//", "id_tokeN(....)<00>"}; - assertNull("Null expected.", accessTokenCreatorImpl.getTokenId()); + Assert.assertNull("Null expected.", accessTokenCreatorImpl.getTokenId()); for (String tokenId : tokenIds) { accessTokenCreatorImpl.setTokenId(tokenId); - assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCreatorImpl.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCreatorImpl.getTokenId()); } } @@ -57,20 +58,20 @@ public void setAndGetTokenIdTest() { public void setAndGetUserIdTest() { KapuaId[] userIds = {null, KapuaId.ONE}; - assertNull("Null expected.", accessTokenCreatorImpl.getUserId()); + Assert.assertNull("Null expected.", accessTokenCreatorImpl.getUserId()); for (KapuaId userId : userIds) { accessTokenCreatorImpl.setUserId(userId); - assertEquals("Expected and actual values should be the same.", userId, accessTokenCreatorImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", userId, accessTokenCreatorImpl.getUserId()); } } @Test public void setAndGetExpiresOnTest() { Date[] expiresOnDates = {null, new Date(), new Date(1L), new Date(9999999999999L)}; - assertNull("Null expected.", accessTokenCreatorImpl.getExpiresOn()); + Assert.assertNull("Null expected.", accessTokenCreatorImpl.getExpiresOn()); for (Date expiresOnDate : expiresOnDates) { accessTokenCreatorImpl.setExpiresOn(expiresOnDate); - assertEquals("Expected and actual values should be the same.", expiresOnDate, accessTokenCreatorImpl.getExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", expiresOnDate, accessTokenCreatorImpl.getExpiresOn()); } } @@ -78,20 +79,20 @@ public void setAndGetExpiresOnTest() { public void setAndGetRefreshTokenTest() { String[] refreshTokens = {null, "", "!!refreshToken-1", "#1(TOKEN.,/refresh token id)9--99", "!$$ 1-2 REFREsh//", "refresh_tokeN(....)<00>"}; - assertNull("Null expected.", accessTokenCreatorImpl.getRefreshToken()); + Assert.assertNull("Null expected.", accessTokenCreatorImpl.getRefreshToken()); for (String refreshToken : refreshTokens) { accessTokenCreatorImpl.setRefreshToken(refreshToken); - assertEquals("Expected and actual values should be the same.", refreshToken, accessTokenCreatorImpl.getRefreshToken()); + Assert.assertEquals("Expected and actual values should be the same.", refreshToken, accessTokenCreatorImpl.getRefreshToken()); } } @Test public void setAndGetRefreshExpiresOnTest() { Date[] refreshExpiresOnDates = {null, new Date(), new Date(1L), new Date(9999999999999L)}; - assertNull("Null expected.", accessTokenCreatorImpl.getRefreshExpiresOn()); + Assert.assertNull("Null expected.", accessTokenCreatorImpl.getRefreshExpiresOn()); for (Date refreshExpiresOnDate : refreshExpiresOnDates) { accessTokenCreatorImpl.setRefreshExpiresOn(refreshExpiresOnDate); - assertEquals("Expected and actual values should be the same.", refreshExpiresOnDate, accessTokenCreatorImpl.getRefreshExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", refreshExpiresOnDate, accessTokenCreatorImpl.getRefreshExpiresOn()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java index 35222768f3a..ee76a291a98 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenFactoryImplTest.java @@ -29,8 +29,9 @@ import java.util.Date; + @Category(JUnitTests.class) -public class AccessTokenFactoryImplTest extends Assert { +public class AccessTokenFactoryImplTest { AccessTokenFactoryImpl accessTokenFactoryImpl; KapuaId[] scopeIds; @@ -64,12 +65,12 @@ public void newCreatorMultipleParametersTest() { for (String refreshToken : refreshTokens) { for (Date refreshExpiresOnDate : refreshExpiresOnDates) { AccessTokenCreatorImpl accessTokenCreatorImpl = accessTokenFactoryImpl.newCreator(scopeId, userId, tokenId, expiresOnDate, refreshToken, refreshExpiresOnDate); - assertEquals("Expected and actual values should be the same.", scopeId, accessTokenCreatorImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", userId, accessTokenCreatorImpl.getUserId()); - assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCreatorImpl.getTokenId()); - assertEquals("Expected and actual values should be the same.", expiresOnDate, accessTokenCreatorImpl.getExpiresOn()); - assertEquals("Expected and actual values should be the same.", refreshToken, accessTokenCreatorImpl.getRefreshToken()); - assertEquals("Expected and actual values should be the same.", refreshExpiresOnDate, accessTokenCreatorImpl.getRefreshExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessTokenCreatorImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", userId, accessTokenCreatorImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", tokenId, accessTokenCreatorImpl.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", expiresOnDate, accessTokenCreatorImpl.getExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", refreshToken, accessTokenCreatorImpl.getRefreshToken()); + Assert.assertEquals("Expected and actual values should be the same.", refreshExpiresOnDate, accessTokenCreatorImpl.getRefreshExpiresOn()); } } } @@ -82,7 +83,7 @@ public void newCreatorMultipleParametersTest() { public void newEntityTest() { for (KapuaId scopeId : scopeIds) { AccessToken accessToken = accessTokenFactoryImpl.newEntity(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, accessToken.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessToken.getScopeId()); } } @@ -90,7 +91,7 @@ public void newEntityTest() { public void newCreatorScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { AccessTokenCreator accessTokenCreator = accessTokenFactoryImpl.newCreator(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, accessTokenCreator.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessTokenCreator.getScopeId()); } } @@ -98,13 +99,13 @@ public void newCreatorScopeIdParameterTest() { public void newQueryTest() { for (KapuaId scopeId : scopeIds) { AccessTokenQuery accessTokenQuery = accessTokenFactoryImpl.newQuery(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, accessTokenQuery.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessTokenQuery.getScopeId()); } } @Test public void newListResultTest() { - assertTrue("True expected.", accessTokenFactoryImpl.newListResult() instanceof AccessTokenListResult); + Assert.assertTrue("True expected.", accessTokenFactoryImpl.newListResult() instanceof AccessTokenListResult); } @Test @@ -124,19 +125,19 @@ public void cloneTest() { Mockito.when(accessToken.getOptlock()).thenReturn(10); AccessToken accessTokenResult = accessTokenFactoryImpl.clone(accessToken); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenResult.getId()); - assertEquals("Expected and actual values should be the same.", createdOn, accessTokenResult.getCreatedOn()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenResult.getCreatedBy()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenResult.getScopeId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessTokenResult.getUserId()); - assertEquals("Expected and actual values should be the same.", "token id", accessTokenResult.getTokenId()); - assertEquals("Expected and actual values should be the same.", expiresOnDates[1], accessTokenResult.getExpiresOn()); - assertEquals("Expected and actual values should be the same.", "refresh token", accessTokenResult.getRefreshToken()); - assertEquals("Expected and actual values should be the same.", refreshExpiresOnDates[1], accessTokenResult.getRefreshExpiresOn()); - assertEquals("Expected and actual values should be the same.", invalidatedOn, accessTokenResult.getInvalidatedOn()); - assertEquals("Expected and actual values should be the same.", modifiedOn, accessTokenResult.getModifiedOn()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenResult.getModifiedBy()); - assertEquals("Expected and actual values should be the same.", 10, accessTokenResult.getOptlock()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenResult.getId()); + Assert.assertEquals("Expected and actual values should be the same.", createdOn, accessTokenResult.getCreatedOn()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenResult.getCreatedBy()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenResult.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessTokenResult.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", "token id", accessTokenResult.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", expiresOnDates[1], accessTokenResult.getExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", "refresh token", accessTokenResult.getRefreshToken()); + Assert.assertEquals("Expected and actual values should be the same.", refreshExpiresOnDates[1], accessTokenResult.getRefreshExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", invalidatedOn, accessTokenResult.getInvalidatedOn()); + Assert.assertEquals("Expected and actual values should be the same.", modifiedOn, accessTokenResult.getModifiedOn()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenResult.getModifiedBy()); + Assert.assertEquals("Expected and actual values should be the same.", 10, accessTokenResult.getOptlock()); } @Test(expected = KapuaEntityCloneException.class) @@ -146,6 +147,6 @@ public void cloneNullTest() { @Test public void newLoginInfoTest() { - assertTrue("True expected.", accessTokenFactoryImpl.newLoginInfo() instanceof LoginInfo); + Assert.assertTrue("True expected.", accessTokenFactoryImpl.newLoginInfo() instanceof LoginInfo); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenImplTest.java index dff34f4a5e1..8a8d67deaa7 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenImplTest.java @@ -25,8 +25,9 @@ import java.util.Date; + @Category(JUnitTests.class) -public class AccessTokenImplTest extends Assert { +public class AccessTokenImplTest { KapuaId[] scopeIds; KapuaEid[] userIds; @@ -74,12 +75,12 @@ public void initialize() throws KapuaException { @Test public void accessTokenImplWithoutParametersTest() { AccessTokenImpl accessTokenImpl = new AccessTokenImpl(); - assertNull("Null expected.", accessTokenImpl.getScopeId()); - assertNull("Null expected.", accessTokenImpl.getUserId()); - assertNull("Null expected.", accessTokenImpl.getTokenId()); - assertNull("Null expected.", accessTokenImpl.getExpiresOn()); - assertNull("Null expected.", accessTokenImpl.getRefreshToken()); - assertNull("Null expected.", accessTokenImpl.getRefreshExpiresOn()); + Assert.assertNull("Null expected.", accessTokenImpl.getScopeId()); + Assert.assertNull("Null expected.", accessTokenImpl.getUserId()); + Assert.assertNull("Null expected.", accessTokenImpl.getTokenId()); + Assert.assertNull("Null expected.", accessTokenImpl.getExpiresOn()); + Assert.assertNull("Null expected.", accessTokenImpl.getRefreshToken()); + Assert.assertNull("Null expected.", accessTokenImpl.getRefreshExpiresOn()); } @Test @@ -91,12 +92,12 @@ public void accessTokenImplMultipleParametersTest() { for (String refreshToken : refreshTokens) { for (Date refreshExpiresOnDate : refreshExpiresOnDates) { AccessTokenImpl accessTokenImpl = new AccessTokenImpl(scopeId, userId, tokenId, expiresOnDate, refreshToken, refreshExpiresOnDate); - assertEquals("Expected and actual values should be the same.", scopeId, accessTokenImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", userId, accessTokenImpl.getUserId()); - assertEquals("Expected and actual values should be the same.", tokenId, accessTokenImpl.getTokenId()); - assertEquals("Expected and actual values should be the same.", expiresOnDate, accessTokenImpl.getExpiresOn()); - assertEquals("Expected and actual values should be the same.", refreshToken, accessTokenImpl.getRefreshToken()); - assertEquals("Expected and actual values should be the same.", refreshExpiresOnDate, accessTokenImpl.getRefreshExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessTokenImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", userId, accessTokenImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", tokenId, accessTokenImpl.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", expiresOnDate, accessTokenImpl.getExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", refreshToken, accessTokenImpl.getRefreshToken()); + Assert.assertEquals("Expected and actual values should be the same.", refreshExpiresOnDate, accessTokenImpl.getRefreshExpiresOn()); } } } @@ -109,28 +110,28 @@ public void accessTokenImplMultipleParametersTest() { public void accessTokenImplScopeIdParameterTest() { for (KapuaId scopeId : scopeIds) { AccessTokenImpl accessTokenImpl = new AccessTokenImpl(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, accessTokenImpl.getScopeId()); - assertNull("Null expected.", accessTokenImpl.getUserId()); - assertNull("Null expected.", accessTokenImpl.getTokenId()); - assertNull("Null expected.", accessTokenImpl.getExpiresOn()); - assertNull("Null expected.", accessTokenImpl.getRefreshToken()); - assertNull("Null expected.", accessTokenImpl.getRefreshExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessTokenImpl.getScopeId()); + Assert.assertNull("Null expected.", accessTokenImpl.getUserId()); + Assert.assertNull("Null expected.", accessTokenImpl.getTokenId()); + Assert.assertNull("Null expected.", accessTokenImpl.getExpiresOn()); + Assert.assertNull("Null expected.", accessTokenImpl.getRefreshToken()); + Assert.assertNull("Null expected.", accessTokenImpl.getRefreshExpiresOn()); } } @Test public void accessTokenImplAccessTokenParameterTest() throws KapuaException { AccessTokenImpl accessTokenImpl = new AccessTokenImpl(accessToken); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", new KapuaEid(KapuaId.ONE), accessTokenImpl.getUserId()); - assertEquals("Expected and actual values should be the same.", "token id", accessTokenImpl.getTokenId()); - assertEquals("Expected and actual values should be the same.", expiresOn, accessTokenImpl.getExpiresOn()); - assertEquals("Expected and actual values should be the same.", "refresh token", accessTokenImpl.getRefreshToken()); - assertEquals("Expected and actual values should be the same.", refreshExpiresOn, accessTokenImpl.getRefreshExpiresOn()); - assertEquals("Expected and actual values should be the same.", invalidatedOn, accessTokenImpl.getInvalidatedOn()); - assertEquals("Expected and actual values should be the same.", modifiedOn, accessTokenImpl.getModifiedOn()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenImpl.getCreatedBy()); - assertEquals("Expected and actual values should be the same.", 10, accessTokenImpl.getOptlock()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", new KapuaEid(KapuaId.ONE), accessTokenImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", "token id", accessTokenImpl.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", expiresOn, accessTokenImpl.getExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", "refresh token", accessTokenImpl.getRefreshToken()); + Assert.assertEquals("Expected and actual values should be the same.", refreshExpiresOn, accessTokenImpl.getRefreshExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", invalidatedOn, accessTokenImpl.getInvalidatedOn()); + Assert.assertEquals("Expected and actual values should be the same.", modifiedOn, accessTokenImpl.getModifiedOn()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenImpl.getCreatedBy()); + Assert.assertEquals("Expected and actual values should be the same.", 10, accessTokenImpl.getOptlock()); } @Test @@ -142,10 +143,10 @@ public void setAndGetUserIdTest() { accessTokenImpl3.setUserId(newUserId); accessTokenImpl4.setUserId(newUserId); - assertEquals("Expected and actual values should be the same.", newUserId, accessTokenImpl1.getUserId()); - assertEquals("Expected and actual values should be the same.", newUserId, accessTokenImpl2.getUserId()); - assertEquals("Expected and actual values should be the same.", newUserId, accessTokenImpl3.getUserId()); - assertEquals("Expected and actual values should be the same.", newUserId, accessTokenImpl4.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, accessTokenImpl1.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, accessTokenImpl2.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, accessTokenImpl3.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, accessTokenImpl4.getUserId()); } } @@ -158,10 +159,10 @@ public void setAndGetTokenIdTest() { accessTokenImpl3.setTokenId(newTokenId); accessTokenImpl4.setTokenId(newTokenId); - assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenImpl1.getTokenId()); - assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenImpl2.getTokenId()); - assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenImpl3.getTokenId()); - assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenImpl4.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenImpl1.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenImpl2.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenImpl3.getTokenId()); + Assert.assertEquals("Expected and actual values should be the same.", newTokenId, accessTokenImpl4.getTokenId()); } } @@ -174,69 +175,69 @@ public void setAndGetExpiresOnTest() { accessTokenImpl3.setExpiresOn(newExpiresOnDate); accessTokenImpl4.setExpiresOn(newExpiresOnDate); - assertEquals("Expected and actual values should be the same.", newExpiresOnDate, accessTokenImpl1.getExpiresOn()); - assertEquals("Expected and actual values should be the same.", newExpiresOnDate, accessTokenImpl2.getExpiresOn()); - assertEquals("Expected and actual values should be the same.", newExpiresOnDate, accessTokenImpl3.getExpiresOn()); - assertEquals("Expected and actual values should be the same.", newExpiresOnDate, accessTokenImpl4.getExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", newExpiresOnDate, accessTokenImpl1.getExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", newExpiresOnDate, accessTokenImpl2.getExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", newExpiresOnDate, accessTokenImpl3.getExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", newExpiresOnDate, accessTokenImpl4.getExpiresOn()); } } @Test public void prePersistsActionTest() { accessTokenImpl1.setUserId(KapuaId.ANY); - assertNull("Null expected.", accessTokenImpl1.getId()); - assertNull("Null expected.", accessTokenImpl1.getCreatedBy()); - assertNull("Null expected.", accessTokenImpl1.getCreatedOn()); - assertNull("Null expected.", accessTokenImpl1.getModifiedBy()); - assertNull("Null expected.", accessTokenImpl1.getModifiedOn()); + Assert.assertNull("Null expected.", accessTokenImpl1.getId()); + Assert.assertNull("Null expected.", accessTokenImpl1.getCreatedBy()); + Assert.assertNull("Null expected.", accessTokenImpl1.getCreatedOn()); + Assert.assertNull("Null expected.", accessTokenImpl1.getModifiedBy()); + Assert.assertNull("Null expected.", accessTokenImpl1.getModifiedOn()); accessTokenImpl1.prePersistsAction(); - assertNotNull("NotNull expected.", accessTokenImpl1.getId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessTokenImpl1.getCreatedBy()); - assertNotNull("NotNullExpected", accessTokenImpl1.getCreatedOn()); - assertNotNull("NotNullExpected", accessTokenImpl1.getModifiedBy()); - assertNotNull("NotNullExpected", accessTokenImpl1.getModifiedOn()); + Assert.assertNotNull("NotNull expected.", accessTokenImpl1.getId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessTokenImpl1.getCreatedBy()); + Assert.assertNotNull("NotNullExpected", accessTokenImpl1.getCreatedOn()); + Assert.assertNotNull("NotNullExpected", accessTokenImpl1.getModifiedBy()); + Assert.assertNotNull("NotNullExpected", accessTokenImpl1.getModifiedOn()); accessTokenImpl2.setUserId(KapuaId.ANY); - assertNull("Null expected.", accessTokenImpl2.getId()); - assertNull("Null expected.", accessTokenImpl2.getCreatedBy()); - assertNull("Null expected.", accessTokenImpl2.getCreatedOn()); - assertNull("Null expected.", accessTokenImpl2.getModifiedBy()); - assertNull("Null expected.", accessTokenImpl2.getModifiedOn()); + Assert.assertNull("Null expected.", accessTokenImpl2.getId()); + Assert.assertNull("Null expected.", accessTokenImpl2.getCreatedBy()); + Assert.assertNull("Null expected.", accessTokenImpl2.getCreatedOn()); + Assert.assertNull("Null expected.", accessTokenImpl2.getModifiedBy()); + Assert.assertNull("Null expected.", accessTokenImpl2.getModifiedOn()); accessTokenImpl2.prePersistsAction(); - assertNotNull("NotNull expected.", accessTokenImpl2.getId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessTokenImpl2.getCreatedBy()); - assertNotNull("NotNullExpected", accessTokenImpl2.getCreatedOn()); - assertNotNull("NotNullExpected", accessTokenImpl2.getModifiedBy()); - assertNotNull("NotNullExpected", accessTokenImpl2.getModifiedOn()); + Assert.assertNotNull("NotNull expected.", accessTokenImpl2.getId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessTokenImpl2.getCreatedBy()); + Assert.assertNotNull("NotNullExpected", accessTokenImpl2.getCreatedOn()); + Assert.assertNotNull("NotNullExpected", accessTokenImpl2.getModifiedBy()); + Assert.assertNotNull("NotNullExpected", accessTokenImpl2.getModifiedOn()); accessTokenImpl3.setUserId(KapuaId.ANY); - assertNull("Null expected.", accessTokenImpl3.getId()); - assertNull("Null expected.", accessTokenImpl3.getCreatedBy()); - assertNull("Null expected.", accessTokenImpl3.getCreatedOn()); - assertNull("Null expected.", accessTokenImpl3.getModifiedBy()); - assertNull("Null expected.", accessTokenImpl3.getModifiedOn()); + Assert.assertNull("Null expected.", accessTokenImpl3.getId()); + Assert.assertNull("Null expected.", accessTokenImpl3.getCreatedBy()); + Assert.assertNull("Null expected.", accessTokenImpl3.getCreatedOn()); + Assert.assertNull("Null expected.", accessTokenImpl3.getModifiedBy()); + Assert.assertNull("Null expected.", accessTokenImpl3.getModifiedOn()); accessTokenImpl3.prePersistsAction(); - assertNotNull("NotNull expected.", accessTokenImpl3.getId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessTokenImpl3.getCreatedBy()); - assertNotNull("NotNullExpected", accessTokenImpl3.getCreatedOn()); - assertNotNull("NotNullExpected", accessTokenImpl3.getModifiedBy()); - assertNotNull("NotNullExpected", accessTokenImpl3.getModifiedOn()); - - assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessTokenImpl4.getId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenImpl4.getCreatedBy()); - assertEquals("Expected and actual values should be the same.", createdOn, accessTokenImpl4.getCreatedOn()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenImpl4.getModifiedBy()); - assertEquals("Expected and actual values should be the same.", modifiedOn, accessTokenImpl4.getModifiedOn()); + Assert.assertNotNull("NotNull expected.", accessTokenImpl3.getId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessTokenImpl3.getCreatedBy()); + Assert.assertNotNull("NotNullExpected", accessTokenImpl3.getCreatedOn()); + Assert.assertNotNull("NotNullExpected", accessTokenImpl3.getModifiedBy()); + Assert.assertNotNull("NotNullExpected", accessTokenImpl3.getModifiedOn()); + + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessTokenImpl4.getId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenImpl4.getCreatedBy()); + Assert.assertEquals("Expected and actual values should be the same.", createdOn, accessTokenImpl4.getCreatedOn()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenImpl4.getModifiedBy()); + Assert.assertEquals("Expected and actual values should be the same.", modifiedOn, accessTokenImpl4.getModifiedOn()); accessTokenImpl4.prePersistsAction(); - assertNotEquals("Expected and actual values should not be the same.", KapuaId.ANY, accessTokenImpl4.getId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenImpl4.getCreatedBy()); - assertNotEquals("Expected and actual values should not be the same.", createdOn, accessTokenImpl4.getCreatedOn()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenImpl4.getModifiedBy()); - assertNotEquals("Expected and actual values should not be the same.", modifiedOn, accessTokenImpl4.getModifiedOn()); + Assert.assertNotEquals("Expected and actual values should not be the same.", KapuaId.ANY, accessTokenImpl4.getId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenImpl4.getCreatedBy()); + Assert.assertNotEquals("Expected and actual values should not be the same.", createdOn, accessTokenImpl4.getCreatedOn()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenImpl4.getModifiedBy()); + Assert.assertNotEquals("Expected and actual values should not be the same.", modifiedOn, accessTokenImpl4.getModifiedOn()); } @Test @@ -248,10 +249,10 @@ public void setAndGetRefreshTokenTest() { accessTokenImpl3.setRefreshToken(newRefreshToken); accessTokenImpl4.setRefreshToken(newRefreshToken); - assertEquals("Expected and actual values should be the same.", newRefreshToken, accessTokenImpl1.getRefreshToken()); - assertEquals("Expected and actual values should be the same.", newRefreshToken, accessTokenImpl2.getRefreshToken()); - assertEquals("Expected and actual values should be the same.", newRefreshToken, accessTokenImpl3.getRefreshToken()); - assertEquals("Expected and actual values should be the same.", newRefreshToken, accessTokenImpl4.getRefreshToken()); + Assert.assertEquals("Expected and actual values should be the same.", newRefreshToken, accessTokenImpl1.getRefreshToken()); + Assert.assertEquals("Expected and actual values should be the same.", newRefreshToken, accessTokenImpl2.getRefreshToken()); + Assert.assertEquals("Expected and actual values should be the same.", newRefreshToken, accessTokenImpl3.getRefreshToken()); + Assert.assertEquals("Expected and actual values should be the same.", newRefreshToken, accessTokenImpl4.getRefreshToken()); } } @@ -264,10 +265,10 @@ public void setAndGetRefreshExpiresOnTest() { accessTokenImpl3.setRefreshExpiresOn(newRefreshExpiresOnDate); accessTokenImpl4.setRefreshExpiresOn(newRefreshExpiresOnDate); - assertEquals("Expected and actual values should be the same.", newRefreshExpiresOnDate, accessTokenImpl1.getRefreshExpiresOn()); - assertEquals("Expected and actual values should be the same.", newRefreshExpiresOnDate, accessTokenImpl2.getRefreshExpiresOn()); - assertEquals("Expected and actual values should be the same.", newRefreshExpiresOnDate, accessTokenImpl3.getRefreshExpiresOn()); - assertEquals("Expected and actual values should be the same.", newRefreshExpiresOnDate, accessTokenImpl4.getRefreshExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", newRefreshExpiresOnDate, accessTokenImpl1.getRefreshExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", newRefreshExpiresOnDate, accessTokenImpl2.getRefreshExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", newRefreshExpiresOnDate, accessTokenImpl3.getRefreshExpiresOn()); + Assert.assertEquals("Expected and actual values should be the same.", newRefreshExpiresOnDate, accessTokenImpl4.getRefreshExpiresOn()); } } @@ -280,10 +281,10 @@ public void setAndGetInvalidatedOnTest() { accessTokenImpl3.setInvalidatedOn(newInvalidatedOnDate); accessTokenImpl4.setInvalidatedOn(newInvalidatedOnDate); - assertEquals("Expected and actual values should be the same.", newInvalidatedOnDate, accessTokenImpl1.getInvalidatedOn()); - assertEquals("Expected and actual values should be the same.", newInvalidatedOnDate, accessTokenImpl2.getInvalidatedOn()); - assertEquals("Expected and actual values should be the same.", newInvalidatedOnDate, accessTokenImpl3.getInvalidatedOn()); - assertEquals("Expected and actual values should be the same.", newInvalidatedOnDate, accessTokenImpl4.getInvalidatedOn()); + Assert.assertEquals("Expected and actual values should be the same.", newInvalidatedOnDate, accessTokenImpl1.getInvalidatedOn()); + Assert.assertEquals("Expected and actual values should be the same.", newInvalidatedOnDate, accessTokenImpl2.getInvalidatedOn()); + Assert.assertEquals("Expected and actual values should be the same.", newInvalidatedOnDate, accessTokenImpl3.getInvalidatedOn()); + Assert.assertEquals("Expected and actual values should be the same.", newInvalidatedOnDate, accessTokenImpl4.getInvalidatedOn()); } } @@ -296,10 +297,10 @@ public void setAndGetTrustKeyTest() { accessTokenImpl3.setTrustKey(newTrustKey); accessTokenImpl4.setTrustKey(newTrustKey); - assertEquals("Expected and actual values should be the same.", newTrustKey, accessTokenImpl1.getTrustKey()); - assertEquals("Expected and actual values should be the same.", newTrustKey, accessTokenImpl2.getTrustKey()); - assertEquals("Expected and actual values should be the same.", newTrustKey, accessTokenImpl3.getTrustKey()); - assertEquals("Expected and actual values should be the same.", newTrustKey, accessTokenImpl4.getTrustKey()); + Assert.assertEquals("Expected and actual values should be the same.", newTrustKey, accessTokenImpl1.getTrustKey()); + Assert.assertEquals("Expected and actual values should be the same.", newTrustKey, accessTokenImpl2.getTrustKey()); + Assert.assertEquals("Expected and actual values should be the same.", newTrustKey, accessTokenImpl3.getTrustKey()); + Assert.assertEquals("Expected and actual values should be the same.", newTrustKey, accessTokenImpl4.getTrustKey()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenQueryImplTest.java index 904196cce93..1bb5a584d51 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenQueryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/AccessTokenQueryImplTest.java @@ -21,26 +21,27 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; + @Category(JUnitTests.class) -public class AccessTokenQueryImplTest extends Assert { +public class AccessTokenQueryImplTest { @Test public void accessTokenQueryImplTest() throws Exception { Constructor accessTokenQueryImpl = AccessTokenQueryImpl.class.getDeclaredConstructor(); accessTokenQueryImpl.setAccessible(true); accessTokenQueryImpl.newInstance(); - assertTrue("True expected.", Modifier.isPrivate(accessTokenQueryImpl.getModifiers())); + Assert.assertTrue("True expected.", Modifier.isPrivate(accessTokenQueryImpl.getModifiers())); } @Test public void accessTokenQueryImplTestScopeIdParameterTest() { AccessTokenQueryImpl accessTokenQueryImpl = new AccessTokenQueryImpl(KapuaId.ONE); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenQueryImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessTokenQueryImpl.getScopeId()); } @Test public void accessTokenQueryImplTestNullScopeIdParameterTest() { AccessTokenQueryImpl accessTokenQueryImpl = new AccessTokenQueryImpl(null); - assertNull("Null expected.", accessTokenQueryImpl.getScopeId()); + Assert.assertNull("Null expected.", accessTokenQueryImpl.getScopeId()); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/LoginInfoImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/LoginInfoImplTest.java index f5cb7a1b912..00f5b66cb56 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/LoginInfoImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authentication/token/shiro/LoginInfoImplTest.java @@ -25,8 +25,9 @@ import java.util.HashSet; import java.util.Set; + @Category(JUnitTests.class) -public class LoginInfoImplTest extends Assert { +public class LoginInfoImplTest { LoginInfoImpl loginInfoImpl; Set rolePermissions; @@ -42,18 +43,18 @@ public void initialize() { @Test public void setAndGetAccessTokenTest() { AccessToken[] accessTokens = {null, Mockito.mock(AccessToken.class)}; - assertNull("Null expected.", loginInfoImpl.getAccessToken()); + Assert.assertNull("Null expected.", loginInfoImpl.getAccessToken()); for (AccessToken accessToken : accessTokens) { loginInfoImpl.setAccessToken(accessToken); - assertEquals("Expected and actual values should be the same.", accessToken, loginInfoImpl.getAccessToken()); + Assert.assertEquals("Expected and actual values should be the same.", accessToken, loginInfoImpl.getAccessToken()); } } @Test public void setAndGetRolePermissionEmptySetTest() { - assertNull("Null expected.", loginInfoImpl.getRolePermission()); + Assert.assertNull("Null expected.", loginInfoImpl.getRolePermission()); loginInfoImpl.setRolePermission(rolePermissions); - assertEquals("Expected and actual values should be the same.", rolePermissions, loginInfoImpl.getRolePermission()); + Assert.assertEquals("Expected and actual values should be the same.", rolePermissions, loginInfoImpl.getRolePermission()); } @Test @@ -61,23 +62,23 @@ public void setAndGetRolePermissionTest() { rolePermissions.add(Mockito.mock(RolePermission.class)); rolePermissions.add(Mockito.mock(RolePermission.class)); - assertNull("Null expected.", loginInfoImpl.getRolePermission()); + Assert.assertNull("Null expected.", loginInfoImpl.getRolePermission()); loginInfoImpl.setRolePermission(rolePermissions); - assertEquals("Expected and actual values should be the same.", rolePermissions, loginInfoImpl.getRolePermission()); + Assert.assertEquals("Expected and actual values should be the same.", rolePermissions, loginInfoImpl.getRolePermission()); } @Test public void setAndGetRolePermissionNullTest() { - assertNull("Null expected.", loginInfoImpl.getRolePermission()); + Assert.assertNull("Null expected.", loginInfoImpl.getRolePermission()); loginInfoImpl.setRolePermission(null); - assertNull("Null expected.", loginInfoImpl.getRolePermission()); + Assert.assertNull("Null expected.", loginInfoImpl.getRolePermission()); } @Test public void setAndGetAccessPermissionEmptySetTest() { - assertNull("Null expected.", loginInfoImpl.getAccessPermission()); + Assert.assertNull("Null expected.", loginInfoImpl.getAccessPermission()); loginInfoImpl.setAccessPermission(accessPermissions); - assertEquals("Expected and actual values should be the same.", accessPermissions, loginInfoImpl.getAccessPermission()); + Assert.assertEquals("Expected and actual values should be the same.", accessPermissions, loginInfoImpl.getAccessPermission()); } @Test @@ -85,15 +86,15 @@ public void setAndGetAccessPermissionTest() { accessPermissions.add(Mockito.mock(AccessPermission.class)); accessPermissions.add(Mockito.mock(AccessPermission.class)); - assertNull("Null expected.", loginInfoImpl.getAccessPermission()); + Assert.assertNull("Null expected.", loginInfoImpl.getAccessPermission()); loginInfoImpl.setAccessPermission(accessPermissions); - assertEquals("Expected and actual values should be the same.", accessPermissions, loginInfoImpl.getAccessPermission()); + Assert.assertEquals("Expected and actual values should be the same.", accessPermissions, loginInfoImpl.getAccessPermission()); } @Test public void setAndGetAccessPermissionNullTest() { - assertNull("Null expected.", loginInfoImpl.getAccessPermission()); + Assert.assertNull("Null expected.", loginInfoImpl.getAccessPermission()); loginInfoImpl.setAccessPermission(null); - assertNull("Null expected.", loginInfoImpl.getAccessPermission()); + Assert.assertNull("Null expected.", loginInfoImpl.getAccessPermission()); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoCacheFactoryTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoCacheFactoryTest.java index 5100b13932a..f726aef7f9f 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoCacheFactoryTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoCacheFactoryTest.java @@ -19,8 +19,9 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class AccessInfoCacheFactoryTest extends Assert { +public class AccessInfoCacheFactoryTest { AccessInfoCacheFactory accessInfoCacheFactory; @@ -31,16 +32,16 @@ public void initialize() { @Test public void accessInfoCacheFactoryTest() { - assertEquals("Expected and actual values should be the same.", "AccessInfoId", accessInfoCacheFactory.getEntityIdCacheName()); + Assert.assertEquals("Expected and actual values should be the same.", "AccessInfoId", accessInfoCacheFactory.getEntityIdCacheName()); } @Test public void createCacheTest() { - assertTrue("True expected.", accessInfoCacheFactory.createCache() instanceof EntityCache); + Assert.assertTrue("True expected.", accessInfoCacheFactory.createCache() instanceof EntityCache); } @Test public void getInstanceTest() { - assertEquals("Expected and actual values should be the same.", "AccessInfoId", AccessInfoCacheFactory.getInstance().getEntityIdCacheName()); + Assert.assertEquals("Expected and actual values should be the same.", "AccessInfoId", AccessInfoCacheFactory.getInstance().getEntityIdCacheName()); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoCacheTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoCacheTest.java index cc984b67176..b16c8960c53 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoCacheTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoCacheTest.java @@ -21,8 +21,9 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; + @Category(JUnitTests.class) -public class AccessInfoCacheTest extends Assert { +public class AccessInfoCacheTest { String[] idCacheNames, nameCacheNames; AccessInfo kapuaEntity; @@ -39,7 +40,7 @@ public void accessInfoCacheTest() { for (String idCacheName : idCacheNames) { for (String nameCacheName : nameCacheNames) { AccessInfoCache accessInfoCache = new AccessInfoCache(idCacheName, nameCacheName); - assertNotNull("NotNull expected.", accessInfoCache.accessInfoByUserIdCache); + Assert.assertNotNull("NotNull expected.", accessInfoCache.accessInfoByUserIdCache); } } } @@ -64,7 +65,7 @@ public void getByUserIdTest() { for (String nameCacheName : nameCacheNames) { AccessInfoCache accessInfoCache = new AccessInfoCache(idCacheName, nameCacheName); //COMMENT: This method always returns null, due to method get(Object key) in Cache.java which always returns null - assertNull("Null expected.", accessInfoCache.getByUserId(KapuaId.ONE, KapuaId.ONE)); + Assert.assertNull("Null expected.", accessInfoCache.getByUserId(KapuaId.ONE, KapuaId.ONE)); } } } @@ -75,7 +76,7 @@ public void getByUserIdNullScopeIdTest() { for (String nameCacheName : nameCacheNames) { AccessInfoCache accessInfoCache = new AccessInfoCache(idCacheName, nameCacheName); //COMMENT: This method always returns null, due to method get(Object key) in Cache.java which always returns null - assertNull("Null expected.", accessInfoCache.getByUserId(null, KapuaId.ONE)); + Assert.assertNull("Null expected.", accessInfoCache.getByUserId(null, KapuaId.ONE)); } } } @@ -85,7 +86,7 @@ public void getByNullUserIdTest() { for (String idCacheName : idCacheNames) { for (String nameCacheName : nameCacheNames) { AccessInfoCache accessInfoCache = new AccessInfoCache(idCacheName, nameCacheName); - assertNull("Null expected.", accessInfoCache.getByUserId(KapuaId.ONE, null)); + Assert.assertNull("Null expected.", accessInfoCache.getByUserId(KapuaId.ONE, null)); } } } @@ -98,7 +99,7 @@ public void putTest() { try { accessInfoCache.put(kapuaEntity); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } } @@ -112,7 +113,7 @@ public void putNullEntityTest() { try { accessInfoCache.put(null); } catch (Exception e) { - fail("Exception not expected."); + Assert.fail("Exception not expected."); } } } @@ -129,7 +130,7 @@ public void removeTest() { // accessInfoByUserIdCache.remove(((AccessInfo) kapuaEntity).getUserId()); // } //and this method always returns null - assertNull("Null expected.", accessInfoCache.remove(KapuaId.ONE, KapuaId.ONE)); + Assert.assertNull("Null expected.", accessInfoCache.remove(KapuaId.ONE, KapuaId.ONE)); } } } @@ -145,7 +146,7 @@ public void removeNullScopeIdTest() { // accessInfoByUserIdCache.remove(((AccessInfo) kapuaEntity).getUserId()); // } //and this method always returns null - assertNull("Null expected.", accessInfoCache.remove(null, KapuaId.ONE)); + Assert.assertNull("Null expected.", accessInfoCache.remove(null, KapuaId.ONE)); } } } @@ -155,7 +156,7 @@ public void removeNullKapuaIdTest() { for (String idCacheName : idCacheNames) { for (String nameCacheName : nameCacheNames) { AccessInfoCache accessInfoCache = new AccessInfoCache(idCacheName, nameCacheName); - assertNull("Null expected.", accessInfoCache.remove(KapuaId.ONE, (KapuaId) null)); + Assert.assertNull("Null expected.", accessInfoCache.remove(KapuaId.ONE, (KapuaId) null)); } } } diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java index 0197d35fe8b..2ce26e553a5 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoFactoryImplTest.java @@ -27,8 +27,9 @@ import java.util.Date; + @Category(JUnitTests.class) -public class AccessInfoFactoryImplTest extends Assert { +public class AccessInfoFactoryImplTest { AccessInfoFactoryImpl accessInfoFactoryImpl; KapuaId scopeId; @@ -58,63 +59,63 @@ public void initialize() { public void newEntityTest() { AccessInfo accessInfo = accessInfoFactoryImpl.newEntity(scopeId); - assertNull("Null expected.", accessInfo.getScopeId()); + Assert.assertNull("Null expected.", accessInfo.getScopeId()); } @Test public void newEntityNullTest() { AccessInfo accessInfo = accessInfoFactoryImpl.newEntity(null); - assertNull("Null expected.", accessInfo.getScopeId()); + Assert.assertNull("Null expected.", accessInfo.getScopeId()); } @Test public void newCreatorTest() { AccessInfoCreator accessInfoCreator = accessInfoFactoryImpl.newCreator(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, accessInfoCreator.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessInfoCreator.getScopeId()); } @Test public void newCreatorNullTest() { AccessInfoCreator accessInfoCreator = accessInfoFactoryImpl.newCreator(null); - assertNull("Null expected.", accessInfoCreator.getScopeId()); + Assert.assertNull("Null expected.", accessInfoCreator.getScopeId()); } @Test public void newQueryTest() { AccessInfoQuery accessInfoQuery = accessInfoFactoryImpl.newQuery(scopeId); - assertEquals("Expected and actual values should be the same.", scopeId, accessInfoQuery.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", scopeId, accessInfoQuery.getScopeId()); } @Test public void newQueryNullTest() { AccessInfoQuery accessInfoQuery = accessInfoFactoryImpl.newQuery(null); - assertNull("Null expected.", accessInfoQuery.getScopeId()); + Assert.assertNull("Null expected.", accessInfoQuery.getScopeId()); } @Test public void newListResultTest() { AccessInfoListResult accessInfoListResult = accessInfoFactoryImpl.newListResult(); - assertTrue("True expected.", accessInfoListResult.isEmpty()); + Assert.assertTrue("True expected.", accessInfoListResult.isEmpty()); } @Test public void cloneTest() { AccessInfo resultAccessInfo = accessInfoFactoryImpl.clone(accessInfo); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, resultAccessInfo.getId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ANY, resultAccessInfo.getScopeId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, resultAccessInfo.getCreatedBy()); - assertEquals("Expected and actual values should be the same.", createdOn, resultAccessInfo.getCreatedOn()); - assertEquals("Expected and actual values should be the same.", KapuaId.ANY, resultAccessInfo.getModifiedBy()); - assertEquals("Expected and actual values should be the same.", modifiedOn, resultAccessInfo.getModifiedOn()); - assertEquals("Expected and actual values should be the same.", 11, resultAccessInfo.getOptlock()); - assertEquals("Expected and actual values should be the same.", KapuaId.ANY, resultAccessInfo.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, resultAccessInfo.getId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ANY, resultAccessInfo.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, resultAccessInfo.getCreatedBy()); + Assert.assertEquals("Expected and actual values should be the same.", createdOn, resultAccessInfo.getCreatedOn()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ANY, resultAccessInfo.getModifiedBy()); + Assert.assertEquals("Expected and actual values should be the same.", modifiedOn, resultAccessInfo.getModifiedOn()); + Assert.assertEquals("Expected and actual values should be the same.", 11, resultAccessInfo.getOptlock()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ANY, resultAccessInfo.getUserId()); } @Test(expected = KapuaEntityCloneException.class) diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoImplTest.java index 8e3367aff2e..51def1645a2 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoImplTest.java @@ -24,8 +24,9 @@ import java.util.Date; + @Category(JUnitTests.class) -public class AccessInfoImplTest extends Assert { +public class AccessInfoImplTest { AccessInfo accessInfo; Date modifiedOn, createdOn; @@ -50,38 +51,38 @@ public void initialize() { public void accessInfoImplWithoutParametersTest() { AccessInfoImpl accessInfoImpl = new AccessInfoImpl(); - assertNull("Null expected.", accessInfoImpl.getScopeId()); - assertNull("Null expected.", accessInfoImpl.getUserId()); + Assert.assertNull("Null expected.", accessInfoImpl.getScopeId()); + Assert.assertNull("Null expected.", accessInfoImpl.getUserId()); } @Test public void accessInfoImplScopeIdParameterTest() { AccessInfoImpl accessInfoImpl = new AccessInfoImpl(KapuaId.ONE); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessInfoImpl.getScopeId()); - assertNull("Null expected.", accessInfoImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessInfoImpl.getScopeId()); + Assert.assertNull("Null expected.", accessInfoImpl.getUserId()); } @Test public void accessInfoImplNullScopeIdParameterTest() { AccessInfoImpl accessInfoImpl = new AccessInfoImpl((KapuaId) null); - assertNull("Null expected.", accessInfoImpl.getScopeId()); - assertNull("Null expected.", accessInfoImpl.getUserId()); + Assert.assertNull("Null expected.", accessInfoImpl.getScopeId()); + Assert.assertNull("Null expected.", accessInfoImpl.getUserId()); } @Test public void accessInfoImplAccessInfoParameterTest() throws KapuaException { AccessInfoImpl accessInfoImpl = new AccessInfoImpl(accessInfo); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessInfoImpl.getScopeId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessInfoImpl.getUserId()); - assertEquals("Expected and actual values should be the same.", modifiedOn, accessInfoImpl.getModifiedOn()); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessInfoImpl.getModifiedBy()); - assertEquals("Expected and actual values should be the same.", 10, accessInfoImpl.getOptlock()); - assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessInfoImpl.getId()); - assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessInfoImpl.getCreatedBy()); - assertEquals("Expected and actual values should be the same.", createdOn, accessInfoImpl.getCreatedOn()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessInfoImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessInfoImpl.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", modifiedOn, accessInfoImpl.getModifiedOn()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessInfoImpl.getModifiedBy()); + Assert.assertEquals("Expected and actual values should be the same.", 10, accessInfoImpl.getOptlock()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessInfoImpl.getId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ANY, accessInfoImpl.getCreatedBy()); + Assert.assertEquals("Expected and actual values should be the same.", createdOn, accessInfoImpl.getCreatedOn()); } @Test(expected = NullPointerException.class) @@ -101,9 +102,9 @@ public void setAndGetUserId() throws KapuaException { accessInfoImpl2.setUserId(newUserId); accessInfoImpl3.setUserId(newUserId); - assertEquals("Expected and actual values should be the same.", newUserId, accessInfoImpl1.getUserId()); - assertEquals("Expected and actual values should be the same.", newUserId, accessInfoImpl2.getUserId()); - assertEquals("Expected and actual values should be the same.", newUserId, accessInfoImpl3.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, accessInfoImpl1.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, accessInfoImpl2.getUserId()); + Assert.assertEquals("Expected and actual values should be the same.", newUserId, accessInfoImpl3.getUserId()); } } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoQueryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoQueryImplTest.java index 4ab90249f4b..30be73ea269 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoQueryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessInfoQueryImplTest.java @@ -18,27 +18,28 @@ import org.junit.Test; import org.junit.experimental.categories.Category; + @Category(JUnitTests.class) -public class AccessInfoQueryImplTest extends Assert { +public class AccessInfoQueryImplTest { @Test public void accessInfoQueryImplWithoutParameterTest() { AccessInfoQueryImpl accessInfoQueryImpl = new AccessInfoQueryImpl(); - assertNull("Null expected.", accessInfoQueryImpl.getScopeId()); + Assert.assertNull("Null expected.", accessInfoQueryImpl.getScopeId()); } @Test public void accessInfoQueryImplScopeIdParameterTest() { AccessInfoQueryImpl accessInfoQueryImpl = new AccessInfoQueryImpl(KapuaId.ONE); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessInfoQueryImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessInfoQueryImpl.getScopeId()); } @Test public void accessInfoQueryImplNullScopeIdParameterTest() { AccessInfoQueryImpl accessInfoQueryImpl = new AccessInfoQueryImpl(null); - assertNull("Null expected.", accessInfoQueryImpl.getScopeId()); + Assert.assertNull("Null expected.", accessInfoQueryImpl.getScopeId()); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCacheFactoryTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCacheFactoryTest.java index d99f6267efd..1c6859a7e21 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCacheFactoryTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCacheFactoryTest.java @@ -20,19 +20,20 @@ import java.lang.reflect.Constructor; import java.lang.reflect.Modifier; + @Category(JUnitTests.class) -public class AccessPermissionCacheFactoryTest extends Assert { +public class AccessPermissionCacheFactoryTest { @Test public void accessPermissionCacheFactoryTest() throws Exception { Constructor accessPermissionCacheFactory = AccessPermissionCacheFactory.class.getDeclaredConstructor(); accessPermissionCacheFactory.setAccessible(true); accessPermissionCacheFactory.newInstance(); - assertTrue("True expected.", Modifier.isPrivate(accessPermissionCacheFactory.getModifiers())); + Assert.assertTrue("True expected.", Modifier.isPrivate(accessPermissionCacheFactory.getModifiers())); } @Test public void getInstanceTest() { - assertTrue("True expected.", AccessPermissionCacheFactory.getInstance() instanceof AccessPermissionCacheFactory); + Assert.assertTrue("True expected.", AccessPermissionCacheFactory.getInstance() instanceof AccessPermissionCacheFactory); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorImplTest.java index 7748db6d694..725ffc74ff2 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionCreatorImplTest.java @@ -20,30 +20,31 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; + @Category(JUnitTests.class) -public class AccessPermissionCreatorImplTest extends Assert { +public class AccessPermissionCreatorImplTest { @Test public void accessPermissionCreatorImplTest() { AccessPermissionCreatorImpl accessPermissionCreatorImpl = new AccessPermissionCreatorImpl(KapuaId.ONE); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessPermissionCreatorImpl.getScopeId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessPermissionCreatorImpl.getScopeId()); } @Test public void accessPermissionCreatorImplNullTest() { AccessPermissionCreatorImpl accessPermissionCreatorImpl = new AccessPermissionCreatorImpl(null); - assertNull("Null expected.", accessPermissionCreatorImpl.getScopeId()); + Assert.assertNull("Null expected.", accessPermissionCreatorImpl.getScopeId()); } @Test public void setAndGetAccessInfoIdTest() { AccessPermissionCreatorImpl accessPermissionCreatorImpl = new AccessPermissionCreatorImpl(KapuaId.ONE); - assertNull("Null expected.", accessPermissionCreatorImpl.getAccessInfoId()); + Assert.assertNull("Null expected.", accessPermissionCreatorImpl.getAccessInfoId()); accessPermissionCreatorImpl.setAccessInfoId(KapuaId.ONE); - assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessPermissionCreatorImpl.getAccessInfoId()); + Assert.assertEquals("Expected and actual values should be the same.", KapuaId.ONE, accessPermissionCreatorImpl.getAccessInfoId()); accessPermissionCreatorImpl.setAccessInfoId(null); - assertNull("Null expected.", accessPermissionCreatorImpl.getAccessInfoId()); + Assert.assertNull("Null expected.", accessPermissionCreatorImpl.getAccessInfoId()); } @Test @@ -51,10 +52,10 @@ public void setAndGetPermissionTest() { AccessPermissionCreatorImpl accessPermissionCreatorImpl = new AccessPermissionCreatorImpl(KapuaId.ONE); Permission permission = Mockito.mock(Permission.class); - assertNull("Null expected.", accessPermissionCreatorImpl.getPermission()); + Assert.assertNull("Null expected.", accessPermissionCreatorImpl.getPermission()); accessPermissionCreatorImpl.setPermission(permission); - assertEquals("Expected and actual values should be the same.", permission, accessPermissionCreatorImpl.getPermission()); + Assert.assertEquals("Expected and actual values should be the same.", permission, accessPermissionCreatorImpl.getPermission()); accessPermissionCreatorImpl.setPermission(null); - assertNull("Null expected.", accessPermissionCreatorImpl.getPermission()); + Assert.assertNull("Null expected.", accessPermissionCreatorImpl.getPermission()); } } \ No newline at end of file diff --git a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java index e3592eacc3e..a7654bd3539 100644 --- a/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java +++ b/service/security/shiro/src/test/java/org/eclipse/kapua/service/authorization/access/shiro/AccessPermissionFactoryImplTest.java @@ -24,8 +24,9 @@ import org.junit.experimental.categories.Category; import org.mockito.Mockito; + @Category(JUnitTests.class) -public class AccessPermissionFactoryImplTest extends Assert { +public class AccessPermissionFactoryImplTest { AccessPermissionFactoryImpl accessPermissionFactoryImpl; KapuaId[] scopeIds; @@ -39,33 +40,33 @@ public void initialize() { @Test public void newEntityTest() { for (KapuaId scopeId : scopeIds) { - assertTrue("True expected.", accessPermissionFactoryImpl.newEntity(scopeId) instanceof AccessPermission); + Assert.assertTrue("True expected.", accessPermissionFactoryImpl.newEntity(scopeId) instanceof AccessPermission); } } @Test public void newCreatorTest() { for (KapuaId scopeId : scopeIds) { - assertTrue("True expected.", accessPermissionFactoryImpl.newCreator(scopeId) instanceof AccessPermissionCreator); + Assert.assertTrue("True expected.", accessPermissionFactoryImpl.newCreator(scopeId) instanceof AccessPermissionCreator); } } @Test public void newQueryTest() { for (KapuaId scopeId : scopeIds) { - assertTrue("True expected.", accessPermissionFactoryImpl.newQuery(scopeId) instanceof AccessPermissionQuery); + Assert.assertTrue("True expected.", accessPermissionFactoryImpl.newQuery(scopeId) instanceof AccessPermissionQuery); } } @Test public void newListResultTest() { - assertTrue("True expected.", accessPermissionFactoryImpl.newListResult() instanceof AccessPermissionListResult); + Assert.assertTrue("True expected.", accessPermissionFactoryImpl.newListResult() instanceof AccessPermissionListResult); } @Test public void cloneTest() { AccessPermission accessPermission = Mockito.mock(AccessPermission.class); - assertTrue("True expected.", accessPermissionFactoryImpl.clone(accessPermission) instanceof AccessPermission); + Assert.assertTrue("True expected.", accessPermissionFactoryImpl.clone(accessPermission) instanceof AccessPermission); } @Test(expected = NullPointerException.class)