use of com.microsoft.appcenter.ingestion.models.LogContainer in project mobile-center-sdk-android by Microsoft.
the class LogContainerTest method compareLogContainer.
@Test
public void compareLogContainer() {
LogContainer container1 = new LogContainer();
LogContainer container2 = new LogContainer();
TestUtils.compareSelfNullClass(container1);
TestUtils.checkEquals(container1, container2);
Log log1 = new AbstractLog() {
@Override
public String getType() {
return "null";
}
};
log1.setSid(UUID.randomUUID());
container1.setLogs(Collections.singletonList(log1));
TestUtils.compareSelfNullClass(container1);
TestUtils.checkNotEquals(container1, container2);
container2.setLogs(Collections.singletonList(log1));
TestUtils.compareSelfNullClass(container1);
TestUtils.checkEquals(container1, container2);
Log log2 = new AbstractLog() {
@Override
public String getType() {
return null;
}
};
log2.setSid(UUID.randomUUID());
container2.setLogs(Collections.singletonList(log2));
TestUtils.compareSelfNullClass(container1);
TestUtils.checkNotEquals(container1, container2);
}
use of com.microsoft.appcenter.ingestion.models.LogContainer 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);
}
use of com.microsoft.appcenter.ingestion.models.LogContainer in project mobile-center-sdk-android by Microsoft.
the class JSONUtilsAndroidTest method serializeContainerWithDefaultWriter.
@Test
public void serializeContainerWithDefaultWriter() throws JSONException {
/* Create a mock log container. */
LogContainer mockContainer = mock(LogContainer.class);
/* Set log level to VERBOSE to instantiate JSONStringer for pretty JSON string. */
AppCenterLog.setLogLevel(Log.VERBOSE);
LogSerializer serializer = new DefaultLogSerializer();
String json = serializer.serializeContainer(mockContainer);
/* Remove new lines and spaces. */
json = json.replace("\n", "").replace(" ", "");
/* Set log level to ERROR to instantiate JSONStringer without indentations. */
AppCenterLog.setLogLevel(Log.ERROR);
/* Verify. */
assertEquals(json, serializer.serializeContainer(mockContainer));
}
use of com.microsoft.appcenter.ingestion.models.LogContainer in project mobile-center-sdk-android by Microsoft.
the class LogSerializerAndroidTest method emptyLogs.
@Test
public void emptyLogs() throws JSONException {
LogContainer expectedContainer = new LogContainer();
expectedContainer.setLogs(Collections.<Log>emptyList());
LogSerializer serializer = new DefaultLogSerializer();
String payload = serializer.serializeContainer(expectedContainer);
android.util.Log.v(TAG, payload);
LogContainer actualContainer = serializer.deserializeContainer(payload);
Assert.assertEquals(expectedContainer, actualContainer);
}
use of com.microsoft.appcenter.ingestion.models.LogContainer in project mobile-center-sdk-android by Microsoft.
the class LogSerializerAndroidTest method oneLog.
@Test
public void oneLog() throws JSONException {
LogContainer expectedContainer = AndroidTestUtils.generateMockLogContainer();
LogSerializer serializer = new DefaultLogSerializer();
serializer.addLogFactory(MOCK_LOG_TYPE, new MockLogFactory());
String payload = serializer.serializeContainer(expectedContainer);
android.util.Log.v(TAG, payload);
LogContainer actualContainer = serializer.deserializeContainer(payload);
Assert.assertEquals(expectedContainer, actualContainer);
Assert.assertEquals(expectedContainer.hashCode(), actualContainer.hashCode());
}
Aggregations