Package com.cumulocity.rest.representation.inventory

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


        return restConnector.post(createChildAssetPath(managedObjectRepresentation), InventoryMediaType.MANAGED_OBJECT_REFERENCE,
                createChildObject(childId));
    }
   
    private ManagedObjectReferenceRepresentation createChildObject(GId childId) {
        ManagedObjectReferenceRepresentation morr = new ManagedObjectReferenceRepresentation();
        ManagedObjectRepresentation mor = new ManagedObjectRepresentation();
        mor.setId(childId);
        morr.setManagedObject(mor);
        return morr;
    }
View Full Code Here


            throws SDKException {

        // Given
        ManagedObjectRepresentation ch1 = inventory.create(aSampleMo().build());
        ManagedObjectRepresentation ch2 = inventory.create(aSampleMo().build());
        ManagedObjectReferenceRepresentation childRef1 = createChildRef(ch1);
        ManagedObjectReferenceRepresentation childRef2 = createChildRef(ch2);

        // When
        childAdder.addChild(childRef1);
        childAdder.addChild(childRef2);
        childAdder.addChild(childRef1);
View Full Code Here

    private List<GId> addChildrenToParent(ChildAdder childrenAdder) throws SDKException {
        List<GId> creationOrder = new LinkedList<GId>();
        for (int i = 1; i <= 20; i++) {
            ManagedObjectRepresentation child = inventory.create(aSampleMo().build());
            creationOrder.add(child.getId());
            ManagedObjectReferenceRepresentation childRef = createChildRef(child);

            childrenAdder.addChild(childRef);
        }
        return creationOrder;
    }
View Full Code Here

    }

    private void addChildDevice(ManagedObjectRepresentation parent, ManagedObjectRepresentation child) throws SDKException {

        ManagedObjectReferenceRepresentation deviceRef = anMoRefRepresentationLike(MO_REF_REPRESENTATION).withMo(child).build();
        inventoryApi.getManagedObject(parent.getId()).addChildDevice(deviceRef);
    }
View Full Code Here

    }

    @Test
    public void testAddChildDevice() throws SDKException {
        //Given
        ManagedObjectReferenceRepresentation created = new ManagedObjectReferenceRepresentation();
        ManagedObjectReferenceRepresentation newChildDevice = new ManagedObjectReferenceRepresentation();
        when(restConnector.post(CHILD_DEVICES_URL, MANAGED_OBJECT_REFERENCE, newChildDevice)).thenReturn(created);

        // when
        ManagedObjectReferenceRepresentation result = managedObject.addChildDevice(newChildDevice);

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

    @Test
    public void testGetChildDevice() throws SDKException {
        //Given
        GId gid = new GId("deviceId");
        ManagedObjectReferenceRepresentation retrieved = new ManagedObjectReferenceRepresentation();
        when(restConnector.get(CHILD_DEVICES_URL + "/deviceId", MANAGED_OBJECT_REFERENCE,
                ManagedObjectReferenceRepresentation.class)).thenReturn(retrieved);

        // when
        ManagedObjectReferenceRepresentation result = managedObject.getChildDevice(gid);

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

    @Test
    public void testGetChildAsset() throws Exception {
        //Given
        GId gid = new GId("assetId");
        ManagedObjectReferenceRepresentation retrieved = new ManagedObjectReferenceRepresentation();
        when(restConnector.get(CHILD_ASSETS_URL + "/assetId", MANAGED_OBJECT_REFERENCE,
                ManagedObjectReferenceRepresentation.class)).thenReturn(retrieved);

        // when
        ManagedObjectReferenceRepresentation result = managedObject.getChildAsset(gid);

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

    }

    @Test
    public void testAddChildAsset() throws Exception {
        //Given
        ManagedObjectReferenceRepresentation created = new ManagedObjectReferenceRepresentation();
        ManagedObjectReferenceRepresentation newChildAsset = new ManagedObjectReferenceRepresentation();
        when(restConnector.post(CHILD_ASSETS_URL, MANAGED_OBJECT_REFERENCE, newChildAsset)).thenReturn(created);

        // when
        ManagedObjectReferenceRepresentation result = managedObject.addChildAssets(newChildAsset);

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

        // Given
        ManagedObjectRepresentation parent = inventory.create(aSampleMo().withName("parent1").build());
        ManagedObjectRepresentation child1 = inventory.create(aSampleMo().withName("child11").build());
        ManagedObjectRepresentation child2 = inventory.create(aSampleMo().withName("child21").build());

        ManagedObjectReferenceRepresentation childRef1 = anMoRefRepresentationLike(MO_REF_REPRESENTATION).withMo(
                child1).build();

        // When
        ManagedObject parentMo = inventory.getManagedObject(parent.getId());
        parentMo.addChildDevice(childRef1);
View Full Code Here

        ManagedObjectRepresentation parent = inventory.create(aSampleMo().withName("parent").build());
        ManagedObject parentMo = inventory.getManagedObject(parent.getId());

        for (int i=0; i<platform.getPageSize()+1; i++){
            ManagedObjectRepresentation child = inventory.create(aSampleMo().withName("child"+i).build());
            ManagedObjectReferenceRepresentation childRef = anMoRefRepresentationLike(MO_REF_REPRESENTATION).withMo(
                    child).build();
            parentMo.addChildDevice(childRef);
        }

        // When
View Full Code Here

TOP

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

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.