From caeb3c8ddb9fd34003dd5ad952ff7fc6d8041000 Mon Sep 17 00:00:00 2001 From: "michele.artini" Date: Wed, 3 Nov 2021 10:51:04 +0100 Subject: [PATCH] migration to junit 5 --- apps/dhp-broker-application/pom.xml | 25 +++ apps/dhp-broker-public-application/pom.xml | 27 ++++ apps/dhp-mdstore-manager/pom.xml | 25 ++- .../controller/MDStoreControllerTest.java | 2 +- .../MDStoreControllerWithMocksTest.java | 2 +- apps/dnet-orgs-database-application/pom.xml | 25 +++ cmd-line-apps/pom.xml | 19 +++ libs/dnet-apps-common/pom.xml | 18 ++- libs/dnet-broker-apps-common/pom.xml | 23 ++- .../common/clients/IndexClientTest.java | 46 +++--- .../common/subscriptions/ConditionTest.java | 152 +++++++++--------- .../broker/common/utils/MapValueTest.java | 19 +-- libs/dnet-openaire-broker-common/pom.xml | 24 +++ pom.xml | 6 + 14 files changed, 288 insertions(+), 125 deletions(-) diff --git a/apps/dhp-broker-application/pom.xml b/apps/dhp-broker-application/pom.xml index 4a796aaf..528914ef 100644 --- a/apps/dhp-broker-application/pom.xml +++ b/apps/dhp-broker-application/pom.xml @@ -33,6 +33,31 @@ ${project.version} + + + org.junit.jupiter + junit-jupiter + test + + + + org.mockito + mockito-core + test + + + + org.mockito + mockito-junit-jupiter + test + + + + org.springframework.boot + spring-boot-starter-test + test + + diff --git a/apps/dhp-broker-public-application/pom.xml b/apps/dhp-broker-public-application/pom.xml index 58deda4f..643d86de 100644 --- a/apps/dhp-broker-public-application/pom.xml +++ b/apps/dhp-broker-public-application/pom.xml @@ -22,10 +22,37 @@ dnet-broker-apps-common ${project.version} + org.apache.hadoop hadoop-client + + + + org.junit.jupiter + junit-jupiter + test + + + + org.mockito + mockito-core + test + + + + org.mockito + mockito-junit-jupiter + test + + + + org.springframework.boot + spring-boot-starter-test + test + + diff --git a/apps/dhp-mdstore-manager/pom.xml b/apps/dhp-mdstore-manager/pom.xml index de0e4a25..3f28c3cd 100644 --- a/apps/dhp-mdstore-manager/pom.xml +++ b/apps/dhp-mdstore-manager/pom.xml @@ -60,12 +60,31 @@ dhp-schemas - + - junit - junit + org.junit.jupiter + junit-jupiter test + + + org.mockito + mockito-core + test + + + + org.mockito + mockito-junit-jupiter + test + + + + org.springframework.boot + spring-boot-starter-test + test + + diff --git a/apps/dhp-mdstore-manager/src/test/java/eu/dnetlib/data/mdstore/manager/controller/MDStoreControllerTest.java b/apps/dhp-mdstore-manager/src/test/java/eu/dnetlib/data/mdstore/manager/controller/MDStoreControllerTest.java index 7eca337e..ef71fa1e 100644 --- a/apps/dhp-mdstore-manager/src/test/java/eu/dnetlib/data/mdstore/manager/controller/MDStoreControllerTest.java +++ b/apps/dhp-mdstore-manager/src/test/java/eu/dnetlib/data/mdstore/manager/controller/MDStoreControllerTest.java @@ -1,8 +1,8 @@ package eu.dnetlib.data.mdstore.manager.controller; -import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Date; diff --git a/apps/dhp-mdstore-manager/src/test/java/eu/dnetlib/data/mdstore/manager/controller/MDStoreControllerWithMocksTest.java b/apps/dhp-mdstore-manager/src/test/java/eu/dnetlib/data/mdstore/manager/controller/MDStoreControllerWithMocksTest.java index a0519a28..95a02970 100644 --- a/apps/dhp-mdstore-manager/src/test/java/eu/dnetlib/data/mdstore/manager/controller/MDStoreControllerWithMocksTest.java +++ b/apps/dhp-mdstore-manager/src/test/java/eu/dnetlib/data/mdstore/manager/controller/MDStoreControllerWithMocksTest.java @@ -1,7 +1,7 @@ package eu.dnetlib.data.mdstore.manager.controller; -import static org.junit.Assert.assertTrue; import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.ArgumentMatchers.anyString; import static org.mockito.Mockito.never; import static org.mockito.Mockito.verify; diff --git a/apps/dnet-orgs-database-application/pom.xml b/apps/dnet-orgs-database-application/pom.xml index be642023..2555b13c 100644 --- a/apps/dnet-orgs-database-application/pom.xml +++ b/apps/dnet-orgs-database-application/pom.xml @@ -72,6 +72,31 @@ true + + + org.junit.jupiter + junit-jupiter + test + + + + org.mockito + mockito-core + test + + + + org.mockito + mockito-junit-jupiter + test + + + + org.springframework.boot + spring-boot-starter-test + test + + diff --git a/cmd-line-apps/pom.xml b/cmd-line-apps/pom.xml index fe4dd3bb..2b1ae00b 100644 --- a/cmd-line-apps/pom.xml +++ b/cmd-line-apps/pom.xml @@ -32,6 +32,25 @@ commons-cli + + + org.junit.jupiter + junit-jupiter + test + + + + org.mockito + mockito-core + test + + + + org.mockito + mockito-junit-jupiter + test + + org.springframework.boot spring-boot-starter-test diff --git a/libs/dnet-apps-common/pom.xml b/libs/dnet-apps-common/pom.xml index 883086a5..d3242582 100644 --- a/libs/dnet-apps-common/pom.xml +++ b/libs/dnet-apps-common/pom.xml @@ -73,10 +73,10 @@ 0.3.0 - + - junit - junit + org.junit.jupiter + junit-jupiter test @@ -86,6 +86,18 @@ test + + org.mockito + mockito-junit-jupiter + test + + + + org.springframework.boot + spring-boot-starter-test + test + + diff --git a/libs/dnet-broker-apps-common/pom.xml b/libs/dnet-broker-apps-common/pom.xml index 7ec913f6..372590b2 100644 --- a/libs/dnet-broker-apps-common/pom.xml +++ b/libs/dnet-broker-apps-common/pom.xml @@ -91,10 +91,15 @@ provided - - junit - junit + org.springframework.boot + spring-boot-configuration-processor + + + + + org.junit.jupiter + junit-jupiter test @@ -105,9 +110,17 @@ - org.springframework.boot - spring-boot-configuration-processor + org.mockito + mockito-junit-jupiter + test + + + org.springframework.boot + spring-boot-starter-test + test + + diff --git a/libs/dnet-broker-apps-common/src/test/java/eu/dnetlib/broker/common/clients/IndexClientTest.java b/libs/dnet-broker-apps-common/src/test/java/eu/dnetlib/broker/common/clients/IndexClientTest.java index 20e82791..2e267b4c 100644 --- a/libs/dnet-broker-apps-common/src/test/java/eu/dnetlib/broker/common/clients/IndexClientTest.java +++ b/libs/dnet-broker-apps-common/src/test/java/eu/dnetlib/broker/common/clients/IndexClientTest.java @@ -7,8 +7,8 @@ import org.apache.lucene.search.join.ScoreMode; import org.elasticsearch.action.search.SearchType; import org.elasticsearch.index.query.BoolQueryBuilder; import org.elasticsearch.index.query.QueryBuilders; -import org.junit.Ignore; -import org.junit.Test; +import org.junit.jupiter.api.Disabled; +import org.junit.jupiter.api.Test; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.domain.PageRequest; import org.springframework.data.elasticsearch.annotations.Document; @@ -26,7 +26,7 @@ import eu.dnetlib.broker.common.subscriptions.NotificationMode; import eu.dnetlib.broker.common.subscriptions.Subscription; import eu.dnetlib.broker.common.utils.DateParser; -@Ignore +@Disabled // @RunWith(SpringJUnit4ClassRunner.class) // @ContextConfiguration(locations = { "classpath:/applicationContext-test-queries.xml" }) public class IndexClientTest { @@ -44,12 +44,12 @@ public class IndexClientTest { System.out.println("Start searching"); final NativeSearchQuery searchQuery = new NativeSearchQueryBuilder() - .withQuery(QueryBuilders.boolQuery() - .must(QueryBuilders.matchQuery("topic", topic)) - .must(QueryBuilders.rangeQuery("creationDate").from(fromDate))) - .withSearchType(SearchType.DEFAULT) - .withPageable(PageRequest.of(0, 10)) - .build(); + .withQuery(QueryBuilders.boolQuery() + .must(QueryBuilders.matchQuery("topic", topic)) + .must(QueryBuilders.rangeQuery("creationDate").from(fromDate))) + .withSearchType(SearchType.DEFAULT) + .withPageable(PageRequest.of(0, 10)) + .build(); int count = 0; final CloseableIterator> it = esOperations.searchForStream(searchQuery, Event.class, IndexCoordinates.of(indexName)); @@ -63,7 +63,7 @@ public class IndexClientTest { } @Test - @Ignore + @Disabled public void testSearchSubscription() { System.out.println("Start searching"); @@ -73,25 +73,25 @@ public class IndexClientTest { s.setTopic("ENRICH/MORE/OPENACCESS_VERSION"); s.setFrequency(NotificationFrequency.daily); s.setMode(NotificationMode.MOCK); - s.setConditions( - "[{\"field\":\"targetDatasourceName\",\"fieldType\":\"STRING\",\"operator\":\"EXACT\",\"listParams\":[{\"value\":\"Research Papers in Economics\"}]},{\"field\":\"trust\",\"fieldType\":\"FLOAT\",\"operator\":\"RANGE\",\"listParams\":[{\"value\":\"0\",\"otherValue\":\"1\"}]}]"); + s.setConditions("[{\"field\":\"targetDatasourceName\",\"fieldType\":\"STRING\",\"operator\":\"EXACT\",\"listParams\":[{\"value\":\"Research Papers in Economics\"}]},{\"field\":\"trust\",\"fieldType\":\"FLOAT\",\"operator\":\"RANGE\",\"listParams\":[{\"value\":\"0\",\"otherValue\":\"1\"}]}]"); final BoolQueryBuilder mapQuery = QueryBuilders.boolQuery(); - s.getConditionsAsList().stream() - .map(MapCondition::asQueryBuilder) - .filter(Objects::nonNull) - .forEach(mapQuery::must); + s.getConditionsAsList() + .stream() + .map(MapCondition::asQueryBuilder) + .filter(Objects::nonNull) + .forEach(mapQuery::must); final NativeSearchQuery searchQuery = new NativeSearchQueryBuilder() - .withQuery(QueryBuilders.boolQuery() - .must(QueryBuilders.matchQuery("topic", s.getTopic())) - .must(QueryBuilders.rangeQuery("creationDate").from(s.getLastNotificationDate())) - .must(QueryBuilders.nestedQuery("map", mapQuery, ScoreMode.None))) - .withSearchType(SearchType.DEFAULT) + .withQuery(QueryBuilders.boolQuery() + .must(QueryBuilders.matchQuery("topic", s.getTopic())) + .must(QueryBuilders.rangeQuery("creationDate").from(s.getLastNotificationDate())) + .must(QueryBuilders.nestedQuery("map", mapQuery, ScoreMode.None))) + .withSearchType(SearchType.DEFAULT) - .withPageable(PageRequest.of(0, 10)) - .build(); + .withPageable(PageRequest.of(0, 10)) + .build(); int count = 0; final CloseableIterator> it = esOperations.searchForStream(searchQuery, Event.class, IndexCoordinates.of(indexName)); diff --git a/libs/dnet-broker-apps-common/src/test/java/eu/dnetlib/broker/common/subscriptions/ConditionTest.java b/libs/dnet-broker-apps-common/src/test/java/eu/dnetlib/broker/common/subscriptions/ConditionTest.java index 4939ae6f..c51e8574 100644 --- a/libs/dnet-broker-apps-common/src/test/java/eu/dnetlib/broker/common/subscriptions/ConditionTest.java +++ b/libs/dnet-broker-apps-common/src/test/java/eu/dnetlib/broker/common/subscriptions/ConditionTest.java @@ -1,30 +1,30 @@ package eu.dnetlib.broker.common.subscriptions; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertTrue; import static org.mockito.Mockito.when; import java.util.Arrays; import java.util.HashMap; import java.util.Map; -import org.junit.Before; -import org.junit.Test; -import org.junit.runner.RunWith; +import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.Test; +import org.junit.jupiter.api.extension.ExtendWith; import org.mockito.Mock; -import org.mockito.runners.MockitoJUnitRunner; +import org.mockito.junit.jupiter.MockitoExtension; import eu.dnetlib.broker.common.elasticsearch.Event; import eu.dnetlib.broker.common.utils.DateParser; import eu.dnetlib.broker.common.utils.MapValueType; -@RunWith(MockitoJUnitRunner.class) +@ExtendWith(MockitoExtension.class) public class ConditionTest { @Mock private Event event; - @Before + @BeforeEach public void setUp() throws Exception { final Map map = new HashMap<>(); @@ -40,94 +40,94 @@ public class ConditionTest { @Test public void testVerifyEvent_String() { - assertTrue((new MapCondition("repo", MapValueType.STRING, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("PUMA", null)))) - .verifyEvent(this.event)); - assertFalse((new MapCondition("repo", MapValueType.STRING, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("People", null)))) - .verifyEvent(this.event)); + assertTrue(new MapCondition("repo", MapValueType.STRING, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("PUMA", null))) + .verifyEvent(this.event)); + assertFalse(new MapCondition("repo", MapValueType.STRING, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("People", null))) + .verifyEvent(this.event)); } @Test public void testVerifyEvent_Integer() { - assertTrue((new MapCondition("total", MapValueType.INTEGER, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("1234", null)))) - .verifyEvent(this.event)); - assertFalse((new MapCondition("total", MapValueType.INTEGER, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("2222", null)))) - .verifyEvent(this.event)); - assertTrue((new MapCondition("total", MapValueType.INTEGER, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("1000", "2000")))) - .verifyEvent(this.event)); - assertTrue((new MapCondition("total", MapValueType.INTEGER, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("1200.52", "1300,45")))) - .verifyEvent(this.event)); - assertTrue((new MapCondition("total", MapValueType.INTEGER, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("1000", null)))) - .verifyEvent(this.event)); - assertTrue((new MapCondition("total", MapValueType.INTEGER, ConditionOperator.RANGE, Arrays.asList(new ConditionParams(null, "2000")))) - .verifyEvent(this.event)); - assertFalse((new MapCondition("total", MapValueType.INTEGER, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("0", "1000")))) - .verifyEvent(this.event)); + assertTrue(new MapCondition("total", MapValueType.INTEGER, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("1234", null))) + .verifyEvent(this.event)); + assertFalse(new MapCondition("total", MapValueType.INTEGER, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("2222", null))) + .verifyEvent(this.event)); + assertTrue(new MapCondition("total", MapValueType.INTEGER, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("1000", "2000"))) + .verifyEvent(this.event)); + assertTrue(new MapCondition("total", MapValueType.INTEGER, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("1200.52", "1300,45"))) + .verifyEvent(this.event)); + assertTrue(new MapCondition("total", MapValueType.INTEGER, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("1000", null))) + .verifyEvent(this.event)); + assertTrue(new MapCondition("total", MapValueType.INTEGER, ConditionOperator.RANGE, Arrays.asList(new ConditionParams(null, "2000"))) + .verifyEvent(this.event)); + assertFalse(new MapCondition("total", MapValueType.INTEGER, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("0", "1000"))) + .verifyEvent(this.event)); } @Test public void testVerifyEvent_Float() { - assertTrue((new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("1.23d", null)))) - .verifyEvent(this.event)); - assertFalse((new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("1.2d", null)))) - .verifyEvent(this.event)); - assertTrue((new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("1", "2")))) - .verifyEvent(this.event)); - assertTrue((new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("1.2", "1.35")))) - .verifyEvent(this.event)); - assertTrue((new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("1", null)))) - .verifyEvent(this.event)); - assertTrue((new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.RANGE, Arrays.asList(new ConditionParams(null, "2")))) - .verifyEvent(this.event)); - assertFalse((new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("2", "3.2")))) - .verifyEvent(this.event)); + assertTrue(new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("1.23d", null))) + .verifyEvent(this.event)); + assertFalse(new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("1.2d", null))) + .verifyEvent(this.event)); + assertTrue(new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("1", "2"))) + .verifyEvent(this.event)); + assertTrue(new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("1.2", "1.35"))) + .verifyEvent(this.event)); + assertTrue(new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("1", null))) + .verifyEvent(this.event)); + assertTrue(new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.RANGE, Arrays.asList(new ConditionParams(null, "2"))) + .verifyEvent(this.event)); + assertFalse(new MapCondition("impact", MapValueType.FLOAT, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("2", "3.2"))) + .verifyEvent(this.event)); } @Test public void testVerifyEvent_Date() { - assertTrue((new MapCondition("date", MapValueType.DATE, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("2012-05-15", null)))) - .verifyEvent(this.event)); - assertFalse((new MapCondition("date", MapValueType.DATE, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("2012-05-16", null)))) - .verifyEvent(this.event)); - assertTrue((new MapCondition("date", MapValueType.DATE, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("2012-05-01", "2012-05-31")))) - .verifyEvent(this.event)); - assertTrue((new MapCondition("date", MapValueType.DATE, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("2012-05-01", null)))) - .verifyEvent(this.event)); - assertTrue((new MapCondition("date", MapValueType.DATE, ConditionOperator.RANGE, Arrays.asList(new ConditionParams(null, "2012-05-31")))) - .verifyEvent(this.event)); - assertFalse((new MapCondition("date", MapValueType.DATE, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("2013-01-01", "2013-12-31")))) - .verifyEvent(this.event)); + assertTrue(new MapCondition("date", MapValueType.DATE, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("2012-05-15", null))) + .verifyEvent(this.event)); + assertFalse(new MapCondition("date", MapValueType.DATE, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("2012-05-16", null))) + .verifyEvent(this.event)); + assertTrue(new MapCondition("date", MapValueType.DATE, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("2012-05-01", "2012-05-31"))) + .verifyEvent(this.event)); + assertTrue(new MapCondition("date", MapValueType.DATE, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("2012-05-01", null))) + .verifyEvent(this.event)); + assertTrue(new MapCondition("date", MapValueType.DATE, ConditionOperator.RANGE, Arrays.asList(new ConditionParams(null, "2012-05-31"))) + .verifyEvent(this.event)); + assertFalse(new MapCondition("date", MapValueType.DATE, ConditionOperator.RANGE, Arrays.asList(new ConditionParams("2013-01-01", "2013-12-31"))) + .verifyEvent(this.event)); } @Test public void testVerifyEvent_Boolean() { - assertTrue((new MapCondition("open", MapValueType.BOOLEAN, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("false", null)))) - .verifyEvent(this.event)); - assertFalse((new MapCondition("open", MapValueType.BOOLEAN, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("true", null)))) - .verifyEvent(this.event)); + assertTrue(new MapCondition("open", MapValueType.BOOLEAN, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("false", null))) + .verifyEvent(this.event)); + assertFalse(new MapCondition("open", MapValueType.BOOLEAN, ConditionOperator.EXACT, Arrays.asList(new ConditionParams("true", null))) + .verifyEvent(this.event)); } @Test public void testVerifyEvent_List_String() { - assertTrue((new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ALL, - Arrays.asList(new ConditionParams("artini michele", null)))).verifyEvent(this.event)); - assertTrue((new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ALL, Arrays.asList(new ConditionParams("artini", null)))) - .verifyEvent(this.event)); - assertTrue((new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ANY, - Arrays.asList(new ConditionParams("artini michele", null)))).verifyEvent(this.event)); - assertTrue((new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ANY, - Arrays.asList(new ConditionParams("artini giuseppe", null)))).verifyEvent(this.event)); - assertTrue((new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ANY, Arrays.asList(new ConditionParams("artini", null)))) - .verifyEvent(this.event)); - assertFalse((new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ALL, - Arrays.asList(new ConditionParams("artini giuseppe", null)))).verifyEvent(this.event)); - assertFalse((new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ALL, Arrays.asList(new ConditionParams("giuseppe", null)))) - .verifyEvent(this.event)); - assertFalse((new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ALL, - Arrays.asList(new ConditionParams("bardi claudio", null)))).verifyEvent(this.event)); - assertFalse((new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ANY, - Arrays.asList(new ConditionParams("andrea mannocci", null)))).verifyEvent(this.event)); - assertFalse((new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ANY, Arrays.asList(new ConditionParams("mannocci", null)))) - .verifyEvent(this.event)); + assertTrue(new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ALL, + Arrays.asList(new ConditionParams("artini michele", null))).verifyEvent(this.event)); + assertTrue(new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ALL, Arrays.asList(new ConditionParams("artini", null))) + .verifyEvent(this.event)); + assertTrue(new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ANY, + Arrays.asList(new ConditionParams("artini michele", null))).verifyEvent(this.event)); + assertTrue(new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ANY, + Arrays.asList(new ConditionParams("artini giuseppe", null))).verifyEvent(this.event)); + assertTrue(new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ANY, Arrays.asList(new ConditionParams("artini", null))) + .verifyEvent(this.event)); + assertFalse(new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ALL, + Arrays.asList(new ConditionParams("artini giuseppe", null))).verifyEvent(this.event)); + assertFalse(new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ALL, Arrays.asList(new ConditionParams("giuseppe", null))) + .verifyEvent(this.event)); + assertFalse(new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ALL, + Arrays.asList(new ConditionParams("bardi claudio", null))).verifyEvent(this.event)); + assertFalse(new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ANY, + Arrays.asList(new ConditionParams("andrea mannocci", null))).verifyEvent(this.event)); + assertFalse(new MapCondition("authors", MapValueType.LIST_STRING, ConditionOperator.MATCH_ANY, Arrays.asList(new ConditionParams("mannocci", null))) + .verifyEvent(this.event)); } } diff --git a/libs/dnet-broker-apps-common/src/test/java/eu/dnetlib/broker/common/utils/MapValueTest.java b/libs/dnet-broker-apps-common/src/test/java/eu/dnetlib/broker/common/utils/MapValueTest.java index 52b86800..429149a8 100644 --- a/libs/dnet-broker-apps-common/src/test/java/eu/dnetlib/broker/common/utils/MapValueTest.java +++ b/libs/dnet-broker-apps-common/src/test/java/eu/dnetlib/broker/common/utils/MapValueTest.java @@ -1,26 +1,19 @@ package eu.dnetlib.broker.common.utils; -import static org.junit.Assert.assertEquals; -import static org.junit.Assert.assertFalse; -import static org.junit.Assert.assertNotNull; -import static org.junit.Assert.assertNull; -import static org.junit.Assert.assertTrue; +import static org.junit.jupiter.api.Assertions.assertEquals; +import static org.junit.jupiter.api.Assertions.assertFalse; +import static org.junit.jupiter.api.Assertions.assertNotNull; +import static org.junit.jupiter.api.Assertions.assertNull; +import static org.junit.jupiter.api.Assertions.assertTrue; import java.util.Arrays; import java.util.Date; import java.util.List; -import org.junit.Before; -import org.junit.Test; - -import eu.dnetlib.broker.common.utils.MapValue; -import eu.dnetlib.broker.common.utils.MapValueType; +import org.junit.jupiter.api.Test; public class MapValueTest { - @Before - public void setUp() throws Exception {} - @Test public void test_null_value() { final MapValue v = new MapValue(MapValueType.STRING, null); diff --git a/libs/dnet-openaire-broker-common/pom.xml b/libs/dnet-openaire-broker-common/pom.xml index 0c914cd3..30245d55 100644 --- a/libs/dnet-openaire-broker-common/pom.xml +++ b/libs/dnet-openaire-broker-common/pom.xml @@ -19,7 +19,31 @@ gson provided + + + + org.junit.jupiter + junit-jupiter + test + + + org.mockito + mockito-core + test + + + + org.mockito + mockito-junit-jupiter + test + + + + org.springframework.boot + spring-boot-starter-test + test + diff --git a/pom.xml b/pom.xml index 02d35652..8c123ed9 100644 --- a/pom.xml +++ b/pom.xml @@ -135,6 +135,12 @@ mockito-junit-jupiter test + + + org.springframework.boot + spring-boot-starter-test + test +