DATAJDBC-137 - Fixes warnings and improves Javadoc.
All packages now use @NoNullApi. All warnings related to that fixed, except a few cases where upstream annotations are simply wrong. Added null checks. Fixed generic types where possible. Improved Javadoc. Code Formatting.
This commit is contained in:
@@ -24,11 +24,6 @@ import java.time.ZonedDateTime;
|
||||
import java.util.Date;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.jdbc.core.mapping.BasicJdbcPersistentProperty;
|
||||
import org.springframework.data.jdbc.core.mapping.Column;
|
||||
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity;
|
||||
import org.springframework.data.jdbc.core.mapping.JdbcPersistentProperty;
|
||||
import org.springframework.data.mapping.PropertyHandler;
|
||||
|
||||
/**
|
||||
|
||||
@@ -18,10 +18,6 @@ package org.springframework.data.jdbc.core.mapping;
|
||||
import static org.assertj.core.api.Assertions.*;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.jdbc.core.mapping.JdbcMappingContext;
|
||||
import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntity;
|
||||
import org.springframework.data.jdbc.core.mapping.JdbcPersistentEntityImpl;
|
||||
import org.springframework.data.jdbc.core.mapping.Table;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link JdbcPersistentEntityImpl}.
|
||||
|
||||
@@ -0,0 +1,57 @@
|
||||
/*
|
||||
* Copyright 2018 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
|
||||
*
|
||||
* http://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.jdbc.core.mapping.event;
|
||||
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import static org.assertj.core.api.Assertions.assertThat;
|
||||
|
||||
/**
|
||||
* Unit tests for {@link Identifier}
|
||||
*
|
||||
* @author Jens Schauder
|
||||
*/
|
||||
public class IdentifierTest {
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void specifiedOffersTheIdentifierValue() {
|
||||
|
||||
Identifier.Specified identifier = Identifier.of("x");
|
||||
|
||||
assertThat(identifier.getValue()).isEqualTo("x");
|
||||
assertThat((Optional<Object>) identifier.getOptionalValue()).contains("x");
|
||||
}
|
||||
|
||||
@Test
|
||||
public void indentifierOfNullHasEmptyValue(){
|
||||
|
||||
Identifier identifier = Identifier.ofNullable(null);
|
||||
|
||||
assertThat(identifier.getOptionalValue()).isEmpty();
|
||||
}
|
||||
|
||||
@SuppressWarnings("unchecked")
|
||||
@Test
|
||||
public void indentifierOfXHasValueX(){
|
||||
|
||||
Identifier identifier = Identifier.ofNullable("x");
|
||||
|
||||
assertThat((Optional<Object>) identifier.getOptionalValue()).hasValue("x");
|
||||
}
|
||||
}
|
||||
@@ -26,6 +26,7 @@ import java.util.concurrent.TimeUnit;
|
||||
import java.util.function.Consumer;
|
||||
|
||||
import org.assertj.core.api.SoftAssertions;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.junit.Test;
|
||||
import org.springframework.context.ConfigurableApplicationContext;
|
||||
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
|
||||
@@ -232,7 +233,7 @@ public class EnableJdbcAuditingHsqlIntegrationTests {
|
||||
|
||||
return new NamingStrategy() {
|
||||
|
||||
public String getTableName(Class<?> type) {
|
||||
public String getTableName(@NotNull Class<?> type) {
|
||||
return "DummyEntity";
|
||||
}
|
||||
};
|
||||
|
||||
@@ -37,6 +37,7 @@ import org.springframework.data.jdbc.repository.config.EnableJdbcRepositories;
|
||||
import org.springframework.data.jdbc.testing.TestConfiguration;
|
||||
import org.springframework.data.repository.CrudRepository;
|
||||
import org.springframework.data.repository.query.Param;
|
||||
import org.springframework.lang.Nullable;
|
||||
import org.springframework.test.context.ActiveProfiles;
|
||||
import org.springframework.test.context.ContextConfiguration;
|
||||
import org.springframework.test.context.junit4.rules.SpringClassRule;
|
||||
@@ -289,6 +290,7 @@ public class QueryAnnotationHsqlIntegrationTests {
|
||||
Optional<DummyEntity> findByNameAsOptional(@Param("name") String name);
|
||||
|
||||
// DATAJDBC-172
|
||||
@Nullable
|
||||
@Query("SELECT * FROM DUMMY_ENTITY WHERE name = :name")
|
||||
DummyEntity findByNameAsEntity(@Param("name") String name);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user