Browse Source

DATAJDBC-296 - Polishing.

Moved test into existing class.

Original pull request: #109.
1.0.x
Jens Schauder 7 years ago
parent
commit
2f1f6d04be
  1. 14
      src/test/java/org/springframework/data/relational/core/mapping/RelationalPersistentEntityImplUnitTests.java
  2. 52
      src/test/java/org/springframework/data/relational/core/mapping/RelationalPersistentEntityWithoutNamesImplUnitTests.java

14
src/test/java/org/springframework/data/relational/core/mapping/RelationalPersistentEntityImplUnitTests.java

@ -29,6 +29,7 @@ import org.springframework.data.annotation.Id; @@ -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 { @@ -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;
}
}

52
src/test/java/org/springframework/data/relational/core/mapping/RelationalPersistentEntityWithoutNamesImplUnitTests.java

@ -1,52 +0,0 @@ @@ -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;
}
}
Loading…
Cancel
Save