Search in sources :

Example 36 with TypedProperty

use of com.microsoft.appcenter.ingestion.models.properties.TypedProperty in project mobile-center-sdk-android by Microsoft.

the class CommonSchemaDataUtilsAndroidTest method unknownTypedProperty.

@Test
public void unknownTypedProperty() {
    MockCommonSchemaLog log = new MockCommonSchemaLog();
    TypedProperty typedProperty = new TypedProperty() {

        @Override
        public String getType() {
            return "unknown";
        }
    };
    typedProperty.setName("a");
    CommonSchemaDataUtils.addCommonSchemaData(Collections.singletonList(typedProperty), log);
    /* Data is empty because the invalid property filtered out. */
    assertEquals(0, log.getData().getProperties().length());
    /* And we don't send metadata when using only standard types. */
    assertNull(log.getExt());
}
Also used : 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 37 with TypedProperty

use of com.microsoft.appcenter.ingestion.models.properties.TypedProperty 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

TypedProperty (com.microsoft.appcenter.ingestion.models.properties.TypedProperty)37 StringTypedProperty (com.microsoft.appcenter.ingestion.models.properties.StringTypedProperty)35 BooleanTypedProperty (com.microsoft.appcenter.ingestion.models.properties.BooleanTypedProperty)31 DateTimeTypedProperty (com.microsoft.appcenter.ingestion.models.properties.DateTimeTypedProperty)31 DoubleTypedProperty (com.microsoft.appcenter.ingestion.models.properties.DoubleTypedProperty)31 LongTypedProperty (com.microsoft.appcenter.ingestion.models.properties.LongTypedProperty)31 ArrayList (java.util.ArrayList)31 Test (org.junit.Test)31 JSONObject (org.json.JSONObject)14 EventLog (com.microsoft.appcenter.analytics.ingestion.models.EventLog)7 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)7 CommonSchemaEventLog (com.microsoft.appcenter.analytics.ingestion.models.one.CommonSchemaEventLog)6 TestUtils.generateString (com.microsoft.appcenter.test.TestUtils.generateString)5 Date (java.util.Date)4 HashMap (java.util.HashMap)3 Matchers.anyString (org.mockito.Matchers.anyString)3 Map (java.util.Map)2 JSONException (org.json.JSONException)2 Context (android.content.Context)1 EventProperties (com.microsoft.appcenter.analytics.EventProperties)1