use of com.microsoft.appcenter.ingestion.models.CustomPropertiesLog in project AppCenter-SDK-Android by Microsoft.
the class AppCenterTest method setCustomPropertiesTest.
@Test
public void setCustomPropertiesTest() throws Exception {
/* Configure mocking. */
CustomPropertiesLog log = mock(CustomPropertiesLog.class);
whenNew(CustomPropertiesLog.class).withAnyArguments().thenReturn(log);
/* Call before start is forbidden. */
AppCenter.setCustomProperties(new CustomProperties().clear("test"));
verify(mChannel, never()).enqueue(eq(log), eq(CORE_GROUP));
verifyStatic(times(1));
AppCenterLog.error(eq(LOG_TAG), anyString());
/* Start. */
AppCenter.start(mApplication, DUMMY_APP_SECRET, DummyService.class);
/* Set null. */
AppCenter.setCustomProperties(null);
verify(mChannel, never()).enqueue(eq(log), eq(CORE_GROUP));
verifyStatic(times(2));
AppCenterLog.error(eq(LOG_TAG), anyString());
/* Set empty. */
CustomProperties empty = new CustomProperties();
AppCenter.setCustomProperties(empty);
verify(mChannel, never()).enqueue(eq(log), eq(CORE_GROUP));
verifyStatic(times(3));
AppCenterLog.error(eq(LOG_TAG), anyString());
/* Set normal. */
CustomProperties properties = new CustomProperties();
properties.set("test", "test");
AppCenter.setCustomProperties(properties);
verify(log).setProperties(eq(properties.getProperties()));
verify(mChannel).enqueue(eq(log), eq(CORE_GROUP));
/* Call after disabled triggers an error. */
AppCenter.setEnabled(false);
AppCenter.setCustomProperties(properties);
verifyStatic(times(4));
AppCenterLog.error(eq(LOG_TAG), anyString());
/* No more log enqueued. */
verify(mChannel).enqueue(eq(log), eq(CORE_GROUP));
}
use of com.microsoft.appcenter.ingestion.models.CustomPropertiesLog in project mobile-center-sdk-android by Microsoft.
the class LogSerializerAndroidTest method serializeWithInvalidType.
@Test(expected = JSONException.class)
public void serializeWithInvalidType() throws JSONException {
LogSerializer serializer = new DefaultLogSerializer();
CustomPropertiesLog invalidTypeLog = new CustomPropertiesLog();
invalidTypeLog.setTimestamp(new Date());
Map<String, Object> invalidTypeProperties = new HashMap<>();
invalidTypeProperties.put("nested", new HashMap<String, Object>());
invalidTypeLog.setProperties(invalidTypeProperties);
serializer.serializeLog(invalidTypeLog);
}
use of com.microsoft.appcenter.ingestion.models.CustomPropertiesLog in project AppCenter-SDK-Android by Microsoft.
the class LogSerializerAndroidTest method serializeWithInvalidType.
@Test(expected = JSONException.class)
public void serializeWithInvalidType() throws JSONException {
LogSerializer serializer = new DefaultLogSerializer();
CustomPropertiesLog invalidTypeLog = new CustomPropertiesLog();
invalidTypeLog.setTimestamp(new Date());
Map<String, Object> invalidTypeProperties = new HashMap<>();
invalidTypeProperties.put("nested", new HashMap<String, Object>());
invalidTypeLog.setProperties(invalidTypeProperties);
serializer.serializeLog(invalidTypeLog);
}
use of com.microsoft.appcenter.ingestion.models.CustomPropertiesLog in project AppCenter-SDK-Android by Microsoft.
the class LogSerializerAndroidTest method customPropertiesLog.
@Test
public void customPropertiesLog() throws JSONException {
CustomPropertiesLog log = new CustomPropertiesLog();
Map<String, Object> properties = new HashMap<>();
properties.put("t1", "test");
properties.put("t2", new Date(0));
properties.put("t3", 0);
properties.put("t4", false);
properties.put("t5", null);
log.setProperties(properties);
UUID sid = UUIDUtils.randomUUID();
log.setSid(sid);
log.setTimestamp(new Date());
/* Verify serialize and deserialize. */
LogSerializer serializer = new DefaultLogSerializer();
serializer.addLogFactory(CustomPropertiesLog.TYPE, new CustomPropertiesLogFactory());
String payload = serializer.serializeLog(log);
Log actualContainer = serializer.deserializeLog(payload);
Assert.assertEquals(log, actualContainer);
}
use of com.microsoft.appcenter.ingestion.models.CustomPropertiesLog in project AppCenter-SDK-Android by Microsoft.
the class LogSerializerAndroidTest method serializeWithoutProperties.
@Test(expected = JSONException.class)
public void serializeWithoutProperties() throws JSONException {
LogSerializer serializer = new DefaultLogSerializer();
CustomPropertiesLog invalidTypeLog = new CustomPropertiesLog();
invalidTypeLog.setTimestamp(new Date());
serializer.serializeLog(invalidTypeLog);
}
Aggregations