Package com.cumulocity.rest.representation.inventory

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


    @Test
    public void createManagedObjectWithCoordinateFragment() throws Exception {
        // Given
        Coordinate coordinate = new Coordinate(100.0, 10.0);
        ManagedObjectRepresentation rep = aSampleMo().with(coordinate).build();

        // When
        ManagedObjectRepresentation result = inventory.create(rep);

        // Then
        assertThat(result.getId(), not(nullValue()));
        Coordinate fragment = result.get(Coordinate.class);
        assertThat(fragment, is(coordinate));
    }
View Full Code Here


    }

    @Test
    public void createManagedObjectWithThreePhaseElectricitySensor() throws Exception {
        // Given
        ManagedObjectRepresentation rep = aSampleMo().with(new ThreePhaseElectricitySensor()).build();

        // When
        ManagedObjectRepresentation result = inventory.create(rep);

        // Then
        assertNotNull(result.getId());
        assertNotNull(result.get(ThreePhaseElectricitySensor.class));
    }
View Full Code Here

    }

    @Test
    public void createManagedObjectWith2ThreePhaseElectricityFragments() throws Exception {
        // Given
        ManagedObjectRepresentation rep = aSampleMo().with(new ThreePhaseElectricitySensor()).with(
                new ThreePhaseElectricitySensor()).build();

        // When
        ManagedObjectRepresentation result = inventory.create(rep);

        // Then
        assertNotNull(result.getId());
        assertNotNull(result.get(ThreePhaseElectricitySensor.class));
    }
View Full Code Here

    }

    @Test
    public void createAndGetManagedObject() throws Exception {
        // Given
        ManagedObjectRepresentation rep = aSampleMo().build();
        ManagedObjectRepresentation created = inventory.create(rep);

        // When
        ManagedObjectRepresentation result = inventory.getManagedObject(created.getId()).get();

        // Then
        assertEquals(result.getId(), created.getId());
        assertEquals(result.getName(), created.getName());
        assertEquals(result.getType(), created.getType());
    }
View Full Code Here

    }

    @Test
    public void createAndDeleteManagedObject() throws Exception {
        // Given
        ManagedObjectRepresentation rep = aSampleMo().build();
        ManagedObjectRepresentation result = inventory.create(rep);

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

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

    }

    @Test
    public void createAndUpdateManagedObject() throws Exception {
        // Given
        ManagedObjectRepresentation rep = aSampleMo().build();
        ManagedObjectRepresentation result = inventory.create(rep);

        // When
        Coordinate coordinate = new Coordinate(100.0, 10.0);
        result.set(coordinate);

        GId id = result.getId();
        result.setId(null);
        result.setLastUpdated(null);

        ManagedObjectRepresentation updated = inventory.getManagedObject(id).update(result);

        //Then
        assertNotNull(updated.getId());
        assertEquals(coordinate, updated.get(Coordinate.class));
    }
View Full Code Here

    }

    @Test
    public void createAndUpdateManagedObjectByRemovingFragment() throws Exception {
        // Given
        ManagedObjectRepresentation rep = aSampleMo().with(new Coordinate()).build();
        ManagedObjectRepresentation created = inventory.create(rep);

        // When
        created.set(null, Coordinate.class);
        GId id = created.getId();
        created.setId(null);
        created.setLastUpdated(null);
        ManagedObjectRepresentation updated = inventory.getManagedObject(id).update(created);

        // Then
        assertNotNull(updated.getId());
        assertNull(updated.get(Coordinate.class));
    }
View Full Code Here

    }

    @Test
    public void tryToGetNonExistentManagedObject() throws Exception {
        // Given
        ManagedObjectRepresentation rep = aSampleMo().withID(new GId("1")).build();

        // Then
        exception.expect(sdkException(NOT_FOUND));

        // When
        inventory.getManagedObject(rep.getId()).get();
    }
View Full Code Here

    }

    @Test
    public void tryToDeleteNonExistentManagedObject() throws Exception {
        // Given
        ManagedObjectRepresentation rep = aSampleMo().withID(new GId("1")).build();

        // Then
        exception.expect(sdkException(NOT_FOUND));

        // When
        inventory.getManagedObject(rep.getId()).delete();
    }
View Full Code Here

    }

    @Test
    public void tryToUpdateNonExistentManagedObject() throws Exception {
        // Given
        ManagedObjectRepresentation rep = aSampleMo().build();

        // Then
        exception.expect(sdkException(NOT_FOUND));

        // When
View Full Code Here

TOP

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

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.