Package com.cumulocity.rest.representation.inventory

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


        List<GId> childIds = getIdsOfChildren(childrenQuery);
        assertThat(childIds, is(childDeviceIdsInCreationOrder));
    }

    private List<GId> getIdsOfChildren(ChildrenQuery childrenQuery) throws SDKException {
        ManagedObjectReferenceCollectionRepresentation refCollection = childrenQuery.getChildren();
        return extractIDs(refCollection);
    }
View Full Code Here


    @Before
    public void setup() throws Exception {
        MockitoAnnotations.initMocks(this);

        ManagedObjectReferenceCollectionRepresentation representation = new ManagedObjectReferenceCollectionRepresentation();
        representation.setSelf(INVENTORY_COLLECTION_URL);
        inventoryRepresentation.setManagedObjects(representation);
      
        inventoryApiResource = new InventoryApiImpl(restConnector, urlProcessor, inventoryRepresentation, DEFAULT_PAGE_SIZE);
    }
View Full Code Here

    }

    @Test
    public void testGetAllChildDevice() throws SDKException {
        //Given
        ManagedObjectReferenceCollectionRepresentation retrieved =
                new ManagedObjectReferenceCollectionRepresentation();
        when(restConnector.get(CHILD_DEVICES_URL+ "?pageSize=" + DEFAULT_PAGE_SIZE, MANAGED_OBJECT_REFERENCE_COLLECTION,
                ManagedObjectReferenceCollectionRepresentation.class)).thenReturn(retrieved);

        // when
        ManagedObjectReferenceCollectionRepresentation result = managedObject.getChildDevices().get();

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

    }

    @Test
    public void testGetAllChildAssets() throws Exception {
        //Given
        ManagedObjectReferenceCollectionRepresentation retrieved = new ManagedObjectReferenceCollectionRepresentation();
        when(restConnector.get(CHILD_ASSETS_URL+ "?pageSize=" +DEFAULT_PAGE_SIZE, MANAGED_OBJECT_REFERENCE_COLLECTION,
                ManagedObjectReferenceCollectionRepresentation.class)).thenReturn(retrieved);

        // when
        ManagedObjectReferenceCollectionRepresentation result = managedObject.getChildAssets().get();

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

        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

        ManagedObject parentMo = inventory.getManagedObject(parent.getId());
        parentMo.addChildDevice(childRef1);
        parentMo.addChildDevice(child2.getId());

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

        List<ManagedObjectReferenceRepresentation> refs = refCollection.getReferences();
        Set<GId> childDeviceIDs = asSet(refs.get(0).getManagedObject().getId(), 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 = inventory.getManagedObject(
                parent.getId()).getChildDevices().get();
        assertEquals(0, allChildDevices.getReferences().size());
    }
View Full Code Here

        assertThat(refCollection.get().getPageStatistics().getCurrentPage(), is(1));
        assertThat(refCollection.get().getSelf(), containsString("pageSize=" + platform.getPageSize() + "&currentPage=1"));
        assertThat(refCollection.get().getNext(), containsString("pageSize=" + platform.getPageSize() + "&currentPage=2"));
        assertThat(refCollection.get().getPrev(), is(nullValue()));

        ManagedObjectReferenceCollectionRepresentation secondPage = refCollection.getPage(refCollection.get(), 2);
        assertThat(secondPage.getReferences().size(), is(1));
    }
View Full Code Here

        ManagedObject parentMo = inventory.getManagedObject(parent.getId());
        parentMo.addChildAssets(childRef1);
        parentMo.addChildAssets(child2.getId());

        // Then
        ManagedObjectReferenceCollectionRepresentation refCollection = inventory.getManagedObject(
                parent.getId()).getChildAssets().get();
        List<ManagedObjectReferenceRepresentation> refs = refCollection.getReferences();
        Set<GId> childDeviceIDs = asSet(refs.get(0).getManagedObject().getId(), 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 = inventory.getManagedObject(
                parent.getId()).getChildAssets().get();
        assertEquals(0, allChildDevices.getReferences().size());
    }
View Full Code Here

TOP

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

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.