Package com.cumulocity.me.rest.json

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


    }

    @Test
    public void shouldConvertDateFromJson() throws Exception {
        String stringDate = DateUtils.format(lastUpdated);
        JSONObject json = minimalJsonManagedObjectRepresentation().withProperty(PROP_LAST_UPDATED, stringDate).build();

        ManagedObjectRepresentation representation = fromJson(json);

        assertThat(representation.getLastUpdated()).isEqualTo(lastUpdated);
    }
View Full Code Here


    @Test
    public void shouldConvertDateToJson() throws Exception {
        ManagedObjectRepresentation representation = minimalManagedObjectBuilder().withLastUpdated(lastUpdated).build();
        String stringDate = DateUtils.format(lastUpdated);
        JSONObject expectedJSON = minimalJsonManagedObjectRepresentation().withProperty(PROP_LAST_UPDATED, stringDate).build();

        JSONObject outputJSON = toJson(representation);
        System.out.println(outputJSON);
        System.out.println(expectedJSON);
        assertThat(outputJSON.toString()).isEqualTo(expectedJSON.toString());
    }
View Full Code Here

        ManagedObjectRepresentation representation = minimalManagedObjectBuilder()
                .withChildAssets(getMinimalMORCR())
                .withChildDevices(getMinimalMORCR())
                .withParents(getMinimalMORCR())
                .build();
        JSONObject expectedJSON = minimalJsonManagedObjectRepresentation()
                .withPropertyBuilder(PROP_CHILD_ASSETS, minimalJsonObjectReferenceRepresentation())
                .withPropertyBuilder(PROP_CHILD_DEVICES, minimalJsonObjectReferenceRepresentation())
                .withPropertyBuilder(PROP_PARENTS, minimalJsonObjectReferenceRepresentation()).build();

        JSONObject outputJSON = toJson(representation);
       
        assertThat(outputJSON.toString()).isEqualTo(expectedJSON.toString());
    }
View Full Code Here

    public JSONObject toJson(Object representation) {
        if (representation == null) {
            return null;
        }
        BaseResourceRepresentation baseRepresentation = (BaseResourceRepresentation) representation;
        JSONObject json = new JSONObject();
        basePropertiesToJson(baseRepresentation, json);
        instanceToJson(baseRepresentation, json);
        extraPropertiesToJson(baseRepresentation, json);
        return json;
    }
View Full Code Here

    protected Class supportedRepresentationType() {
        return PageStatisticsRepresentation.class;
    }

    public JSONObject toJson(Object representation) {
        JSONObject json = new JSONObject();
        putInt(json, PROP_TOTAL_PAGES, $(representation).getTotalPages());
        putInt(json, PROP_CURRENT_PAGE, $(representation).getCurrentPage());
        putInt(json, PROP_PAGE_SIZE, $(representation).getPageSize());
        return json;
    }
View Full Code Here

    private ResourceRepresentation getEntity(WebResponse response, Class entityType) {
        if (response.getData() == null || entityType == null) {
            return null;
        }
        JSONObject json = new JSONObject(getJsonSource(response));
        return (ResourceRepresentation) conversionService.fromJson(json, entityType);
    }
View Full Code Here

public class RelayConverter extends BaseRepresentationConverter {

    private static final String PROP_STATE = "state";
   
    public JSONObject toJson(Object representation) {
        JSONObject json = new JSONObject();
        Relay relayControl = (Relay) representation;
        putString(json, PROP_STATE, relayControl.getRelayState().name());
        return json;
    }
View Full Code Here

        return null;
    }

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

        return FragmentThree.class;
    }

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

        return Agent.class;
    }

    @Override
    public JSONObject toJson(Object representation) {
        return new JSONObject();
    }
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.