DATACMNS-1375 - AnnotationRepositoryMetadata now exposes the offending repository name.
This commit is contained in:
@@ -28,7 +28,7 @@ import org.springframework.util.Assert;
|
||||
*/
|
||||
public class AnnotationRepositoryMetadata extends AbstractRepositoryMetadata {
|
||||
|
||||
private static final String NO_ANNOTATION_FOUND = String.format("Interface must be annotated with @%s!",
|
||||
private static final String NO_ANNOTATION_FOUND = String.format("Interface %%s must be annotated with @%s!",
|
||||
RepositoryDefinition.class.getName());
|
||||
|
||||
private final Class<?> idType;
|
||||
@@ -43,7 +43,9 @@ public class AnnotationRepositoryMetadata extends AbstractRepositoryMetadata {
|
||||
public AnnotationRepositoryMetadata(Class<?> repositoryInterface) {
|
||||
|
||||
super(repositoryInterface);
|
||||
Assert.isTrue(repositoryInterface.isAnnotationPresent(RepositoryDefinition.class), NO_ANNOTATION_FOUND);
|
||||
|
||||
Assert.isTrue(repositoryInterface.isAnnotationPresent(RepositoryDefinition.class),
|
||||
String.format(NO_ANNOTATION_FOUND, repositoryInterface.getName()));
|
||||
|
||||
this.idType = resolveIdType(repositoryInterface);
|
||||
this.domainType = resolveDomainType(repositoryInterface);
|
||||
|
||||
@@ -37,10 +37,12 @@ public class AnnotationRepositoryMetadataUnitTests {
|
||||
assertThat(metadata.getIdType()).isEqualTo(Integer.class);
|
||||
}
|
||||
|
||||
@Test(expected = IllegalArgumentException.class)
|
||||
@Test // DATACMNS-37, DATACMNS-1375
|
||||
public void preventsUnannotatedInterface() {
|
||||
|
||||
new AnnotationRepositoryMetadata(UnannotatedRepository.class);
|
||||
assertThatExceptionOfType(IllegalArgumentException.class) //
|
||||
.isThrownBy(() -> new AnnotationRepositoryMetadata(UnannotatedRepository.class)) //
|
||||
.withMessageContaining(UnannotatedRepository.class.getName());
|
||||
}
|
||||
|
||||
@SuppressWarnings("unused")
|
||||
|
||||
Reference in New Issue
Block a user