Search in sources :

Example 36 with Response

use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.

the class StatusMonitor method switchStatus.

private void switchStatus(String thing, boolean status) {
    // Update
    Bindings bindings = new Bindings();
    if (status)
        bindings.addBinding("value", new RDFTermLiteral("true"));
    else
        bindings.addBinding("value", new RDFTermLiteral("false"));
    bindings.addBinding("thing", new RDFTermURI(thing));
    Response ret = update(bindings);
    if (ret.isUpdateResponse()) {
        discoverables.put(thing, status);
        if (status)
            logger.warn("Web Thing: " + thing + " turned ON");
        else
            logger.warn("Web Thing: " + thing + " turned OFF");
    }
}
Also used : Response(it.unibo.arces.wot.sepa.commons.response.Response) ErrorResponse(it.unibo.arces.wot.sepa.commons.response.ErrorResponse) RDFTermURI(it.unibo.arces.wot.sepa.commons.sparql.RDFTermURI) Bindings(it.unibo.arces.wot.sepa.commons.sparql.Bindings) RDFTermLiteral(it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral)

Example 37 with Response

use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.

the class ITProtocolTest method Subscribe.

@Test(timeout = 5000)
public void Subscribe() {
    final Response response = submitSubscribe(TestQueries.SIMPLE_QUERY, client);
    assertFalse(String.valueOf(response.getAsJsonObject()), response.isError());
}
Also used : Response(it.unibo.arces.wot.sepa.commons.response.Response) QueryResponse(it.unibo.arces.wot.sepa.commons.response.QueryResponse) Test(org.junit.Test)

Example 38 with Response

use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.

the class ITProtocolTest method Update.

@Test(timeout = 5000)
public void Update() {
    final Response update = SubmitUpdate(client, TestQueries.SIMPLE_UPDATE);
    assertFalse(String.valueOf(update.getAsJsonObject()), update.isError());
}
Also used : Response(it.unibo.arces.wot.sepa.commons.response.Response) QueryResponse(it.unibo.arces.wot.sepa.commons.response.QueryResponse) Test(org.junit.Test)

Example 39 with Response

use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.

the class ITSecureProtocolTest method Register.

@Test
public void Register() {
    Response response;
    response = client.register(NOT_VALID_ID);
    assertTrue("Accepted not valid ID", response.isError());
    response = client.register(VALID_ID);
    assertTrue("Not accepted valid ID", response.isError());
}
Also used : Response(it.unibo.arces.wot.sepa.commons.response.Response) Test(org.junit.Test)

Example 40 with Response

use of it.unibo.arces.wot.sepa.commons.response.Response in project SEPA by arces-wot.

the class ITSecureProtocolTest method RequestToken.

@Test
@Ignore
public void RequestToken() throws SEPASecurityException {
    Response response;
    response = client.requestToken();
    assertFalse(String.valueOf(response.getAsJsonObject()), response.isError());
    assertFalse("SEPA returned an expired token", properties.isTokenExpired());
}
Also used : Response(it.unibo.arces.wot.sepa.commons.response.Response) Ignore(org.junit.Ignore) Test(org.junit.Test)

Aggregations

Response (it.unibo.arces.wot.sepa.commons.response.Response)40 ErrorResponse (it.unibo.arces.wot.sepa.commons.response.ErrorResponse)31 SubscribeResponse (it.unibo.arces.wot.sepa.commons.response.SubscribeResponse)19 QueryResponse (it.unibo.arces.wot.sepa.commons.response.QueryResponse)15 Bindings (it.unibo.arces.wot.sepa.commons.sparql.Bindings)12 Test (org.junit.Test)8 RDFTermLiteral (it.unibo.arces.wot.sepa.commons.sparql.RDFTermLiteral)7 UpdateResponse (it.unibo.arces.wot.sepa.commons.response.UpdateResponse)6 RDFTermURI (it.unibo.arces.wot.sepa.commons.sparql.RDFTermURI)5 JsonObject (com.google.gson.JsonObject)3 SubscribeRequest (it.unibo.arces.wot.sepa.commons.request.SubscribeRequest)3 ARBindingsResults (it.unibo.arces.wot.sepa.commons.sparql.ARBindingsResults)3 BindingsResults (it.unibo.arces.wot.sepa.commons.sparql.BindingsResults)3 IOException (java.io.IOException)3 Header (org.apache.http.Header)3 JsonArray (com.google.gson.JsonArray)2 JsonElement (com.google.gson.JsonElement)2 QueryRequest (it.unibo.arces.wot.sepa.commons.request.QueryRequest)2 UnsubscribeRequest (it.unibo.arces.wot.sepa.commons.request.UnsubscribeRequest)2 UpdateRequest (it.unibo.arces.wot.sepa.commons.request.UpdateRequest)2