Package com.cumulocity.me.rest.json

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


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


    @Test
    public void shouldFormatWithComplexProps() throws Exception {
        when(conversionService.toJson(managedObject)).thenReturn(aJSONObject().withProperty("id", "src_id").build());
        representation.withExternalId(externalId).withType(type).withManagedObject(managedObject);
       
        JSONObject json = converter.toJson(representation.build());
       
        assertThat(json.toString()).isEqualTo("{\"externalId\":\"some_id\",\"managedObject\":{\"id\":\"src_id\"},\"type\":\"some_type\"}");
    }
View Full Code Here

    }
   
    @Test
    public void shouldParseWithComplexProps() throws Exception {
        when(conversionService.fromJson(jsonObject("{\"id\":\"src_id\"}"), same(ManagedObjectRepresentation.class))).thenReturn(managedObject);
        JSONObject json = new JSONObject("{\"externalId\":\"some_id\",\"managedObject\":{\"id\":\"src_id\"},\"type\":\"some_type\"}");
       
        ExternalIDRepresentation parsed = (ExternalIDRepresentation) converter.fromJson(json);
       
        assertThat(parsed.getExternalId()).isEqualTo(externalId);
        assertThat(parsed.getType()).isEqualTo(type);
View Full Code Here

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

        assertThat(parsed).isInstanceOf(AuditRecordsRepresentation.class);
    }
   
    @Test
    public void shouldParseWithSimpleProps() throws Exception {
        JSONObject json = new JSONObject("{\"auditRecordsForUserAndType\":\"for_user_type\",\"auditRecordsForUserAndApplication\":\"for_user_app\",\"auditRecordsForType\":\"for_type\",\"auditRecordsForTypeAndUserAndApplication\":\"for_type_user_app\",\"auditRecordsForTypeAndApplication\":\"for_type_app\",\"auditRecordsForApplication\":\"for_app\",\"auditRecordsForUser\":\"for_user\"}");
       
        AuditRecordsRepresentation parsed = (AuditRecordsRepresentation) converter.fromJson(json);
       
        assertThat(parsed.getAuditRecordsForApplication()).isEqualTo(auditRecordsForApplication);
        assertThat(parsed.getAuditRecordsForType()).isEqualTo(auditRecordsForType);
View Full Code Here

    ManagedObjectReferenceCollectionRepresentationConverter converter = new ManagedObjectReferenceCollectionRepresentationConverter();
   
    @Test
    public void shouldConvertToEmptyReferencesJson() throws Exception {
        JSONObject expectedJSON = aJSONObject().withProperty(PROP_REFERENCES, aJSONArray().build()).build();

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

   
    @Test
    public void shouldConvertToJson() throws Exception {
        ManagedObjectReferenceCollectionRepresentation representation = new ManagedObjectReferenceCollectionRepresentation();
        representation.setReferences(getListOfReferences());
        JSONObject expectedJSON = aJSONObject().withProperty(PROP_REFERENCES, getJsonArrayReferenceRepresentation()).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_REFERENCES, getJsonArrayReferenceRepresentation()).build();
       
        ManagedObjectReferenceCollectionRepresentation representation = fromJson(json);

        assertThat(representation.getReferences().size()).isEqualTo(getListOfReferences().size());
    }
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

        .withApplication(application)
        .withSeverity(severity)
        .withActivity(activity)
        .withUser(user);
       
        JSONObject json = converter.toJson(representation.build());

        assertThat(json.toString()).isEqualTo("{\"user\":\"us\",\"severity\":\"sever\",\"application\":\"app\",\"activity\":\"activity\"}");
    }
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.