It's all about the answers!

Ask a question

[SOLVED] AssertionFailedException when try getvalue of enum

Joao Bosco Jares A. Chaves (324813) | asked Sep 09 '13, 3:08 p.m.
edited Sep 16 '13, 10:18 a.m.

Any one knows how to get combobox (as a enum type) selected value? So, I have a work item that has a enum attribute and one advisor to get this enum value, but when I try to get it, I take a Assert failed like below:

Caused by: org.eclipse.core.runtime.AssertionFailedException: assertion failed: 
at org.eclipse.core.runtime.Assert.isTrue(
at org.eclipse.core.runtime.Assert.isTrue(
... 111 more

The interesting thing is that I can get the attribute but can not the selected value.. below my code:

IAttribute attribute = workItemService.findAttribute(wi.getProjectArea(), "tipoFuncaoComboBox", monitor);

Object test1 = ((IWorkItem) wi.getWorkingCopy()).getValue(attribute);  //fail
Object test2 = wi.getValue(attribute);  //fail
Object test3 = attribute.getValue(auditableCommon, wi, monitor);  //fail

The process template is:

sam detweiler commented Sep 10 '13, 9:55 a.m. | edited Sep 10 '13, 9:57 a.m.

enum's don't have 'values', you have to 'resolve' them

see my sample in

see the code following this line
" // this will throw exception if not enumeration"

Accepted answer

permanent link
Ralph Schoon (63.0k33645) | answered Sep 10 '13, 1:52 a.m.
This post should provide you with some examples, I believe:
Joao Bosco Jares A. Chaves selected this answer as the correct answer

Joao Bosco Jares A. Chaves commented Sep 10 '13, 9:00 a.m.

 I was read this, but when ever I try the start point of this post that is: workItem.getValue(iAttribute); I get the org.eclipse.core.runtime.AssertionFailedException: assertion failed.


Joao Bosco Jares A. Chaves commented Sep 11 '13, 3:04 p.m. | edited Sep 11 '13, 3:33 p.m.

So I am using server side code, then I had to translate some code to the server side api, as below. However the same exception persists on the line that has this comment: //AssertionFailedException: assertion failed.

Is this possible that is caused by some bad process configuration, related with the enumeration?

Best Regards,

My Code:

// this will throw exception if not enumeration
IEnumeration<ILiteral> enumeration = (IEnumeration<ILiteral>) workItemService.resolveEnumeration(attribute, monitor);
if (enumeration != null) {
String[] iaval = attribute.getValue(auditableCommon, wi, monitor).toString().split(":"); //AssertionFailedException: assertion failed.
if (iaval.length > 1 && iaval[1] != null) {
List<ILiteral> enumerationLiterals = enumeration.getEnumerationLiterals();
for (ILiteral literal : enumerationLiterals) {
if (literal.getIdentifier2().getStringIdentifier().equalsIgnoreCase(iaval[1])) {
System.out.println("\t\t\t\t --> attribute id=" + attribute.getIdentifier() + ", type" + "=" + attribute.getAttributeType() + " literal=" + literal.getIdentifier2().getStringIdentifier() + " literal name=" + literal.getName());




Ralph Schoon commented Sep 12 '13, 4:37 a.m.

I can't debug your code. Here is some code I wrote on the server. It is basically the same as on the client, except the services IWorkitemServer and IWorkItemCommon used instead of Client Libraries.

        // Get the references for the trigger work item, we need it to add new
        // links
        IWorkItemReferences triggerItemReferences = iWorkItemServer
                .resolveWorkItemReferences(resolvedTriggerItem, monitor);

    // Iterate the enumeration literals and create
    IEnumeration<? extends ILiteral> targetEnumeration = iWorkItemCommon
            .resolveEnumeration(enumerationAttribute, monitor);
    List<? extends ILiteral> literals = targetEnumeration
    for (ILiteral targetLiteral : literals) {
        // Skip literals that are on the ignore list
        if (parsedConfig.fSkipLiterals.contains(targetLiteral
                .getIdentifier2().getStringIdentifier())) {


I would suggest to look into the links provided in the answers and debug your code on Jetty as suggested in to understand where your code is wrong.

4 other answers

permanent link
Joao Bosco Jares A. Chaves (324813) | answered Sep 10 '13, 9:06 a.m.
Below my code:

IWorkItem wi = (IWorkItem) entry.getValue().getWorkingCopy();
IAttribute attribute = workItemService.findAttribute(wi.getProjectArea(), "tipoFuncaoComboBox", monitor);
int t = wi.getId();

permanent link
Joao Bosco Jares A. Chaves (324813) | answered Sep 11 '13, 3:04 p.m.
Sam, thanks very much again =)

permanent link
Joao Bosco Jares A. Chaves (324813) | answered Sep 16 '13, 10:18 a.m.
 Hi friends, 

So, I discovered that enum resolver is to simple as explained by @Ralph Schoon and @sam detweiler. However, my case is a bit different, because I need the enum value of a work item child (second level), and when I try to get the enum value on the on save action of the parent of parent work item, I can not access the enum value of the second level child, as described below:

WI_A (parent);
WI_B (child first level);
WI_C (child scond level);


WI_C is child of WI_B that is child of WI_A.

So, I have to obtain all the values from WIB_B and WI_C, at the on save (precondition advisor) of the WI_A. But, as mentioned above, I can not do it, or I can not know how to do it, and I am so glad if any one can help. But, I will close this thread as solved, and open another one more specific for this situation, that I think is different for this one.

Ralph Schoon commented Sep 16 '13, 10:27 a.m.


how to iterate the children and get their values can be found here:

Please be aware that you are not supposed to modify the work item that is saved during a precondition/advisor, see because the extension point assumes the item is unmodified.

Please spend a bit more time to talk about your use case and which context (client/server) it is supposed to run in, next time.

Finally please pick Sam's answer as the correct one, as it answers your initial question as far as I can tell, so he should get his credit for the effort of answering.

Joao Bosco Jares A. Chaves commented Sep 16 '13, 10:33 a.m.

Ohh sure.. thanks @Ralph. Sorry @sam, I will correct this mistake now. So I am working with a precondition (on save) server side advisor.

permanent link
Joao Bosco Jares A. Chaves (324813) | answered Sep 18 '13, 10:56 a.m.
This thing is simple a lot, the sercret is how to obtain the children as my source code fragment below.. Look for this comment //SECRET :)
After, is just resolve de enumeration.. Thanks a lot @sam and @ralph  ;)

IWorkItemReferences processoElementarChildWorkItemAllRefs = workItemService.resolveWorkItemReferences(funcionalidadeWi, monitor);
List<IReference> processoElementarChildWorkItemAllRefschildList = getChildReferences(processoElementarChildWorkItemAllRefs);

IReference parentEndpoint = IReferenceFactory.INSTANCE.createReferenceToItem(funcionalidadeWi);

for (Object element : processoElementarChildWorkItemAllRefschildList) {
IReference iReference = (IReference) element;
ILink link = iReference.getLink();
if (link.getOtherEndpointDescriptor(parentEndpoint) == WorkItemEndPoints.CHILD_WORK_ITEMS) {
IWorkItem child = workItemServer.getAuditableCommon().resolveAuditable((IWorkItemHandle) link.getOtherRef(parentEndpoint).resolve(), WorkItem.FULL_PROFILE, monitor);//SECRET :)
IAttribute pf = workItemService.findAttribute(child.getProjectArea(), "pf", monitor);
String teste = getPF(child, pf, monitor);

IAttribute attributeT1enum_ = workItemService.findAttribute(child.getProjectArea(), "t1enum", monitor);
IAttribute attributeT1enumList_ = workItemService.findAttribute(child.getProjectArea(), "t1enumlist", monitor);

IEnumeration<ILiteral> enumerationT1enum_ = (IEnumeration<ILiteral>) workItemService.resolveEnumeration(attributeT1enum_, monitor);
IEnumeration<ILiteral> enumerationT1enumList_ = (IEnumeration<ILiteral>) workItemService.resolveEnumeration(attributeT1enumList_, monitor); attributeT1enumiaval_ =  (Identifier) child.getValue(attributeT1enum_);
List attributeT1enumListiaval_ = (List) child.getValue(attributeT1enumList_);


Your answer

Register or to post your answer.