Package com.cumulocity.me.rest.representation.event

Examples of com.cumulocity.me.rest.representation.event.EventRepresentation


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


    @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\"}");
       
        EventRepresentation parsed = (EventRepresentation) converter.fromJson(json);
       
        assertThat(parsed.getId()).isEqualTo(id);
        assertThat(parsed.getSource()).isSameAs(source);
    }
View Full Code Here

    @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\"}");
       
        EventRepresentation parsed = (EventRepresentation) 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

   
    @Test
    public void shouldParseWithStringFragment() throws Exception {
        JSONObject json = new JSONObject("{\"test_fragment\":{\"type\":\"test\"},\"id\":\"testid\"}");
       
        EventRepresentation parsed = (EventRepresentation) converter.fromJson(json);
       
        assertThat(parsed.getId()).isEqualTo(id);
        assertThat(parsed.getAttrs().size()).isEqualTo(1);
        assertThat(parsed.get("test_fragment")).isEqualTo("{\"type\":\"test\"}");
    }
View Full Code Here

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

    @Given("I have '(\\d+)' Events of type '([^']*)' for the managed object$")
    public void iHaveEvents(int n, String type) {
        for (int i = 0; i < n; i++) {
            EventRepresentation rep = new EventRepresentation();
            rep.setType(type);
            rep.setTime(new Date());
            rep.setText(" Event of Managed Object : " + i);
            rep.setSource(managedObject);
            input.add(rep);
        }
    }
View Full Code Here

    }

    @Given("I have '(\\d+)' Events with type '([^']*)' for the managed object$")
    public void iHaveEventsWithFragments(int n, String type) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        for (int i = 0; i < n; i++) {
            EventRepresentation rep = new EventRepresentation();
            rep.setType(type);
            rep.setTime(new Date());
            rep.setText(" Event of Managed Object : " + i);
            rep.setSource(managedObject);
            input.add(rep);
        }
    }
View Full Code Here

        }
    }

    @Given("I have a Event with no type value for the managed object$")
    public void iHaveAEventWithNoType() {
        EventRepresentation rep = new EventRepresentation();
        rep.setTime(new Date());
        rep.setText(" Event of Managed Object : " + 0);
        rep.setSource(managedObject);
        input.add(rep);
    }
View Full Code Here

        input.add(rep);
    }

    @Given("I have a Event with no text value for the managed object$")
    public void iHaveAEventWithNoText() {
        EventRepresentation rep = new EventRepresentation();
        rep.setType("type");
        rep.setTime(new Date());
        rep.setSource(managedObject);
        input.add(rep);
    }
View Full Code Here

        input.add(rep);
    }

    @Given("I have a Event with no time value for the managed object$")
    public void iHaveAEventWithNoTime() {
        EventRepresentation rep = new EventRepresentation();
        rep.setType("type");
        rep.setText(" Event of Managed Object : " + 1);
        rep.setSource(managedObject);
        input.add(rep);
    }
View Full Code Here

    }

    @Given("I have '(\\d+)' Events for the source '(\\d+)' the managed object$")
    public void iHaveEventsForSource(int n, int index) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        for (int i = 0; i < n; i++) {
            EventRepresentation rep = new EventRepresentation();
            rep.setType("type");
            rep.setTime(new Date());
            rep.setText(" Event of Managed Object : " + i);
            rep.setSource(managedObject);
            input.add(rep);
        }
    }
View Full Code Here

TOP

Related Classes of com.cumulocity.me.rest.representation.event.EventRepresentation

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.