Examples of ManagedObjectRepresentation


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

    }

    @Test
    public void testGet() throws Exception {
        //when
        ManagedObjectRepresentation mor = managedObject.get();

        // then
        assertThat(mor, sameInstance(managedObjectRep));
    }
View Full Code Here

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

    }

    @Test
    public void testUpdate() throws SDKException {
        //Given
        ManagedObjectRepresentation mo = new ManagedObjectRepresentation();
        ManagedObjectRepresentation updated = new ManagedObjectRepresentation();
        when(restConnector.put(MANAGED_OBJECT_URL, InventoryMediaType.MANAGED_OBJECT, mo)).thenReturn(updated);

        // when
        ManagedObjectRepresentation result = managedObject.update(mo);

        // then
        assertThat(result, sameInstance(updated));

    }
View Full Code Here

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

        // then
        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

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

    private static ManagedObjectRepresentation managedObject;

    @BeforeClass
    public static void createManagedObject() throws Exception {
        ManagedObjectRepresentation mo = new ManagedObjectRepresentation();
        mo.setName("MO");

        managedObject = platform.getInventoryApi().create(mo);
    }
View Full Code Here

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

    }

    @Test
    public void getAllWhen2ManagedObjectArePresent() throws Exception {
        // Given
        ManagedObjectRepresentation rep1 = aSampleMo().withName("MO1").build();
        ManagedObjectRepresentation rep2 = aSampleMo().withName("MO2").build();

        // When
        inventory.create(rep1);
        inventory.create(rep2);
View Full Code Here

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

    }

    @When("I query all Events by source '(\\d+)'$")
    public void iQueryAllBySource(int index) throws SDKException {
        try {
            ManagedObjectRepresentation mo = managedObject;
            EventFilter filter = new EventFilter().bySource(mo);
            collection = eventApi.getEventsByFilter(filter).get();
        } catch (SDKException ex) {
            status = ex.getHttpStatus();
        }
View Full Code Here

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

    }

    @Test
    public void addGetAndRemoveChildDevices() throws Exception {
        // 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);
        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

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

    }

    @When("I query all Events by source '(\\d+)' and type '([^']*)'$")
    public void iQueryAllBySourceAndType(int index, String type) throws SDKException, ClassNotFoundException {
        try {
            ManagedObjectRepresentation mo = managedObject;
            EventFilter filter = new EventFilter().bySource(mo).byType(type);
            collection = eventApi.getEventsByFilter(filter).get();
        } catch (SDKException ex) {
            status = ex.getHttpStatus();
        }
View Full Code Here

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

    }
   
    @When("I query all Events by source '(\\d+)' and time '([^']*)'$")
    public void iQueryAllBySourceAndTime(int index, String time) throws SDKException, ClassNotFoundException {
        try {
            ManagedObjectRepresentation mo = managedObject;
            EventFilter filter = new EventFilter().byDate(DateConverter.string2Date(time), DateConverter.string2Date(time));
            collection = eventApi.getEventsByFilter(filter).get();
        } catch (SDKException ex) {
            status = ex.getHttpStatus();
        }
View Full Code Here

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

    }

    @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);
        }
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.