diff --git a/eng/versioning/external_dependencies.txt b/eng/versioning/external_dependencies.txt
index 30cd272f5fbb..a215ba5f8cc6 100644
--- a/eng/versioning/external_dependencies.txt
+++ b/eng/versioning/external_dependencies.txt
@@ -339,7 +339,6 @@ springboot3_io.projectreactor:reactor-test;3.7.9
springboot3_jakarta.servlet:jakarta.servlet-api;6.0.0
springboot3_jakarta.validation:jakarta.validation-api;3.0.2
springboot3_javax.annotation:javax.annotation-api;1.3.2
-springboot3_junit:junit;4.13.2
springboot3_net.bytebuddy:byte-buddy-agent;1.17.7
springboot3_net.bytebuddy:byte-buddy;1.17.7
springboot3_org.apache.commons:commons-lang3;3.17.0
@@ -355,7 +354,6 @@ springboot3_org.assertj:assertj-core;3.27.4
springboot3_org.hibernate.validator:hibernate-validator;8.0.3.Final
springboot3_org.javatuples:javatuples;1.2
springboot3_org.junit.jupiter:junit-jupiter;5.12.2
-springboot3_org.junit.vintage:junit-vintage-engine;5.12.2
springboot3_org.messaginghub:pooled-jms;3.1.7
springboot3_org.mockito:mockito-core;5.17.0
springboot3_org.postgresql:postgresql;42.7.7
diff --git a/sdk/spring/azure-spring-data-cosmos/pom.xml b/sdk/spring/azure-spring-data-cosmos/pom.xml
index b5840b325b6a..67b68bf41a42 100644
--- a/sdk/spring/azure-spring-data-cosmos/pom.xml
+++ b/sdk/spring/azure-spring-data-cosmos/pom.xml
@@ -154,12 +154,6 @@
1.17.7
test
-
- junit
- junit
- 4.13.2
- test
-
org.springframework.boot
spring-boot-starter-test
@@ -202,18 +196,6 @@
slf4j-api
2.0.17
-
- org.junit.vintage
- junit-vintage-engine
- 5.12.2
- test
-
-
- org.hamcrest
- hamcrest-core
-
-
-
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/AbstractIntegrationTestCollectionManager.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/AbstractIntegrationTestCollectionManager.java
index b856a0f85888..d5edd2a06f1a 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/AbstractIntegrationTestCollectionManager.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/AbstractIntegrationTestCollectionManager.java
@@ -6,9 +6,6 @@
import com.azure.spring.data.cosmos.core.CosmosTemplate;
import com.azure.spring.data.cosmos.core.ReactiveCosmosTemplate;
import com.azure.spring.data.cosmos.repository.support.CosmosEntityInformation;
-import org.junit.rules.TestRule;
-import org.junit.runner.Description;
-import org.junit.runners.model.Statement;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -19,7 +16,7 @@
import java.util.concurrent.ConcurrentMap;
@SuppressWarnings({"rawtypes", "unchecked"})
-public abstract class AbstractIntegrationTestCollectionManager implements TestRule {
+public abstract class AbstractIntegrationTestCollectionManager {
private static final Logger LOGGER = LoggerFactory.getLogger(AbstractIntegrationTestCollectionManager.class);
private static final Duration LEASE_DURATION = Duration.ofSeconds(5 * 60);
@@ -115,19 +112,6 @@ private void releaseLocks() {
}
}
- @Override
- public Statement apply(Statement base, Description description) {
- return new Statement() {
- public void evaluate() throws Throwable {
- try {
- base.evaluate();
- } finally {
- releaseLocks();
- }
- }
- };
- }
-
private static class ContainerRefs {
CosmosEntityInformation cosmosEntityInformation;
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/ContainerLockIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/ContainerLockIT.java
index 38e28ada4d18..0874f91e7cf6 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/ContainerLockIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/ContainerLockIT.java
@@ -6,21 +6,21 @@
import com.azure.spring.data.cosmos.domain.Address;
import com.azure.spring.data.cosmos.repository.TestRepositoryConfig;
import com.azure.spring.data.cosmos.repository.support.CosmosEntityInformation;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.time.Duration;
import java.time.OffsetDateTime;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestRepositoryConfig.class)
@SuppressWarnings({"rawtypes", "unchecked"})
public class ContainerLockIT {
@@ -36,7 +36,7 @@ public class ContainerLockIT {
private ContainerLock lock;
private ContainerLock otherLock;
- @Before
+ @BeforeEach
public void setup() {
staticTemplate = template;
CosmosEntityInformation entityInfo = new CosmosEntityInformation(Address.class);
@@ -46,7 +46,7 @@ public void setup() {
otherLock = new ContainerLock(reactiveTemplate, entityInfo.getContainerName(), SHORT_LEASE_DURATION);
}
- @After
+ @AfterEach
public void cleanup() {
releaseLockIgnoreException(lock);
releaseLockIgnoreException(otherLock);
@@ -81,7 +81,7 @@ public void acquireShouldThrowExceptionIfWaitForIsLessThanLeaseDuration() {
try {
otherLock.acquire(SHORT_LEASE_DURATION.minusSeconds(1));
- Assert.fail();
+ Assertions.fail();
} catch (ContainerLock.LockAcquisitionFailedException ex) {
}
}
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/CosmosFactoryTestIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/CosmosFactoryTestIT.java
index 12cb621cf85a..108d70296bd5 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/CosmosFactoryTestIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/CosmosFactoryTestIT.java
@@ -5,17 +5,17 @@
import com.azure.cosmos.CosmosAsyncClient;
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.spring.data.cosmos.repository.TestRepositoryConfig;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.lang.reflect.Field;
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestRepositoryConfig.class)
public class CosmosFactoryTestIT {
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/ExpressionResolverUnitTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/ExpressionResolverUnitTest.java
index 40bf96bfa513..4f4cec394d2d 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/ExpressionResolverUnitTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/ExpressionResolverUnitTest.java
@@ -2,15 +2,15 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.common;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.config.ConfigurableBeanFactory;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.PropertySource;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class ExpressionResolverUnitTest {
private static final String LITERAL_EXPRESSION = "literal expression";
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/MemoizerUnitTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/MemoizerUnitTest.java
index 88c79e428d33..178113c302b0 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/MemoizerUnitTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/MemoizerUnitTest.java
@@ -2,8 +2,8 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.common;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import java.util.HashMap;
import java.util.Map;
@@ -11,7 +11,7 @@
import java.util.function.Function;
import java.util.stream.IntStream;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
public class MemoizerUnitTest {
@@ -20,7 +20,7 @@ public class MemoizerUnitTest {
private static final Function MEMOIZED_FUNCTION =
Memoizer.memoize(MemoizerUnitTest::incrCount);
- @Before
+ @BeforeEach
public void setUp() {
COUNT_MAP.put(KEY, new AtomicInteger(0));
}
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/PageTestUtils.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/PageTestUtils.java
index 36ce7dc5bff2..e51797db2ba0 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/PageTestUtils.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/PageTestUtils.java
@@ -11,7 +11,7 @@
import org.springframework.data.domain.Pageable;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertTrue;
+import static org.junit.jupiter.api.Assertions.assertTrue;
public class PageTestUtils {
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/PropertyLoaderUnitTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/PropertyLoaderUnitTest.java
index ccbe5eddb73f..11e1a089307f 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/PropertyLoaderUnitTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/common/PropertyLoaderUnitTest.java
@@ -2,8 +2,8 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.common;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
public class PropertyLoaderUnitTest {
@@ -11,8 +11,8 @@ public class PropertyLoaderUnitTest {
public void testGetProjectVersion() {
final String version = PropertyLoader.getProjectVersion();
- Assert.assertNotNull(version);
- Assert.assertNotEquals(version, "");
- Assert.assertNotEquals(version, "@project.version@");
+ Assertions.assertNotNull(version);
+ Assertions.assertNotEquals(version, "");
+ Assertions.assertNotEquals(version, "@project.version@");
}
}
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/config/AbstractCosmosConfigurationIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/config/AbstractCosmosConfigurationIT.java
index c3371d44f68f..24f29aeffbf7 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/config/AbstractCosmosConfigurationIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/config/AbstractCosmosConfigurationIT.java
@@ -11,10 +11,7 @@
import com.azure.spring.data.cosmos.common.ExpressionResolver;
import com.azure.spring.data.cosmos.common.TestConstants;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.assertj.core.api.Assertions;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
@@ -26,13 +23,13 @@
import java.lang.reflect.Field;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.assertj.core.api.Assertions.assertThat;
+import static org.junit.jupiter.api.Assertions.assertThrows;
public class AbstractCosmosConfigurationIT {
- @SuppressWarnings("deprecation")
- @Rule
- public ExpectedException exception = ExpectedException.none();
+
@Test
public void containsExpressionResolver() {
@@ -47,15 +44,17 @@ public void containsCosmosFactory() {
final AbstractApplicationContext context = new AnnotationConfigApplicationContext(
TestCosmosConfiguration.class);
- Assertions.assertThat(context.getBean(CosmosFactory.class)).isNotNull();
+ assertThat(context.getBean(CosmosFactory.class)).isNotNull();
}
- @Test(expected = NoSuchBeanDefinitionException.class)
+ @Test
public void defaultObjectMapperBeanNotExists() {
- final AbstractApplicationContext context = new AnnotationConfigApplicationContext(
- TestCosmosConfiguration.class);
+ assertThrows(NoSuchBeanDefinitionException.class, () -> {
+ final AbstractApplicationContext context = new AnnotationConfigApplicationContext(
+ TestCosmosConfiguration.class);
- context.getBean(ObjectMapper.class);
+ context.getBean(ObjectMapper.class);
+ });
}
@Test
@@ -63,8 +62,8 @@ public void objectMapperIsConfigurable() {
final AbstractApplicationContext context = new AnnotationConfigApplicationContext(
ObjectMapperConfiguration.class);
- Assertions.assertThat(context.getBean(ObjectMapper.class)).isNotNull();
- Assertions.assertThat(context.getBean(Constants.OBJECT_MAPPER_BEAN_NAME)).isNotNull();
+ assertThat(context.getBean(ObjectMapper.class)).isNotNull();
+ assertThat(context.getBean(Constants.OBJECT_MAPPER_BEAN_NAME)).isNotNull();
}
@Test
@@ -73,16 +72,16 @@ public void testCosmosClientBuilderConfigurable() throws IllegalAccessException,
RequestOptionsConfiguration.class);
final CosmosFactory factory = context.getBean(CosmosFactory.class);
- Assertions.assertThat(factory).isNotNull();
+ assertThat(factory).isNotNull();
final CosmosAsyncClient cosmosAsyncClient = factory.getCosmosAsyncClient();
- Assertions.assertThat(cosmosAsyncClient).isNotNull();
+ assertThat(cosmosAsyncClient).isNotNull();
Field desiredConsistencyLevel = cosmosAsyncClient.getClass().getDeclaredField("desiredConsistencyLevel");
desiredConsistencyLevel.setAccessible(true);
ConsistencyLevel consistencyLevel =
(ConsistencyLevel) desiredConsistencyLevel.get(cosmosAsyncClient);
- Assertions.assertThat(consistencyLevel).isEqualTo(ConsistencyLevel.CONSISTENT_PREFIX);
+ assertThat(consistencyLevel).isEqualTo(ConsistencyLevel.CONSISTENT_PREFIX);
}
@Configuration
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosFactoryUnitTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosFactoryUnitTest.java
index cca2296ee87d..940c3caeec01 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosFactoryUnitTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosFactoryUnitTest.java
@@ -7,16 +7,16 @@
import com.azure.spring.data.cosmos.Constants;
import com.azure.spring.data.cosmos.CosmosFactory;
import com.azure.spring.data.cosmos.common.PropertyLoader;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method;
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class CosmosFactoryUnitTest {
@Test
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIT.java
index f0939fae596a..9daa3a398ba4 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIT.java
@@ -46,11 +46,10 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import org.assertj.core.util.Lists;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-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.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.context.ApplicationContext;
@@ -62,7 +61,6 @@
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.query.parser.Part;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.util.ReflectionTestUtils;
import java.lang.reflect.InvocationTargetException;
@@ -102,12 +100,9 @@
import static com.azure.spring.data.cosmos.common.TestConstants.TRANSIENT_PROPERTY;
import static com.azure.spring.data.cosmos.common.TestConstants.UPDATED_FIRST_NAME;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.assertTrue;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.*;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestRepositoryConfig.class)
public class CosmosTemplateIT {
private static final Person TEST_PERSON = new Person(ID_1, FIRST_NAME, LAST_NAME, HOBBIES,
@@ -160,7 +155,7 @@ public class CosmosTemplateIT {
private static final CosmosPatchItemRequestOptions options = new CosmosPatchItemRequestOptions();
- @ClassRule
+
public static final IntegrationTestCollectionManager collectionManager = new IntegrationTestCollectionManager();
private static CosmosAsyncClient client;
@@ -192,7 +187,7 @@ public class CosmosTemplateIT {
public CosmosTemplateIT() throws JsonProcessingException {
}
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
if (cosmosTemplate == null) {
client = CosmosFactory.createCosmosAsyncClient(cosmosClientBuilder);
@@ -243,7 +238,7 @@ public void testInsertDocShouldNotPersistTransientFields() {
final Person personWithTransientField = TEST_PERSON_4;
assertThat(personWithTransientField.getTransientProperty()).isNotNull();
final Person insertedPerson = cosmosTemplate.insert(Person.class.getSimpleName(), personWithTransientField, new PartitionKey(personInfo.getPartitionKeyFieldValue(TEST_PERSON_4)));
- Assert.assertEquals(TRANSIENT_PROPERTY, insertedPerson.getTransientProperty());
+ assertEquals(TRANSIENT_PROPERTY, insertedPerson.getTransientProperty());
final Person retrievedPerson = cosmosTemplate.findById(Person.class.getSimpleName(), insertedPerson.getId(), Person.class);
assertThat(retrievedPerson.getTransientProperty()).isNull();
}
@@ -258,7 +253,7 @@ public void testInsertAllAndFindAllWithTransientField() {
Iterable insertAllResponse = cosmosTemplate.insertAll(personInfo, entitiesToSave);
//check that the transient field is retained in the response
for (Person person : insertAllResponse) {
- Assert.assertEquals(TRANSIENT_PROPERTY, person.getTransientProperty());
+ assertEquals(TRANSIENT_PROPERTY, person.getTransientProperty());
}
Iterable findByIdsResponse = cosmosTemplate.findByIds(Arrays.asList(TEST_PERSON_4.getId()), Person.class, containerName);
@@ -269,10 +264,12 @@ public void testInsertAllAndFindAllWithTransientField() {
}
- @Test(expected = CosmosBadRequestException.class)
+ @Test
public void testInsertShouldFailIfColumnNotAnnotatedWithAutoGenerate() {
- final Person person = new Person(null, FIRST_NAME, LAST_NAME, HOBBIES, ADDRESSES, AGE, PASSPORT_IDS_BY_COUNTRY);
- cosmosTemplate.insert(Person.class.getSimpleName(), person, new PartitionKey(person.getLastName()));
+ assertThrows(CosmosBadRequestException.class, () -> {
+ final Person person = new Person(null, FIRST_NAME, LAST_NAME, HOBBIES, ADDRESSES, AGE, PASSPORT_IDS_BY_COUNTRY);
+ cosmosTemplate.insert(Person.class.getSimpleName(), person, new PartitionKey(person.getLastName()));
+ });
}
@Test
@@ -481,7 +478,7 @@ public void testUpsertNewDocumentIgnoresTransientFields() {
final Person person = cosmosTemplate.upsertAndReturnEntity(Person.class.getSimpleName(), newPerson);
- Assert.assertEquals(TRANSIENT_PROPERTY, person.getTransientProperty());
+ assertEquals(TRANSIENT_PROPERTY, person.getTransientProperty());
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIllegalTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIllegalTest.java
index e18960ae2da6..bae7b195bee9 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIllegalTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateIllegalTest.java
@@ -8,12 +8,12 @@
import com.azure.spring.data.cosmos.core.query.CriteriaType;
import com.azure.spring.data.cosmos.domain.Person;
import org.apache.commons.lang3.StringUtils;
-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.Answers;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.mockito.Mock;
-import org.mockito.junit.MockitoJUnitRunner;
import org.springframework.data.repository.query.parser.Part;
import org.springframework.util.Assert;
@@ -21,7 +21,7 @@
import java.lang.reflect.Method;
import java.util.Arrays;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class CosmosTemplateIllegalTest {
private static final String NULL_STR = null;
private static final String DUMMY_COLL = "dummy";
@@ -35,7 +35,7 @@ public class CosmosTemplateIllegalTest {
private CosmosTemplate cosmosTemplate;
private Class> cosmosTemplateClass;
- @Before
+ @BeforeEach
public void setUp() {
cosmosTemplateClass = cosmosTemplate.getClass();
}
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplatePartitionIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplatePartitionIT.java
index ad9cf498a005..62beed86c8d1 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplatePartitionIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplatePartitionIT.java
@@ -3,6 +3,9 @@
package com.azure.spring.data.cosmos.core;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
import com.azure.cosmos.CosmosAsyncClient;
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.cosmos.models.PartitionKey;
@@ -22,10 +25,9 @@
import com.azure.spring.data.cosmos.domain.PartitionPerson;
import com.azure.spring.data.cosmos.repository.TestRepositoryConfig;
import com.azure.spring.data.cosmos.repository.support.CosmosEntityInformation;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.context.ApplicationContext;
@@ -35,7 +37,6 @@
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.query.parser.Part;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.Collections;
import java.util.List;
@@ -57,11 +58,11 @@
import static com.azure.spring.data.cosmos.common.TestConstants.UPDATED_FIRST_NAME;
import static com.azure.spring.data.cosmos.common.TestConstants.ZIP_CODE;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertNull;
+import static org.junit.jupiter.api.Assertions.assertNull;
import static org.junit.jupiter.api.Assertions.assertEquals;
import static org.springframework.data.domain.Sort.Direction.ASC;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestRepositoryConfig.class)
public class CosmosTemplatePartitionIT {
private static final PartitionPerson TEST_PERSON = new PartitionPerson(ID_1, FIRST_NAME, ZIP_CODE,
@@ -73,7 +74,7 @@ public class CosmosTemplatePartitionIT {
private static final PartitionPerson TEST_PERSON_3 = new PartitionPerson(ID_3, FIRST_NAME, NEW_ZIP_CODE,
HOBBIES, ADDRESSES);
- @ClassRule
+
public static final IntegrationTestCollectionManager collectionManager = new IntegrationTestCollectionManager();
private static CosmosFactory cosmosFactory;
@@ -90,7 +91,7 @@ public class CosmosTemplatePartitionIT {
@Autowired
private ResponseDiagnosticsTestUtils responseDiagnosticsTestUtils;
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
if (cosmosTemplate == null) {
// Query plan caching is enabled by default
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateUnitTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateUnitTest.java
index 54f515a8a62c..c9aaaa74e4a9 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateUnitTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/CosmosTemplateUnitTest.java
@@ -7,18 +7,22 @@
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.spring.data.cosmos.CosmosFactory;
import com.azure.spring.data.cosmos.common.TestConstants;
-import org.junit.Test;
-import org.junit.runner.RunWith;
-import org.mockito.junit.MockitoJUnitRunner;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.mockito.junit.jupiter.MockitoExtension;
-@RunWith(MockitoJUnitRunner.class)
+import static org.junit.jupiter.api.Assertions.assertThrows;
+
+@ExtendWith(MockitoExtension.class)
public class CosmosTemplateUnitTest {
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void rejectNullDbFactory() {
- CosmosAsyncClient client = CosmosFactory.createCosmosAsyncClient(new CosmosClientBuilder()
- .endpoint("")
- .key(""));
- new CosmosFactory(client, TestConstants.DB_NAME);
+ assertThrows(IllegalArgumentException.class, () -> {
+ CosmosAsyncClient client = CosmosFactory.createCosmosAsyncClient(new CosmosClientBuilder()
+ .endpoint("")
+ .key(""));
+ new CosmosFactory(client, TestConstants.DB_NAME);
+ });
}
}
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/MultiTenantContainerCosmosFactoryIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/MultiTenantContainerCosmosFactoryIT.java
index a301a7d65e97..f087dd4888d0 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/MultiTenantContainerCosmosFactoryIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/MultiTenantContainerCosmosFactoryIT.java
@@ -16,17 +16,16 @@
import com.azure.spring.data.cosmos.domain.Person;
import com.azure.spring.data.cosmos.repository.MultiTenantTestRepositoryConfig;
import com.azure.spring.data.cosmos.repository.support.CosmosEntityInformation;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.context.ApplicationContext;
import org.springframework.data.annotation.Persistent;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.List;
@@ -40,9 +39,9 @@
import static com.azure.spring.data.cosmos.common.TestConstants.LAST_NAME;
import static com.azure.spring.data.cosmos.common.TestConstants.PASSPORT_IDS_BY_COUNTRY;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = MultiTenantTestRepositoryConfig.class)
public class MultiTenantContainerCosmosFactoryIT {
@@ -54,7 +53,7 @@ public class MultiTenantContainerCosmosFactoryIT {
private final Person TEST_PERSON_1 = new Person(ID_1, FIRST_NAME, LAST_NAME, HOBBIES, ADDRESSES, AGE, PASSPORT_IDS_BY_COUNTRY);
private final Person TEST_PERSON_2 = new Person(ID_2, FIRST_NAME, LAST_NAME, HOBBIES, ADDRESSES, AGE, PASSPORT_IDS_BY_COUNTRY);
- @ClassRule
+
public static final IntegrationTestCollectionManager collectionManager = new IntegrationTestCollectionManager();
@Autowired
@@ -69,7 +68,7 @@ public class MultiTenantContainerCosmosFactoryIT {
private CosmosAsyncClient client;
private CosmosEntityInformation personInfo;
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
/// Setup
client = CosmosFactory.createCosmosAsyncClient(cosmosClientBuilder);
@@ -79,7 +78,7 @@ public void setUp() throws ClassNotFoundException {
try {
mappingContext.setInitialEntitySet(new EntityScanner(this.applicationContext).scan(Persistent.class));
} catch (Exception e) {
- Assert.fail();
+ Assertions.fail();
}
final MappingCosmosConverter cosmosConverter = new MappingCosmosConverter(mappingContext, null);
@@ -109,7 +108,7 @@ public void testGetContainerFunctionality() {
Iterable iterableDB2 = cosmosTemplate.findAll(personInfo.getContainerName(), Person.class);
List resultDB2 = new ArrayList<>();
iterableDB2.forEach(resultDB2::add);
- Assert.assertEquals(expectedResultsContainer2, resultDB2);
+ assertEquals(expectedResultsContainer2, resultDB2);
// Check that testContainer1 has the correct contents
cosmosFactory.manuallySetContainerName = testContainer1;
@@ -118,7 +117,7 @@ public void testGetContainerFunctionality() {
Iterable iterableDB1 = cosmosTemplate.findAll(personInfo.getContainerName(), Person.class);
List resultDB1 = new ArrayList<>();
iterableDB1.forEach(resultDB1::add);
- Assert.assertEquals(expectedResultsContainer1, resultDB1);
+ assertEquals(expectedResultsContainer1, resultDB1);
//Cleanup
deleteDatabaseIfExists(testDB1);
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/MultiTenantDBCosmosFactoryIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/MultiTenantDBCosmosFactoryIT.java
index dc16252d651a..0de37438ecea 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/MultiTenantDBCosmosFactoryIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/MultiTenantDBCosmosFactoryIT.java
@@ -16,17 +16,16 @@
import com.azure.spring.data.cosmos.domain.Person;
import com.azure.spring.data.cosmos.repository.MultiTenantTestRepositoryConfig;
import com.azure.spring.data.cosmos.repository.support.CosmosEntityInformation;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.context.ApplicationContext;
import org.springframework.data.annotation.Persistent;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.List;
@@ -40,9 +39,9 @@
import static com.azure.spring.data.cosmos.common.TestConstants.LAST_NAME;
import static com.azure.spring.data.cosmos.common.TestConstants.PASSPORT_IDS_BY_COUNTRY;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = MultiTenantTestRepositoryConfig.class)
public class MultiTenantDBCosmosFactoryIT {
@@ -52,7 +51,7 @@ public class MultiTenantDBCosmosFactoryIT {
private final Person TEST_PERSON_1 = new Person(ID_1, FIRST_NAME, LAST_NAME, HOBBIES, ADDRESSES, AGE, PASSPORT_IDS_BY_COUNTRY);
private final Person TEST_PERSON_2 = new Person(ID_2, FIRST_NAME, LAST_NAME, HOBBIES, ADDRESSES, AGE, PASSPORT_IDS_BY_COUNTRY);
- @ClassRule
+
public static final IntegrationTestCollectionManager collectionManager = new IntegrationTestCollectionManager();
@Autowired
@@ -67,7 +66,7 @@ public class MultiTenantDBCosmosFactoryIT {
private CosmosAsyncClient client;
private CosmosEntityInformation personInfo;
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
/// Setup
client = CosmosFactory.createCosmosAsyncClient(cosmosClientBuilder);
@@ -77,7 +76,7 @@ public void setUp() throws ClassNotFoundException {
try {
mappingContext.setInitialEntitySet(new EntityScanner(this.applicationContext).scan(Persistent.class));
} catch (Exception e) {
- Assert.fail();
+ Assertions.fail();
}
final MappingCosmosConverter cosmosConverter = new MappingCosmosConverter(mappingContext, null);
@@ -106,7 +105,7 @@ public void testGetDatabaseFunctionality() {
Iterable iterableDB2 = cosmosTemplate.findAll(personInfo.getContainerName(), Person.class);
List resultDB2 = new ArrayList<>();
iterableDB2.forEach(resultDB2::add);
- Assert.assertEquals(expectedResultsDB2, resultDB2);
+ assertEquals(expectedResultsDB2, resultDB2);
// Check that DB1 has the correct contents
cosmosFactory.manuallySetDatabaseName = testDB1;
@@ -115,7 +114,7 @@ public void testGetDatabaseFunctionality() {
Iterable iterableDB1 = cosmosTemplate.findAll(personInfo.getContainerName(), Person.class);
List resultDB1 = new ArrayList<>();
iterableDB1.forEach(resultDB1::add);
- Assert.assertEquals(expectedResultsDB1, resultDB1);
+ assertEquals(expectedResultsDB1, resultDB1);
//Cleanup
deleteDatabaseIfExists(testDB1);
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplateIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplateIT.java
index 98e4f466400c..407187e1c35e 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplateIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplateIT.java
@@ -45,14 +45,12 @@
import com.azure.spring.data.cosmos.repository.support.CosmosEntityInformation;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
-import org.assertj.core.api.Assertions;
import org.assertj.core.util.Lists;
-import org.junit.After;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
@@ -61,7 +59,6 @@
import org.springframework.data.auditing.IsNewAwareAuditingHandler;
import org.springframework.data.repository.query.parser.Part;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.util.ReflectionTestUtils;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
@@ -95,11 +92,11 @@
import static com.azure.spring.data.cosmos.common.TestConstants.PATCH_HOBBY1;
import static com.azure.spring.data.cosmos.common.TestConstants.TRANSIENT_PROPERTY;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
-import static org.junit.Assert.assertNotNull;
-import static org.junit.Assert.fail;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.fail;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestRepositoryConfig.class)
public class ReactiveCosmosTemplateIT {
private static final Person TEST_PERSON = new Person(TestConstants.ID_1, TestConstants.FIRST_NAME,
@@ -153,7 +150,7 @@ public class ReactiveCosmosTemplateIT {
private static final CosmosPatchItemRequestOptions options = new CosmosPatchItemRequestOptions();
- @ClassRule
+
public static final ReactiveIntegrationTestCollectionManager collectionManager = new ReactiveIntegrationTestCollectionManager();
@Value("${cosmos.secondaryKey}")
@@ -191,7 +188,7 @@ public class ReactiveCosmosTemplateIT {
@Autowired
private StubDateTimeProvider stubDateTimeProvider;
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
if (cosmosTemplate == null) {
azureKeyCredential = new AzureKeyCredential(cosmosDbKey);
@@ -223,7 +220,7 @@ private ReactiveCosmosTemplate createReactiveCosmosTemplate(CosmosConfig config,
return new ReactiveCosmosTemplate(cosmosFactory, config, cosmosConverter, inah);
}
- @After
+ @AfterEach
public void cleanup() {
// Reset master key
azureKeyCredential.update(cosmosDbKey);
@@ -246,7 +243,7 @@ public void testInsertDocShouldNotPersistTransientFields() {
final Person personWithTransientField = TEST_PERSON_5;
assertThat(personWithTransientField.getTransientProperty()).isNotNull();
final Mono insertedPerson = cosmosTemplate.insert(Person.class.getSimpleName(), personWithTransientField, new PartitionKey(personInfo.getPartitionKeyFieldValue(TEST_PERSON_5)));
- Assert.assertEquals(TRANSIENT_PROPERTY, insertedPerson.block().getTransientProperty());
+ assertEquals(TRANSIENT_PROPERTY, insertedPerson.block().getTransientProperty());
final Mono retrievedPerson = cosmosTemplate.findById(Person.class.getSimpleName(), personWithTransientField.getId(), Person.class);
assertThat(retrievedPerson.block().getTransientProperty()).isNull();
}
@@ -283,7 +280,7 @@ public void testFindByIdPointRead() {
BASIC_ITEM.getId(),
BasicItem.class);
StepVerifier.create(findById)
- .consumeNextWith(actual -> Assert.assertEquals(actual, BASIC_ITEM))
+ .consumeNextWith(actual -> assertEquals(actual, BASIC_ITEM))
.verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
@@ -296,11 +293,11 @@ public void testFindByID() {
TEST_PERSON.getId(),
Person.class);
StepVerifier.create(findById)
- .consumeNextWith(actual -> Assert.assertEquals(actual, TEST_PERSON))
+ .consumeNextWith(actual -> assertEquals(actual, TEST_PERSON))
.verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@Test
@@ -310,13 +307,13 @@ public void testFindByIDBySecondaryKey() {
TEST_PERSON.getId(),
Person.class);
StepVerifier.create(findById).consumeNextWith(actual -> {
- Assert.assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
- Assert.assertEquals(actual.getLastName(), TEST_PERSON.getLastName());
+ assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
+ assertEquals(actual.getLastName(), TEST_PERSON.getLastName());
}).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@Test
@@ -326,20 +323,20 @@ public void testFindAll() {
StepVerifier.create(flux).expectNextCount(1).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@Test
public void testFindByIdWithContainerName() {
StepVerifier.create(cosmosTemplate.findById(Person.class.getSimpleName(),
TEST_PERSON.getId(), Person.class))
- .consumeNextWith(actual -> Assert.assertEquals(actual, TEST_PERSON))
+ .consumeNextWith(actual -> assertEquals(actual, TEST_PERSON))
.verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@Test
@@ -349,29 +346,29 @@ public void testSaveSetsAuditData() {
stubDateTimeProvider.setNow(now);
StepVerifier.create(cosmosTemplate.insert(TEST_AUDITABLE_ENTITY_1))
.consumeNextWith(actual -> {
- Assert.assertEquals(actual.getId(), UUID_1);
+ assertEquals(actual.getId(), UUID_1);
}).verifyComplete();
StepVerifier.create(cosmosTemplate.insert(TEST_AUDITABLE_ENTITY_2))
.consumeNextWith(actual -> {
- Assert.assertEquals(actual.getId(), UUID_2);
+ assertEquals(actual.getId(), UUID_2);
}).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
final Flux flux = cosmosTemplate.findAll(auditableEntityInfo.getContainerName(), AuditableEntity.class);
StepVerifier.create(flux).consumeNextWith(actual -> {
- Assert.assertEquals(actual.getId(), UUID_1);
- Assert.assertEquals(actual.getCreatedBy(), "test-auditor");
- Assert.assertEquals(actual.getLastModifiedBy(), "test-auditor");
- Assert.assertEquals(actual.getCreatedDate(), now);
- Assert.assertEquals(actual.getLastModifiedByDate(), now);
+ assertEquals(actual.getId(), UUID_1);
+ assertEquals(actual.getCreatedBy(), "test-auditor");
+ assertEquals(actual.getLastModifiedBy(), "test-auditor");
+ assertEquals(actual.getCreatedDate(), now);
+ assertEquals(actual.getLastModifiedByDate(), now);
}).consumeNextWith(actual -> {
- Assert.assertEquals(actual.getId(), UUID_2);
- Assert.assertEquals(actual.getCreatedBy(), "test-auditor");
- Assert.assertEquals(actual.getLastModifiedBy(), "test-auditor");
- Assert.assertEquals(actual.getCreatedDate(), now);
- Assert.assertEquals(actual.getLastModifiedByDate(), now);
+ assertEquals(actual.getId(), UUID_2);
+ assertEquals(actual.getCreatedBy(), "test-auditor");
+ assertEquals(actual.getLastModifiedBy(), "test-auditor");
+ assertEquals(actual.getCreatedDate(), now);
+ assertEquals(actual.getLastModifiedByDate(), now);
}).verifyComplete();
}
@@ -383,22 +380,22 @@ public void testSaveAllSetsAuditData() {
StepVerifier.create(cosmosTemplate.insertAll(auditableEntityInfo, Lists.newArrayList(TEST_AUDITABLE_ENTITY_1,
TEST_AUDITABLE_ENTITY_2))).expectNextCount(2).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
final Flux flux = cosmosTemplate.findAll(auditableEntityInfo.getContainerName(), AuditableEntity.class);
StepVerifier.create(flux).consumeNextWith(actual -> {
- Assert.assertEquals(actual.getId(), UUID_1);
- Assert.assertEquals(actual.getCreatedBy(), "test-auditor-2");
- Assert.assertEquals(actual.getLastModifiedBy(), "test-auditor-2");
- Assert.assertEquals(actual.getCreatedDate(), now);
- Assert.assertEquals(actual.getLastModifiedByDate(), now);
+ assertEquals(actual.getId(), UUID_1);
+ assertEquals(actual.getCreatedBy(), "test-auditor-2");
+ assertEquals(actual.getLastModifiedBy(), "test-auditor-2");
+ assertEquals(actual.getCreatedDate(), now);
+ assertEquals(actual.getLastModifiedByDate(), now);
}).consumeNextWith(actual -> {
- Assert.assertEquals(actual.getId(), UUID_2);
- Assert.assertEquals(actual.getCreatedBy(), "test-auditor-2");
- Assert.assertEquals(actual.getLastModifiedBy(), "test-auditor-2");
- Assert.assertEquals(actual.getCreatedDate(), now);
- Assert.assertEquals(actual.getLastModifiedByDate(), now);
+ assertEquals(actual.getId(), UUID_2);
+ assertEquals(actual.getCreatedBy(), "test-auditor-2");
+ assertEquals(actual.getLastModifiedBy(), "test-auditor-2");
+ assertEquals(actual.getCreatedDate(), now);
+ assertEquals(actual.getLastModifiedByDate(), now);
}).verifyComplete();
}
@@ -410,7 +407,7 @@ public void testSaveAllFailureAuditData() {
StepVerifier.create(cosmosTemplate.insertAll(auditableEntityInfo, Lists.newArrayList(TEST_AUDITABLE_ENTITY_1,
TEST_AUDITABLE_ENTITY_2, TEST_AUDITABLE_ENTITY_3))).expectNextCount(3).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
final List result = cosmosTemplate.findAll(auditableEntityInfo.getContainerName(), AuditableEntity.class).collectList().block();
@@ -421,28 +418,28 @@ public void testSaveAllFailureAuditData() {
stubDateTimeProvider.setNow(now2);
StepVerifier.create(cosmosTemplate.insertAll(auditableEntityInfo, result))
- .consumeNextWith(actual -> Assert.assertEquals(actual.getId(), UUID_1))
- .consumeNextWith(actual -> Assert.assertEquals(actual.getId(), UUID_3)).verifyComplete();
+ .consumeNextWith(actual -> assertEquals(actual.getId(), UUID_1))
+ .consumeNextWith(actual -> assertEquals(actual.getId(), UUID_3)).verifyComplete();
final Flux flux = cosmosTemplate.findAll(auditableEntityInfo.getContainerName(), AuditableEntity.class);
StepVerifier.create(flux).consumeNextWith(actual -> {
- Assert.assertEquals(actual.getId(), UUID_1);
- Assert.assertEquals(actual.getCreatedBy(), "test-auditor-2");
- Assert.assertEquals(actual.getLastModifiedBy(), "test-auditor-3");
- Assert.assertEquals(actual.getCreatedDate(), now);
- Assert.assertEquals(actual.getLastModifiedByDate(), now2);
+ assertEquals(actual.getId(), UUID_1);
+ assertEquals(actual.getCreatedBy(), "test-auditor-2");
+ assertEquals(actual.getLastModifiedBy(), "test-auditor-3");
+ assertEquals(actual.getCreatedDate(), now);
+ assertEquals(actual.getLastModifiedByDate(), now2);
}).consumeNextWith(actual -> {
- Assert.assertEquals(actual.getId(), UUID_2);
- Assert.assertEquals(actual.getCreatedBy(), "test-auditor-2");
- Assert.assertEquals(actual.getLastModifiedBy(), "test-auditor-2");
- Assert.assertEquals(actual.getCreatedDate(), now);
- Assert.assertEquals(actual.getLastModifiedByDate(), now);
+ assertEquals(actual.getId(), UUID_2);
+ assertEquals(actual.getCreatedBy(), "test-auditor-2");
+ assertEquals(actual.getLastModifiedBy(), "test-auditor-2");
+ assertEquals(actual.getCreatedDate(), now);
+ assertEquals(actual.getLastModifiedByDate(), now);
}).consumeNextWith(actual -> {
- Assert.assertEquals(actual.getId(), UUID_3);
- Assert.assertEquals(actual.getCreatedBy(), "test-auditor-2");
- Assert.assertEquals(actual.getLastModifiedBy(), "test-auditor-3");
- Assert.assertEquals(actual.getCreatedDate(), now);
- Assert.assertEquals(actual.getLastModifiedByDate(), now2);
+ assertEquals(actual.getId(), UUID_3);
+ assertEquals(actual.getCreatedBy(), "test-auditor-2");
+ assertEquals(actual.getLastModifiedBy(), "test-auditor-3");
+ assertEquals(actual.getCreatedDate(), now);
+ assertEquals(actual.getLastModifiedByDate(), now2);
}).verifyComplete();
}
@@ -453,7 +450,7 @@ public void testInsert() {
.expectNext(TEST_PERSON_3).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
}
@@ -465,7 +462,7 @@ public void testInsertBySecondaryKey() {
.expectNext(TEST_PERSON_3).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
}
@@ -476,7 +473,7 @@ public void testInsertWithContainerName() {
.expectNext(TEST_PERSON_2).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
}
@@ -509,7 +506,7 @@ public void testUpsert() {
p.setHobbies(hobbies);
final Mono upsert = cosmosTemplate.upsert(p);
StepVerifier.create(upsert).expectNextCount(1).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
}
@@ -525,7 +522,7 @@ public void testUpsertNewDocumentIgnoresTransientFields() {
final Mono person = cosmosTemplate.upsert(Person.class.getSimpleName(), newPerson);
- Assert.assertEquals(TRANSIENT_PROPERTY, person.block().getTransientProperty());
+ assertEquals(TRANSIENT_PROPERTY, person.block().getTransientProperty());
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
@@ -605,7 +602,7 @@ public void testUpsertBySecondaryKey() {
StepVerifier.create(upsert).expectNextCount(1).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
}
@@ -619,7 +616,7 @@ public void testUpsertWithContainerName() {
StepVerifier.create(upsert).expectNextCount(1).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
}
@@ -629,15 +626,15 @@ public void testDeleteById() {
new PartitionKey(personInfo.getPartitionKeyFieldValue(TEST_PERSON_4))).block();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
Flux flux = cosmosTemplate.findAll(Person.class.getSimpleName(), Person.class);
StepVerifier.create(flux).expectNextCount(2).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
final Mono voidMono = cosmosTemplate.deleteById(Person.class.getSimpleName(),
@@ -646,15 +643,15 @@ public void testDeleteById() {
StepVerifier.create(voidMono).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
flux = cosmosTemplate.findAll(Person.class.getSimpleName(), Person.class);
StepVerifier.create(flux).expectNextCount(1).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@@ -664,30 +661,30 @@ public void testDeleteByEntity() {
new PartitionKey(personInfo.getPartitionKeyFieldValue(TEST_PERSON_4))).block();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
Flux flux = cosmosTemplate.findAll(Person.class.getSimpleName(), Person.class);
StepVerifier.create(flux).expectNextCount(2).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
final Mono voidMono = cosmosTemplate.deleteEntity(Person.class.getSimpleName(), insertedPerson);
StepVerifier.create(voidMono).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
flux = cosmosTemplate.findAll(Person.class.getSimpleName(), Person.class);
StepVerifier.create(flux).expectNextCount(1).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@@ -696,7 +693,7 @@ public void testDeleteByQuery() {
cosmosTemplate.insert(TEST_PERSON_4,
new PartitionKey(personInfo.getPartitionKeyFieldValue(TEST_PERSON_4))).block();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
final Criteria criteria = Criteria.getInstance(CriteriaType.IS_EQUAL, "id",
@@ -707,8 +704,8 @@ public void testDeleteByQuery() {
StepVerifier.create(deleteFlux).expectNextCount(1).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
Mono itemMono = cosmosTemplate.findById(TEST_PERSON_4.getId(), Person.class);
StepVerifier.create(itemMono).expectNextCount(0).verifyComplete();
@@ -747,8 +744,8 @@ public void testFind() {
StepVerifier.create(personFluxIgnoreCase).expectNextCount(1).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@Test
@@ -767,8 +764,8 @@ public void testExists() {
StepVerifier.create(existsIgnoreCase).expectNext(true).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@Test
@@ -787,8 +784,8 @@ public void testNotExists() {
StepVerifier.create(existsIgnoreCase).expectNext(false).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@Test
@@ -797,8 +794,8 @@ public void testCount() {
StepVerifier.create(count).expectNext((long) 1).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@Test
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplatePartitionIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplatePartitionIT.java
index dcc7bd8a1e46..ffbfe5068841 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplatePartitionIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveCosmosTemplatePartitionIT.java
@@ -2,6 +2,9 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.core;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
+
import com.azure.cosmos.CosmosAsyncClient;
import com.azure.cosmos.CosmosClientBuilder;
import com.azure.cosmos.models.PartitionKey;
@@ -18,19 +21,15 @@
import com.azure.spring.data.cosmos.domain.PartitionPerson;
import com.azure.spring.data.cosmos.repository.TestRepositoryConfig;
import com.azure.spring.data.cosmos.repository.support.CosmosEntityInformation;
-import org.assertj.core.api.Assertions;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.BeforeEach;
+
+import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.context.ApplicationContext;
import org.springframework.data.annotation.Persistent;
import org.springframework.data.repository.query.parser.Part;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import reactor.core.publisher.Flux;
import reactor.core.publisher.Mono;
import reactor.test.StepVerifier;
@@ -42,7 +41,7 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestRepositoryConfig.class)
public class ReactiveCosmosTemplatePartitionIT {
private static final PartitionPerson TEST_PERSON = new PartitionPerson(TestConstants.ID_1,
@@ -53,7 +52,7 @@ public class ReactiveCosmosTemplatePartitionIT {
TestConstants.NEW_FIRST_NAME,
TestConstants.NEW_ZIP_CODE, TestConstants.HOBBIES, TestConstants.ADDRESSES);
- @ClassRule
+
public static final ReactiveIntegrationTestCollectionManager collectionManager = new ReactiveIntegrationTestCollectionManager();
private static CosmosFactory cosmosFactory;
@@ -70,7 +69,7 @@ public class ReactiveCosmosTemplatePartitionIT {
@Autowired
private ResponseDiagnosticsTestUtils responseDiagnosticsTestUtils;
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
if (cosmosTemplate == null) {
// Query plan caching is enabled by default
@@ -101,13 +100,13 @@ public void testFindWithPartition() {
PartitionPerson.class,
PartitionPerson.class.getSimpleName());
StepVerifier.create(partitionPersonFlux).consumeNextWith(actual -> {
- Assert.assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
- Assert.assertEquals(actual.getZipCode(), TEST_PERSON.getZipCode());
+ assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
+ assertEquals(actual.getZipCode(), TEST_PERSON.getZipCode());
}).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
// TODO: Find a way to test the query plan cache contents without using implementation package
@@ -121,8 +120,8 @@ public void testFindWithPartitionWithQueryPlanCachingEnabled() {
PartitionPerson.class,
PartitionPerson.class.getSimpleName());
StepVerifier.create(partitionPersonFlux).consumeNextWith(actual -> {
- Assert.assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
- Assert.assertEquals(actual.getZipCode(), TEST_PERSON.getZipCode());
+ assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
+ assertEquals(actual.getZipCode(), TEST_PERSON.getZipCode());
}).verifyComplete();
// CosmosAsyncClient cosmosAsyncClient = cosmosFactory.getCosmosAsyncClient();
@@ -142,8 +141,8 @@ public void testFindWithPartitionWithQueryPlanCachingEnabled() {
PartitionPerson.class,
PartitionPerson.class.getSimpleName());
StepVerifier.create(partitionPersonFlux).consumeNextWith(actual -> {
- Assert.assertEquals(actual.getFirstName(), TEST_PERSON_2.getFirstName());
- Assert.assertEquals(actual.getZipCode(), TEST_PERSON_2.getZipCode());
+ assertEquals(actual.getFirstName(), TEST_PERSON_2.getFirstName());
+ assertEquals(actual.getZipCode(), TEST_PERSON_2.getZipCode());
}).verifyComplete();
// Map postQueryCallCache = asyncDocumentClient.getQueryPlanCache();
@@ -160,13 +159,13 @@ public void testFindIgnoreCaseWithPartition() {
PartitionPerson.class,
PartitionPerson.class.getSimpleName());
StepVerifier.create(partitionPersonFlux).consumeNextWith(actual -> {
- Assert.assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
- Assert.assertEquals(actual.getZipCode(), TEST_PERSON.getZipCode());
+ assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
+ assertEquals(actual.getZipCode(), TEST_PERSON.getZipCode());
}).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@@ -176,8 +175,8 @@ public void testFindByIdWithPartition() {
PartitionPerson.class,
new PartitionKey(personInfo.getPartitionKeyFieldValue(TEST_PERSON)));
StepVerifier.create(partitionPersonMono).consumeNextWith(actual -> {
- Assert.assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
- Assert.assertEquals(actual.getZipCode(), TEST_PERSON.getZipCode());
+ assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
+ assertEquals(actual.getZipCode(), TEST_PERSON.getZipCode());
}).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
@@ -220,8 +219,8 @@ public void testUpdateWithPartition() {
assertEquals(person, updated);
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@Test
@@ -236,8 +235,8 @@ public void testDeleteByIdPartition() {
.verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@Test
@@ -250,8 +249,8 @@ public void testDeleteAll() {
.verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@Test
@@ -263,8 +262,8 @@ public void testCountForPartitionedCollection() {
.expectNext((long) 2).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@Test
@@ -277,8 +276,8 @@ public void testCountForPartitionedCollectionByQuery() {
.expectNext((long) 1).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
@Test
@@ -291,8 +290,8 @@ public void testCountIgnoreCaseForPartitionedCollectionByQuery() {
.expectNext((long) 1).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNotNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics().getRequestCharge()).isGreaterThan(0);
}
}
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveMultiTenantContainerCosmosFactoryIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveMultiTenantContainerCosmosFactoryIT.java
index 88b78a9e9ade..77eef43b221b 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveMultiTenantContainerCosmosFactoryIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveMultiTenantContainerCosmosFactoryIT.java
@@ -16,17 +16,16 @@
import com.azure.spring.data.cosmos.domain.Person;
import com.azure.spring.data.cosmos.repository.MultiTenantTestRepositoryConfig;
import com.azure.spring.data.cosmos.repository.support.CosmosEntityInformation;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.context.ApplicationContext;
import org.springframework.data.annotation.Persistent;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;
@@ -42,9 +41,9 @@
import static com.azure.spring.data.cosmos.common.TestConstants.LAST_NAME;
import static com.azure.spring.data.cosmos.common.TestConstants.PASSPORT_IDS_BY_COUNTRY;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = MultiTenantTestRepositoryConfig.class)
public class ReactiveMultiTenantContainerCosmosFactoryIT {
@@ -56,7 +55,7 @@ public class ReactiveMultiTenantContainerCosmosFactoryIT {
private final Person TEST_PERSON_1 = new Person(ID_1, FIRST_NAME, LAST_NAME, HOBBIES, ADDRESSES, AGE, PASSPORT_IDS_BY_COUNTRY);
private final Person TEST_PERSON_2 = new Person(ID_2, FIRST_NAME, LAST_NAME, HOBBIES, ADDRESSES, AGE, PASSPORT_IDS_BY_COUNTRY);
- @ClassRule
+
public static final IntegrationTestCollectionManager collectionManager = new IntegrationTestCollectionManager();
@Autowired
@@ -71,7 +70,7 @@ public class ReactiveMultiTenantContainerCosmosFactoryIT {
private CosmosAsyncClient client;
private CosmosEntityInformation personInfo;
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
/// Setup
client = CosmosFactory.createCosmosAsyncClient(cosmosClientBuilder);
@@ -81,7 +80,7 @@ public void setUp() throws ClassNotFoundException {
try {
mappingContext.setInitialEntitySet(new EntityScanner(this.applicationContext).scan(Persistent.class));
} catch (Exception e) {
- Assert.fail();
+ Assertions.fail();
}
final MappingCosmosConverter cosmosConverter = new MappingCosmosConverter(mappingContext, null);
@@ -112,7 +111,7 @@ public void testGetContainerFunctionality() {
StepVerifier.create(fluxDB2).expectNextCount(1).verifyComplete();
List resultDB2 = new ArrayList<>();
fluxDB2.toIterable().forEach(resultDB2::add);
- Assert.assertEquals(expectedResultsContainer2, resultDB2);
+ assertEquals(expectedResultsContainer2, resultDB2);
// Check that testContainer1 has the correct contents
cosmosFactory.manuallySetContainerName = testContainer1;
@@ -122,7 +121,7 @@ public void testGetContainerFunctionality() {
StepVerifier.create(fluxDB1).expectNextCount(1).verifyComplete();
List resultDB1 = new ArrayList<>();
fluxDB1.toIterable().forEach(resultDB1::add);
- Assert.assertEquals(expectedResultsContainer1, resultDB1);
+ assertEquals(expectedResultsContainer1, resultDB1);
//Cleanup
deleteDatabaseIfExists(testDB1);
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveMultiTenantDBCosmosFactoryIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveMultiTenantDBCosmosFactoryIT.java
index a865e65a1a07..56bc2acd0499 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveMultiTenantDBCosmosFactoryIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/ReactiveMultiTenantDBCosmosFactoryIT.java
@@ -16,17 +16,16 @@
import com.azure.spring.data.cosmos.domain.Person;
import com.azure.spring.data.cosmos.repository.MultiTenantTestRepositoryConfig;
import com.azure.spring.data.cosmos.repository.support.CosmosEntityInformation;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.autoconfigure.domain.EntityScanner;
import org.springframework.context.ApplicationContext;
import org.springframework.data.annotation.Persistent;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import reactor.core.publisher.Flux;
import reactor.test.StepVerifier;
@@ -42,9 +41,9 @@
import static com.azure.spring.data.cosmos.common.TestConstants.LAST_NAME;
import static com.azure.spring.data.cosmos.common.TestConstants.PASSPORT_IDS_BY_COUNTRY;
import static org.assertj.core.api.Assertions.assertThat;
-import static org.junit.Assert.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertEquals;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = MultiTenantTestRepositoryConfig.class)
public class ReactiveMultiTenantDBCosmosFactoryIT {
@@ -54,7 +53,7 @@ public class ReactiveMultiTenantDBCosmosFactoryIT {
private final Person TEST_PERSON_1 = new Person(ID_1, FIRST_NAME, LAST_NAME, HOBBIES, ADDRESSES, AGE, PASSPORT_IDS_BY_COUNTRY);
private final Person TEST_PERSON_2 = new Person(ID_2, FIRST_NAME, LAST_NAME, HOBBIES, ADDRESSES, AGE, PASSPORT_IDS_BY_COUNTRY);
- @ClassRule
+
public static final IntegrationTestCollectionManager collectionManager = new IntegrationTestCollectionManager();
@Autowired
@@ -69,7 +68,7 @@ public class ReactiveMultiTenantDBCosmosFactoryIT {
private CosmosAsyncClient client;
private CosmosEntityInformation personInfo;
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
/// Setup
client = CosmosFactory.createCosmosAsyncClient(cosmosClientBuilder);
@@ -79,7 +78,7 @@ public void setUp() throws ClassNotFoundException {
try {
mappingContext.setInitialEntitySet(new EntityScanner(this.applicationContext).scan(Persistent.class));
} catch (Exception e) {
- Assert.fail();
+ Assertions.fail();
}
final MappingCosmosConverter cosmosConverter = new MappingCosmosConverter(mappingContext, null);
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/convert/ZonedDateTimeDeserializerTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/convert/ZonedDateTimeDeserializerTest.java
index 88b593f2fe95..57059cfc962f 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/convert/ZonedDateTimeDeserializerTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/convert/ZonedDateTimeDeserializerTest.java
@@ -2,7 +2,7 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.core.convert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import java.io.IOException;
import java.time.ZoneId;
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/converter/MappingCosmosConverterUnitTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/converter/MappingCosmosConverterUnitTest.java
index 0a11e4a78741..f86817f8f79a 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/converter/MappingCosmosConverterUnitTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/converter/MappingCosmosConverterUnitTest.java
@@ -15,11 +15,11 @@
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.node.ObjectNode;
-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.junit.MockitoJUnitRunner;
+import org.mockito.junit.jupiter.MockitoExtension;
import org.springframework.context.ApplicationContext;
import java.text.ParseException;
@@ -29,7 +29,7 @@
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(MockitoJUnitRunner.class)
+@ExtendWith(MockitoExtension.class)
public class MappingCosmosConverterUnitTest {
private static final SimpleDateFormat DATE = new SimpleDateFormat(TestConstants.DATE_FORMAT);
private static final SimpleDateFormat TIMEZONE_DATE = new SimpleDateFormat(TestConstants.DATE_TIMEZONE_FORMAT);
@@ -39,7 +39,7 @@ public class MappingCosmosConverterUnitTest {
@Mock
ApplicationContext applicationContext;
- @Before
+ @BeforeEach
public void setUp() {
final CosmosMappingContext mappingContext = new CosmosMappingContext();
final ObjectMapper objectMapper = new ObjectMapper();
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/generator/AbstractQueryGeneratorTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/generator/AbstractQueryGeneratorTest.java
index 55c21c65ce11..9c6d48004646 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/generator/AbstractQueryGeneratorTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/generator/AbstractQueryGeneratorTest.java
@@ -10,9 +10,9 @@
import com.azure.spring.data.cosmos.core.query.CriteriaType;
import org.hamcrest.MatcherAssert;
import org.hamcrest.Matchers;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.query.parser.Part;
@@ -22,13 +22,14 @@
import java.util.stream.Collectors;
import static org.springframework.data.domain.Sort.Direction.ASC;
+import static org.junit.jupiter.api.Assertions.*;
public class AbstractQueryGeneratorTest {
@Mock
private EmptyQueryGenerator queryGenerator;
- @Before
+ @BeforeEach
public void setUp() {
this.queryGenerator = new EmptyQueryGenerator();
}
@@ -45,7 +46,7 @@ public void binaryOperatorPriorityPreserved() {
final CosmosQuery query = new CosmosQuery(and);
SqlQuerySpec querySpec = queryGenerator.generateCosmos(query);
List parameterNames = querySpec.getParameters().stream().map(SqlParameter::getName).collect(Collectors.toList());
- Assert.assertNotNull(querySpec.getQueryText());
+ Assertions.assertNotNull(querySpec.getQueryText());
MatcherAssert.assertThat(querySpec.getQueryText(), Matchers.stringContainsInOrder(
parameterNames.get(0), CriteriaType.AND.getSqlKeyword(),
"(", parameterNames.get(1), CriteriaType.OR.getSqlKeyword(), parameterNames.get(2), ")"));
@@ -60,7 +61,7 @@ public void generateBinaryQueryWithStartsWithDoesNotUseUpper() {
SqlQuerySpec result = queryGenerator.generateCosmos(query);
- Assert.assertEquals(result.getQueryText(), " WHERE STARTSWITH(r.firstName, @firstName0, true) ");
+ assertEquals(result.getQueryText(), " WHERE STARTSWITH(r.firstName, @firstName0, true) ");
}
@Test
@@ -72,7 +73,7 @@ public void generateBinaryQueryWithSort() {
SqlQuerySpec result = queryGenerator.generateCosmos(query);
- Assert.assertEquals(result.getQueryText(), " WHERE ARRAY_CONTAINS(UPPER(r.lastName), UPPER(@lastName0)) ORDER BY r.id ASC");
+ assertEquals(result.getQueryText(), " WHERE ARRAY_CONTAINS(UPPER(r.lastName), UPPER(@lastName0)) ORDER BY r.id ASC");
}
@Test
@@ -84,7 +85,7 @@ public void generateBinaryQueryWithArrayContainsUsesUpper() {
SqlQuerySpec result = queryGenerator.generateCosmos(query);
- Assert.assertEquals(result.getQueryText(), " WHERE ARRAY_CONTAINS(UPPER(r.lastName), UPPER(@lastName0)) ");
+ assertEquals(result.getQueryText(), " WHERE ARRAY_CONTAINS(UPPER(r.lastName), UPPER(@lastName0)) ");
}
@Test
@@ -98,9 +99,9 @@ public void generateBinaryQueryWithStringEquals() {
SqlQuerySpec result = queryGenerator.generateCosmos(query);
if (ignoreCaseType == Part.IgnoreCaseType.NEVER) {
- Assert.assertEquals(result.getQueryText(), " WHERE STRINGEQUALS(r.firstName, @firstName0) ");
+ assertEquals(result.getQueryText(), " WHERE STRINGEQUALS(r.firstName, @firstName0) ");
} else {
- Assert.assertEquals(result.getQueryText(), " WHERE STRINGEQUALS(r.firstName, @firstName0, true) ");
+ assertEquals(result.getQueryText(), " WHERE STRINGEQUALS(r.firstName, @firstName0, true) ");
}
}
}
@@ -114,7 +115,7 @@ public void generateBinaryQueryWithIsEqualIntUsesUpper() {
SqlQuerySpec result = queryGenerator.generateCosmos(query);
- Assert.assertEquals(result.getQueryText(), " WHERE UPPER(r.zipcode) = UPPER(@zipcode0) ");
+ assertEquals(result.getQueryText(), " WHERE UPPER(r.zipcode) = UPPER(@zipcode0) ");
}
@Test
@@ -126,7 +127,7 @@ public void generateBinaryQueryWithIsEqualStringDoesNotUseUpper() {
SqlQuerySpec result = queryGenerator.generateCosmos(query);
- Assert.assertEquals(result.getQueryText(), " WHERE STRINGEQUALS(r.firstName, @firstName0, true) ");
+ assertEquals(result.getQueryText(), " WHERE STRINGEQUALS(r.firstName, @firstName0, true) ");
}
private static class EmptyQueryGenerator extends AbstractQueryGenerator implements QuerySpecGenerator {
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/generator/NativeQueryGeneratorTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/generator/NativeQueryGeneratorTest.java
index a21f4aeb60fc..e6c165623020 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/generator/NativeQueryGeneratorTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/generator/NativeQueryGeneratorTest.java
@@ -6,9 +6,8 @@
import com.azure.cosmos.models.SqlParameter;
import com.azure.cosmos.models.SqlQuerySpec;
import com.azure.spring.data.cosmos.core.query.CosmosQuery;
-import org.junit.Assert;
-import org.junit.Before;
-import org.junit.Test;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.springframework.data.domain.Sort;
@@ -16,13 +15,14 @@
import java.util.List;
import static org.springframework.data.domain.Sort.Direction.ASC;
+import static org.junit.jupiter.api.Assertions.*;
public class NativeQueryGeneratorTest {
@Mock
private EmptyQueryGenerator queryGenerator;
- @Before
+ @BeforeEach
public void setUp() {
this.queryGenerator = new EmptyQueryGenerator();
}
@@ -35,7 +35,7 @@ public void generateSortedQueryTest() {
SqlQuerySpec querySpec = new SqlQuerySpec("select * from a where a.firstName = @firstName", sqlParameters);
final SqlQuerySpec sortedQuerySpec = NativeQueryGenerator.getInstance().generateSortedQuery(querySpec, Sort.by(ASC, "id"));
- Assert.assertEquals(sortedQuerySpec.getQueryText(), "select * from a where a.firstName = @firstName ORDER BY a.id ASC");
+ assertEquals(sortedQuerySpec.getQueryText(), "select * from a where a.firstName = @firstName ORDER BY a.id ASC");
}
private static class EmptyQueryGenerator extends NativeQueryGenerator implements QuerySpecGenerator {
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/BasicCosmosPersistentEntityUnitTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/BasicCosmosPersistentEntityUnitTest.java
index 59d3e5c6a7f6..345457579818 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/BasicCosmosPersistentEntityUnitTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/BasicCosmosPersistentEntityUnitTest.java
@@ -4,7 +4,7 @@
package com.azure.spring.data.cosmos.core.mapping;
import com.azure.spring.data.cosmos.domain.Person;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.data.util.ClassTypeInformation;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/CosmosMappingContextUnitTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/CosmosMappingContextUnitTest.java
index 2ed4fbbdc906..506f5034267f 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/CosmosMappingContextUnitTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/CosmosMappingContextUnitTest.java
@@ -3,7 +3,7 @@
package com.azure.spring.data.cosmos.core.mapping;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.springframework.context.ApplicationContext;
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventErrorIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventErrorIT.java
index ff4f63e10c08..200d92e55202 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventErrorIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventErrorIT.java
@@ -10,21 +10,21 @@
import com.azure.spring.data.cosmos.repository.TestRepositoryConfig;
import com.azure.spring.data.cosmos.repository.repository.AddressRepository;
import org.assertj.core.util.Lists;
-import org.junit.Before;
-import org.junit.ClassRule;
-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.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static com.azure.spring.data.cosmos.domain.Address.TEST_ADDRESS1_PARTITION1;
+import static org.junit.jupiter.api.Assertions.assertThrows;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {TestRepositoryConfig.class, ErrorEventListenerConfig.class})
public class ApplicationContextEventErrorIT {
- @ClassRule
+
public static final IntegrationTestCollectionManager collectionManager = new IntegrationTestCollectionManager();
@Autowired
@@ -32,14 +32,16 @@ public class ApplicationContextEventErrorIT {
@Autowired
private CosmosTemplate template;
- @Before
+ @BeforeEach
public void setUp() {
collectionManager.ensureContainersCreatedAndEmpty(template, Address.class);
repository.saveAll(Lists.newArrayList(TEST_ADDRESS1_PARTITION1));
}
- @Test(expected = CosmosAccessException.class)
+ @Test
public void shouldThrowExceptionIfEventListenerThrowsException() {
- repository.findById(TEST_ADDRESS1_PARTITION1.getPostalCode(), new PartitionKey(TEST_ADDRESS1_PARTITION1.getCity()));
+ assertThrows(CosmosAccessException.class, () ->
+ repository.findById(TEST_ADDRESS1_PARTITION1.getPostalCode(),
+ new PartitionKey(TEST_ADDRESS1_PARTITION1.getCity())));
}
}
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventErrorReactiveIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventErrorReactiveIT.java
index 6f833a984b6f..5db9dea65ea7 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventErrorReactiveIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventErrorReactiveIT.java
@@ -10,21 +10,20 @@
import com.azure.spring.data.cosmos.repository.TestRepositoryConfig;
import com.azure.spring.data.cosmos.repository.repository.ReactiveAddressRepository;
import org.assertj.core.util.Lists;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Test;
-import org.junit.runner.RunWith;
+import org.junit.jupiter.api.Test;
+import org.junit.jupiter.api.extension.ExtendWith;
+import org.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import static com.azure.spring.data.cosmos.domain.Address.TEST_ADDRESS1_PARTITION1;
+import static org.junit.jupiter.api.Assertions.assertThrows;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = {TestRepositoryConfig.class, ErrorEventListenerConfig.class})
public class ApplicationContextEventErrorReactiveIT {
- @ClassRule
+
public static final IntegrationTestCollectionManager collectionManager = new IntegrationTestCollectionManager();
@Autowired
@@ -32,14 +31,12 @@ public class ApplicationContextEventErrorReactiveIT {
@Autowired
private CosmosTemplate template;
- @Before
- public void setUp() {
- collectionManager.ensureContainersCreatedAndEmpty(template, Address.class);
- repository.saveAll(Lists.newArrayList(TEST_ADDRESS1_PARTITION1)).collectList().block();
- }
-
- @Test(expected = CosmosAccessException.class)
+ @Test
public void shouldThrowExceptionIfEventListenerThrowsException() {
- repository.findById(TEST_ADDRESS1_PARTITION1.getPostalCode(), new PartitionKey(TEST_ADDRESS1_PARTITION1.getCity())).block();
+ assertThrows(CosmosAccessException.class, () -> {
+ collectionManager.ensureContainersCreatedAndEmpty(template, Address.class);
+ repository.saveAll(Lists.newArrayList(TEST_ADDRESS1_PARTITION1)).collectList().block();
+ repository.findById(TEST_ADDRESS1_PARTITION1.getPostalCode(), new PartitionKey(TEST_ADDRESS1_PARTITION1.getCity())).block();
+ });
}
}
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventIT.java
index 91654aee2bb6..f63cd324cd57 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventIT.java
@@ -11,15 +11,12 @@
import com.azure.spring.data.cosmos.repository.TestRepositoryConfig;
import com.azure.spring.data.cosmos.repository.repository.AddressRepository;
import org.assertj.core.util.Lists;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-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.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.List;
@@ -30,11 +27,11 @@
import static com.azure.spring.data.cosmos.domain.Address.TEST_ADDRESS4_PARTITION3;
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestRepositoryConfig.class)
public class ApplicationContextEventIT {
- @ClassRule
+
public static final IntegrationTestCollectionManager collectionManager = new IntegrationTestCollectionManager();
@Autowired
@@ -44,11 +41,9 @@ public class ApplicationContextEventIT {
@Autowired
private SimpleCosmosMappingEventListener simpleCosmosMappingEventListener;
- @SuppressWarnings("deprecation")
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
- @Before
+
+ @BeforeEach
public void setUp() {
collectionManager.ensureContainersCreatedAndEmpty(template, Address.class);
repository.saveAll(Lists.newArrayList(TEST_ADDRESS1_PARTITION1, TEST_ADDRESS1_PARTITION2,
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventReactiveIT.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventReactiveIT.java
index 9ce320cb6a46..4ce9f3e4a148 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventReactiveIT.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/ApplicationContextEventReactiveIT.java
@@ -10,15 +10,12 @@
import com.azure.spring.data.cosmos.repository.TestRepositoryConfig;
import com.azure.spring.data.cosmos.repository.repository.ReactiveAddressRepository;
import org.assertj.core.util.Lists;
-import org.junit.Before;
-import org.junit.ClassRule;
-import org.junit.Rule;
-import org.junit.Test;
-import org.junit.rules.ExpectedException;
-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.springframework.test.context.junit.jupiter.SpringExtension;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
-import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import java.util.ArrayList;
import java.util.List;
@@ -29,11 +26,11 @@
import static com.azure.spring.data.cosmos.domain.Address.TEST_ADDRESS4_PARTITION3;
import static org.assertj.core.api.Assertions.assertThat;
-@RunWith(SpringJUnit4ClassRunner.class)
+@ExtendWith(SpringExtension.class)
@ContextConfiguration(classes = TestRepositoryConfig.class)
public class ApplicationContextEventReactiveIT {
- @ClassRule
+
public static final IntegrationTestCollectionManager collectionManager = new IntegrationTestCollectionManager();
@Autowired
@@ -43,11 +40,9 @@ public class ApplicationContextEventReactiveIT {
@Autowired
private SimpleCosmosMappingEventListener simpleCosmosMappingEventListener;
- @SuppressWarnings("deprecation")
- @Rule
- public ExpectedException expectedException = ExpectedException.none();
- @Before
+
+ @BeforeEach
public void setUp() {
collectionManager.ensureContainersCreatedAndEmpty(template, Address.class);
repository.saveAll(Lists.newArrayList(TEST_ADDRESS1_PARTITION1, TEST_ADDRESS1_PARTITION2,
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/CosmosEventListenerUnitTests.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/CosmosEventListenerUnitTests.java
index e604fdddd8a9..50339dc8194b 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/CosmosEventListenerUnitTests.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/mapping/event/CosmosEventListenerUnitTests.java
@@ -7,7 +7,7 @@
import com.azure.spring.data.cosmos.domain.Student;
import com.fasterxml.jackson.databind.JsonNode;
import com.fasterxml.jackson.databind.node.NullNode;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import static org.assertj.core.api.Assertions.assertThat;
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/query/CosmosQueryUnitTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/query/CosmosQueryUnitTest.java
index 39e0e584129a..6a163bc57a7d 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/query/CosmosQueryUnitTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/query/CosmosQueryUnitTest.java
@@ -2,8 +2,7 @@
// Licensed under the MIT License.
package com.azure.spring.data.cosmos.core.query;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Test;
import org.springframework.data.domain.Pageable;
import org.springframework.data.domain.Sort;
import org.springframework.data.repository.query.parser.Part;
@@ -12,6 +11,7 @@
import static com.azure.spring.data.cosmos.common.TestConstants.CRITERIA_KEY;
import static com.azure.spring.data.cosmos.common.TestConstants.CRITERIA_OBJECT;
+import static org.junit.jupiter.api.Assertions.*;
public class CosmosQueryUnitTest {
@@ -22,9 +22,9 @@ public void testDocumentQueryCreate() {
final CosmosQuery query = new CosmosQuery(criteria);
- Assert.assertEquals(criteria, query.getCriteria());
- Assert.assertEquals(Sort.unsorted(), query.getSort());
- Assert.assertEquals(Pageable.unpaged(), query.getPageable());
- Assert.assertEquals(Part.IgnoreCaseType.NEVER, criteria.getIgnoreCase());
+ assertEquals(criteria, query.getCriteria());
+ assertEquals(Sort.unsorted(), query.getSort());
+ assertEquals(Pageable.unpaged(), query.getPageable());
+ assertEquals(Part.IgnoreCaseType.NEVER, criteria.getIgnoreCase());
}
}
diff --git a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/query/CriteriaUnitTest.java b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/query/CriteriaUnitTest.java
index 3ac5bdd4e561..70eac9006d0b 100644
--- a/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/query/CriteriaUnitTest.java
+++ b/sdk/spring/azure-spring-data-cosmos/src/test/java/com/azure/spring/data/cosmos/core/query/CriteriaUnitTest.java
@@ -4,8 +4,8 @@
import com.azure.spring.data.cosmos.core.generator.FindQuerySpecGenerator;
import com.azure.spring.data.cosmos.exception.IllegalQueryException;
-import org.junit.Assert;
-import org.junit.Test;
+import org.junit.jupiter.api.Assertions;
+import org.junit.jupiter.api.Test;
import org.springframework.data.repository.query.parser.Part;
import java.util.Arrays;
@@ -14,6 +14,7 @@
import static com.azure.spring.data.cosmos.common.TestConstants.CRITERIA_KEY;
import static com.azure.spring.data.cosmos.common.TestConstants.CRITERIA_OBJECT;
+import static org.junit.jupiter.api.Assertions.*;
public class CriteriaUnitTest {
@@ -23,12 +24,12 @@ public void testUnaryCriteria() {
final Criteria criteria = Criteria.getInstance(CriteriaType.IS_EQUAL,
CRITERIA_KEY, values, Part.IgnoreCaseType.NEVER);
- Assert.assertTrue(criteria.getSubCriteria().isEmpty());
- Assert.assertEquals(values, criteria.getSubjectValues());
- Assert.assertEquals(CriteriaType.IS_EQUAL, criteria.getType());
- Assert.assertEquals(CRITERIA_KEY, criteria.getSubject());
- Assert.assertTrue(CriteriaType.isBinary(criteria.getType()));
- Assert.assertEquals(Part.IgnoreCaseType.NEVER, criteria.getIgnoreCase());
+ Assertions.assertTrue(criteria.getSubCriteria().isEmpty());
+ assertEquals(values, criteria.getSubjectValues());
+ assertEquals(CriteriaType.IS_EQUAL, criteria.getType());
+ assertEquals(CRITERIA_KEY, criteria.getSubject());
+ Assertions.assertTrue(CriteriaType.isBinary(criteria.getType()));
+ assertEquals(Part.IgnoreCaseType.NEVER, criteria.getIgnoreCase());
}
@Test
@@ -40,37 +41,41 @@ public void testBinaryCriteria() {
CRITERIA_OBJECT, values, Part.IgnoreCaseType.NEVER);
final Criteria criteria = Criteria.getInstance(CriteriaType.AND, leftCriteria, rightCriteria);
- Assert.assertNotNull(criteria.getSubCriteria());
- Assert.assertNull(criteria.getSubjectValues());
- Assert.assertNull(criteria.getSubject());
- Assert.assertEquals(criteria.getType(), CriteriaType.AND);
- Assert.assertTrue(CriteriaType.isClosed(criteria.getType()));
+ Assertions.assertNotNull(criteria.getSubCriteria());
+ Assertions.assertNull(criteria.getSubjectValues());
+ Assertions.assertNull(criteria.getSubject());
+ assertEquals(criteria.getType(), CriteriaType.AND);
+ Assertions.assertTrue(CriteriaType.isClosed(criteria.getType()));
- Assert.assertEquals(2, criteria.getSubCriteria().size());
- Assert.assertEquals(leftCriteria, criteria.getSubCriteria().get(0));
- Assert.assertEquals(rightCriteria, criteria.getSubCriteria().get(1));
+ assertEquals(2, criteria.getSubCriteria().size());
+ assertEquals(leftCriteria, criteria.getSubCriteria().get(0));
+ assertEquals(rightCriteria, criteria.getSubCriteria().get(1));
- Assert.assertEquals(Part.IgnoreCaseType.NEVER, criteria.getSubCriteria().get(0).getIgnoreCase());
- Assert.assertEquals(Part.IgnoreCaseType.NEVER, criteria.getSubCriteria().get(1).getIgnoreCase());
+ assertEquals(Part.IgnoreCaseType.NEVER, criteria.getSubCriteria().get(0).getIgnoreCase());
+ assertEquals(Part.IgnoreCaseType.NEVER, criteria.getSubCriteria().get(1).getIgnoreCase());
}
- @Test(expected = IllegalQueryException.class)
+ @Test
public void testInvalidInKeywordParameter() {
- final List