Package com.cumulocity.me.rest.json

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


        return FragmentOne.class;
    }

    @Override
    public JSONObject toJson(Object representation) {
        return new JSONObject();
    }
View Full Code Here


        return ThreePhaseElectricitySensor.class;
    }

    @Override
    public JSONObject toJson(Object representation) {
        return new JSONObject();
    }
View Full Code Here

        return FragmentTwo.class;
    }

    @Override
    public JSONObject toJson(Object representation) {
        return new JSONObject();
    }
View Full Code Here

        return Coordinate.class;
    }

    @Override
    public JSONObject toJson(Object object) {
        JSONObject json = new JSONObject();
        Coordinate representation = (Coordinate) object;
        putDoubleObj(json, PROP_LONGITUDE, representation.getLongitude());
        putDoubleObj(json, PROP_LATITUDE, representation.getLatitude());
        return json;
    }
View Full Code Here

    protected void putObject(JSONObject json, String key, Object representation) {
        if (representation instanceof String) {
            String representationString = (String) representation;
            if (representationString.startsWith("{") && representationString.endsWith("}")) {
                json.putOpt(key, new JSONObject(representationString));
            } else {
                json.putOpt(key, representationString);
            }
        } else {
            json.putOpt(key, getConversionService().toJson(representation));
View Full Code Here

        return this;
    }
   
    @Override
    protected JSONObject createDomainObject() {
        return new JSONObject();
    }
View Full Code Here

    private static final String PROP_TYPE = "type";
    private static final String PROP_PREVIOUS_VALUE = "previousValue";
    private static final String PROP_NEW_VALUE = "newValue";
   
    public JSONObject toJson(Object representation) {
        JSONObject json = new JSONObject();
        json.putOpt(PROP_ATTRIBUTE, ((Change)representation).getAttribute());
        json.putOpt(PROP_TYPE, ((Change)representation).getType());
        json.putOpt(PROP_PREVIOUS_VALUE, (getConversionService().toJson(((Change)representation).getPreviousValue())));
        json.putOpt(PROP_NEW_VALUE, (getConversionService().toJson(((Change)representation).getNewValue())));
        return json;
    }
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).withType(type).withTime(time);
       
        JSONObject json = converter.toJson(representation.build());
       
        assertThat(json.toString()).isEqualTo("{\"type\":\"some_type\",\"time\":\"2001-01-01T00:00:01.0Z\",\"id\":\"testid\"}");
    }
View Full Code Here

    @Test
    public void shouldFormatWithComplexProps() throws Exception {
        when(conversionService.toJson(source)).thenReturn(aJSONObject().withProperty("id", "src_id").build());
        representation.withID(id).withSource(source);
       
        JSONObject json = converter.toJson(representation.build());
       
        assertThat(json.toString()).isEqualTo("{\"source\":{\"id\":\"src_id\"},\"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.