Package com.cumulocity.me.rest.json

Examples of com.cumulocity.me.rest.json.JSONObject


    @Test
    public void shouldFormatWithFragments() throws Exception {
        when(conversionService.toJson(fragment)).thenReturn(aJSONObject().withProperty("type", "test").build());
        representation.withID(id).with(fragment);
       
        JSONObject json = converter.toJson(representation.build());
       
        assertThat(json.toString()).isEqualTo("{\"com_cumulocity_me_rest_convert_TestFragment\":{\"type\":\"test\"},\"id\":\"testid\"}");
    }
View Full Code Here


        assertThat(json.toString()).isEqualTo("{\"com_cumulocity_me_rest_convert_TestFragment\":{\"type\":\"test\"},\"id\":\"testid\"}");
    }
   
    @Test
    public void shouldParseEmptyJson() throws Exception {
        Object parsed = converter.fromJson(new JSONObject("{}"));
       
        assertThat(parsed).isInstanceOf(MeasurementRepresentation.class);
    }
View Full Code Here

        assertThat(parsed).isInstanceOf(MeasurementRepresentation.class);
    }
   
    @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);
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\"}");
       
        MeasurementRepresentation parsed = (MeasurementRepresentation) 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\"}");
       
        MeasurementRepresentation parsed = (MeasurementRepresentation) converter.fromJson(json);
       
        assertThat(parsed.getId()).isEqualTo(id);
        assertThat(parsed.getAttrs().size()).isEqualTo(1);
View Full Code Here

        converter.setJsonConversionService(conversionService);
    }
   
    @Test
    public void shouldFormatEmptyRepresentation() throws Exception {
        JSONObject json = converter.toJson(representation.build());
       
        assertThat(json.toString()).isEqualTo("{}");
    }
View Full Code Here

   
    @Test
    public void shouldFormatWithSimpleProps() throws Exception {
        representation.withID(id).withDeviceId(deviceId).withFailureReason(failureReason).withStatus(status).withCreationTime(creationTime);
       
        JSONObject json = converter.toJson(representation.build());
       
        assertThat(json.toString()).isEqualTo("{\"status\":\"some_status\",\"creationTime\":\"2001-01-01T00:00:01.0Z\",\"deviceId\":\"deviceId\",\"failureReason\":\"some_failure_reason\",\"id\":\"testid\"}");
    }
View Full Code Here

        assertThat(json.toString()).isEqualTo("{\"status\":\"some_status\",\"creationTime\":\"2001-01-01T00:00:01.0Z\",\"deviceId\":\"deviceId\",\"failureReason\":\"some_failure_reason\",\"id\":\"testid\"}");
    }
   
    @Test
    public void shouldParseEmptyJson() throws Exception {
        Object parsed = converter.fromJson(new JSONObject("{}"));
       
        assertThat(parsed).isInstanceOf(OperationRepresentation.class);
    }
View Full Code Here

        assertThat(parsed).isInstanceOf(OperationRepresentation.class);
    }
   
    @Test
    public void shouldParseWithSimpleProps() throws Exception {
        JSONObject json = new JSONObject("{\"creationTime\":\"2001-01-01T00:00:01.0Z\",\"status\":\"some_status\",\"deviceId\":\"deviceId\",\"failureReason\":\"some_failure_reason\",\"id\":\"testid\"}");
       
        OperationRepresentation parsed = (OperationRepresentation) converter.fromJson(json);
       
        assertThat(parsed.getId()).isEqualTo(id);
        assertThat(parsed.getDeviceId()).isEqualTo(deviceId);
View Full Code Here

    @Test
    public void shouldFormatWithFragments() throws Exception {
        when(conversionService.toJson(fragment)).thenReturn(aJSONObject().withProperty("type", "test").build());
        representation.withID(id).with(fragment);
       
        JSONObject json = converter.toJson(representation.build());
       
        assertThat(json.toString()).isEqualTo("{\"com_cumulocity_me_rest_convert_TestFragment\":{\"type\":\"test\"},\"id\":\"testid\"}");
    }
View Full Code Here

TOP

Related Classes of com.cumulocity.me.rest.json.JSONObject

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.