Skip to content

Commit

Permalink
FORGE-1814, FORGE-1815: Fixes for null values in components
Browse files Browse the repository at this point in the history
  • Loading branch information
gastaldi committed May 13, 2014
1 parent 9075e30 commit 88af6a1
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package org.jboss.forge.addon.ui.impl.input;

import java.util.Collections;
import java.util.concurrent.Callable;

import javax.enterprise.inject.Vetoed;
Expand Down Expand Up @@ -51,7 +52,8 @@ public IMPLTYPE setItemLabelConverter(Converter<VALUETYPE, String> converter)
@Override
public Iterable<VALUETYPE> getValueChoices()
{
return Callables.call(choices);
Iterable<VALUETYPE> valueChoices = Callables.call(choices);
return valueChoices == null ? Collections.<VALUETYPE> emptyList() : valueChoices;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@

package org.jboss.forge.addon.ui.impl.input;

import java.util.Collections;
import java.util.Set;
import java.util.concurrent.Callable;

Expand Down Expand Up @@ -84,7 +85,8 @@ public UIInputMany<VALUETYPE> setDefaultValue(Iterable<VALUETYPE> value)
@Override
public Iterable<VALUETYPE> getValue()
{
return (value == null) ? Callables.call(defaultValue) : value;
Iterable<VALUETYPE> iterableValue = (value == null) ? Callables.call(defaultValue) : value;
return iterableValue == null ? Collections.<VALUETYPE> emptyList() : iterableValue;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
*/
package org.jboss.forge.addon.ui.impl.input;

import java.util.Collections;
import java.util.Set;
import java.util.concurrent.Callable;

Expand Down Expand Up @@ -59,7 +60,8 @@ public UISelectMany<VALUETYPE> setDefaultValue(Iterable<VALUETYPE> value)
@Override
public Iterable<VALUETYPE> getValue()
{
return (value == null) ? Callables.call(defaultValue) : value;
Iterable<VALUETYPE> iterableValue = (value == null) ? Callables.call(defaultValue) : value;
return iterableValue == null ? Collections.<VALUETYPE> emptyList() : iterableValue;
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,4 +243,21 @@ public void testInputWithAttributes()
Assert.assertEquals("REQUIRED_MESSAGE", attributedInput.getRequiredMessage());
Assert.assertEquals('a', attributedInput.getShortName());
}

@Test
public void testNotNullValueChoices()
{
// FORGE-1814
Assert.assertNotNull(gender.getValueChoices());
Assert.assertNotNull(partners.getValueChoices());
}

@Test
public void testNotNullValuesForUISelectComponents()
{
// FORGE-1815
Assert.assertNotNull(partners.getValue());
Assert.assertNotNull(unknown.getValue());
}

}

0 comments on commit 88af6a1

Please sign in to comment.