Examples of MeasurementRepresentation


Examples of com.cumulocity.me.rest.representation.measurement.MeasurementRepresentation

    @Test
    public void shouldParseWithFragment() throws Exception {
        when(conversionService.fromJson(jsonObject("{\"type\":\"test\"}"), same(TestFragment.class))).thenReturn(fragment);
        JSONObject json = new JSONObject("{\"com_cumulocity_me_rest_convert_TestFragment\":{\"type\":\"test\"},\"id\":\"testid\"}");
       
        MeasurementRepresentation parsed = (MeasurementRepresentation) converter.fromJson(json);
       
        assertThat(parsed.getId()).isEqualTo(id);
        assertThat(parsed.getAttrs().size()).isEqualTo(1);
        assertThat(parsed.get(TestFragment.class)).isSameAs(fragment);
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.measurement.MeasurementRepresentation

    @Test
    public void getMeasurementCollectionByDefaultPageSettings() throws Exception {
        // Given
        for (int i = 0; i < 12; i++) {
            MeasurementRepresentation rep = aSampleMeasurement(managedObjects.get(0));
            measurementApi.create(rep);
        }

        // When
        MeasurementCollectionRepresentation measurements = measurementApi.getMeasurements().get();
View Full Code Here

Examples of com.cumulocity.rest.representation.measurement.MeasurementRepresentation

        // Then
        assertThat(page4th.getMeasurements().size(), is(equalTo(0)));
    }

    private MeasurementRepresentation aSampleMeasurement(ManagedObjectRepresentation source) {
        MeasurementRepresentation rep = new MeasurementRepresentation();
        rep.setTime(new Date());
        rep.setType("com.type1");
        rep.setSource(source);

        rep.set(new FragmentOne());
        return rep;
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.measurement.MeasurementRepresentation

    // ------------------------------------------------------------------------

    @Given("I have '(\\d+)' measurements of type '([^']*)' for the managed object")
    public void iHaveMeasurements(int n, String type) {
        for (int i = 0; i < n; i++) {
            MeasurementRepresentation rep = new MeasurementRepresentation();
            rep.setType(type);
            rep.setTime(new Date());
            rep.setSource(managedObjects.get(0));
            input.add(rep);
        }
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.measurement.MeasurementRepresentation

    @Given("I have '(\\d+)' measurements with fragment type '([^']*)' for the managed object")
    public void iHaveMeasurementsWithFragments(int n, String fragmentType)
            throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        for (int i = 0; i < n; i++) {
            MeasurementRepresentation rep = new MeasurementRepresentation();
            rep.setTime(new Date());
            rep.setType("com.type1");
            rep.setSource(managedObjects.get(0));

            // Set fragment
            Class<?> cls = Class.forName(fragmentType);
            Object fragment = cls.newInstance();
            rep.set(fragment);

            input.add(rep);
        }
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.measurement.MeasurementRepresentation

    }

    @Given("I have '(\\d+)' measurements for the source '(\\d+)' the managed object")
    public void iHaveMeasurementsForSource(int n, int index) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        for (int i = 0; i < n; i++) {
            MeasurementRepresentation rep = new MeasurementRepresentation();
            rep.setTime(new Date());
            rep.setType("com.type1");
            rep.setSource(managedObjects.get(index));
            input.add(rep);
        }
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.measurement.MeasurementRepresentation

        }
    }

    @Given("I have a measurement of type '([^']*)' and no time value for the managed object")
    public void iHaveAMeasurementWithNoTime(String type) {
        MeasurementRepresentation rep = new MeasurementRepresentation();
        rep.setType(type);
        rep.setSource(managedObjects.get(0));
        input.add(rep);
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.measurement.MeasurementRepresentation

    }

    @Given("I have a measurement with time '([^']*)' with fragment type '([^']*)' and for '(\\d+)' managed object")
    public void iHaveAMeasurementWithTypeAndTime(String time, String fragmentType, int index)
            throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        MeasurementRepresentation rep = new MeasurementRepresentation();
        rep.setType("com.type1");
        rep.setTime(DateConverter.string2Date(time));
        rep.setSource(managedObjects.get(index));

        // Set fragment
        Class<?> cls = Class.forName(fragmentType);
        Object fragment = cls.newInstance();
        rep.set(fragment);

        input.add(rep);
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.measurement.MeasurementRepresentation

        for (MeasurementRepresentation rep : result1) {
            map.put(rep.getId(), rep);
        }

        for (MeasurementRepresentation rep : collection1.getMeasurements()) {
            MeasurementRepresentation orig = map.get(rep.getId());
            assertThat(orig, is(notNullValue()));
        }
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.measurement.MeasurementRepresentation

    public void shouldReturnMeasurementRep() throws SDKException {
        // Given
        String gidValue = "123";
        GId gid = new GId(gidValue);

        MeasurementRepresentation meas = new MeasurementRepresentation();
        when(
                restConnector.get(MEASUREMENT_COLLECTION_URL + "/" + gidValue, MeasurementMediaType.MEASUREMENT,
                        MeasurementRepresentation.class)).thenReturn(meas);

        //when
        MeasurementRepresentation result = measurementApi.getMeasurement(gid);

        //then
        assertThat(result, sameInstance(meas));
    }
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.