Examples of ManagedObjectReferenceCollectionRepresentation


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

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

        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

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

   
    @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

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

                .build();
        return representation;
    }

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

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

        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

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

        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

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

        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

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

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

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

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

    @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
TOP
Copyright © 2018 www.massapi.com. 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.