Examples of OperationRepresentation


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

        assertThat(testObj.size(), equalTo(2));
    }
   
    @Test
    public void testAddNonUniqueList() {
        OperationRepresentation opNonUnique1 = new OperationRepresentation();
        opNonUnique1.setId(new GId("op1"));
        OperationRepresentation opNonUnique2 = new OperationRepresentation();
        opNonUnique2.setId(new GId("op2"));
        List<OperationRepresentation> list = new LinkedList<OperationRepresentation>();
        list.add(opNonUnique1);
        list.add(opNonUnique2);
       
        assertFalse(testObj.addAll(list));
View Full Code Here

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

        assertThat(testObj.size(), equalTo(2));
    }
   
    @Test
    public void testAddUniqueList() {
        OperationRepresentation opUnique1 = new OperationRepresentation();
        opUnique1.setId(new GId("op3"));
        OperationRepresentation opUnique2 = new OperationRepresentation();
        opUnique2.setId(new GId("op4"));
        List<OperationRepresentation> list = new LinkedList<OperationRepresentation>();
        list.add(opUnique1);
        list.add(opUnique2);
       
        assertTrue(testObj.addAll(list));
View Full Code Here

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

        assertThat(testObj.size(), equalTo(4));
    }
   
    @Test
    public void testAddMixedList() {
        OperationRepresentation opUnique1 = new OperationRepresentation();
        opUnique1.setId(new GId("op3"));
        OperationRepresentation opNonUnique2 = new OperationRepresentation();
        opNonUnique2.setId(new GId("op1"));
        List<OperationRepresentation> list = new LinkedList<OperationRepresentation>();
        list.add(opUnique1);
        list.add(opNonUnique2);
       
        assertTrue(testObj.addAll(list)); //queue was changed, even if not all elements were added
View Full Code Here

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

        when(deviceControlApi.getOperation(any(GId.class))).thenReturn(operationRep);
        when(deviceControlApi.update(any(OperationRepresentation.class))).thenAnswer(new Answer<OperationRepresentation>() {
            @Override
            public OperationRepresentation answer(InvocationOnMock invocation) throws Throwable {
                OperationRepresentation passedOperation = (OperationRepresentation) invocation.getArguments()[0];
                statusesRecordedOnDeviceControlApiMock.add(passedOperation.getStatus());
                return passedOperation;
            }
        });
    }
View Full Code Here

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

    @Test
    public void testOperationProcessingSuccessful() throws Exception {
        //GIVEN
        GId id = new GId("op");

        OperationRepresentation op = new OperationRepresentation();
        op.setId(id);
        queue.add(op);
        when(operationProcessor.process(op)).thenReturn(true);

        //WHEN
        testObj.start();
View Full Code Here

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

    @Test
    public void testOperationProcessingFailed() throws Exception {
        //GIVEN
        GId id = new GId("op");
        OperationRepresentation op = new OperationRepresentation();
        op.setId(id);
        queue.add(op);
        when(operationProcessor.process(op)).thenReturn(false);

        //WHEN
        testObj.start();
View Full Code Here

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

    }

    @Test
    public void testStartStop() throws Exception {
        // Given
        OperationRepresentation op = new OperationRepresentation();
        op.setId(new GId("op"));

        // When
        queue.add(op);

        // Then
View Full Code Here

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

    public boolean contains(Object arg0) {
        //if not instance of OperationRepresentation then not contains
        if (!(arg0 instanceof OperationRepresentation)) {
            return false;
        }
        OperationRepresentation operation = (OperationRepresentation) arg0;

        //iterate over all elements in queue and compare theirs ids
        Iterator<OperationRepresentation> iterator = iterator();
        while (iterator.hasNext()) {
            OperationRepresentation current = iterator.next();
            //if element in list have the same id, we know list contains it
            if (current != null && current.getId() != null && current.getId().equals(operation.getId())) {
                return true;
            }
        }

        //if no match, then list doesn't contain that element
View Full Code Here

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

    DeviceControlApi deviceControlApi;

    class Executor implements Runnable {
        @Override
        public void run() {
            OperationRepresentation op = null;
            running.set(true);
            while (isActive()) {
                try {
                    op = queue.poll(queuePollTimeOut, TimeUnit.MILLISECONDS);
                    if (op != null) {
                        // TODO - refactor. This isn't pretty
                        GId gid = op.getId();
                        Boolean internalOperation = false;
                        if (gid.getValue().startsWith(OperationsQueueHandler.INTERNAL)) {
                            internalOperation = true;
                        }

                        OperationRepresentation executingOperation = null;
                        if (!internalOperation) {
                            // change status of operation in REST to "executing"
                            op.setStatus(OperationStatus.EXECUTING.toString());
                            executingOperation = deviceControlApi.update(op);
                        }

                        boolean result = operationProcessor.process(op);

                        if (!internalOperation) {
                            // change status of operation in REST according to
                            // result
                            if (result) {
                                executingOperation.setStatus(OperationStatus.SUCCESSFUL.toString());
                            } else {
                                executingOperation.setStatus(OperationStatus.FAILED.toString());
                            }
                            deviceControlApi.update(executingOperation);
                        }

                    }
View Full Code Here

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

    }

    @When("^I create an operation for device '([^']*)'$")
    public void iCreateAnOperationForDevice(int deviceNum) throws Exception {
        GId deviceId = getMoId(deviceNum);
        OperationRepresentation operationRepresentation = new OperationRepresentation();
        operationRepresentation.setDeviceId(deviceId);
        operationRepresentation.set("smaple_value", "sample_operation_type");
        operation1 = deviceControlResource.create(operationRepresentation);
    }
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.