Examples of OperationRepresentation


Examples of com.cumulocity.rest.representation.operation.OperationRepresentation

    private String getSelfUri() throws SDKException {
        return getDeviceControlRepresentation().getOperations().getSelf();
    }

    private OperationRepresentation prepareOperationForUpdate(OperationRepresentation operation) {
        OperationRepresentation toSend = new OperationRepresentation();
        toSend.setStatus(operation.getStatus());
        if (OperationStatus.FAILED.name().equals(operation.getStatus())) {
            toSend.setFailureReason(operation.getFailureReason());
        }
        toSend.setAttrs(operation.getAttrs());
        return toSend;
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.operation.OperationRepresentation

    @Test
    public void shouldGetOperation() throws SDKException {
        // Given
        GId gid = new GId("value");
        OperationRepresentation op = new OperationRepresentation();
        when(restConnector.get(DEVICE_CONTROL_COLLECTION_URL + "/value", DeviceControlMediaType.OPERATION, OperationRepresentation.class))
                .thenReturn(op);

        // When
        OperationRepresentation retrieved = deviceControlApi.getOperation(gid);

        // Then
        assertThat(retrieved, sameInstance(op));
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.operation.OperationRepresentation

    }

    @Test
    public void shouldCreateOperation() throws Exception {
        //Given
        OperationRepresentation operation = new OperationRepresentation();
        OperationRepresentation created = new OperationRepresentation();

        when(restConnector.post(DEVICE_CONTROL_COLLECTION_URL, DeviceControlMediaType.OPERATION, operation)).thenReturn(created);

        //when
        OperationRepresentation result = deviceControlApi.create(operation);

        // then
        assertThat(result, sameInstance(created));
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.operation.OperationRepresentation

    }

    @Test
    public void shouldUpdateOperation() throws SDKException {
        //Given
        OperationRepresentation op = new OperationRepresentation();
        op.setStatus(OperationStatus.EXECUTING.toString());
        op.setId(new GId("myId"));
        op.setCreationTime(new Date());
        OperationRepresentation updated = new OperationRepresentation();
        when(restConnector.put(eq(DEVICE_CONTROL_COLLECTION_URL + "/myId"), eq(DeviceControlMediaType.OPERATION),
                argThat(hasOnlyUpdateFields(op)))).thenReturn(updated);

        //when
        OperationRepresentation result = deviceControlApi.update(op);

        // then
        assertThat(result, sameInstance(updated));
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.operation.OperationRepresentation

*/
public class MeasurementRequestTask implements Runnable {
    private static final Logger LOG = LoggerFactory.getLogger(MeasurementRequestTask.class);

    public OperationRepresentation getNewMeasurementOperation() {
        OperationRepresentation newOp = Operations.createNewMeasurementOperation();
        newOp.setId(new GId(OperationsQueueHandler.INTERNAL + ":NewMeasurement-" + String.valueOf(System.currentTimeMillis())));
        return newOp;
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.