Dependency cleanup and minor updates.

Original Pull Request #1829
Closes #1828
This commit is contained in:
Peter-Josef Meisch 2021-05-24 14:47:47 +02:00 committed by GitHub
parent 67d084beea
commit 44e7ab63b0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 123 deletions

21
pom.xml
View File

@ -18,10 +18,9 @@
<url>https://github.com/spring-projects/spring-data-elasticsearch</url>
<properties>
<commonslang>2.6</commonslang>
<elasticsearch>7.12.1</elasticsearch>
<log4j>2.13.3</log4j>
<netty>4.1.52.Final</netty>
<log4j>2.14.1</log4j>
<netty>4.1.65.Final</netty>
<springdata.commons>2.6.0-SNAPSHOT</springdata.commons>
<testcontainers>1.15.3</testcontainers>
<blockhound-junit>1.0.6.RELEASE</blockhound-junit>
@ -132,22 +131,6 @@
<scope>test</scope>
</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 -->
<dependency>
<groupId>org.elasticsearch.client</groupId>

View File

@ -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());
}
}
}

View File

@ -18,19 +18,18 @@ package org.springframework.data.elasticsearch.config;
import static org.assertj.core.api.Assertions.*;
import static org.mockito.Mockito.*;
import org.springframework.context.annotation.Bean;
import reactor.core.publisher.Mono;
import java.util.Collection;
import java.util.Collections;
import org.apache.commons.lang.ClassUtils;
import org.elasticsearch.Version;
import org.elasticsearch.action.main.MainResponse;
import org.elasticsearch.client.RestHighLevelClient;
import org.elasticsearch.cluster.ClusterName;
import org.junit.jupiter.api.Test;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.context.support.AbstractApplicationContext;
import org.springframework.data.elasticsearch.annotations.Document;
@ -52,7 +51,7 @@ public class ElasticsearchConfigurationSupportUnitTests {
public void usesConfigClassPackageAsBaseMappingPackage() throws ClassNotFoundException {
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);
}

View File

@ -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");
}
}

View File

@ -2,17 +2,21 @@ package org.springframework.data.elasticsearch.utils;
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;
/**
* Created by akonczak on 02/12/2015.
*
* @author Peter-Josef Meisch
*/
public class IndexBuilder {
public static IndexQuery buildIndex(Object object) {
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 {
f.setAccessible(true);
IndexQuery indexQuery = new IndexQuery();