migration to junit 5
This commit is contained in:
parent
e774487903
commit
caeb3c8ddb
|
@ -33,6 +33,31 @@
|
|||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<!-- Tests -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -22,10 +22,37 @@
|
|||
<artifactId>dnet-broker-apps-common</artifactId>
|
||||
<version>${project.version}</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.hadoop</groupId>
|
||||
<artifactId>hadoop-client</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Tests -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -60,12 +60,31 @@
|
|||
<artifactId>dhp-schemas</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- JUnit -->
|
||||
<!-- Tests -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -72,6 +72,31 @@
|
|||
<optional>true</optional>
|
||||
</dependency>
|
||||
|
||||
<!-- Tests -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
|
|
|
@ -32,6 +32,25 @@
|
|||
<artifactId>commons-cli</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Tests -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
|
|
|
@ -73,10 +73,10 @@
|
|||
<version>0.3.0</version>
|
||||
</dependency>
|
||||
|
||||
<!-- JUNIT -->
|
||||
<!-- Tests -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -86,6 +86,18 @@
|
|||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -91,10 +91,15 @@
|
|||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- JUNIT -->
|
||||
<dependency>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!-- Tests -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
|
@ -105,9 +110,17 @@
|
|||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-configuration-processor</artifactId>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
</dependencies>
|
||||
|
||||
</project>
|
||||
|
|
|
@ -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<SearchHit<Event>> 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<SearchHit<Event>> it = esOperations.searchForStream(searchQuery, Event.class, IndexCoordinates.of(indexName));
|
||||
|
|
|
@ -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<String, Object> 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));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -19,7 +19,31 @@
|
|||
<artifactId>gson</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
|
||||
<!-- Tests -->
|
||||
<dependency>
|
||||
<groupId>org.junit.jupiter</groupId>
|
||||
<artifactId>junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-core</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.mockito</groupId>
|
||||
<artifactId>mockito-junit-jupiter</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.springframework.boot</groupId>
|
||||
<artifactId>spring-boot-starter-test</artifactId>
|
||||
<scope>test</scope>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue