Container managed fields must have at least one element for container-managed
persistence, and have no container managed fields defined for bean managed
persistence test.
Result result = getInitializedResult();
ComponentNameConstructor compName = getVerifierContext().getComponentNameConstructor();
if (descriptor instanceof EjbEntityDescriptor) {
String persistentType =
((EjbEntityDescriptor)descriptor).getPersistenceType();
if (EjbEntityDescriptor.CONTAINER_PERSISTENCE.equals(persistentType)) {
// RULE:
// Container managed fields must have at least one element for container-
// managed persistence, and have no container managed fields defined for
// bean managed persistence test.
Set persistentFields =
((EjbCMPEntityDescriptor)descriptor).getPersistenceDescriptor().getCMPFields();
if (persistentFields.size() >= 1) {
result.addGoodDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.passed(smh.getLocalString
(getClass().getName() + ".passed",
"[ {0} ] container managed fields found in [ {1} ]",
new Object[] {new Integer(persistentFields.size()).toString(),descriptor.getName()}));
} else {
result.addErrorDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.failed(smh.getLocalString
(getClass().getName() + ".failed",
"Error: [ {0} ] container managed fields found in [ {1} ]. Container managed fields must have at least one element for container-managed persistence",
new Object[] {new Integer(persistentFields.size()).toString(),descriptor.getName()}));
}
} else { //if (BEAN_PERSISTENCE.equals(persistentType))
result.addNaDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.notApplicable(smh.getLocalString
(getClass().getName() + ".notApplicable1",
"Expected persistence type [ {0} ], but [ {1} ] bean has persistence type [ {2} ]",
new Object[] {EjbEntityDescriptor.CONTAINER_PERSISTENCE,descriptor.getName(),persistentType}));
}
return result;
} else {
result.addNaDetails(smh.getLocalString
("tests.componentNameConstructor",
"For [ {0} ]",
new Object[] {compName.toString()}));
result.notApplicable(smh.getLocalString
(getClass().getName() + ".notApplicable",
"[ {0} ] expected {1} bean, but called with {2} bean.",
new Object[] {getClass(),"Entity","Session"}));
return result;
}