use of org.apache.stanbol.entityhub.servicesapi.model.Representation in project stanbol by apache.
the class RepresentationTest method testStringArrayWithNullTextConversion.
/**
* Parsing a String Array with null as first element MUST NOT add a value (because null values are not
* supported by {@link Representation}).
*/
@Test
public void testStringArrayWithNullTextConversion() {
String field = "urn:the.field:used.for.this.Test";
Representation rep = createRepresentation(null);
rep.add(field, new String[] { null, "en" });
assertFalse(rep.get(field).hasNext());
}
use of org.apache.stanbol.entityhub.servicesapi.model.Representation in project stanbol by apache.
the class RepresentationTest method testNullFieldGetFirstReference.
@Test(expected = IllegalArgumentException.class)
public void testNullFieldGetFirstReference() {
Representation rep = createRepresentation(null);
rep.getFirstReference(null);
}
use of org.apache.stanbol.entityhub.servicesapi.model.Representation in project stanbol by apache.
the class ValueFactoryTest method testMultipleInstanceForSameID.
@Test
public void testMultipleInstanceForSameID() {
Representation rep = testRepresentation("urn:testSameId");
Representation rep1 = testRepresentation("urn:testSameId");
// check that multiple calls with the same ID create different instances
// -> this is very important to allow mapping of Representations (e.g.
// when they are stored within a cache
assertNotSame(rep, rep1);
// if an ID is parsed, than the two instance should be equal
assertTrue(rep.equals(rep1));
// check the hash code
assertTrue(rep.hashCode() == rep1.hashCode());
}
use of org.apache.stanbol.entityhub.servicesapi.model.Representation in project stanbol by apache.
the class RepresentationTest method testEmptyFieldGetNaturalLanguateText.
@Test(expected = IllegalArgumentException.class)
public void testEmptyFieldGetNaturalLanguateText() {
Representation rep = createRepresentation(null);
rep.get("", "en");
}
use of org.apache.stanbol.entityhub.servicesapi.model.Representation in project stanbol by apache.
the class RepresentationTest method testAddUnsupportedType.
/*--------------------------------------------------------------------------
* Set of Tests that check if Methods correctly process UnsupportedTypes
* This means that the toString Method is used to get the lexical
* representation of such types
*--------------------------------------------------------------------------
*/
/**
* Adding an unsupported type should use the {@link Object#toString()} to store the parsed instance
*/
@Test
public void testAddUnsupportedType() {
String field = "urn:the.field:used.for.this.Test";
Representation rep = createRepresentation(null);
Object value = getUnsupportedValueInstance();
if (value == null) {
// this test is not needed
return;
}
rep.add(field, value);
Iterator<Object> valueIterator = rep.get(field);
assertNotNull(valueIterator);
assertTrue(valueIterator.hasNext());
Object repValue = valueIterator.next();
assertEquals(value.toString(), repValue.toString());
}
Aggregations