mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-06-28 23:02:12 +00:00
DATAES-619 - Migrate remaining tests to AssertJ.
This commit is contained in:
parent
e23f6f1d33
commit
2c4ca358f3
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.config.nested;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
import static org.springframework.data.elasticsearch.annotations.FieldType.*;
|
||||
|
||||
import lombok.Builder;
|
||||
@ -70,7 +70,7 @@ public class EnableNestedElasticsearchRepositoriesTests {
|
||||
|
||||
@Test
|
||||
public void hasNestedRepository() {
|
||||
assertNotNull(nestedRepository);
|
||||
assertThat(nestedRepository).isNotNull();
|
||||
}
|
||||
|
||||
@Data
|
||||
|
@ -15,7 +15,7 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.aggregation;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
|
||||
@ -34,9 +34,9 @@ public class AggregatedPageImplTest {
|
||||
public void constructFacetedPageWithPageable() {
|
||||
Page<String> page = new AggregatedPageImpl<>(Arrays.asList("Test", "Test 2"), PageRequest.of(0, 2), 10);
|
||||
|
||||
assertEquals(10, page.getTotalElements());
|
||||
assertEquals(2, page.getNumberOfElements());
|
||||
assertEquals(2, page.getSize());
|
||||
assertEquals(5, page.getTotalPages());
|
||||
assertThat(page.getTotalElements()).isEqualTo(10);
|
||||
assertThat(page.getNumberOfElements()).isEqualTo(2);
|
||||
assertThat(page.getSize()).isEqualTo(2);
|
||||
assertThat(page.getTotalPages()).isEqualTo(5);
|
||||
}
|
||||
}
|
||||
|
@ -15,13 +15,14 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.core.convert;
|
||||
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Calendar;
|
||||
import java.util.TimeZone;
|
||||
|
||||
import org.joda.time.DateTime;
|
||||
import org.joda.time.DateTimeZone;
|
||||
import org.joda.time.LocalDateTime;
|
||||
import org.junit.Assert;
|
||||
import org.junit.Test;
|
||||
|
||||
/**
|
||||
@ -32,32 +33,32 @@ public class DateTimeConvertersTests {
|
||||
|
||||
@Test
|
||||
public void testJodaDateTimeConverterWithNullValue() {
|
||||
Assert.assertNull(DateTimeConverters.JodaDateTimeConverter.INSTANCE.convert(null));
|
||||
assertThat(DateTimeConverters.JodaDateTimeConverter.INSTANCE.convert(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJodaDateTimeConverter() {
|
||||
DateTime dateTime = new DateTime(2013, 1, 24, 6, 35, 0, DateTimeZone.UTC);
|
||||
Assert.assertEquals("2013-01-24T06:35:00.000Z",
|
||||
DateTimeConverters.JodaDateTimeConverter.INSTANCE.convert(dateTime));
|
||||
assertThat(DateTimeConverters.JodaDateTimeConverter.INSTANCE.convert(dateTime))
|
||||
.isEqualTo("2013-01-24T06:35:00.000Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJodaLocalDateTimeConverterWithNullValue() {
|
||||
Assert.assertNull(DateTimeConverters.JodaLocalDateTimeConverter.INSTANCE.convert(null));
|
||||
assertThat(DateTimeConverters.JodaLocalDateTimeConverter.INSTANCE.convert(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJodaLocalDateTimeConverter() {
|
||||
LocalDateTime dateTime = new LocalDateTime(new DateTime(2013, 1, 24, 6, 35, 0, DateTimeZone.UTC).getMillis(),
|
||||
DateTimeZone.UTC);
|
||||
Assert.assertEquals("2013-01-24T06:35:00.000Z",
|
||||
DateTimeConverters.JodaLocalDateTimeConverter.INSTANCE.convert(dateTime));
|
||||
assertThat(DateTimeConverters.JodaLocalDateTimeConverter.INSTANCE.convert(dateTime))
|
||||
.isEqualTo("2013-01-24T06:35:00.000Z");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testJavaDateConverterWithNullValue() {
|
||||
Assert.assertNull(DateTimeConverters.JavaDateConverter.INSTANCE.convert(null));
|
||||
assertThat(DateTimeConverters.JavaDateConverter.INSTANCE.convert(null)).isNull();
|
||||
}
|
||||
|
||||
@Test
|
||||
@ -67,7 +68,7 @@ public class DateTimeConvertersTests {
|
||||
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
|
||||
calendar.setTimeInMillis(dateTime.getMillis());
|
||||
|
||||
Assert.assertEquals("2013-01-24T06:35:00.000Z",
|
||||
DateTimeConverters.JavaDateConverter.INSTANCE.convert(calendar.getTime()));
|
||||
assertThat(DateTimeConverters.JavaDateConverter.INSTANCE.convert(calendar.getTime()))
|
||||
.isEqualTo("2013-01-24T06:35:00.000Z");
|
||||
}
|
||||
}
|
||||
|
@ -15,12 +15,13 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.repositories.dynamicindex;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ImportResource;
|
||||
@ -74,11 +75,11 @@ public class DynamicIndexEntityTests {
|
||||
|
||||
indexNameProvider.setIndexName("index1");
|
||||
repository.save(new DynamicIndexEntity());
|
||||
assertTrue(indexNameProvider.callsCount > initialCallsCount);
|
||||
assertEquals(1L, repository.count());
|
||||
assertThat(indexNameProvider.callsCount > initialCallsCount).isTrue();
|
||||
assertThat(repository.count()).isEqualTo(1L);
|
||||
|
||||
indexNameProvider.setIndexName("index2");
|
||||
assertEquals(0L, repository.count());
|
||||
assertThat(repository.count()).isEqualTo(0L);
|
||||
}
|
||||
|
||||
@ImportResource(value = "classpath:/dynamic-index-repository-test.xml")
|
||||
|
@ -15,11 +15,12 @@
|
||||
*/
|
||||
package org.springframework.data.elasticsearch.repository.config;
|
||||
|
||||
import static org.junit.Assert.*;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import org.springframework.beans.factory.support.BeanDefinitionRegistry;
|
||||
import org.springframework.beans.factory.support.DefaultListableBeanFactory;
|
||||
import org.springframework.core.env.Environment;
|
||||
|
Loading…
x
Reference in New Issue
Block a user