Search in sources :

Example 11 with UserExtension

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

the class PropertyConfiguratorTest method defaultTargetIsNotReturnedFromGetTransmissionTarget.

@Test
public void defaultTargetIsNotReturnedFromGetTransmissionTarget() {
    /* Start the application with a token. */
    Analytics analytics = Analytics.getInstance();
    analytics.onStarting(mAppCenterHandler);
    String defaultToken = "test";
    analytics.onStarted(mock(Context.class), mChannel, null, defaultToken, true);
    /* Create the test target with the same default token. */
    AnalyticsTransmissionTarget target = Analytics.getTransmissionTarget(defaultToken);
    /* Verify it's not the same instance. */
    assertNotSame(target, analytics.mDefaultTransmissionTarget);
    /* Set a Part A property on the target. */
    target.getPropertyConfigurator().setAppName("someName");
    /* Simulate what the pipeline does to convert from App Center to Common Schema. */
    CommonSchemaLog log = new CommonSchemaEventLog();
    log.setExt(new Extensions());
    log.getExt().setApp(new AppExtension());
    log.getExt().setUser(new UserExtension());
    log.addTransmissionTarget("test");
    log.setTag(target);
    /* When the callback is called on the default target. */
    analytics.mDefaultTransmissionTarget.getPropertyConfigurator().onPreparingLog(log, "groupName");
    /* Then the log is not modified. */
    assertNull(log.getExt().getApp().getName());
    /* When the callback is called on the returned target. */
    target.getPropertyConfigurator().onPreparingLog(log, "groupName");
    /* Check the property is added to the log. */
    assertEquals("someName", log.getExt().getApp().getName());
}
Also used : Context(android.content.Context) CommonSchemaLog(com.microsoft.appcenter.ingestion.models.one.CommonSchemaLog) AppExtension(com.microsoft.appcenter.ingestion.models.one.AppExtension) UserExtension(com.microsoft.appcenter.ingestion.models.one.UserExtension) Matchers.anyString(org.mockito.Matchers.anyString) CommonSchemaEventLog(com.microsoft.appcenter.analytics.ingestion.models.one.CommonSchemaEventLog) Extensions(com.microsoft.appcenter.ingestion.models.one.Extensions) PrepareForTest(org.powermock.core.classloader.annotations.PrepareForTest) Test(org.junit.Test)

Aggregations

UserExtension (com.microsoft.appcenter.ingestion.models.one.UserExtension)11 CommonSchemaEventLog (com.microsoft.appcenter.analytics.ingestion.models.one.CommonSchemaEventLog)10 AppExtension (com.microsoft.appcenter.ingestion.models.one.AppExtension)10 CommonSchemaLog (com.microsoft.appcenter.ingestion.models.one.CommonSchemaLog)10 Extensions (com.microsoft.appcenter.ingestion.models.one.Extensions)10 Test (org.junit.Test)10 PrepareForTest (org.powermock.core.classloader.annotations.PrepareForTest)10 Context (android.content.Context)2 DeviceExtension (com.microsoft.appcenter.ingestion.models.one.DeviceExtension)2 SuppressLint (android.annotation.SuppressLint)1 ContentResolver (android.content.ContentResolver)1 AppCenterHandler (com.microsoft.appcenter.AppCenterHandler)1 LinkedList (java.util.LinkedList)1 Matchers.anyString (org.mockito.Matchers.anyString)1 Mockito.doAnswer (org.mockito.Mockito.doAnswer)1 InvocationOnMock (org.mockito.invocation.InvocationOnMock)1 Answer (org.mockito.stubbing.Answer)1