Package com.cumulocity.rest.representation.inventory

Examples of com.cumulocity.rest.representation.inventory.ManagedObjectRepresentation


    @Test
    public void shouldPutRepresentationSupportingIdWithNoResponseBodyAndNoLocation() throws Exception {
        // Given
        clientParameters.setRequireResponseBody(false);

        ManagedObjectRepresentation representation = new ManagedObjectRepresentation();
        returnResponseWhenPut(representation);
        when(parser.parse(response, 200, ManagedObjectRepresentation.class)).thenReturn(null);
        when(response.getLocation()).thenReturn(null);

        // When
        ManagedObjectRepresentation result = restConnector.put(PATH, mediaType, representation);

        // Then
        verify(typeBuilder, never()).accept(any(MediaType.class));
        assertThat(result, sameInstance(representation));
        assertThat(result.getId(), nullValue());
    }
View Full Code Here


    @Test
    public void shouldReturnResponse() {
        Future future = bufferRequestService.create(new BufferedRequest());
        Result result = new Result();
        result.setResponse(new ManagedObjectRepresentation());
        bufferRequestService.addResponse(REQUEST_ID, result);
       
        assertThat(future.get()).isInstanceOf(ManagedObjectRepresentation.class);
    }
View Full Code Here

            .withSource(source())
            .build();
    }

    private ManagedObjectRepresentation source() {
        ManagedObjectRepresentation source = new ManagedObjectRepresentation();
        source.setId(new GId("1"));
        return source;
    }
View Full Code Here

    }

    @Test
    public void shouldCreateMo() throws Exception {
        //Given
        ManagedObjectRepresentation managedObjectRepresentation = new ManagedObjectRepresentation();
        ManagedObjectRepresentation created = new ManagedObjectRepresentation();
        when(restConnector.post(INVENTORY_COLLECTION_URL, InventoryMediaType.MANAGED_OBJECT, managedObjectRepresentation)).thenReturn(
                created);

        // When
        ManagedObjectRepresentation mor = inventoryApiResource.create(managedObjectRepresentation);

        // Then
        assertThat(mor, sameInstance(created));
    }
View Full Code Here

    }

    @Test
    public void testGet() throws Exception {
        //when
        ManagedObjectRepresentation mor = managedObject.get();

        // then
        assertThat(mor, sameInstance(managedObjectRep));
    }
View Full Code Here

    }

    @Test
    public void testUpdate() throws SDKException {
        //Given
        ManagedObjectRepresentation mo = new ManagedObjectRepresentation();
        ManagedObjectRepresentation updated = new ManagedObjectRepresentation();
        when(restConnector.put(MANAGED_OBJECT_URL, InventoryMediaType.MANAGED_OBJECT, mo)).thenReturn(updated);

        // when
        ManagedObjectRepresentation result = managedObject.update(mo);

        // then
        assertThat(result, sameInstance(updated));

    }
View Full Code Here

        // then
        assertThat(result, sameInstance(created));
    }

    private ManagedObjectRepresentation createMoWithChildDevicesAndAssets() {
        ManagedObjectRepresentation mo = new ManagedObjectRepresentation();
        ManagedObjectReferenceCollectionRepresentation childDevices = new ManagedObjectReferenceCollectionRepresentation();
        childDevices.setSelf(CHILD_DEVICES_URL);
        mo.setChildDevices(childDevices);

        ManagedObjectReferenceCollectionRepresentation childAssets = new ManagedObjectReferenceCollectionRepresentation();
        childAssets.setSelf(CHILD_ASSETS_URL);
        mo.setChildAssets(childAssets);

        return mo;
    }
View Full Code Here

    private static ManagedObjectRepresentation managedObject;

    @BeforeClass
    public static void createManagedObject() throws Exception {
        ManagedObjectRepresentation mo = new ManagedObjectRepresentation();
        mo.setName("MO");

        managedObject = platform.getInventoryApi().create(mo);
    }
View Full Code Here

    }

    @Test
    public void getAllWhen2ManagedObjectArePresent() throws Exception {
        // Given
        ManagedObjectRepresentation rep1 = aSampleMo().withName("MO1").build();
        ManagedObjectRepresentation rep2 = aSampleMo().withName("MO2").build();

        // When
        inventory.create(rep1);
        inventory.create(rep2);
View Full Code Here

    }

    @When("I query all Events by source '(\\d+)'$")
    public void iQueryAllBySource(int index) throws SDKException {
        try {
            ManagedObjectRepresentation mo = managedObject;
            EventFilter filter = new EventFilter().bySource(mo);
            collection = eventApi.getEventsByFilter(filter).get();
        } catch (SDKException ex) {
            status = ex.getHttpStatus();
        }
View Full Code Here

TOP

Related Classes of com.cumulocity.rest.representation.inventory.ManagedObjectRepresentation

Copyright © 2018 www.massapicom. 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.