DATAJDBC-296 - Polishing.

Moved test into existing class.

Original pull request: #109.
This commit is contained in:
Jens Schauder
2019-01-17 08:52:41 +01:00
parent 4daba8d745
commit 2f1f6d04be
2 changed files with 14 additions and 52 deletions

View File

@@ -29,6 +29,7 @@ import org.springframework.data.annotation.Id;
*
* @author Oliver Gierke
* @author Kazuki Shimizu
* @author Bastian Wilhelm
*/
public class RelationalPersistentEntityImplUnitTests {
@@ -50,8 +51,21 @@ public class RelationalPersistentEntityImplUnitTests {
assertThat(entity.getIdColumn()).isEqualTo("renamedId");
}
@Test // DATAJDBC-296
public void emptyTableAnnotationFallsBackToNamingStrategy() {
RelationalPersistentEntity<?> entity = mappingContext.getPersistentEntity(DummyEntityWithEmptyAnnotation.class);
assertThat(entity.getTableName()).isEqualTo("dummy_entity_with_empty_annotation");
}
@Table("dummy_sub_entity")
static class DummySubEntity {
@Id @Column("renamedId") Long id;
}
@Table()
static class DummyEntityWithEmptyAnnotation {
@Id @Column() Long id;
}
}

View File

@@ -1,52 +0,0 @@
/*
* Copyright 2018-2019 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.relational.core.mapping;
import org.junit.Test;
import org.springframework.data.annotation.Id;
import static org.assertj.core.api.Assertions.assertThat;
/**
* Unit tests for {@link RelationalPersistentEntityImpl} without names in {@link Column} and {@link Table}.
*
* @author Bastian Wilhelm
*/
public class RelationalPersistentEntityWithoutNamesImplUnitTests {
RelationalMappingContext mappingContext = new RelationalMappingContext();
@Test // DATAJDBC-296
public void discoversAnnotatedTableName() {
RelationalPersistentEntity<?> entity = mappingContext.getPersistentEntity(DummySubEntity.class);
assertThat(entity.getTableName()).isEqualTo("dummy_sub_entity");
}
@Test // DATAJDBC-296
public void considerIdColumnName() {
RelationalPersistentEntity<?> entity = mappingContext.getPersistentEntity(DummySubEntity.class);
assertThat(entity.getIdColumn()).isEqualTo("id");
}
@Table()
static class DummySubEntity {
@Id @Column() Long id;
}
}