Search code examples
javanoraui

NoraUI - "Cannot infer Type argument" error using Result.Warning<> in a custom step


I need to raise a warning during one of my scenario but i don't stop to have this error appearing : "Cannot infer type arguments for Result.Warning<>"

I actually tried to raise the Warning the same way i was raising Failure until now :

new Result.Warning<>(targetKey, Messages.format(TaroMessages.WARNING_RESOURCES_VALUE_DIFFERENCE_AFTER_REAFFECTATION, existing_value, new_value), true, oscarAccesClientPage.getCallBack());

The custom step i am using it inside is the following : I'm trying to go over a list of Element and checking that the existing value of them is the same or not as the one saved before.

protected void checkXyResourcesValue(Integer xyIterator, List<WebElement> elements, String keyParameter) throws TechnicalException, FailureException  {
        try {
            Integer resIterator = 1;
            for(WebElement element : elements) {
                String targetKey = "XY" + xyIterator + "RES" + resIterator + keyParameter;
                String new_value = element.getAttribute(VALUE) != null ? element.getAttribute(VALUE) : element.getText();
                String existing_value = Context.getValue(targetKey) != null ? Context.getValue(targetKey) : targetKey;
                if (new_value != existing_value) {
                    new Result.Warning<>(targetKey, Messages.format(TaroMessages.WARNING_RESOURCES_VALUE_DIFFERENCE_AFTER_REAFFECTATION, existing_value, new_value), true, oscarAccesClientPage.getCallBack());
                }
                resIterator++;
            }
        } catch (Exception e) {
            new Result.Failure<>(e.getMessage(), Messages.format(TaroMessages.FAIL_MESSAGE_ACCES_CLIENT_XY_CHECK_RESOURCES_VALUE, keyParameter, xyIterator), true, oscarAccesClientPage.getCallBack());
        }
    }

For the method to check and saved value I actually inspired myself for the piece of code from NoraUI to save a value on Context or read it from.

I'm using Eclipse Luna 4.4.2 and i try to compile using JDK1.8.0_131.

It may be more related to me not knowing how this work in Java than a real problem so thank you in advance for your help or insights. Don't hesitate to ask if you need more information on the piece of code or the context.


Solution

  • new Result.Warning<>(targetKey, Messages.format(TaroMessages.WARNING_RESOURCES_VALUE_DIFFERENCE_AFTER_REAFFECTATION, existing_value, new_value), true, 0);

    use 0 if you do not use any Model (data serialized) or use id of your Object in the serial.