Package com.cumulocity.me.rest.json

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


        .withSeverity(severity)
        .withActivity(activity)
        .withUser(user)
        .withChanges(new HashSet());
       
        JSONObject json = converter.toJson(representation.build());

        assertThat(json.toString()).isEqualTo("{\"user\":\"us\",\"severity\":\"sever\",\"application\":\"app\",\"changes\":[],\"activity\":\"activity\"}");
    }
View Full Code Here


        assertThat(json.toString()).isEqualTo("{\"user\":\"us\",\"severity\":\"sever\",\"application\":\"app\",\"changes\":[],\"activity\":\"activity\"}");
    }
   
    @Test
    public void shouldParseEmptyJson() throws Exception {
        Object parsed = converter.fromJson(new JSONObject("{}"));
       
        assertThat(parsed).isInstanceOf(AuditRecordRepresentation.class);
    }
View Full Code Here

        assertThat(parsed).isInstanceOf(AuditRecordRepresentation.class);
    }
   
    @Test
    public void shouldParseWithSimpleProps() throws Exception {
        JSONObject json = new JSONObject("{\"user\":\"us\",\"severity\":\"sever\",\"application\":\"app\",\"activity\":\"activity\"}");
       
        AuditRecordRepresentation parsed = (AuditRecordRepresentation) converter.fromJson(json);
       
        assertThat(parsed.getUser()).isEqualTo(user);
        assertThat(parsed.getSeverity()).isEqualTo(severity);
View Full Code Here

        assertThat(parsed.getChanges()).isNull();
    }
   
    @Test
    public void shouldParseWithChanges() throws Exception {
        JSONObject json = new JSONObject("{\"user\":\"us\",\"severity\":\"sever\",\"application\":\"app\",\"changes\":[],\"activity\":\"activity\"}");
       
        AuditRecordRepresentation parsed = (AuditRecordRepresentation) converter.fromJson(json);
       
        assertThat(parsed.getUser()).isEqualTo(user);
        assertThat(parsed.getSeverity()).isEqualTo(severity);
View Full Code Here

    }
   
    @Test
    public void shouldConvertToJson() throws Exception {
        ManagedObjectReferenceRepresentation representation = getSampleManagedObjectReferenceRepresentation();
        JSONObject expectedJSON = aJSONObject().withPropertyBuilder(PROP_MANAGED_OBJECT, getSampleJsonManagedObjectRepresentation()).build();
       
        JSONObject outputJSON = toJson(representation);
       
        assertThat(outputJSON.toString()).isEqualTo(expectedJSON.toString());
    }
View Full Code Here

        assertThat(outputJSON.toString()).isEqualTo(expectedJSON.toString());
    }
   
    @Test
    public void shouldConvertFromJson() throws Exception {
        JSONObject json = aJSONObject().withProperty(PROP_MANAGED_OBJECT, getSampleJsonManagedObjectRepresentation().build()).build();
       
        ManagedObjectReferenceRepresentation representation = fromJson(json);

        assertThat(representation.getManagedObject()).isNotNull();
    }
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).withCreationTime(time).withText(text);
       
        JSONObject json = converter.toJson(representation.build());
       
        assertThat(json.toString()).isEqualTo("{\"type\":\"some_type\",\"creationTime\":\"2001-01-01T00:00:01.0Z\",\"time\":\"2001-01-01T00:00:01.0Z\",\"text\":\"sample text\",\"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

    @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.