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

Examples of com.cumulocity.me.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 = (EventCollectionRepresentation) eventApi.getEventsByFilter(filter).get();
        } catch (SDKException ex) {
            status = ex.getHttpStatus();
        }
View Full Code Here


    }

    @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 = (EventCollectionRepresentation) eventApi.getEventsByFilter(filter).get();
        } catch (SDKException ex) {
            status = ex.getHttpStatus();
        }
View Full Code Here

    @Test
  public void shouldCreateManagedObject() throws Exception {
    when(restConnector.post(inventoryRepresentation.getManagedObjects().getSelf(), MANAGED_OBJECT, inputMo))
        .thenReturn(outputMo);
     
      ManagedObjectRepresentation result = inventoryApi.create(inputMo);
   
    assertThat(result).isSameAs(outputMo);
  }
View Full Code Here

    }

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

        // Then
        assertThat(created).isNotNull();
        assertThat(created.getId()).isNotNull();
        assertThat(created.getSelf()).isNotNull();
        assertThat(created).isNotSameAs(rep);
    }
View Full Code Here

    @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()).isNotNull();
        Coordinate fragment = (Coordinate) result.get(Coordinate.class);
        assertThat(fragment).isEqualTo(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
        assertThat(result.getId()).isNotNull();
        assertThat(result.get(ThreePhaseElectricitySensor.class)).isNotNull();
    }
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
        assertThat(result.getId()).isNotNull();
        assertThat(result.get(ThreePhaseElectricitySensor.class)).isNotNull();
    }
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
        assertThat(result.getId()).isEqualTo(created.getId());
        assertThat(result.getName()).isEqualTo(created.getName());
        assertThat(result.getType()).isEqualTo(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(HTTP_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
        assertThat(updated.getId()).isNotNull();
        assertThat(coordinate).isEqualTo(updated.get(Coordinate.class));
    }
View Full Code Here

TOP

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