mirror of
https://github.com/spring-projects/spring-data-elasticsearch.git
synced 2025-05-31 09:12:11 +00:00
Dependency cleanup and minor updates.
Original Pull Request #1829 Closes #1828
This commit is contained in:
parent
67d084beea
commit
44e7ab63b0
21
pom.xml
21
pom.xml
@ -18,10 +18,9 @@
|
|||||||
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
|
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
|
||||||
|
|
||||||
<properties>
|
<properties>
|
||||||
<commonslang>2.6</commonslang>
|
|
||||||
<elasticsearch>7.12.1</elasticsearch>
|
<elasticsearch>7.12.1</elasticsearch>
|
||||||
<log4j>2.13.3</log4j>
|
<log4j>2.14.1</log4j>
|
||||||
<netty>4.1.52.Final</netty>
|
<netty>4.1.65.Final</netty>
|
||||||
<springdata.commons>2.6.0-SNAPSHOT</springdata.commons>
|
<springdata.commons>2.6.0-SNAPSHOT</springdata.commons>
|
||||||
<testcontainers>1.15.3</testcontainers>
|
<testcontainers>1.15.3</testcontainers>
|
||||||
<blockhound-junit>1.0.6.RELEASE</blockhound-junit>
|
<blockhound-junit>1.0.6.RELEASE</blockhound-junit>
|
||||||
@ -132,22 +131,6 @@
|
|||||||
<scope>test</scope>
|
<scope>test</scope>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
|
||||||
<!-- APACHE -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>commons-lang</groupId>
|
|
||||||
<artifactId>commons-lang</artifactId>
|
|
||||||
<version>${commonslang}</version>
|
|
||||||
<scope>test</scope>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- JODA Time -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>joda-time</groupId>
|
|
||||||
<artifactId>joda-time</artifactId>
|
|
||||||
<version>${jodatime}</version>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
<!-- Elasticsearch -->
|
<!-- Elasticsearch -->
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.elasticsearch.client</groupId>
|
<groupId>org.elasticsearch.client</groupId>
|
||||||
|
@ -1,50 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2013-2021 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
package org.springframework.data.elasticsearch.core.convert;
|
|
||||||
|
|
||||||
import java.util.Date;
|
|
||||||
|
|
||||||
import org.joda.time.DateTimeZone;
|
|
||||||
import org.joda.time.LocalDateTime;
|
|
||||||
import org.joda.time.ReadableInstant;
|
|
||||||
import org.joda.time.format.DateTimeFormatter;
|
|
||||||
import org.joda.time.format.ISODateTimeFormat;
|
|
||||||
import org.springframework.core.convert.converter.Converter;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* DateTimeConverters
|
|
||||||
*
|
|
||||||
* @author Rizwan Idrees
|
|
||||||
* @author Mohsin Husen
|
|
||||||
*/
|
|
||||||
public final class DateTimeConverters {
|
|
||||||
|
|
||||||
private static DateTimeFormatter formatter = ISODateTimeFormat.dateTime().withZone(DateTimeZone.UTC);
|
|
||||||
|
|
||||||
public enum JavaDateConverter implements Converter<Date, String> {
|
|
||||||
INSTANCE;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String convert(Date source) {
|
|
||||||
if (source == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return formatter.print(source.getTime());
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
||||||
}
|
|
@ -18,19 +18,18 @@ package org.springframework.data.elasticsearch.config;
|
|||||||
import static org.assertj.core.api.Assertions.*;
|
import static org.assertj.core.api.Assertions.*;
|
||||||
import static org.mockito.Mockito.*;
|
import static org.mockito.Mockito.*;
|
||||||
|
|
||||||
import org.springframework.context.annotation.Bean;
|
|
||||||
import reactor.core.publisher.Mono;
|
import reactor.core.publisher.Mono;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
|
||||||
import org.apache.commons.lang.ClassUtils;
|
|
||||||
import org.elasticsearch.Version;
|
import org.elasticsearch.Version;
|
||||||
import org.elasticsearch.action.main.MainResponse;
|
import org.elasticsearch.action.main.MainResponse;
|
||||||
import org.elasticsearch.client.RestHighLevelClient;
|
import org.elasticsearch.client.RestHighLevelClient;
|
||||||
import org.elasticsearch.cluster.ClusterName;
|
import org.elasticsearch.cluster.ClusterName;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||||
|
import org.springframework.context.annotation.Bean;
|
||||||
import org.springframework.context.annotation.Configuration;
|
import org.springframework.context.annotation.Configuration;
|
||||||
import org.springframework.context.support.AbstractApplicationContext;
|
import org.springframework.context.support.AbstractApplicationContext;
|
||||||
import org.springframework.data.elasticsearch.annotations.Document;
|
import org.springframework.data.elasticsearch.annotations.Document;
|
||||||
@ -52,7 +51,7 @@ public class ElasticsearchConfigurationSupportUnitTests {
|
|||||||
public void usesConfigClassPackageAsBaseMappingPackage() throws ClassNotFoundException {
|
public void usesConfigClassPackageAsBaseMappingPackage() throws ClassNotFoundException {
|
||||||
|
|
||||||
ElasticsearchConfigurationSupport configuration = new StubConfig();
|
ElasticsearchConfigurationSupport configuration = new StubConfig();
|
||||||
assertThat(configuration.getMappingBasePackages()).contains(ClassUtils.getPackageName(StubConfig.class));
|
assertThat(configuration.getMappingBasePackages()).contains(StubConfig.class.getPackage().getName());
|
||||||
assertThat(configuration.getInitialEntitySet()).contains(Entity.class);
|
assertThat(configuration.getInitialEntitySet()).contains(Entity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,49 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright 2013-2021 the original author or authors.
|
|
||||||
*
|
|
||||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
||||||
* you may not use this file except in compliance with the License.
|
|
||||||
* You may obtain a copy of the License at
|
|
||||||
*
|
|
||||||
* https://www.apache.org/licenses/LICENSE-2.0
|
|
||||||
*
|
|
||||||
* Unless required by applicable law or agreed to in writing, software
|
|
||||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
||||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
||||||
* See the License for the specific language governing permissions and
|
|
||||||
* limitations under the License.
|
|
||||||
*/
|
|
||||||
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.jupiter.api.Test;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* @author Rizwan Idrees
|
|
||||||
* @author Mohsin Husen
|
|
||||||
*/
|
|
||||||
public class DateTimeConvertersTests {
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testJavaDateConverterWithNullValue() {
|
|
||||||
assertThat(DateTimeConverters.JavaDateConverter.INSTANCE.convert(null)).isNull();
|
|
||||||
}
|
|
||||||
|
|
||||||
@Test
|
|
||||||
public void testJavaDateConverter() {
|
|
||||||
DateTime dateTime = new DateTime(2013, 1, 24, 6, 35, 0, DateTimeZone.UTC);
|
|
||||||
Calendar calendar = Calendar.getInstance();
|
|
||||||
calendar.setTimeZone(TimeZone.getTimeZone("UTC"));
|
|
||||||
calendar.setTimeInMillis(dateTime.getMillis());
|
|
||||||
|
|
||||||
assertThat(DateTimeConverters.JavaDateConverter.INSTANCE.convert(calendar.getTime()))
|
|
||||||
.isEqualTo("2013-01-24T06:35:00.000Z");
|
|
||||||
}
|
|
||||||
}
|
|
@ -2,17 +2,21 @@ package org.springframework.data.elasticsearch.utils;
|
|||||||
|
|
||||||
import java.lang.reflect.Field;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
import org.apache.commons.lang.ArrayUtils;
|
import org.springframework.core.annotation.AnnotationUtils;
|
||||||
|
import org.springframework.data.annotation.Id;
|
||||||
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
import org.springframework.data.elasticsearch.core.query.IndexQuery;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by akonczak on 02/12/2015.
|
* Created by akonczak on 02/12/2015.
|
||||||
|
*
|
||||||
|
* @author Peter-Josef Meisch
|
||||||
*/
|
*/
|
||||||
public class IndexBuilder {
|
public class IndexBuilder {
|
||||||
|
|
||||||
public static IndexQuery buildIndex(Object object) {
|
public static IndexQuery buildIndex(Object object) {
|
||||||
for (Field f : object.getClass().getDeclaredFields()) {
|
for (Field f : object.getClass().getDeclaredFields()) {
|
||||||
if (ArrayUtils.isNotEmpty(f.getAnnotationsByType(org.springframework.data.annotation.Id.class))) {
|
|
||||||
|
if (AnnotationUtils.findAnnotation(f, Id.class) != null) {
|
||||||
try {
|
try {
|
||||||
f.setAccessible(true);
|
f.setAccessible(true);
|
||||||
IndexQuery indexQuery = new IndexQuery();
|
IndexQuery indexQuery = new IndexQuery();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user