Commit a2da6b4b authored by cdanger's avatar cdanger

Merge branch 'gh-10' of https://github.com/authzforce/core.git into

gh-10

Conflicts:
	pdp-engine/src/main/java/org/ow2/authzforce/core/pdp/impl/value/StandardAttributeValueFactories.java
parents 8edaa97e 216df14d
......@@ -740,7 +740,7 @@ public final class StandardAttributeValueFactories
*/
public static AttributeBag<?> newAttributeBag(final Collection<Serializable> rawVals) throws UnsupportedOperationException, IllegalArgumentException
{
Preconditions.checkArgument(rawVals != null && rawVals.isEmpty(), "Null/empty arg");
Preconditions.checkArgument(rawVals != null && !rawVals.isEmpty(), "Null/empty arg");
final Serializable rawVal0 = rawVals.iterator().next();
final StringParseableValueFactory<?> factory = getAttributeValueFactory(rawVal0.getClass());
if (factory == null)
......
......@@ -21,13 +21,16 @@ import java.io.Serializable;
import java.time.LocalDate;
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import org.junit.Assert;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.junit.runners.Parameterized;
import org.junit.runners.Parameterized.Parameters;
import org.ow2.authzforce.core.pdp.api.value.AttributeDatatype;
import org.ow2.authzforce.core.pdp.api.value.AttributeValue;
import org.ow2.authzforce.core.pdp.api.value.StandardDatatypes;
import org.ow2.authzforce.core.pdp.impl.value.StandardAttributeValueFactories;
/**
*
......@@ -36,46 +39,52 @@ import org.ow2.authzforce.core.pdp.api.value.StandardDatatypes;
@RunWith(value = Parameterized.class)
public class PojoToAttributeBagConversionTest
{
@Parameters
@Parameters()
public static Collection<Object[]> data()
{
final Object[][] data = new Object[][] {
/* string type */
{ "string", StandardDatatypes.STRING },
/*
* date
*/
/*
* matching type (LocalDate)
*/
{ LocalDate.now(), StandardDatatypes.DATE },
/* subtype (of Date) */
{ java.sql.Date.valueOf(LocalDate.now()), StandardDatatypes.DATE } };
/*
* TODO: others
*/
/* empty collection */
{ Collections.emptyList(), StandardDatatypes.STRING.getId() },
/* string type */
{ Arrays.asList("string"), StandardDatatypes.STRING.getId() },
/*
* date
*/
/*
* matching type (LocalDate)
*/
{ Arrays.asList(LocalDate.now()), StandardDatatypes.DATE.getId() },
/* subtype (of Date) */
{ Arrays.asList(java.sql.Date.valueOf(LocalDate.now())), StandardDatatypes.DATE.getId() },
/*
* TODO: others
*/
/* invalid mix of datatypes */
{ Arrays.asList(new Integer(0), LocalDate.now()), StandardDatatypes.DATE.getId() } };
return Arrays.asList(data);
}
private final Serializable value;
private final AttributeDatatype<?> expectedXacmlDatatype;
private final Collection<? extends Serializable> rawValues;
private final String expectedAttributeDatatypeId;
public PojoToAttributeBagConversionTest(final Serializable rawValue, final AttributeDatatype<?> expectedReturnedXacmlDataType)
public PojoToAttributeBagConversionTest(final Collection<? extends Serializable> rawValues,
final String expectedAttributeDatatypeId)
{
this.value = rawValue;
this.expectedXacmlDatatype = expectedReturnedXacmlDataType;
this.rawValues = rawValues;
this.expectedAttributeDatatypeId = expectedAttributeDatatypeId;
}
@Test
public void testSingleValue()
public void test()
{
// TODO
}
if (rawValues.isEmpty())
{
@Test
public void testCollection()
{
// TODO
}
final AttributeValue attVal = StandardAttributeValueFactories.newAttributeValue(rawValue);
Assert.assertEquals(attVal.getDataType(), expectedAttributeDatatypeId,
"Unexpected datatype for created attribute value");
}
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment