Search in sources :

Example 16 with LongTypedProperty

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());
}
Also used : LongTypedProperty(com.microsoft.appcenter.ingestion.models.properties.LongTypedProperty) JSONObject(org.json.JSONObject) ArrayList(java.util.ArrayList) DoubleTypedProperty(com.microsoft.appcenter.ingestion.models.properties.DoubleTypedProperty) LongTypedProperty(com.microsoft.appcenter.ingestion.models.properties.LongTypedProperty) BooleanTypedProperty(com.microsoft.appcenter.ingestion.models.properties.BooleanTypedProperty) StringTypedProperty(com.microsoft.appcenter.ingestion.models.properties.StringTypedProperty) TypedProperty(com.microsoft.appcenter.ingestion.models.properties.TypedProperty) DateTimeTypedProperty(com.microsoft.appcenter.ingestion.models.properties.DateTimeTypedProperty) Test(org.junit.Test)

Example 17 with LongTypedProperty

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());
}
Also used : LongTypedProperty(com.microsoft.appcenter.ingestion.models.properties.LongTypedProperty) ArrayList(java.util.ArrayList) DoubleTypedProperty(com.microsoft.appcenter.ingestion.models.properties.DoubleTypedProperty) LongTypedProperty(com.microsoft.appcenter.ingestion.models.properties.LongTypedProperty) BooleanTypedProperty(com.microsoft.appcenter.ingestion.models.properties.BooleanTypedProperty) StringTypedProperty(com.microsoft.appcenter.ingestion.models.properties.StringTypedProperty) TypedProperty(com.microsoft.appcenter.ingestion.models.properties.TypedProperty) DateTimeTypedProperty(com.microsoft.appcenter.ingestion.models.properties.DateTimeTypedProperty) Test(org.junit.Test)

Aggregations

LongTypedProperty (com.microsoft.appcenter.ingestion.models.properties.LongTypedProperty)17 BooleanTypedProperty (com.microsoft.appcenter.ingestion.models.properties.BooleanTypedProperty)14 DateTimeTypedProperty (com.microsoft.appcenter.ingestion.models.properties.DateTimeTypedProperty)14 DoubleTypedProperty (com.microsoft.appcenter.ingestion.models.properties.DoubleTypedProperty)14 StringTypedProperty (com.microsoft.appcenter.ingestion.models.properties.StringTypedProperty)14 Test (org.junit.Test)13 TypedProperty (com.microsoft.appcenter.ingestion.models.properties.TypedProperty)11 ArrayList (java.util.ArrayList)11 JSONObject (org.json.JSONObject)8 Date (java.util.Date)3 EventLog (com.microsoft.appcenter.analytics.ingestion.models.EventLog)2 Context (android.content.Context)1 PageLog (com.microsoft.appcenter.analytics.ingestion.models.PageLog)1 StartSessionLog (com.microsoft.appcenter.analytics.ingestion.models.StartSessionLog)1 EventLogFactory (com.microsoft.appcenter.analytics.ingestion.models.json.EventLogFactory)1 PageLogFactory (com.microsoft.appcenter.analytics.ingestion.models.json.PageLogFactory)1 StartSessionLogFactory (com.microsoft.appcenter.analytics.ingestion.models.json.StartSessionLogFactory)1 CommonSchemaEventLog (com.microsoft.appcenter.analytics.ingestion.models.one.CommonSchemaEventLog)1 Channel (com.microsoft.appcenter.channel.Channel)1 Device (com.microsoft.appcenter.ingestion.models.Device)1