Examples of MeasurementRepresentation


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

    }

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

        MeasurementCollectionRepresentation measurements = (MeasurementCollectionRepresentation) measurementApi.getMeasurements().get();
        MeasurementCollectionRepresentation page1st = (MeasurementCollectionRepresentation) measurementApi.getMeasurements().getPage(
View Full Code Here

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

        assertThat(page3rd.getMeasurements().size(), is(equalTo(2)));
        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.me.rest.representation.measurement.MeasurementRepresentation

    private int status;

    @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((ManagedObjectRepresentation) managedObjects.get(0));
            input.add(rep);
        }
    }
View Full Code Here

Examples of com.cumulocity.me.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((ManagedObjectRepresentation) 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.me.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((ManagedObjectRepresentation) managedObjects.get(index));
            input.add(rep);
        }
    }
View Full Code Here

Examples of com.cumulocity.me.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((ManagedObjectRepresentation) managedObjects.get(0));
        input.add(rep);
    }
View Full Code Here

Examples of com.cumulocity.me.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((ManagedObjectRepresentation) 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.me.rest.representation.measurement.MeasurementRepresentation

            map.put(rep.getId(), rep);
        }

        Iterator iterator = collection1.getMeasurements().iterator();
        while (iterator.hasNext()) {
            MeasurementRepresentation orig = (MeasurementRepresentation) map.get(((MeasurementRepresentation) iterator.next()).getId());
            assertThat(orig, is(notNullValue()));
        }
    }
View Full Code Here

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

   
    @Test
    public void shouldParseWithSimpleProps() throws Exception {
        JSONObject json = new JSONObject("{\"type\":\"some_type\",\"time\":\"2001-01-01T00:00:01.0Z\",\"id\":\"testid\"}");
       
        MeasurementRepresentation parsed = (MeasurementRepresentation) converter.fromJson(json);
       
        assertThat(parsed.getId()).isEqualTo(id);
        assertThat(parsed.getType()).isEqualTo(type);
        assertThat(parsed.getTime()).isEqualTo(time);
    }
View Full Code Here

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

    @Test
    public void shouldParseWithComplexProps() throws Exception {
        when(conversionService.fromJson(jsonObject("{\"id\":\"src_id\"}"), same(ManagedObjectRepresentation.class))).thenReturn(source);
        JSONObject json = new JSONObject("{\"source\":{\"id\":\"src_id\"},\"id\":\"testid\"}");
       
        MeasurementRepresentation parsed = (MeasurementRepresentation) converter.fromJson(json);
       
        assertThat(parsed.getId()).isEqualTo(id);
        assertThat(parsed.getSource()).isSameAs(source);
    }
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.