|
| 1 | +/* |
| 2 | + * Copyright 2019 the original author or authors. |
| 3 | + * |
| 4 | + * Licensed under the Apache License, Version 2.0 (the "License"); |
| 5 | + * you may not use this file except in compliance with the License. |
| 6 | + * You may obtain a copy of the License at |
| 7 | + * |
| 8 | + * https://www.apache.org/licenses/LICENSE-2.0 |
| 9 | + * |
| 10 | + * Unless required by applicable law or agreed to in writing, software |
| 11 | + * distributed under the License is distributed on an "AS IS" BASIS, |
| 12 | + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 13 | + * See the License for the specific language governing permissions and |
| 14 | + * limitations under the License. |
| 15 | + */ |
| 16 | +package org.springframework.data.mapping.model; |
| 17 | + |
| 18 | +import static org.assertj.core.api.Assertions.*; |
| 19 | + |
| 20 | +import org.junit.Test; |
| 21 | +import org.springframework.data.mapping.PersistentEntity; |
| 22 | +import org.springframework.data.mapping.context.SampleMappingContext; |
| 23 | +import org.springframework.data.mapping.context.SamplePersistentProperty; |
| 24 | +import org.springframework.data.mapping.model.ClassGeneratingPropertyAccessorFactory.PropertyAccessorClassGenerator; |
| 25 | + |
| 26 | +/** |
| 27 | + * Unit tests for {@link PropertyAccessorClassGeneratorUnitTests}. |
| 28 | + * |
| 29 | + * @author Oliver Drotbohm |
| 30 | + */ |
| 31 | +public class PropertyAccessorClassGeneratorUnitTests { |
| 32 | + |
| 33 | + @Test // DATACMNS-1602 |
| 34 | + public void reusesAlreadyDeclaredClass() { |
| 35 | + |
| 36 | + SampleMappingContext context = new SampleMappingContext(); |
| 37 | + PersistentEntity<Object, SamplePersistentProperty> entity = context.getRequiredPersistentEntity(Sample.class); |
| 38 | + |
| 39 | + PropertyAccessorClassGenerator.generateCustomAccessorClass(entity); |
| 40 | + |
| 41 | + assertThatCode(() -> PropertyAccessorClassGenerator.generateCustomAccessorClass(entity)) // |
| 42 | + .doesNotThrowAnyException(); |
| 43 | + } |
| 44 | + |
| 45 | + static class Sample {} |
| 46 | +} |
0 commit comments