Skip to content

Commit

Permalink
:fix: importing org.junit.Assert and explicitly referencing its metho…
Browse files Browse the repository at this point in the history
…ds instead of having test classes extend it

Signed-off-by: dseurotech <davide.salvador@eurotech.com>
  • Loading branch information
dseurotech authored and Coduz committed Nov 2, 2022
1 parent 9f7c36d commit 1fa4404
Show file tree
Hide file tree
Showing 56 changed files with 900 additions and 845 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down Expand Up @@ -105,38 +106,38 @@ 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
public void dataIndexNameByScopeIdAndTimestamp() throws KapuaException, ParseException {

// 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 {
Expand Down Expand Up @@ -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);
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,16 +15,16 @@
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;

import java.time.ZoneOffset;
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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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'";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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());
}
}
}
Expand All @@ -59,31 +60,31 @@ 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());
}
}

@Test
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());
}
}

@Test
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());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,9 @@

import java.util.Date;


@Category(JUnitTests.class)
public class MfaOptionFactoryImplTest extends Assert {
public class MfaOptionFactoryImplTest {

MfaOptionFactoryImpl mfaOptionFactoryImpl;
KapuaId[] scopeIds;
Expand All @@ -56,24 +57,24 @@ 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());
}
}
}
}

@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());
}
}

Expand All @@ -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());
}
}
}
Expand All @@ -95,15 +96,15 @@ 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());
}
}

@Test
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());
}
}

Expand All @@ -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)
Expand Down

0 comments on commit 1fa4404

Please sign in to comment.