Package com.cumulocity.me.rest.json

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


        return SecondFragment.class;
    }

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


        converter.setJsonConversionService(conversionService);
    }
   
    @Test
    public void shouldParseEmptyJson() throws Exception {
        Object parsed = converter.fromJson(new JSONObject("{}"));
       
        assertThat(parsed).isInstanceOf(IdentityRepresentation.class);
    }
View Full Code Here

        assertThat(parsed).isInstanceOf(IdentityRepresentation.class);
    }
   
    @Test
    public void shouldParseWithSimpleProps() throws Exception {
        JSONObject json = new JSONObject("{\"externalId\":\"some_id\",\"externalIdsOfGlobalId\":\"externalIdsOfGlobalId\"}");
       
        IdentityRepresentation parsed = (IdentityRepresentation) converter.fromJson(json);
       
        assertThat(parsed.getExternalId()).isEqualTo(externalId);
        assertThat(parsed.getExternalIdsOfGlobalId()).isEqualTo(externalIdsOfGlobalId);
View Full Code Here

        converter.setJsonConversionService(conversionService);
    }
   
    @Test
    public void shouldFormatEmptyRepresentation() throws Exception {
        JSONObject json = converter.toJson(new ExternalIDCollectionRepresentation());
       
        assertThat(json.toString()).isEqualTo("{\"externalIds\":[]}");
    }
View Full Code Here

        assertThat(json.toString()).isEqualTo("{\"externalIds\":[]}");
    }
   
    @Test
    public void shouldParseEmptyJson() throws Exception {
        Object parsed = converter.fromJson(new JSONObject("{}"));
       
        assertThat(parsed).isInstanceOf(ExternalIDCollectionRepresentation.class);
    }
View Full Code Here

    @Test
    public void shouldFormatWithExternalId() throws Exception {
        when(conversionService.toJson(externalId)).thenReturn(aJSONObject().withProperty("externalId","some_id").withProperty("type", "some_type").build());
        representation.getExternalIds().add(externalId);
       
        JSONObject json = converter.toJson(representation);
       
        assertThat(json.toString()).isEqualTo("{\"externalIds\":[{\"externalId\":\"some_id\",\"type\":\"some_type\"}]}");
    }
View Full Code Here

    }
   
    @Test
    public void shouldParseWithExternalId() throws Exception {
        when(conversionService.fromJson(jsonObject("{\"externalId\":\"some_id\",\"type\":\"some_type\"}"), same(ExternalIDRepresentation.class))).thenReturn(externalId);
        JSONObject json = new JSONObject("{\"externalIds\":[{\"externalId\":\"some_id\",\"type\":\"some_type\"}]}");
       
        ExternalIDCollectionRepresentation parsed = (ExternalIDCollectionRepresentation) converter.fromJson(json);
       
        assertThat(parsed.getExternalIds().size()).isEqualTo(1);
        assertThat(parsed.getExternalIds().get(0)).isSameAs(externalId);
View Full Code Here

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

   
    @Test
    public void shouldFormatExternalIDRepresentationWithSimpleProps() throws Exception {
        representation.withExternalId(externalId).withType(type);
       
        JSONObject json = converter.toJson(representation.build());
       
        assertThat(json.toString()).isEqualTo("{\"externalId\":\"some_id\",\"type\":\"some_type\"}");
    }
View Full Code Here

        assertThat(json.toString()).isEqualTo("{\"externalId\":\"some_id\",\"type\":\"some_type\"}");
    }
   
    @Test
    public void shouldParseEmptyJson() throws Exception {
        Object parsed = converter.fromJson(new JSONObject("{}"));
       
        assertThat(parsed).isInstanceOf(ExternalIDRepresentation.class);
    }
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.