Package com.cumulocity.me.sdk.client.inventory

Examples of com.cumulocity.me.sdk.client.inventory.ManagedObject


    @Test
    public void getPagedChildDevices() throws Exception {
        // Given
        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
        PagedCollectionResource refCollection = inventory.getManagedObject(parent.getId()).getChildDevices();
View Full Code Here


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

        // When
        ManagedObject parentMo = inventory.getManagedObject(parent.getId());
        parentMo.addChildAssets(childRef1);
        parentMo.addChildAssets(childRef2);

        // Then
        ManagedObjectReferenceCollectionRepresentation refCollection = (ManagedObjectReferenceCollectionRepresentation) inventory.getManagedObject(parent.getId()).getChildAssets().get();

        List refs = refCollection.getReferences();
        Set<GId> childDeviceIDs = asSet(
                ((ManagedObjectReferenceRepresentation) refs.get(0)).getManagedObject().getId(),
                ((ManagedObjectReferenceRepresentation) refs.get(1)).getManagedObject().getId());
       
        assertThat(childDeviceIDs, is(asSet(child1.getId(), child2.getId())));

        // When
        parentMo.deleteChildAsset(child1.getId());
        parentMo.deleteChildAsset(child2.getId());

        // Then
        ManagedObjectReferenceCollectionRepresentation allChildDevices = (ManagedObjectReferenceCollectionRepresentation) inventory.getManagedObject(parent.getId()).getChildAssets().get();
        assertThat(allChildDevices.getReferences().size()).isEqualTo(0);
    }
View Full Code Here

    @Test
    public void getPagedChildAssets() throws Exception {
        // Given
        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.addChildAssets(childRef);
        }

        // When
        PagedCollectionResource refCollection = inventory.getManagedObject(parent.getId()).getChildAssets();
View Full Code Here

        // Given
        ManagedObjectRepresentation rep = aSampleMo().build();
        ManagedObjectRepresentation result = inventory.create(rep);

        // When
        ManagedObject mo = inventory.getManagedObject(result.getId());
        mo.delete();

        // Then
        exception.expect(sdkException(HTTP_NOT_FOUND));
        ManagedObject deletedMo = inventory.getManagedObject(result.getId());
        deletedMo.get();
    }
View Full Code Here

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

        // When
        ManagedObject parentMo = inventory.getManagedObject(parent.getId());
        parentMo.addChildDevice(childRef1);
        parentMo.addChildDevice(childRef2);

        // Then
        ManagedObjectReferenceCollectionRepresentation refCollection = (ManagedObjectReferenceCollectionRepresentation) inventory.getManagedObject(parent.getId()).getChildDevices().get();

        List refs = refCollection.getReferences();
        Set<GId> childDeviceIDs = asSet(
                ((ManagedObjectReferenceRepresentation) refs.get(0)).getManagedObject().getId(),
                ((ManagedObjectReferenceRepresentation) refs.get(1)).getManagedObject().getId());
        assertThat(childDeviceIDs, is(asSet(child1.getId(), child2.getId())));

        // When
        parentMo.deleteChildDevice(child1.getId());
        parentMo.deleteChildDevice(child2.getId());

        // Then
        ManagedObjectReferenceCollectionRepresentation allChildDevices = (ManagedObjectReferenceCollectionRepresentation) inventory.getManagedObject(parent.getId()).getChildDevices().get();
        assertThat(allChildDevices.getReferences().size()).isEqualTo(0);
    }
View Full Code Here

TOP

Related Classes of com.cumulocity.me.sdk.client.inventory.ManagedObject

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.