use of com.microsoft.appcenter.ingestion.models.properties.LongTypedProperty in project mobile-center-sdk-android by Microsoft.
the class CommonSchemaDataUtilsAndroidTest method longTypedProperty.
@Test
public void longTypedProperty() throws JSONException {
MockCommonSchemaLog log = new MockCommonSchemaLog();
List<TypedProperty> properties = new ArrayList<>();
LongTypedProperty property = new LongTypedProperty();
property.setName("a");
property.setValue(10000000000L);
properties.add(property);
CommonSchemaDataUtils.addCommonSchemaData(properties, log);
assertEquals(1, log.getData().getProperties().length());
assertEquals(10000000000L, log.getData().getProperties().getLong("a"));
/* Check metadata. */
JSONObject expectedMetadata = new JSONObject();
JSONObject a = new JSONObject();
a.put("a", DATA_TYPE_INT64);
expectedMetadata.put(METADATA_FIELDS, a);
assertNotNull(log.getExt());
assertNotNull(log.getExt().getMetadata());
assertEquals(expectedMetadata.toString(), log.getExt().getMetadata().getMetadata().toString());
}
use of com.microsoft.appcenter.ingestion.models.properties.LongTypedProperty in project mobile-center-sdk-android by Microsoft.
the class CommonSchemaDataUtilsAndroidTest method invalidBaseType.
@Test
public void invalidBaseType() {
/* When using invalid base type. */
MockCommonSchemaLog log = new MockCommonSchemaLog();
log.setExt(new Extensions());
List<TypedProperty> properties = new ArrayList<>();
LongTypedProperty a = new LongTypedProperty();
a.setName("baseType");
a.setValue(1);
properties.add(a);
CommonSchemaDataUtils.addCommonSchemaData(properties, log);
/* Check data and metadata is missing type. */
assertEquals(0, log.getData().getProperties().length());
assertNull(log.getExt().getMetadata());
}
Aggregations