Search in sources :

Example 1 with PushInstallationLog

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

the class PushSerializerTest method serialize.

@Test
public void serialize() throws JSONException {
    LogContainer expectedContainer = new LogContainer();
    List<Log> logs = new ArrayList<>();
    {
        PushInstallationLog log = new PushInstallationLog();
        log.setTimestamp(new Date());
        log.setPushToken("TEST");
        logs.add(log);
    }
    expectedContainer.setLogs(logs);
    UUID sid = UUIDUtils.randomUUID();
    for (Log log : logs) {
        log.setSid(sid);
    }
    LogSerializer serializer = new DefaultLogSerializer();
    serializer.addLogFactory(PushInstallationLog.TYPE, new PushInstallationLogFactory());
    String payload = serializer.serializeContainer(expectedContainer);
    LogContainer actualContainer = serializer.deserializeContainer(payload);
    Assert.assertEquals(expectedContainer, actualContainer);
}
Also used : PushInstallationLog(com.microsoft.appcenter.push.ingestion.models.PushInstallationLog) Log(com.microsoft.appcenter.ingestion.models.Log) PushInstallationLog(com.microsoft.appcenter.push.ingestion.models.PushInstallationLog) ArrayList(java.util.ArrayList) LogContainer(com.microsoft.appcenter.ingestion.models.LogContainer) DefaultLogSerializer(com.microsoft.appcenter.ingestion.models.json.DefaultLogSerializer) LogSerializer(com.microsoft.appcenter.ingestion.models.json.LogSerializer) UUID(java.util.UUID) PushInstallationLogFactory(com.microsoft.appcenter.push.ingestion.models.json.PushInstallationLogFactory) Date(java.util.Date) DefaultLogSerializer(com.microsoft.appcenter.ingestion.models.json.DefaultLogSerializer) Test(org.junit.Test)

Example 2 with PushInstallationLog

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

the class Push method enqueuePushInstallationLog.

/**
 * Enqueue a push installation log.
 *
 * @param pushToken the push token value
 */
private void enqueuePushInstallationLog(@NonNull String pushToken) {
    PushInstallationLog log = new PushInstallationLog();
    log.setPushToken(pushToken);
    mChannel.enqueue(log, PUSH_GROUP);
}
Also used : PushInstallationLog(com.microsoft.appcenter.push.ingestion.models.PushInstallationLog)

Aggregations

PushInstallationLog (com.microsoft.appcenter.push.ingestion.models.PushInstallationLog)2 Log (com.microsoft.appcenter.ingestion.models.Log)1 LogContainer (com.microsoft.appcenter.ingestion.models.LogContainer)1 DefaultLogSerializer (com.microsoft.appcenter.ingestion.models.json.DefaultLogSerializer)1 LogSerializer (com.microsoft.appcenter.ingestion.models.json.LogSerializer)1 PushInstallationLogFactory (com.microsoft.appcenter.push.ingestion.models.json.PushInstallationLogFactory)1 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 UUID (java.util.UUID)1 Test (org.junit.Test)1