From 1d52f70a81b8d4358afcfcff7c710d7dd6d7888a Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 21 Nov 2025 03:18:59 +0000
Subject: [PATCH 01/10] Initial plan
From 926dca1c9919941ef5a2b3913732263547a3b2a7 Mon Sep 17 00:00:00 2001
From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com>
Date: Fri, 21 Nov 2025 03:36:33 +0000
Subject: [PATCH 02/10] Migrate JUnit 4 to JUnit 5 - work in progress
- Removed JUnit 4 and junit-vintage-engine dependencies from pom.xml
- Migrated 85+ test files from JUnit 4 to JUnit 5
- Updated imports from org.junit to org.junit.jupiter.api
- Replaced @Before/@After with @BeforeEach/@AfterEach
- Replaced @BeforeClass/@AfterClass with @BeforeAll/@AfterAll
- Replaced @RunWith with @ExtendWith for Mockito and Spring
- Replaced Assert with Assertions
- Removed TestRule interface from AbstractIntegrationTestCollectionManager
- Fixed static imports for AssertJ and JUnit Jupiter
Remaining work:
- Fix a few remaining compilation errors in 3 test files
- Run full test suite to ensure all tests pass
Co-authored-by: Netyyyy <92105726+Netyyyy@users.noreply.github.com>
---
sdk/spring/azure-spring-data-cosmos/pom.xml | 18 --
...tractIntegrationTestCollectionManager.java | 18 +-
.../spring/data/cosmos/ContainerLockIT.java | 21 +-
.../data/cosmos/CosmosFactoryTestIT.java | 7 +-
.../common/ExpressionResolverUnitTest.java | 6 +-
.../data/cosmos/common/MemoizerUnitTest.java | 8 +-
.../data/cosmos/common/PageTestUtils.java | 2 +-
.../cosmos/common/PropertyLoaderUnitTest.java | 10 +-
.../config/AbstractCosmosConfigurationIT.java | 24 +--
.../cosmos/core/CosmosFactoryUnitTest.java | 8 +-
.../data/cosmos/core/CosmosTemplateIT.java | 33 +--
.../core/CosmosTemplateIllegalTest.java | 14 +-
.../core/CosmosTemplatePartitionIT.java | 18 +-
.../cosmos/core/CosmosTemplateUnitTest.java | 10 +-
.../MultiTenantContainerCosmosFactoryIT.java | 24 +--
.../core/MultiTenantDBCosmosFactoryIT.java | 24 +--
.../cosmos/core/ReactiveCosmosTemplateIT.java | 198 +++++++++---------
.../ReactiveCosmosTemplatePartitionIT.java | 70 ++++---
...veMultiTenantContainerCosmosFactoryIT.java | 24 +--
.../ReactiveMultiTenantDBCosmosFactoryIT.java | 20 +-
.../ZonedDateTimeDeserializerTest.java | 2 +-
.../MappingCosmosConverterUnitTest.java | 12 +-
.../generator/AbstractQueryGeneratorTest.java | 24 +--
.../generator/NativeQueryGeneratorTest.java | 10 +-
.../BasicCosmosPersistentEntityUnitTest.java | 2 +-
.../mapping/CosmosMappingContextUnitTest.java | 2 +-
.../event/ApplicationContextEventErrorIT.java | 16 +-
...pplicationContextEventErrorReactiveIT.java | 16 +-
.../event/ApplicationContextEventIT.java | 20 +-
.../ApplicationContextEventReactiveIT.java | 20 +-
.../event/CosmosEventListenerUnitTests.java | 2 +-
.../core/query/CosmosQueryUnitTest.java | 12 +-
.../cosmos/core/query/CriteriaUnitTest.java | 40 ++--
.../exception/CosmosExceptionUtilsTest.java | 4 +-
.../repository/CosmosAnnotationUnitTest.java | 46 ++--
.../repository/EntityImplRepositoryIT.java | 14 +-
.../repository/MultiCosmosTemplateIT.java | 18 +-
.../ReactiveUUIDIdDomainRepositoryIT.java | 16 +-
.../SimpleCosmosRepositoryIllegalTest.java | 28 +--
.../SimpleCosmosRepositoryUnitTest.java | 20 +-
...ositoryConfigurationExtensionUnitTest.java | 2 +-
...ositoryConfigurationExtensionUnitTest.java | 2 +-
.../integration/AddressRepositoryIT.java | 30 ++-
.../AddressRepositoryNoMetricsIT.java | 14 +-
.../integration/AnnotatedQueryIT.java | 14 +-
.../repository/integration/AuditableIT.java | 18 +-
.../integration/BasicItemRepositoryIT.java | 22 +-
.../integration/BigTypeRepositoryIT.java | 14 +-
.../integration/CompositeIndexIT.java | 18 +-
.../integration/ContactRepositoryIT.java | 60 +++---
.../integration/CosmosAnnotationIT.java | 16 +-
.../repository/integration/CountIT.java | 40 ++--
.../integration/CustomerRepositoryIT.java | 26 +--
.../cosmos/repository/integration/EtagIT.java | 54 ++---
.../HierarchicalPartitionKeyRepositoryIT.java | 22 +-
.../integration/IndexPolicyUpdateIT.java | 14 +-
.../IntegerIdDomainRepositoryIT.java | 76 +++----
.../integration/LongIdDomainRepositoryIT.java | 86 ++++----
.../integration/MemoRepositoryIT.java | 74 +++----
.../NestedPartitionKeyRepositoryIT.java | 18 +-
.../PageableAddressRepositoryIT.java | 14 +-
.../integration/PageableMemoRepositoryIT.java | 14 +-
.../PageablePersonRepositoryIT.java | 14 +-
.../repository/integration/PersistableIT.java | 32 ++-
.../integration/PersonCrossPartitionIT.java | 18 +-
.../integration/ProjectRepositoryIT.java | 76 +++----
.../integration/ProjectRepositorySortIT.java | 56 ++---
.../integration/QuestionRepositoryIT.java | 30 +--
.../integration/ReactiveAuditableIT.java | 14 +-
.../ReactiveCourseRepositoryIT.java | 24 +--
.../ReactiveCourseRepositoryNoMetricsIT.java | 14 +-
.../integration/ReactiveEtagIT.java | 56 ++---
...eHierarchicalPartitionKeyRepositoryIT.java | 24 +--
.../ReactiveIndexPolicyUpdateIT.java | 14 +-
...dDomainPartitionPartitionRepositoryIT.java | 16 +-
...eactiveNestedPartitionKeyRepositoryIT.java | 18 +-
.../integration/ReactiveRoleRepositoryIT.java | 14 +-
.../ReactiveTeacherRepositoryIT.java | 14 +-
.../integration/SpELCosmosAnnotationIT.java | 18 +-
.../integration/SquareRepositoryIT.java | 14 +-
.../integration/StudentRepositoryIT.java | 26 +--
.../integration/TeacherRepositoryIT.java | 26 +--
.../integration/UUIDIdDomainRepositoryIT.java | 58 ++---
.../integration/UniqueKeyPolicyIT.java | 18 +-
.../query/AbstractCosmosQueryUnitTest.java | 8 +-
.../AbstractReactiveCosmosQueryUnitTest.java | 8 +-
.../CosmosEntityInformationUnitTest.java | 2 +-
.../CosmosRepositoryFactoryBeanUnitTest.java | 8 +-
.../CosmosRepositoryFactoryUnitTest.java | 10 +-
.../StringBasedCosmosQueryUnitTest.java | 8 +-
...tringBasedReactiveCosmosQueryUnitTest.java | 8 +-
91 files changed, 1063 insertions(+), 1112 deletions(-)
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..2d637a2935db 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,11 +6,12 @@
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;
@@ -18,9 +19,9 @@
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 +37,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 +47,7 @@ public void setup() {
otherLock = new ContainerLock(reactiveTemplate, entityInfo.getContainerName(), SHORT_LEASE_DURATION);
}
- @After
+ @AfterEach
public void cleanup() {
releaseLockIgnoreException(lock);
releaseLockIgnoreException(otherLock);
@@ -81,7 +82,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..a28d5c4916fe 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,8 +5,9 @@
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;
@@ -15,7 +16,7 @@
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..9cb4788b2e5e 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
@@ -12,9 +12,7 @@
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 +24,11 @@
import java.lang.reflect.Field;
-import static org.junit.Assert.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
public class AbstractCosmosConfigurationIT {
- @SuppressWarnings("deprecation")
- @Rule
- public ExpectedException exception = ExpectedException.none();
+
@Test
public void containsExpressionResolver() {
@@ -47,10 +43,10 @@ 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);
@@ -63,8 +59,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 +69,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..3d2c32d426d3 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,11 @@
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.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;
@@ -102,12 +102,13 @@
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.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertNotNull;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+import static org.junit.jupiter.api.Assertions.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 +161,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 +193,7 @@ public class CosmosTemplateIT {
public CosmosTemplateIT() throws JsonProcessingException {
}
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
if (cosmosTemplate == null) {
client = CosmosFactory.createCosmosAsyncClient(cosmosClientBuilder);
@@ -243,7 +244,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());
+ Assertions.assertEquals(TRANSIENT_PROPERTY, insertedPerson.getTransientProperty());
final Person retrievedPerson = cosmosTemplate.findById(Person.class.getSimpleName(), insertedPerson.getId(), Person.class);
assertThat(retrievedPerson.getTransientProperty()).isNull();
}
@@ -258,7 +259,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());
+ Assertions.assertEquals(TRANSIENT_PROPERTY, person.getTransientProperty());
}
Iterable findByIdsResponse = cosmosTemplate.findByIds(Arrays.asList(TEST_PERSON_4.getId()), Person.class, containerName);
@@ -269,7 +270,7 @@ 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()));
@@ -481,7 +482,7 @@ public void testUpsertNewDocumentIgnoresTransientFields() {
final Person person = cosmosTemplate.upsertAndReturnEntity(Person.class.getSimpleName(), newPerson);
- Assert.assertEquals(TRANSIENT_PROPERTY, person.getTransientProperty());
+ Assertions.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..c7c05593769a 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();
}
@@ -78,7 +78,7 @@ private void checkIllegalArgument(Method method, Object... args) {
try {
method.invoke(cosmosTemplate, args);
} catch (IllegalAccessException | InvocationTargetException e) {
- Assert.isTrue(e.getCause() instanceof IllegalArgumentException, CHECK_FAILURE_MSG);
+ Assertions.isTrue(e.getCause() instanceof IllegalArgumentException, CHECK_FAILURE_MSG);
return; // Test passed
}
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..31941d3b6ca4 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;
@@ -57,11 +59,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 +75,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 +92,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..d9f1b66083e2 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,14 +7,14 @@
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)
+@ExtendWith(MockitoExtension.class)
public class CosmosTemplateUnitTest {
- @Test(expected = IllegalArgumentException.class)
+ @Test
public void rejectNullDbFactory() {
CosmosAsyncClient client = CosmosFactory.createCosmosAsyncClient(new CosmosClientBuilder()
.endpoint("")
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..a3a02b688763 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,11 +16,11 @@
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;
@@ -40,9 +40,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 +54,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 +69,7 @@ public class MultiTenantContainerCosmosFactoryIT {
private CosmosAsyncClient client;
private CosmosEntityInformation personInfo;
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
/// Setup
client = CosmosFactory.createCosmosAsyncClient(cosmosClientBuilder);
@@ -79,7 +79,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 +109,7 @@ public void testGetContainerFunctionality() {
Iterable iterableDB2 = cosmosTemplate.findAll(personInfo.getContainerName(), Person.class);
List resultDB2 = new ArrayList<>();
iterableDB2.forEach(resultDB2::add);
- Assert.assertEquals(expectedResultsContainer2, resultDB2);
+ Assertions.assertEquals(expectedResultsContainer2, resultDB2);
// Check that testContainer1 has the correct contents
cosmosFactory.manuallySetContainerName = testContainer1;
@@ -118,7 +118,7 @@ public void testGetContainerFunctionality() {
Iterable iterableDB1 = cosmosTemplate.findAll(personInfo.getContainerName(), Person.class);
List resultDB1 = new ArrayList<>();
iterableDB1.forEach(resultDB1::add);
- Assert.assertEquals(expectedResultsContainer1, resultDB1);
+ Assertions.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..2744d21727db 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,11 +16,11 @@
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;
@@ -40,9 +40,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 +52,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 +67,7 @@ public class MultiTenantDBCosmosFactoryIT {
private CosmosAsyncClient client;
private CosmosEntityInformation personInfo;
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
/// Setup
client = CosmosFactory.createCosmosAsyncClient(cosmosClientBuilder);
@@ -77,7 +77,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 +106,7 @@ public void testGetDatabaseFunctionality() {
Iterable iterableDB2 = cosmosTemplate.findAll(personInfo.getContainerName(), Person.class);
List resultDB2 = new ArrayList<>();
iterableDB2.forEach(resultDB2::add);
- Assert.assertEquals(expectedResultsDB2, resultDB2);
+ Assertions.assertEquals(expectedResultsDB2, resultDB2);
// Check that DB1 has the correct contents
cosmosFactory.manuallySetDatabaseName = testDB1;
@@ -115,7 +115,7 @@ public void testGetDatabaseFunctionality() {
Iterable iterableDB1 = cosmosTemplate.findAll(personInfo.getContainerName(), Person.class);
List resultDB1 = new ArrayList<>();
iterableDB1.forEach(resultDB1::add);
- Assert.assertEquals(expectedResultsDB1, resultDB1);
+ Assertions.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..584b2c245db6 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
@@ -47,12 +47,11 @@
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;
@@ -95,11 +94,12 @@
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;
+import static org.junit.jupiter.api.Assertions.*;
-@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 +153,7 @@ public class ReactiveCosmosTemplateIT {
private static final CosmosPatchItemRequestOptions options = new CosmosPatchItemRequestOptions();
- @ClassRule
+
public static final ReactiveIntegrationTestCollectionManager collectionManager = new ReactiveIntegrationTestCollectionManager();
@Value("${cosmos.secondaryKey}")
@@ -191,7 +191,7 @@ public class ReactiveCosmosTemplateIT {
@Autowired
private StubDateTimeProvider stubDateTimeProvider;
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
if (cosmosTemplate == null) {
azureKeyCredential = new AzureKeyCredential(cosmosDbKey);
@@ -223,7 +223,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 +246,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());
+ Assertions.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 +283,7 @@ public void testFindByIdPointRead() {
BASIC_ITEM.getId(),
BasicItem.class);
StepVerifier.create(findById)
- .consumeNextWith(actual -> Assert.assertEquals(actual, BASIC_ITEM))
+ .consumeNextWith(actual -> Assertions.assertEquals(actual, BASIC_ITEM))
.verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
@@ -296,11 +296,11 @@ public void testFindByID() {
TEST_PERSON.getId(),
Person.class);
StepVerifier.create(findById)
- .consumeNextWith(actual -> Assert.assertEquals(actual, TEST_PERSON))
+ .consumeNextWith(actual -> Assertions.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 +310,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());
+ Assertions.assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
+ Assertions.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 +326,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 -> Assertions.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 +349,29 @@ public void testSaveSetsAuditData() {
stubDateTimeProvider.setNow(now);
StepVerifier.create(cosmosTemplate.insert(TEST_AUDITABLE_ENTITY_1))
.consumeNextWith(actual -> {
- Assert.assertEquals(actual.getId(), UUID_1);
+ Assertions.assertEquals(actual.getId(), UUID_1);
}).verifyComplete();
StepVerifier.create(cosmosTemplate.insert(TEST_AUDITABLE_ENTITY_2))
.consumeNextWith(actual -> {
- Assert.assertEquals(actual.getId(), UUID_2);
+ Assertions.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);
+ Assertions.assertEquals(actual.getId(), UUID_1);
+ Assertions.assertEquals(actual.getCreatedBy(), "test-auditor");
+ Assertions.assertEquals(actual.getLastModifiedBy(), "test-auditor");
+ Assertions.assertEquals(actual.getCreatedDate(), now);
+ Assertions.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);
+ Assertions.assertEquals(actual.getId(), UUID_2);
+ Assertions.assertEquals(actual.getCreatedBy(), "test-auditor");
+ Assertions.assertEquals(actual.getLastModifiedBy(), "test-auditor");
+ Assertions.assertEquals(actual.getCreatedDate(), now);
+ Assertions.assertEquals(actual.getLastModifiedByDate(), now);
}).verifyComplete();
}
@@ -383,22 +383,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);
+ Assertions.assertEquals(actual.getId(), UUID_1);
+ Assertions.assertEquals(actual.getCreatedBy(), "test-auditor-2");
+ Assertions.assertEquals(actual.getLastModifiedBy(), "test-auditor-2");
+ Assertions.assertEquals(actual.getCreatedDate(), now);
+ Assertions.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);
+ Assertions.assertEquals(actual.getId(), UUID_2);
+ Assertions.assertEquals(actual.getCreatedBy(), "test-auditor-2");
+ Assertions.assertEquals(actual.getLastModifiedBy(), "test-auditor-2");
+ Assertions.assertEquals(actual.getCreatedDate(), now);
+ Assertions.assertEquals(actual.getLastModifiedByDate(), now);
}).verifyComplete();
}
@@ -410,7 +410,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 +421,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 -> Assertions.assertEquals(actual.getId(), UUID_1))
+ .consumeNextWith(actual -> Assertions.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);
+ Assertions.assertEquals(actual.getId(), UUID_1);
+ Assertions.assertEquals(actual.getCreatedBy(), "test-auditor-2");
+ Assertions.assertEquals(actual.getLastModifiedBy(), "test-auditor-3");
+ Assertions.assertEquals(actual.getCreatedDate(), now);
+ Assertions.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);
+ Assertions.assertEquals(actual.getId(), UUID_2);
+ Assertions.assertEquals(actual.getCreatedBy(), "test-auditor-2");
+ Assertions.assertEquals(actual.getLastModifiedBy(), "test-auditor-2");
+ Assertions.assertEquals(actual.getCreatedDate(), now);
+ Assertions.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);
+ Assertions.assertEquals(actual.getId(), UUID_3);
+ Assertions.assertEquals(actual.getCreatedBy(), "test-auditor-2");
+ Assertions.assertEquals(actual.getLastModifiedBy(), "test-auditor-3");
+ Assertions.assertEquals(actual.getCreatedDate(), now);
+ Assertions.assertEquals(actual.getLastModifiedByDate(), now2);
}).verifyComplete();
}
@@ -453,7 +453,7 @@ public void testInsert() {
.expectNext(TEST_PERSON_3).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
}
@@ -465,7 +465,7 @@ public void testInsertBySecondaryKey() {
.expectNext(TEST_PERSON_3).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
}
@@ -476,7 +476,7 @@ public void testInsertWithContainerName() {
.expectNext(TEST_PERSON_2).verifyComplete();
- Assertions.assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
+ assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
}
@@ -509,7 +509,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 +525,7 @@ public void testUpsertNewDocumentIgnoresTransientFields() {
final Mono person = cosmosTemplate.upsert(Person.class.getSimpleName(), newPerson);
- Assert.assertEquals(TRANSIENT_PROPERTY, person.block().getTransientProperty());
+ Assertions.assertEquals(TRANSIENT_PROPERTY, person.block().getTransientProperty());
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
assertThat(responseDiagnosticsTestUtils.getCosmosResponseStatistics()).isNull();
@@ -605,7 +605,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 +619,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 +629,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 +646,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 +664,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 +696,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 +707,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 +747,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 +767,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 +787,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 +797,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..e7e356cb7e7f 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;
@@ -19,11 +22,9 @@
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;
@@ -41,8 +42,9 @@
import static com.azure.spring.data.cosmos.common.TestConstants.NOT_EXIST_ID;
import static org.assertj.core.api.Assertions.assertThat;
import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.*;
-@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 +55,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 +72,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 +103,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());
+ Assertions.assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
+ Assertions.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 +123,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());
+ Assertions.assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
+ Assertions.assertEquals(actual.getZipCode(), TEST_PERSON.getZipCode());
}).verifyComplete();
// CosmosAsyncClient cosmosAsyncClient = cosmosFactory.getCosmosAsyncClient();
@@ -142,8 +144,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());
+ Assertions.assertEquals(actual.getFirstName(), TEST_PERSON_2.getFirstName());
+ Assertions.assertEquals(actual.getZipCode(), TEST_PERSON_2.getZipCode());
}).verifyComplete();
// Map postQueryCallCache = asyncDocumentClient.getQueryPlanCache();
@@ -160,13 +162,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());
+ Assertions.assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
+ Assertions.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 +178,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());
+ Assertions.assertEquals(actual.getFirstName(), TEST_PERSON.getFirstName());
+ Assertions.assertEquals(actual.getZipCode(), TEST_PERSON.getZipCode());
}).verifyComplete();
assertThat(responseDiagnosticsTestUtils.getCosmosDiagnostics()).isNotNull();
@@ -220,8 +222,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 +238,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 +252,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 +265,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 +279,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 +293,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..e7969c0122ac 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,11 +16,11 @@
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;
@@ -42,9 +42,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 +56,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 +71,7 @@ public class ReactiveMultiTenantContainerCosmosFactoryIT {
private CosmosAsyncClient client;
private CosmosEntityInformation personInfo;
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
/// Setup
client = CosmosFactory.createCosmosAsyncClient(cosmosClientBuilder);
@@ -81,7 +81,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 +112,7 @@ public void testGetContainerFunctionality() {
StepVerifier.create(fluxDB2).expectNextCount(1).verifyComplete();
List resultDB2 = new ArrayList<>();
fluxDB2.toIterable().forEach(resultDB2::add);
- Assert.assertEquals(expectedResultsContainer2, resultDB2);
+ Assertions.assertEquals(expectedResultsContainer2, resultDB2);
// Check that testContainer1 has the correct contents
cosmosFactory.manuallySetContainerName = testContainer1;
@@ -122,7 +122,7 @@ public void testGetContainerFunctionality() {
StepVerifier.create(fluxDB1).expectNextCount(1).verifyComplete();
List resultDB1 = new ArrayList<>();
fluxDB1.toIterable().forEach(resultDB1::add);
- Assert.assertEquals(expectedResultsContainer1, resultDB1);
+ Assertions.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..38fa04cef85f 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,11 +16,11 @@
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;
@@ -42,9 +42,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 +54,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 +69,7 @@ public class ReactiveMultiTenantDBCosmosFactoryIT {
private CosmosAsyncClient client;
private CosmosEntityInformation personInfo;
- @Before
+ @BeforeEach
public void setUp() throws ClassNotFoundException {
/// Setup
client = CosmosFactory.createCosmosAsyncClient(cosmosClientBuilder);
@@ -79,7 +79,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..97f67326aaa7 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;
@@ -28,7 +28,7 @@ public class AbstractQueryGeneratorTest {
@Mock
private EmptyQueryGenerator queryGenerator;
- @Before
+ @BeforeEach
public void setUp() {
this.queryGenerator = new EmptyQueryGenerator();
}
@@ -45,7 +45,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 +60,7 @@ public void generateBinaryQueryWithStartsWithDoesNotUseUpper() {
SqlQuerySpec result = queryGenerator.generateCosmos(query);
- Assert.assertEquals(result.getQueryText(), " WHERE STARTSWITH(r.firstName, @firstName0, true) ");
+ Assertions.assertEquals(result.getQueryText(), " WHERE STARTSWITH(r.firstName, @firstName0, true) ");
}
@Test
@@ -72,7 +72,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");
+ Assertions.assertEquals(result.getQueryText(), " WHERE ARRAY_CONTAINS(UPPER(r.lastName), UPPER(@lastName0)) ORDER BY r.id ASC");
}
@Test
@@ -84,7 +84,7 @@ public void generateBinaryQueryWithArrayContainsUsesUpper() {
SqlQuerySpec result = queryGenerator.generateCosmos(query);
- Assert.assertEquals(result.getQueryText(), " WHERE ARRAY_CONTAINS(UPPER(r.lastName), UPPER(@lastName0)) ");
+ Assertions.assertEquals(result.getQueryText(), " WHERE ARRAY_CONTAINS(UPPER(r.lastName), UPPER(@lastName0)) ");
}
@Test
@@ -98,9 +98,9 @@ public void generateBinaryQueryWithStringEquals() {
SqlQuerySpec result = queryGenerator.generateCosmos(query);
if (ignoreCaseType == Part.IgnoreCaseType.NEVER) {
- Assert.assertEquals(result.getQueryText(), " WHERE STRINGEQUALS(r.firstName, @firstName0) ");
+ Assertions.assertEquals(result.getQueryText(), " WHERE STRINGEQUALS(r.firstName, @firstName0) ");
} else {
- Assert.assertEquals(result.getQueryText(), " WHERE STRINGEQUALS(r.firstName, @firstName0, true) ");
+ Assertions.assertEquals(result.getQueryText(), " WHERE STRINGEQUALS(r.firstName, @firstName0, true) ");
}
}
}
@@ -114,7 +114,7 @@ public void generateBinaryQueryWithIsEqualIntUsesUpper() {
SqlQuerySpec result = queryGenerator.generateCosmos(query);
- Assert.assertEquals(result.getQueryText(), " WHERE UPPER(r.zipcode) = UPPER(@zipcode0) ");
+ Assertions.assertEquals(result.getQueryText(), " WHERE UPPER(r.zipcode) = UPPER(@zipcode0) ");
}
@Test
@@ -126,7 +126,7 @@ public void generateBinaryQueryWithIsEqualStringDoesNotUseUpper() {
SqlQuerySpec result = queryGenerator.generateCosmos(query);
- Assert.assertEquals(result.getQueryText(), " WHERE STRINGEQUALS(r.firstName, @firstName0, true) ");
+ Assertions.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..415aa8a5fab9 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,9 @@
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.Assertions;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
import org.mockito.Mock;
import org.springframework.data.domain.Sort;
@@ -22,7 +22,7 @@ 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");
+ Assertions.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..275b1ee11d7a 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;
-@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,13 +32,13 @@ 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()));
}
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..35e7f3668443 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,21 @@
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.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;
-@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,13 +32,13 @@ public class ApplicationContextEventErrorReactiveIT {
@Autowired
private CosmosTemplate template;
- @Before
+ @BeforeEach
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();
}
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..bc6fab71a858 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,12 +11,10 @@
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;
@@ -30,11 +28,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 +42,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..25a14ad12025 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,12 +10,10 @@
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;
@@ -29,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 ApplicationContextEventReactiveIT {
- @ClassRule
+
public static final IntegrationTestCollectionManager collectionManager = new IntegrationTestCollectionManager();
@Autowired
@@ -43,11 +41,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..e795327c97f8 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,8 @@
// 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.Assertions;
+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;
@@ -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());
+ Assertions.assertEquals(criteria, query.getCriteria());
+ Assertions.assertEquals(Sort.unsorted(), query.getSort());
+ Assertions.assertEquals(Pageable.unpaged(), query.getPageable());
+ Assertions.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..e9fb75dffbda 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;
@@ -23,12 +23,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());
+ Assertions.assertEquals(values, criteria.getSubjectValues());
+ Assertions.assertEquals(CriteriaType.IS_EQUAL, criteria.getType());
+ Assertions.assertEquals(CRITERIA_KEY, criteria.getSubject());
+ Assertions.assertTrue(CriteriaType.isBinary(criteria.getType()));
+ Assertions.assertEquals(Part.IgnoreCaseType.NEVER, criteria.getIgnoreCase());
}
@Test
@@ -40,21 +40,21 @@ 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());
+ Assertions.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));
+ Assertions.assertEquals(2, criteria.getSubCriteria().size());
+ Assertions.assertEquals(leftCriteria, criteria.getSubCriteria().get(0));
+ Assertions.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());
+ Assertions.assertEquals(Part.IgnoreCaseType.NEVER, criteria.getSubCriteria().get(0).getIgnoreCase());
+ Assertions.assertEquals(Part.IgnoreCaseType.NEVER, criteria.getSubCriteria().get(1).getIgnoreCase());
}
- @Test(expected = IllegalQueryException.class)
+ @Test
public void testInvalidInKeywordParameter() {
final List