Examples of BaseResourceRepresentation


Examples of com.cumulocity.me.rest.representation.BaseResourceRepresentation

   
    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

Examples of com.cumulocity.me.rest.representation.BaseResourceRepresentation

   
    public Object fromJson(JSONObject json) {
        if (json == null) {
            return null;
        }
        BaseResourceRepresentation representation = newRepresentation();
        basePropertiesFromJson(json, representation);
        instanceFromJson(json, representation);
        extraPropertiesFromJson(json, representation);
        return representation;
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.BaseResourceRepresentation

    public void shouldRetrieveResource() throws Exception {
        // Given
        when(webResource.accept(mediaType)).thenReturn(typeBuilder);
        when(typeBuilder.get(ClientResponse.class)).thenReturn(response);

        BaseResourceRepresentation representation = new BaseResourceRepresentation();
        when(parser.parse(response, 200, BaseResourceRepresentation.class)).thenReturn(representation);

        // When
        BaseResourceRepresentation result = restConnector.get(PATH, mediaType,
                BaseResourceRepresentation.class);

        // Then
        assertThat(result, sameInstance(representation));
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.BaseResourceRepresentation

    }

    @Test
    public void shouldPostBaseRepresentation() throws Exception {
        // Given
        BaseResourceRepresentation representation = new BaseResourceRepresentation();
        returnResponseWhenPosting(representation);
        BaseResourceRepresentation outputRepresentation = new BaseResourceRepresentation();
        when(parser.parse(response, 201, BaseResourceRepresentation.class)).thenReturn(outputRepresentation);

        // When
        BaseResourceRepresentation result = restConnector.post(PATH, mediaType, representation);

        // Then
        assertThat(result, sameInstance(outputRepresentation));
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.BaseResourceRepresentation

    }

    @Test
    public void shouldPutBaseRepresentation() throws Exception {
        // Given
        BaseResourceRepresentation representation = new BaseResourceRepresentation();
        BaseResourceRepresentation outputRepresentation = new BaseResourceRepresentation();
        returnResponseWhenPut(representation);
        when(parser.parse(response, 200, BaseResourceRepresentation.class)).thenReturn(outputRepresentation);

        // When
        BaseResourceRepresentation result = restConnector.put(PATH, mediaType, representation);

        // Then
        assertThat(result, sameInstance(outputRepresentation));
    }
View Full Code Here

Examples of com.cumulocity.rest.representation.BaseResourceRepresentation

    @Test
    public void shouldParse() throws Exception {
        // Given
        when(response.getStatus()).thenReturn(EXPECTED_STATUS);
        BaseResourceRepresentation representation = new BaseResourceRepresentation();
        when(response.getEntity(BaseResourceRepresentation.class)).thenReturn(representation);

        // When
        BaseResourceRepresentation result = parser.parse(response, EXPECTED_STATUS,
                BaseResourceRepresentation.class);

        // Then
        assertThat(result, sameInstance(representation));
    }
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.