Package com.cumulocity.me.rest.representation.inventory

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


   
    @Test
    public void shouldConvertToEmptyReferencesJson() throws Exception {
        JSONObject expectedJSON = aJSONObject().withProperty(PROP_REFERENCES, aJSONArray().build()).build();

        JSONObject outputJSON = toJson(new ManagedObjectReferenceCollectionRepresentation());
       
        assertThat(outputJSON.toString()).isEqualTo(expectedJSON.toString());
    }
View Full Code Here


        assertThat(outputJSON.toString()).isEqualTo(expectedJSON.toString());
    }
   
    @Test
    public void shouldConvertToJson() throws Exception {
        ManagedObjectReferenceCollectionRepresentation representation = new ManagedObjectReferenceCollectionRepresentation();
        representation.setReferences(getListOfReferences());
        JSONObject expectedJSON = aJSONObject().withProperty(PROP_REFERENCES, getJsonArrayReferenceRepresentation()).build();
       
        JSONObject outputJSON = toJson(representation);
       
        assertThat(outputJSON.toString()).isEqualTo(expectedJSON.toString());
View Full Code Here

   
    @Test
    public void shouldConvertFromJson() throws Exception {
        JSONObject json = aJSONObject().withProperty(PROP_REFERENCES, getJsonArrayReferenceRepresentation()).build();
       
        ManagedObjectReferenceCollectionRepresentation representation = fromJson(json);

        assertThat(representation.getReferences().size()).isEqualTo(getListOfReferences().size());
    }
View Full Code Here

                .build();
        return representation;
    }

    protected ManagedObjectReferenceCollectionRepresentation getMinimalMORCR() {
        ManagedObjectReferenceCollectionRepresentation representation = new ManagedObjectReferenceCollectionRepresentation();
        representation.setSelf(SELF);
        return representation;
    }
View Full Code Here

        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

        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

        assertCollectionPaged(refCollection);
    }
   

    private void assertCollectionPaged(PagedCollectionResource refCollection) throws SDKException {
        ManagedObjectReferenceCollectionRepresentation firstPage = (ManagedObjectReferenceCollectionRepresentation)
                refCollection.get();
       
        assertThat(firstPage.getReferences().size()).isEqualTo(platform.getPageSize());
        assertThat(firstPage.getPageStatistics().getPageSize()).isEqualTo(platform.getPageSize());
        assertThat(firstPage.getPageStatistics().getCurrentPage()).isEqualTo(1);
        assertThat(firstPage.getSelf()).contains("pageSize=" + platform.getPageSize() + "&currentPage=1");
        assertThat(firstPage.getNext()).contains("pageSize=" + platform.getPageSize() + "&currentPage=2");
        assertThat(firstPage.getPrev()).isEmpty();

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

    public InventoryRepresentationBuilder(String baseUrl) {
        this.baseUrl = baseUrl;
    }
   
    public InventoryRepresentationBuilder withManagedObjects() {
        managedObjects = new ManagedObjectReferenceCollectionRepresentation();
        managedObjects.setSelf(baseUrl + "/managedObjects");
        return this;
    }
View Full Code Here

TOP

Related Classes of com.cumulocity.me.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.