Search in sources :

Example 6 with SEPABindingsException

use of it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException in project SEPA by arces-wot.

the class Bindings method getRDFTerm.

public RDFTerm getRDFTerm(String variable) throws SEPABindingsException {
    if (!solution.has(variable))
        throw new SEPABindingsException(String.format("Variable not found: %s", variable));
    try {
        String type = getType(variable);
        String value = getValue(variable);
        switch(type) {
            case "uri":
                return new RDFTermURI(value);
            case "literal":
            case "typed-literal":
                if (getDatatype(variable) == null)
                    return new RDFTermLiteral(value);
                return new RDFTermLiteral(value, getDatatype(variable));
            case "bnode":
                return new RDFTermBNode(value);
        }
    } catch (Exception e) {
        throw new SEPABindingsException(e);
    }
    return null;
}
Also used : SEPABindingsException(it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException) SEPABindingsException(it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException)

Example 7 with SEPABindingsException

use of it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException in project SEPA by arces-wot.

the class ITPattern method genericClientSingleSubscribe.

@RepeatedTest(ConfigurationProvider.REPEATED_TEST)
@Timeout(10)
public void genericClientSingleSubscribe() {
    try {
        genericClient = new GenericClient(provider.getJsap(), handler);
        genericClient.subscribe("ALL", null, "first", provider.TIMEOUT, provider.NRETRY);
        handler.waitSubscribes(1);
        Response ret = genericClient.update("RANDOM", null, provider.TIMEOUT, provider.NRETRY);
        assertFalse(ret.isError(), ret.toString());
        handler.waitEvents(2);
        genericClient.unsubscribe(handler.getSpuid("first"), provider.TIMEOUT, provider.NRETRY);
        handler.waitUnsubscribes(1);
    } catch (SEPAProtocolException | SEPASecurityException | SEPAPropertiesException | SEPABindingsException | InterruptedException | IOException e) {
        e.printStackTrace();
        assertFalse(true, e.getMessage());
    }
}
Also used : Response(it.unibo.arces.wot.sepa.commons.response.Response) SEPAProtocolException(it.unibo.arces.wot.sepa.commons.exceptions.SEPAProtocolException) SEPABindingsException(it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException) SEPAPropertiesException(it.unibo.arces.wot.sepa.commons.exceptions.SEPAPropertiesException) SEPASecurityException(it.unibo.arces.wot.sepa.commons.exceptions.SEPASecurityException) IOException(java.io.IOException) RepeatedTest(org.junit.jupiter.api.RepeatedTest) Timeout(org.junit.jupiter.api.Timeout)

Aggregations

SEPABindingsException (it.unibo.arces.wot.sepa.commons.exceptions.SEPABindingsException)7 SEPAPropertiesException (it.unibo.arces.wot.sepa.commons.exceptions.SEPAPropertiesException)5 SEPAProtocolException (it.unibo.arces.wot.sepa.commons.exceptions.SEPAProtocolException)5 SEPASecurityException (it.unibo.arces.wot.sepa.commons.exceptions.SEPASecurityException)5 Response (it.unibo.arces.wot.sepa.commons.response.Response)3 IOException (java.io.IOException)3 RepeatedTest (org.junit.jupiter.api.RepeatedTest)3 Timeout (org.junit.jupiter.api.Timeout)2 JsonPrimitive (com.google.gson.JsonPrimitive)1 ConsumerTestUnit (it.unibo.arces.wot.sepa.ConsumerTestUnit)1 SPARQL11SEProtocol (it.unibo.arces.wot.sepa.api.SPARQL11SEProtocol)1 WebsocketSubscriptionProtocol (it.unibo.arces.wot.sepa.api.protocols.websocket.WebsocketSubscriptionProtocol)1