Search in sources :

Example 1 with UnsupportedTypeException

use of org.apache.stanbol.entityhub.servicesapi.model.UnsupportedTypeException in project stanbol by apache.

the class RepresentationTest method testGetFirstValueWithUnsupportedType.

@Test(expected = UnsupportedTypeException.class)
public void testGetFirstValueWithUnsupportedType() {
    String field = "urn:the.field:used.for.this.Test";
    Representation rep = createRepresentation(null);
    Object value = getUnsupportedValueInstance();
    if (value == null) {
        // this test is not needed therefore return an dummy Exception
        throw new UnsupportedTypeException(Object.class, "dummy exception to successfully complete this unnecessary test");
    } else {
        Class<?> unsupported = value.getClass();
        rep.getFirst(field, unsupported);
    }
}
Also used : UnsupportedTypeException(org.apache.stanbol.entityhub.servicesapi.model.UnsupportedTypeException) Representation(org.apache.stanbol.entityhub.servicesapi.model.Representation) Test(org.junit.Test)

Example 2 with UnsupportedTypeException

use of org.apache.stanbol.entityhub.servicesapi.model.UnsupportedTypeException in project stanbol by apache.

the class RepresentationTest method testGetValueWithUnsupportedType.

@Test(expected = UnsupportedTypeException.class)
public void testGetValueWithUnsupportedType() {
    String field = "urn:the.field:used.for.this.Test";
    Representation rep = createRepresentation(null);
    Object value = getUnsupportedValueInstance();
    if (value == null) {
        // this test is not needed therefore return an dummy Exception
        throw new UnsupportedTypeException(Object.class, "dummy exception to successfully complete this unnecessary test");
    } else {
        Class<?> unsupported = value.getClass();
        rep.get(field, unsupported);
    }
}
Also used : UnsupportedTypeException(org.apache.stanbol.entityhub.servicesapi.model.UnsupportedTypeException) Representation(org.apache.stanbol.entityhub.servicesapi.model.Representation) Test(org.junit.Test)

Aggregations

Representation (org.apache.stanbol.entityhub.servicesapi.model.Representation)2 UnsupportedTypeException (org.apache.stanbol.entityhub.servicesapi.model.UnsupportedTypeException)2 Test (org.junit.Test)2