use of com.microsoft.appcenter.ingestion.models.properties.TypedProperty in project mobile-center-sdk-android by Microsoft.
the class CommonSchemaDataUtilsAndroidTest method baseDataMissing.
@Test
public void baseDataMissing() {
/* When using invalid base data. */
MockCommonSchemaLog log = new MockCommonSchemaLog();
log.setExt(new Extensions());
List<TypedProperty> properties = new ArrayList<>();
StringTypedProperty a = new StringTypedProperty();
a.setName("baseType");
a.setValue("Some.Type");
properties.add(a);
CommonSchemaDataUtils.addCommonSchemaData(properties, log);
/* Check data and metadata is missing type. */
assertEquals(0, log.getData().getProperties().length());
assertNull(log.getExt().getMetadata());
}
use of com.microsoft.appcenter.ingestion.models.properties.TypedProperty in project mobile-center-sdk-android by Microsoft.
the class CommonSchemaDataUtilsAndroidTest method noNestingAccident.
@Test
public void noNestingAccident() throws JSONException {
MockCommonSchemaLog log = new MockCommonSchemaLog();
log.setExt(new Extensions());
List<TypedProperty> properties = new ArrayList<>();
LongTypedProperty a = new LongTypedProperty();
a.setName("a.b");
a.setValue(1);
properties.add(a);
DoubleTypedProperty b = new DoubleTypedProperty();
b.setName("b.c");
b.setValue(2.2);
properties.add(b);
CommonSchemaDataUtils.addCommonSchemaData(properties, log);
/* Check data. */
JSONObject aData = new JSONObject();
aData.put("b", 1);
JSONObject bData = new JSONObject();
bData.put("c", 2.2);
JSONObject expectedData = new JSONObject();
expectedData.put("a", aData);
expectedData.put("b", bData);
assertEquals(expectedData.toString(), log.getData().getProperties().toString());
/* Check metadata. a.b */
JSONObject aFields = new JSONObject();
aFields.put("b", DATA_TYPE_INT64);
JSONObject aMetadata = new JSONObject();
aMetadata.put(METADATA_FIELDS, aFields);
/* b.c */
JSONObject bFields = new JSONObject();
bFields.put("c", DATA_TYPE_DOUBLE);
JSONObject bMetadata = new JSONObject();
bMetadata.put(METADATA_FIELDS, bFields);
/* f at root. */
JSONObject rootFields = new JSONObject();
rootFields.put("a", aMetadata);
rootFields.put("b", bMetadata);
/* Check. */
JSONObject expectedMetadata = new JSONObject();
expectedMetadata.put(METADATA_FIELDS, rootFields);
assertEquals(expectedMetadata.toString(), log.getExt().getMetadata().getMetadata().toString());
}
use of com.microsoft.appcenter.ingestion.models.properties.TypedProperty in project mobile-center-sdk-android by Microsoft.
the class CommonSchemaDataUtilsAndroidTest method baseTypeMissing.
@Test
public void baseTypeMissing() {
/* When using invalid base data. */
MockCommonSchemaLog log = new MockCommonSchemaLog();
log.setExt(new Extensions());
List<TypedProperty> properties = new ArrayList<>();
StringTypedProperty a = new StringTypedProperty();
a.setName("baseData.test");
a.setValue("test");
properties.add(a);
CommonSchemaDataUtils.addCommonSchemaData(properties, log);
/* Check data and metadata is missing type. */
assertEquals(0, log.getData().getProperties().length());
assertNull(log.getExt().getMetadata());
}
use of com.microsoft.appcenter.ingestion.models.properties.TypedProperty in project mobile-center-sdk-android by Microsoft.
the class CommonSchemaDataUtilsAndroidTest method overrideMetadataToNull.
@Test
public void overrideMetadataToNull() throws JSONException {
MockCommonSchemaLog log = new MockCommonSchemaLog();
log.setExt(new Extensions());
List<TypedProperty> properties = new ArrayList<>();
LongTypedProperty a = new LongTypedProperty();
a.setName("a.b.c");
a.setValue(1);
properties.add(a);
StringTypedProperty b = new StringTypedProperty();
b.setName("a.b");
b.setValue("2");
properties.add(b);
CommonSchemaDataUtils.addCommonSchemaData(properties, log);
/* Check data. */
JSONObject aData = new JSONObject();
aData.put("b", "2");
JSONObject expectedData = new JSONObject();
expectedData.put("a", aData);
assertEquals(expectedData.toString(), log.getData().getProperties().toString());
/* Check metadata is null */
assertNull(log.getExt().getMetadata());
}
use of com.microsoft.appcenter.ingestion.models.properties.TypedProperty 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());
}
Aggregations