Constraints ignored for Entities
--------------------------------
Key: QI-59
URL: http://issues.ops4j.org/jira/browse/QI-59
Project: Qi4j
Issue Type: Bug
Components: Core Runtime
Affects Versions: 0.2
Reporter: Richard Wallace
Assignee: Rickard Öberg
Priority: Critical
Originally reported on the mailing list thread [Unit of Work and
Constraints|http://lists.ops4j.org/pipermail/qi4j-dev/2008-May/002168.html]
I'm having a problem getting constraints to work on Entities. In short, they
seem to be ignored. I'm trying it with the following interface
[code]
public interface Nameable {
@NonEmptyString Property<String> name();
}
[code]
using the following test
[code]
public class NameableTest extends AbstractQi4jTest {
@Test
public void assertNameCannotBeSetToNull() throws
ConcurrentEntityModificationException, UnitOfWorkCompletionException {
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
Nameable nameable = uow.newEntity(Nameable.class);
nameable.name().set(null);
uow.complete();
}
@Test
public void assertNameCannotBeSetToEmptyString() throws
ConcurrentEntityModificationException, UnitOfWorkCompletionException {
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
Nameable nameable = uow.newEntity(Nameable.class);
nameable.name().set("");
uow.complete();
}
@Test
public void assertNameCannotBeSetToStringWithOnlyWhitespace() throws
ConcurrentEntityModificationException, UnitOfWorkCompletionException {
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
Nameable nameable = uow.newEntity(Nameable.class);
nameable.name().set(" \t \n");
uow.complete();
}
@Test
public void assertNameCannotBeLeftUnset() throws
ConcurrentEntityModificationException, UnitOfWorkCompletionException {
UnitOfWork uow = unitOfWorkFactory.newUnitOfWork();
uow.newEntity(Nameable.class);
uow.complete();
}
@SuppressWarnings("unchecked")
public void assemble(ModuleAssembly module) throws AssemblyException {
module.addComposites(NameableEntity.class);
module.addServices(UuidIdentityGeneratorService.class,
MemoryEntityStoreService.class);
}
static interface NameableEntity extends Nameable, EntityComposite {}
}
[code]
I tried changing the constraint to just @NotNull and got the same result (all
the tests pass when they should all fail).
--
This message is automatically generated by JIRA.
-
If you think it was sent incorrectly contact one of the administrators:
http://issues.ops4j.org/jira/secure/Administrators.jspa
-
For more information on JIRA, see: http://www.atlassian.com/software/jira
_______________________________________________
qi4j-dev mailing list
[email protected]
http://lists.ops4j.org/mailman/listinfo/qi4j-dev