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 Oct 27, 2022
1 parent da3dad4 commit 7f444ac
Show file tree
Hide file tree
Showing 40 changed files with 890 additions and 856 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,10 @@
import java.util.Collection;
import java.util.List;


@Category(JUnitTests.class)
@RunWith(value = Parameterized.class)
public class AbstractKapuaQueryTest extends Assert {
public class AbstractKapuaQueryTest {

private final String attributeName;

Expand Down Expand Up @@ -85,7 +86,7 @@ public ActualKapuaQuery(KapuaQuery query) {
public void abstractKapuaQueryScopeIdTest() {
KapuaId scopeId = new KapuaEid();
AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery(scopeId);
assertEquals("Actual and expected values are not the same!", scopeId, kapuaQuery.getScopeId());
Assert.assertEquals("Actual and expected values are not the same!", scopeId, kapuaQuery.getScopeId());
}

@Test
Expand All @@ -104,11 +105,11 @@ public void abstractKapuaQueryQueryIdTest() {
kapuaQuery.setOffset(offset);
kapuaQuery.setSortCriteria(sortCriteria);
AbstractKapuaQuery kapuaCopyQuery = new ActualKapuaQuery(kapuaQuery);
assertEquals("Actual and expected values are not the same!", kapuaQuery.getFetchAttributes(), kapuaCopyQuery.getFetchAttributes());
assertEquals("Actual and expected values are not the same!", kapuaQuery.getPredicate(), kapuaCopyQuery.getPredicate());
assertEquals("Actual and expected values are not the same!", kapuaQuery.getLimit(), kapuaCopyQuery.getLimit());
assertEquals("Actual and expected values are not the same!", kapuaQuery.getOffset(), kapuaCopyQuery.getOffset());
assertEquals("Actual and expected values are not the same!", kapuaQuery.getSortCriteria(), kapuaCopyQuery.getSortCriteria());
Assert.assertEquals("Actual and expected values are not the same!", kapuaQuery.getFetchAttributes(), kapuaCopyQuery.getFetchAttributes());
Assert.assertEquals("Actual and expected values are not the same!", kapuaQuery.getPredicate(), kapuaCopyQuery.getPredicate());
Assert.assertEquals("Actual and expected values are not the same!", kapuaQuery.getLimit(), kapuaCopyQuery.getLimit());
Assert.assertEquals("Actual and expected values are not the same!", kapuaQuery.getOffset(), kapuaCopyQuery.getOffset());
Assert.assertEquals("Actual and expected values are not the same!", kapuaQuery.getSortCriteria(), kapuaCopyQuery.getSortCriteria());
}

@Test
Expand All @@ -117,38 +118,38 @@ public void addFetchAttributesTest() {
String emptyFetchAttribute = "";
String fetchAttribute = "fetchAttribute";
kapuaQuery.addFetchAttributes(null);
assertEquals("Actual and expected values are not the same!", null, kapuaQuery.getFetchAttributes().get(0));
Assert.assertEquals("Actual and expected values are not the same!", null, kapuaQuery.getFetchAttributes().get(0));
kapuaQuery.addFetchAttributes(fetchAttribute);
assertEquals("Actual and expected values are not the same!", fetchAttribute, kapuaQuery.getFetchAttributes().get(1));
Assert.assertEquals("Actual and expected values are not the same!", fetchAttribute, kapuaQuery.getFetchAttributes().get(1));
kapuaQuery.addFetchAttributes(emptyFetchAttribute);
assertEquals("Actual and expected values are not the same!", emptyFetchAttribute, kapuaQuery.getFetchAttributes().get(2));
Assert.assertEquals("Actual and expected values are not the same!", emptyFetchAttribute, kapuaQuery.getFetchAttributes().get(2));
}

@Test
public void attributePredicateTest() {
AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery();
Object attributeValue = new Object();
AttributePredicate<Object> attributePredicate = kapuaQuery.attributePredicate(attributeName, attributeValue);
assertEquals("Actual and expected values are not the same!", attributeName, attributePredicate.getAttributeName());
assertEquals("Actual and expected values are not the same!", attributeValue, attributePredicate.getAttributeValue());
Assert.assertEquals("Actual and expected values are not the same!", attributeName, attributePredicate.getAttributeName());
Assert.assertEquals("Actual and expected values are not the same!", attributeValue, attributePredicate.getAttributeValue());
}

@Test
public void attributePredicateWithOperatorTest() {
AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery();
Object attributeValue = new Object();
AttributePredicate<Object> attributePredicate = kapuaQuery.attributePredicate(attributeName, attributeValue, operator);
assertEquals("Actual and expected values are not the same!", attributeName, attributePredicate.getAttributeName());
assertEquals("Actual and expected values are not the same!", attributeValue, attributePredicate.getAttributeValue());
assertEquals("Actual and expected values are not the same!", operator, attributePredicate.getOperator());
Assert.assertEquals("Actual and expected values are not the same!", attributeName, attributePredicate.getAttributeName());
Assert.assertEquals("Actual and expected values are not the same!", attributeValue, attributePredicate.getAttributeValue());
Assert.assertEquals("Actual and expected values are not the same!", operator, attributePredicate.getOperator());
}

@Test
public void andPredicateTest() {
AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery();
AndPredicate andPredicate = kapuaQuery.andPredicate();
ArrayList<QueryPredicate> queryPredicateArray = new ArrayList<>();
assertEquals("Actual and expected values are not the same!", queryPredicateArray, andPredicate.getPredicates());
Assert.assertEquals("Actual and expected values are not the same!", queryPredicateArray, andPredicate.getPredicates());
}

@Test
Expand All @@ -159,15 +160,15 @@ public void andPredicateWithQueryPredicatesTest() {
queryPredicateArray[i] = Mockito.mock(AndPredicateImpl.class);
}
AndPredicate andPredicate = new AndPredicateImpl(queryPredicateArray);
assertEquals("Actual and expected values are not the same!", andPredicate.getPredicates(), kapuaQuery.andPredicate(queryPredicateArray).getPredicates());
Assert.assertEquals("Actual and expected values are not the same!", andPredicate.getPredicates(), kapuaQuery.andPredicate(queryPredicateArray).getPredicates());
}

@Test
public void orPredicateTest() {
AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery();
OrPredicate orPredicate = kapuaQuery.orPredicate();
ArrayList<QueryPredicate> queryPredicateArray = new ArrayList<>();
assertEquals("Actual and expected values are not the same!", queryPredicateArray, orPredicate.getPredicates());
Assert.assertEquals("Actual and expected values are not the same!", queryPredicateArray, orPredicate.getPredicates());
}

@Test
Expand All @@ -178,15 +179,15 @@ public void orPredicateWithQueryPredicatesTest() {
queryPredicateArray[i] = Mockito.mock(AndPredicateImpl.class);
}
OrPredicate orPredicate = new OrPredicateImpl(queryPredicateArray);
assertEquals("Actual and expected values are not the same!", orPredicate.getPredicates(), kapuaQuery.orPredicate(queryPredicateArray).getPredicates());
Assert.assertEquals("Actual and expected values are not the same!", orPredicate.getPredicates(), kapuaQuery.orPredicate(queryPredicateArray).getPredicates());
}

@Test
public void getAskTotalCountTest() {
AbstractKapuaQuery kapuaQuery = new ActualKapuaQuery();
kapuaQuery.setAskTotalCount(true);
assertEquals("Actual and expected values are not the same!", true, kapuaQuery.getAskTotalCount());
Assert.assertEquals("Actual and expected values are not the same!", true, kapuaQuery.getAskTotalCount());
kapuaQuery.setAskTotalCount(false);
assertEquals("Actual and expected values are not the same!", false, kapuaQuery.getAskTotalCount());
Assert.assertEquals("Actual and expected values are not the same!", false, kapuaQuery.getAskTotalCount());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,10 @@

import java.util.Arrays;


@Category(JUnitTests.class)
@RunWith(value = Parameterized.class)
public class FieldSortCriteriaImplTest extends Assert {
public class FieldSortCriteriaImplTest {

private final String attributeName;
private SortOrder sortOrder;
Expand All @@ -50,11 +51,11 @@ public static Iterable<Object[]> attributeNames() {
public void fieldSortCriteriaImplTest() {
SortOrder sortOrderAscending = SortOrder.ASCENDING;
FieldSortCriteriaImpl fieldSortCriteriaAscending = new FieldSortCriteriaImpl(attributeName, sortOrderAscending);
assertEquals("Actual and expected values are not the same!", attributeName, fieldSortCriteriaAscending.getAttributeName());
assertEquals("Actual and expected values are not the same!", sortOrderAscending, fieldSortCriteriaAscending.getSortOrder());
Assert.assertEquals("Actual and expected values are not the same!", attributeName, fieldSortCriteriaAscending.getAttributeName());
Assert.assertEquals("Actual and expected values are not the same!", sortOrderAscending, fieldSortCriteriaAscending.getSortOrder());
SortOrder sortOrderDescending = SortOrder.DESCENDING;
FieldSortCriteriaImpl fieldSortCriteriaDescending = new FieldSortCriteriaImpl(attributeName, sortOrderDescending);
assertEquals("Actual and expected values are not the same!", attributeName, fieldSortCriteriaDescending.getAttributeName());
assertEquals("Actual and expected values are not the same!", sortOrderDescending, fieldSortCriteriaDescending.getSortOrder());
Assert.assertEquals("Actual and expected values are not the same!", attributeName, fieldSortCriteriaDescending.getAttributeName());
Assert.assertEquals("Actual and expected values are not the same!", sortOrderDescending, fieldSortCriteriaDescending.getSortOrder());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -21,28 +21,29 @@
import java.util.ArrayList;
import java.util.List;


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

@Test
public void andPredicateImpl() {
AndPredicateImpl andPredicate = new AndPredicateImpl();
ArrayList<Object> array = new ArrayList<>();
assertEquals("Actual and expected values are not the same!", array, andPredicate.getPredicates());
Assert.assertEquals("Actual and expected values are not the same!", array, andPredicate.getPredicates());
}

@Test
public void andPredicateImplQueryPredicateId() {
QueryPredicate queryPredicate = new AndPredicateImpl();
AndPredicateImpl andPredicate = new AndPredicateImpl(queryPredicate);
assertEquals("Actual and expected values are not the same!", queryPredicate, andPredicate.getPredicates().get(0));
Assert.assertEquals("Actual and expected values are not the same!", queryPredicate, andPredicate.getPredicates().get(0));
QueryPredicate queryPredicate1 = new AndPredicateImpl();
QueryPredicate queryPredicate2 = new AndPredicateImpl();
QueryPredicate queryPredicate3 = new AndPredicateImpl();
QueryPredicate[] queryPredicateArray = {queryPredicate1, queryPredicate2, queryPredicate3};
AndPredicateImpl andPredicateWithMultiplePredicates = new AndPredicateImpl(queryPredicate1, queryPredicate2, queryPredicate3);
for (int i = 0; i < queryPredicateArray.length; i++) {
assertEquals("Actual and expected values are not the same!", queryPredicateArray[i], andPredicateWithMultiplePredicates.getPredicates().get(i));
Assert.assertEquals("Actual and expected values are not the same!", queryPredicateArray[i], andPredicateWithMultiplePredicates.getPredicates().get(i));
}
}

Expand All @@ -51,14 +52,14 @@ public void andTest() {
AndPredicateImpl andPredicate = new AndPredicateImpl();
QueryPredicate queryPredicate = new AndPredicateImpl();
andPredicate.and(queryPredicate);
assertEquals("Actual and expected values are not the same!", queryPredicate, andPredicate.getPredicates().get(0));
Assert.assertEquals("Actual and expected values are not the same!", queryPredicate, andPredicate.getPredicates().get(0));
}

@Test
public void andWithNullPredicateTest() {
AndPredicateImpl andPredicate = new AndPredicateImpl();
andPredicate.and(null);
assertNull(andPredicate.getPredicates().get(0));
Assert.assertNull(andPredicate.getPredicates().get(0));
}

@Test
Expand All @@ -70,7 +71,7 @@ public void getPredicatesTest() {
predicates.add(new AndPredicateImpl());
andPredicate.setPredicates(predicates);
for (int i = 0; i < predicates.size(); i++) {
assertEquals("Actual and expected values are not the same!", predicates.get(i), andPredicate.getPredicates().get(i));
Assert.assertEquals("Actual and expected values are not the same!", predicates.get(i), andPredicate.getPredicates().get(i));
}
}
}
Loading

0 comments on commit 7f444ac

Please sign in to comment.