/** * @deprecated use {@link CloudContext#getRoleInstance()} */ @Deprecated String getRoleInstance() { return MapUtil.getValueOrNull(tags, ContextTagKeys.getKeys().getDeviceRoleInstance()); }
/** * @deprecated use {@link CloudContext#setRoleInstance(String)} */ @Deprecated public void setRoleInstance(String roleInstance) { MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getDeviceRoleInstance(), roleInstance); }
/** * @deprecated use {@link CloudContext#setRole(String)} */ @Deprecated public void setRoleName(String roleName) { MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getDeviceRoleName(), roleName); }
/** * Gets a value indicating whether it is the first session. * @return True if first session, false otherwise. */ public Boolean getIsFirst() { return MapUtil.getBoolValueOrNull(tags, ContextTagKeys.getKeys().getSessionIsFirst()); }
/** * Gets the operation id. * @return Operation id. */ public String getId() { return MapUtil.getValueOrNull(tags, ContextTagKeys.getKeys().getOperationId()); }
/** * Sets the operation id. * @param id The operation id. */ public void setId(String id) { MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getOperationId(), id); }
/** * Sets the synthetic source. * @param syntheticSource The synthetic source. */ public void setSyntheticSource(String syntheticSource) { MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getSyntheticSource(), syntheticSource); } }
/** * Sets the session ID. * @param id the session ID. */ public void setId(String id) { MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getSessionId(), id); }
/** * Sets whether it is the first session. * @param isFirst a value indicating whether it is the first session. */ public void setIsFirst(Boolean isFirst) { MapUtil.setBoolValueOrRemove(tags, ContextTagKeys.getKeys().getSessionIsFirst(), isFirst); }
/** * Gets a value indicating whether it is a new session. * @return True if new session, false otherwise. */ public Boolean getIsNewSession() { return MapUtil.getBoolValueOrNull(tags, ContextTagKeys.getKeys().getSessionIsNew()); }
/** * Sets the operation name. * @param name Operation name. */ public void setName(String name) { MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getOperationName(), name); }
/** * Gets the synthetic source. * @return The synthetic source. */ public String getSyntheticSource() { return MapUtil.getValueOrNull(tags, ContextTagKeys.getKeys().getSyntheticSource()); }
public void setIp(String value) { if (!Strings.isNullOrEmpty(value) && isIPV4(value)) { MapUtil.setStringValueOrRemove(tags, ContextTagKeys.getKeys().getLocationIP(), value); } }
@Test public void testSetIsNewSessionTrue() { ConcurrentHashMap<String, String> map = new ConcurrentHashMap<String, String>(); SessionContext context = new SessionContext(map); context.setIsNewSession(true); assertEquals(context.getIsNewSession(), true); assertEquals(map.size(), 1); assertEquals(Boolean.valueOf(map.get(ContextTagKeys.getKeys().getSessionIsNew())), true); } }
@Test public void testSetRoleName() { ConcurrentHashMap<String, String> map = new ConcurrentHashMap<String, String>(); CloudContext context = new CloudContext(map); final String expected = "mock-role"; context.setRole(expected); assertEquals(expected, context.getRole()); assertEquals(1, map.size()); assertEquals(expected, map.get(ContextTagKeys.getKeys().getCloudRole())); } }
@Test public void testSetVersion() { ConcurrentHashMap<String, String> map = new ConcurrentHashMap<String, String>(); ComponentContext context = new ComponentContext(map); context.setVersion("version1"); assertEquals(context.getVersion(), "version1"); assertEquals(map.size(), 1); assertEquals(map.get(ContextTagKeys.getKeys().getApplicationVersion()), "version1"); } }
@Test public void testSetAgentVersion() { ConcurrentHashMap<String, String> map = new ConcurrentHashMap<String, String>(); InternalContext context = new InternalContext(map); context.setAgentVersion("mock"); assertEquals("mock", context.getAgentVersion()); assertEquals(1, map.size()); assertEquals("mock", map.get(ContextTagKeys.getKeys().getInternalAgentVersion())); }
@Test public void testSetId() { ConcurrentHashMap<String, String> map = new ConcurrentHashMap<String, String>(); DeviceContext context = new DeviceContext(map); context.setId("mock"); assertEquals("mock", context.getId()); assertEquals(1, map.size()); assertEquals("mock", map.get(ContextTagKeys.getKeys().getDeviceId())); }
@Test public void testSetModel() { ConcurrentHashMap<String, String> map = new ConcurrentHashMap<String, String>(); DeviceContext context = new DeviceContext(map); context.setModel("mock"); assertEquals("mock", context.getModel()); assertEquals(1, map.size()); assertEquals("mock", map.get(ContextTagKeys.getKeys().getDeviceModel())); }