use of com.microsoft.azure.mobile.ingestion.models.CustomPropertiesLog in project mobile-center-sdk-android by Microsoft.
the class MobileCenter method queueCustomProperties.
/**
* Send custom properties.
*
* @param properties properties to send.
*/
private synchronized void queueCustomProperties(@NonNull Map<String, Object> properties) {
CustomPropertiesLog customPropertiesLog = new CustomPropertiesLog();
customPropertiesLog.setProperties(properties);
mChannel.enqueue(customPropertiesLog, CORE_GROUP);
}
use of com.microsoft.azure.mobile.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();
Map<String, Object> invalidTypeProperties = new HashMap<>();
invalidTypeProperties.put("nested", new HashMap<String, Object>());
invalidTypeLog.setProperties(invalidTypeProperties);
serializer.serializeLog(invalidTypeLog);
}
use of com.microsoft.azure.mobile.ingestion.models.CustomPropertiesLog in project mobile-center-sdk-android by Microsoft.
the class MobileCenterTest 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. */
MobileCenter.setCustomProperties(new CustomProperties().clear("test"));
verify(mChannel, never()).enqueue(eq(log), eq(CORE_GROUP));
verifyStatic(times(1));
MobileCenterLog.error(eq(LOG_TAG), anyString());
/* Start. */
MobileCenter.start(application, DUMMY_APP_SECRET, DummyService.class);
/* Set null. */
MobileCenter.setCustomProperties(null);
verify(mChannel, never()).enqueue(eq(log), eq(CORE_GROUP));
verifyStatic(times(2));
MobileCenterLog.error(eq(LOG_TAG), anyString());
/* Set empty. */
CustomProperties empty = new CustomProperties();
MobileCenter.setCustomProperties(empty);
verify(mChannel, never()).enqueue(eq(log), eq(CORE_GROUP));
verifyStatic(times(3));
MobileCenterLog.error(eq(LOG_TAG), anyString());
/* Set normal. */
CustomProperties properties = new CustomProperties();
properties.set("test", "test");
MobileCenter.setCustomProperties(properties);
verify(log).setProperties(eq(properties.getProperties()));
verify(mChannel).enqueue(eq(log), eq(CORE_GROUP));
}
use of com.microsoft.azure.mobile.ingestion.models.CustomPropertiesLog in project mobile-center-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);
/* 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.azure.mobile.ingestion.models.CustomPropertiesLog in project mobile-center-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();
serializer.serializeLog(invalidTypeLog);
}
Aggregations