improve format of error messages relating to getters/setters
This commit is contained in:
parent
1f6564d345
commit
dc9a997f5f
|
@ -485,9 +485,9 @@ public final class ReflectHelper {
|
|||
throw new PropertyNotFoundException(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"Could not locate getter method for property [%s#%s]",
|
||||
containerClass.getName(),
|
||||
propertyName
|
||||
"Could not locate getter method for property '%s' of class '%s'",
|
||||
propertyName,
|
||||
containerClass.getName()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -608,12 +608,11 @@ public final class ReflectHelper {
|
|||
throw new MappingException(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"In trying to locate getter for property [%s], Class [%s] defined " +
|
||||
"both a `get` [%s] and `is` [%s] variant",
|
||||
propertyName,
|
||||
"Class '%s' declares both 'get' [%s] and 'is' [%s] variants of getter for property '%s'",
|
||||
containerClass.getName(),
|
||||
getMethod.toString(),
|
||||
isMethod.toString()
|
||||
getMethod,
|
||||
isMethod,
|
||||
propertyName
|
||||
)
|
||||
);
|
||||
}
|
||||
|
@ -731,9 +730,9 @@ public final class ReflectHelper {
|
|||
throw new PropertyNotFoundException(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"Could not locate setter method for property [%s#%s]",
|
||||
containerClass.getName(),
|
||||
propertyName
|
||||
"Could not locate setter method for property '%s' of class '%s'",
|
||||
propertyName,
|
||||
containerClass.getName()
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -152,12 +152,11 @@ public class AccessStrategyHelper {
|
|||
throw new MappingException(
|
||||
String.format(
|
||||
Locale.ROOT,
|
||||
"In trying to locate getter for property [%s], Class [%s] defined " +
|
||||
"both a `get` [%s] and `is` [%s] variant",
|
||||
propertyName,
|
||||
"Class '%s' declares both 'get' [%s] and 'is' [%s] variants of getter for property '%s'",
|
||||
containerClass.getName(),
|
||||
method.toString(),
|
||||
isMethodVariant.toString()
|
||||
isMethodVariant,
|
||||
propertyName
|
||||
)
|
||||
);
|
||||
}
|
||||
|
|
|
@ -25,6 +25,7 @@ import org.junit.AfterClass;
|
|||
import org.junit.BeforeClass;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.endsWith;
|
||||
import static org.hamcrest.CoreMatchers.startsWith;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertThat;
|
||||
|
@ -61,7 +62,7 @@ public class GetAndIsVariantGetterTest {
|
|||
fail( "Expecting a failure" );
|
||||
}
|
||||
catch (MappingException e) {
|
||||
assertThat( e.getMessage(), startsWith( "In trying to locate getter for property [id]" ) );
|
||||
assertThat( e.getMessage(), endsWith( "variants of getter for property 'id'" ) );
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -13,7 +13,6 @@ import jakarta.persistence.Id;
|
|||
import org.hibernate.MappingException;
|
||||
import org.hibernate.SessionFactory;
|
||||
import org.hibernate.boot.registry.BootstrapServiceRegistryBuilder;
|
||||
import org.hibernate.boot.registry.StandardServiceRegistryBuilder;
|
||||
import org.hibernate.cfg.Configuration;
|
||||
import org.hibernate.cfg.Environment;
|
||||
import org.hibernate.service.ServiceRegistry;
|
||||
|
@ -64,7 +63,8 @@ public class MissingSetterWithEnhancementTest {
|
|||
}
|
||||
catch (MappingException e) {
|
||||
assertEquals(
|
||||
"Could not locate setter method for property [" + EntityWithMissingSetter.class.getName() + "#name]",
|
||||
"Could not locate setter method for property 'name' of class '"
|
||||
+ EntityWithMissingSetter.class.getName() + "'",
|
||||
e.getMessage()
|
||||
);
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue