Search in sources :

Example 1 with DistributionStartSessionLogFactory

use of com.microsoft.appcenter.distribute.ingestion.models.json.DistributionStartSessionLogFactory in project mobile-center-sdk-android by Microsoft.

the class DistributeSerializerTest method serialize.

@Test
public void serialize() throws JSONException {
    LogContainer expectedContainer = new LogContainer();
    List<Log> logs = new ArrayList<>();
    {
        DistributionStartSessionLog log = new DistributionStartSessionLog();
        log.setTimestamp(new Date());
        logs.add(log);
    }
    expectedContainer.setLogs(logs);
    UUID sid = UUIDUtils.randomUUID();
    for (Log log : logs) {
        log.setSid(sid);
    }
    /* Serialize and deserialize logs container. */
    LogSerializer serializer = new DefaultLogSerializer();
    serializer.addLogFactory(DistributionStartSessionLog.TYPE, new DistributionStartSessionLogFactory());
    String payload = serializer.serializeContainer(expectedContainer);
    LogContainer actualContainer = serializer.deserializeContainer(payload);
    /* Verify that logs container successfully deserialized. */
    Assert.assertEquals(expectedContainer, actualContainer);
}
Also used : DistributionStartSessionLogFactory(com.microsoft.appcenter.distribute.ingestion.models.json.DistributionStartSessionLogFactory) DistributionStartSessionLog(com.microsoft.appcenter.distribute.ingestion.models.DistributionStartSessionLog) Log(com.microsoft.appcenter.ingestion.models.Log) DistributionStartSessionLog(com.microsoft.appcenter.distribute.ingestion.models.DistributionStartSessionLog) 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) Date(java.util.Date) DefaultLogSerializer(com.microsoft.appcenter.ingestion.models.json.DefaultLogSerializer) Test(org.junit.Test)

Aggregations

DistributionStartSessionLog (com.microsoft.appcenter.distribute.ingestion.models.DistributionStartSessionLog)1 DistributionStartSessionLogFactory (com.microsoft.appcenter.distribute.ingestion.models.json.DistributionStartSessionLogFactory)1 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 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 UUID (java.util.UUID)1 Test (org.junit.Test)1