Here are the examples of the java api com.iris.messages.MessageBody taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.
1238 Examples
19
Source : IrisNettyMessageHandler.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public clreplaced IrisNettyMessageHandler implements DeviceMessageHandler<String> {
private static final String SESSION_SERVICE_ADDRESS = Addresses.toServiceAddress(SessionService.NAMESPACE);
private static final Counter NUM_VIDEO_CACHE_RESPONSE_HIT = IrisMetrics.metrics("client.bridge").counter("video.cached.response.hit");
private static final Counter NUM_VIDEO_CACHE_RESPONSE_MISS = IrisMetrics.metrics("client.bridge").counter("video.cached.response.miss");
private static final MessageBody EMPTY_LIST_RECORDINGS_RESPONSE = VideoService.ListRecordingsResponse.builder().withRecordings(Collections.emptyList()).build();
private static final Logger logger = LoggerFactory.getLogger(IrisNettyMessageHandler.clreplaced);
private final PlatformBusService platformBusService;
private final Authorizer authorizer;
private final IrisNettyMessageUtil messageUtil;
private final ClientRequestDispatcher clientRequestDispatcher;
private final PlacePopulationCacheManager populationCacheMgr;
@Inject
public IrisNettyMessageHandler(PlatformBusService platformBusService, Authorizer authorizer, IrisNettyMessageUtil messageUtil, ClientRequestDispatcher clientRequestDispatcher, PlacePopulationCacheManager populationCacheMgr) {
this.platformBusService = platformBusService;
this.authorizer = authorizer;
this.messageUtil = messageUtil;
this.clientRequestDispatcher = clientRequestDispatcher;
this.populationCacheMgr = populationCacheMgr;
}
@Override
public String handleMessage(Session session, String message) {
logger.debug("Received message from client [{}]", message);
Client client = session.getClient();
if (client == null || !client.isAuthenticated()) {
session.disconnect(Constants.SESSION_EXPIRED_STATUS);
return null;
}
ClientMessage clientMsg = JSON.fromJson(message, ClientMessage.clreplaced);
if (clientMsg.isRequest()) {
session.getClient().requestReceived();
}
/*
* try(...) - Uses Java 1.7+ Automatic Resource Management eliminating need for finally block to
* manage closeable resources. All resources that implement AutoCloseable will be automatically
* closed as necessary without a finally block. e.g. MdcContextReference
*/
try (MdcContextReference context = BridgeMdcUtil.captureAndInitializeContext(session, clientMsg)) {
if (SESSION_SERVICE_ADDRESS.equals(clientMsg.getDestination())) {
clientRequestDispatcher.submit(clientMsg, session);
return null;
}
Address actor = Address.platformService(session.getAuthorizationContext().getPrincipal().getUserId(), PersonCapability.NAMESPACE);
PlatformMessage platformMessage = null;
try {
platformMessage = messageUtil.convertClientToPlatform(clientMsg, session, actor, populationCacheMgr);
} catch (Exception ex) {
ErrorEvent err = Errors.fromException(ex);
// Return error response instead of disconnecting socket which would cause a reconnect
return createResponseFromErrorEvent(session, clientMsg, err);
}
if (VideoService.ListRecordingsRequest.NAME.equals(clientMsg.getType())) {
MessageBody result = EMPTY_LIST_RECORDINGS_RESPONSE;
NUM_VIDEO_CACHE_RESPONSE_HIT.inc();
PlatformMessage cachedResponse = PlatformMessage.createResponse(platformMessage, result);
return JSON.toJson(messageUtil.convertPlatformToClient(cachedResponse));
}
try {
if (authorizer.isAuthorized(session.getAuthorizationContext(), session.getActivePlace(), platformMessage)) {
logger.debug("Placing message on platform bus [{}] for place id [{}] and population [{}]", platformMessage, platformMessage.getPlaceId(), platformMessage.getPopulation());
platformBusService.placeMessageOnPlatformBus(platformMessage);
} else {
logger.debug("Placing unauthorized error message on platform bus");
platformBusService.placeMessageOnPlatformBus(PlatformMessage.createResponse(platformMessage, AuthzUtil.createUnauthorizedEvent()));
}
} catch (UnknownSessionException use) {
session.disconnect(Constants.SESSION_EXPIRED_STATUS);
} catch (Exception e) {
ErrorEvent err = Errors.fromException(e);
return createResponseFromErrorEvent(session, clientMsg, err);
}
return null;
}
}
private String createResponseFromErrorEvent(Session session, ClientMessage clientMsg, ErrorEvent err) {
Address dest = Address.fromString(messageUtil.buildId(session.getClientToken().getRepresentation()));
ClientMessage.Builder builder = ClientMessage.builder().withPayload(err).withSource(SESSION_SERVICE_ADDRESS).withDestination(dest.getRepresentation());
if (!StringUtils.isBlank(clientMsg.getCorrelationId())) {
builder.withCorrelationId(clientMsg.getCorrelationId());
}
ClientMessage response = builder.create();
return JSON.toJson(response);
}
}
19
Source : WeatherSubsystemTestCase.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected PlatformMessage weatherPlatformMessage(MessageBody body) {
return weatherPlatformMessage(body, clientAddress);
}
19
Source : SubsystemTestCase.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected MessageReceivedEvent request(MessageBody body, String correlationId) {
return request(body, clientAddress, null);
}
19
Source : SubsystemTestCase.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected MessageReceivedEvent request(MessageBody body) {
return request(body, clientAddress, null);
}
19
Source : SecuritySubsystemTestCase.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected PlatformMessage securityPlatformMessage(MessageBody body) {
return securityPlatformMessage(body, clientAddress);
}
19
Source : SafetySubsystemTestCase.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected PlatformMessage safetyPlatformMessage(MessageBody body) {
return safetyPlatformMessage(body, clientAddress);
}
19
Source : CareSubsystemTestCase.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected PlatformMessage carePlatformMessage(MessageBody body) {
return carePlatformMessage(body, clientAddress);
}
19
Source : TestAlarmSubsystem_KeyPadStates.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected void replacedertDisarmed() {
MessageBody request = requests.getValue();
replacedertEquals(DisarmedRequest.NAME, request.getMessageType());
requests.reset();
}
19
Source : SubsystemUtils.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public static Map<String, Address> sendToHub(SubsystemContext<?> context, MessageBody message, Optional<Integer> timeToLive) {
return sendTo(context, isHub, message, timeToLive);
}
19
Source : LawnNGardenValidation.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public static ScheduleMode getAndValidateMode(MessageBody body, String attribute) {
return getAndValidateMode(body, attribute, null);
}
19
Source : LawnNGardenValidation.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public static String getAndValidateEventId(MessageBody body, String attr) {
String eventId = LawnNGardenTypeUtil.string(body.getAttributes().get(attr));
validateEventId(eventId);
return eventId;
}
19
Source : LawnNGardenValidation.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public static Address getAndValidateController(MessageBody body, String attr, SubsystemContext<LawnNGardenSubsystemModel> context) {
Address controller = LawnNGardenTypeUtil.address(body.getAttributes().get(attr));
validateController(controller, context);
return controller;
}
19
Source : PendingOperation.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public boolean eventMatches(MessageBody event) {
return opId().equals(event.getAttributes().get("opId")) && eventTypeMatches(event.getMessageType());
}
19
Source : WaterAlarm.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
/**
* @author tweidlin
*/
public clreplaced WaterAlarm extends AlarmStateMachine<AlarmSubsystemModel> {
public static final String NAME = "WATER";
private static final Predicate<Model> IS_WATER_VALVE = Predicates.isA(ValveCapability.NAMESPACE);
private static final MessageBody CLOSE_VALVE = MessageBody.buildMessage(Capability.CMD_SET_ATTRIBUTES, ImmutableMap.<String, Object>of(ValveCapability.ATTR_VALVESTATE, ValveCapability.VALVESTATE_CLOSED));
public static Predicate<Model> isWaterValve() {
return IS_WATER_VALVE;
}
public static MessageBody closeValve() {
return CLOSE_VALVE;
}
public WaterAlarm() {
super(NAME, Predicates.isA(LeakH2OCapability.NAMESPACE), Predicates.attributeEquals(LeakH2OCapability.ATTR_STATE, LeakH2OCapability.STATE_LEAK));
}
@Override
protected AlarmState<? super AlarmSubsystemModel> state(String name) {
if (AlarmCapability.ALERTSTATE_ALERT.equals(name)) {
return WaterAlertState.instance();
}
return super.state(name);
}
@Override
protected TriggerEvent getTriggerType(SubsystemContext<AlarmSubsystemModel> context, Model model) {
return TriggerEvent.LEAK;
}
}
19
Source : AlarmSubsystemState.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public abstract clreplaced AlarmSubsystemState {
public static final int ALERT_TIMEOUT_SEC = 300;
private static final Predicate<Model> isKeypad = isA(KeyPadCapability.NAMESPACE);
private static final Predicate<Model> isSiren = and(isA(AlertCapability.NAMESPACE), not(isA(KeyPadCapability.NAMESPACE)));
private static final Predicate<Model> isHub = isA(HubCapability.NAMESPACE);
private static final MessageBody alertSirenAttributes = MessageBody.messageBuilder(Capability.CMD_SET_ATTRIBUTES).withAttribute(AlertCapability.ATTR_STATE, AlertCapability.STATE_ALERTING).create();
private static final MessageBody quietSirenAttributes = MessageBody.messageBuilder(Capability.CMD_SET_ATTRIBUTES).withAttribute(AlertCapability.ATTR_STATE, AlertCapability.STATE_QUIET).create();
public enum Name {
DISARMED, ARMING, ARMED, PREALERT, ALERT
}
public static AlarmSubsystemState get(SubsystemContext<AlarmSubsystemModel> context) {
Name name = context.getVariable("statemachine").as(Name.clreplaced);
if (name == null) {
switch(context.model().getAlarmState()) {
case AlarmSubsystemCapability.ALARMSTATE_INACTIVE:
case AlarmSubsystemCapability.ALARMSTATE_CLEARING:
name = Name.DISARMED;
break;
case AlarmSubsystemCapability.ALARMSTATE_READY:
switch(AlarmModel.getAlertState(SecurityAlarm.NAME, context.model(), AlarmCapability.ALERTSTATE_INACTIVE)) {
case AlarmCapability.ALERTSTATE_INACTIVE:
case AlarmCapability.ALERTSTATE_DISARMED:
case AlarmCapability.ALERTSTATE_CLEARING:
name = Name.DISARMED;
break;
case AlarmCapability.ALERTSTATE_ARMING:
name = Name.ARMING;
break;
case AlarmCapability.ALERTSTATE_READY:
name = Name.ARMED;
break;
default:
context.logger().warn("AlarmSubsystem state [{}] and security alarm state [{}] are inconsistent", context.model().getAlarmState(), AlarmModel.getAlertState(SecurityAlarm.NAME, context.model(), AlarmCapability.ALERTSTATE_INACTIVE));
name = Name.DISARMED;
}
break;
case AlarmSubsystemCapability.ALARMSTATE_PREALERT:
name = Name.PREALERT;
break;
case AlarmSubsystemCapability.ALARMSTATE_ALERTING:
name = Name.ALERT;
break;
default:
context.logger().warn("AlarmSubsystem state [{}] is not recognized", context.model().getAlarmState());
name = Name.DISARMED;
}
}
return get(name);
}
public static AlarmSubsystemState get(Name name) {
switch(name) {
case DISARMED:
return DisarmedState.instance();
case ARMING:
return ArmingState.instance();
case ARMED:
return ArmedState.instance();
case PREALERT:
return PreAlertState.instance();
case ALERT:
return AlertState.instance();
default:
throw new IllegalArgumentException("Unsupported state " + name);
}
}
public static void start(SubsystemContext<AlarmSubsystemModel> context) {
AlarmSubsystemState state = get(context);
state.restoreTimeout(context);
KeyPad.bind(context);
Name next = state.onStarted(context);
context.setVariable("statemachine", next);
transition(context, state, next);
}
public static void timeout(SubsystemContext<AlarmSubsystemModel> context, ScheduledEvent timeout) {
AlarmSubsystemState state = get(context);
if (SubsystemUtils.isMatchingTimeout(timeout, state.getTimeout(context))) {
state.cancelTimeout(context);
Name next = state.onTimeout(context);
transition(context, state, next);
}
}
public static AlarmSubsystemState transition(SubsystemContext<AlarmSubsystemModel> context, AlarmSubsystemState current, Name next) {
if (current.getName().equals(next)) {
return current;
}
context.logger().debug("AlarmSubsystem transitioning from [{}] to [{}]", current.getName(), next);
try {
current.onExit(context);
} catch (Exception e) {
context.logger().warn("Error exiting state [{}]", current, e);
}
context.setVariable("statemachine", next);
current = get(next);
try {
next = current.onEnter(context);
} catch (Exception e) {
context.logger().warn("Error entering state [{}]", next, e);
}
return transition(context, current, next);
}
public abstract Name getName();
/**
* Called when a subsystem in this state is restored into memory.
* @param context
* @param name
* @return
*/
public Name onStarted(SubsystemContext<AlarmSubsystemModel> context) {
restoreTimeout(context);
return getName();
}
/**
* Called when a subsystem transitions into this state.
* @param context
* @param name
* @return
*/
public Name onEnter(SubsystemContext<AlarmSubsystemModel> context) {
return getName();
}
/**
* Called before a subsystem transitions out of this state.
* @param context
* @param name
* @return
*/
public void onExit(SubsystemContext<AlarmSubsystemModel> context) {
}
public Name onAlertInactive(SubsystemContext<AlarmSubsystemModel> context, String alert) {
return getName();
}
public Name onAlertReady(SubsystemContext<AlarmSubsystemModel> context, String alert) {
return getName();
}
public Name onAlertClearing(SubsystemContext<AlarmSubsystemModel> context, String alert) {
return getName();
}
public Name onAlert(SubsystemContext<AlarmSubsystemModel> context, String alarm) {
return getName();
}
// security only transitions
public Name onArming(SubsystemContext<AlarmSubsystemModel> context) {
return getName();
}
public Name onArmed(SubsystemContext<AlarmSubsystemModel> context) {
return getName();
}
public Name onDisarmed(SubsystemContext<AlarmSubsystemModel> context) {
return getName();
}
public Name onPreAlert(SubsystemContext<AlarmSubsystemModel> context) {
return getName();
}
public Name onTimeout(SubsystemContext<AlarmSubsystemModel> context) {
return getName();
}
protected List<String> getAlertsOfType(SubsystemContext<AlarmSubsystemModel> context, String alertState) {
List<String> alerts = new ArrayList<>();
for (Model model : context.models().getModels(AlarmSubsystem.hasAlarm())) {
for (Map.Entry<String, Set<String>> instance : model.getInstances().entrySet()) {
if (instance.getValue().contains(AlarmCapability.NAMESPACE) && alertState.equals(AlarmModel.getAlertState(instance.getKey(), model))) {
alerts.add(instance.getKey());
}
}
}
Collections.sort(alerts, AlarmSubsystem.alarmPriorityComparator());
return alerts;
}
protected Set<String> getAlertTypes(SubsystemContext<AlarmSubsystemModel> context) {
Set<String> alertType = Sets.newHashSetWithExpectedSize(8);
for (Model model : context.models().getModels(AlarmSubsystem.hasAlarm())) {
for (Map.Entry<String, Set<String>> instance : model.getInstances().entrySet()) {
if (instance.getValue().contains(AlarmCapability.NAMESPACE)) {
alertType.add(AlarmModel.getAlertState(instance.getKey(), model, AlarmCapability.ALERTSTATE_INACTIVE));
}
}
}
return alertType;
}
protected void silence(SubsystemContext<AlarmSubsystemModel> context) {
SubsystemUtils.sendTo(context, isSiren, quietSirenAttributes);
SubsystemUtils.sendTo(context, isHub, HubSoundsCapability.QuietRequest.instance());
}
protected void sendArming(SubsystemContext<?> context, String mode, int armingTimeSec) {
Model securitySubsystem = context.models().getModelByAddress(Address.platformService(context.getPlaceId(), SecuritySubsystemCapability.NAMESPACE));
boolean makeNoises = SecurityAlarmModeModel.getSoundsEnabled(mode, securitySubsystem, true);
if (makeNoises) {
MessageBody hubArming = HubSoundsCapability.PlayToneRequest.builder().withTone(HubSoundsCapability.PlayToneRequest.TONE_ARMING).withDurationSec(armingTimeSec).build();
SubsystemUtils.sendTo(context, isHub, hubArming);
}
MessageBody keypadArming = KeyPadCapability.BeginArmingRequest.builder().withAlarmMode(mode).withDelayInS(armingTimeSec).build();
sendKeyPads(context, keypadArming);
}
protected void sendArmed(SubsystemContext<?> context, String mode) {
MessageBody keypadArmed = KeyPadCapability.ArmedRequest.builder().withAlarmMode(mode).build();
sendKeyPads(context, keypadArmed);
}
protected void sendPreAlert(SubsystemContext<?> context, String mode, int prealertTimeSec) {
Model securitySubsystem = context.models().getModelByAddress(Address.platformService(context.getPlaceId(), SecuritySubsystemCapability.NAMESPACE));
boolean makeNoises = SecurityAlarmModeModel.getSoundsEnabled(mode, securitySubsystem, true) && !AlarmModel.getSilent(SecurityAlarm.NAME, context.model(), false);
if (makeNoises) {
MessageBody hubArming = HubSoundsCapability.PlayToneRequest.builder().withTone(HubSoundsCapability.PlayToneRequest.TONE_ARMING).withDurationSec(prealertTimeSec).build();
SubsystemUtils.sendTo(context, isHub, hubArming);
}
MessageBody keypadSoaking = KeyPadCapability.SoakingRequest.builder().withAlarmMode(mode).withDurationInS(prealertTimeSec).build();
sendKeyPads(context, keypadSoaking);
}
public static void sendAlert(SubsystemContext<?> context, String tone) {
SubsystemUtils.sendTo(context, isSiren, alertSirenAttributes);
/*
* Sending a new play sounds request should preempt any existing ones executing on the hub
* Unfortunately this isn't happening and the TONE_ARMED request gets ignored. Sending
* The TONE_NO_SOUND request before the TONE_INTRUDER request fixes the issue.
*/
SubsystemUtils.sendTo(context, isHub, HubSoundsCapability.QuietRequest.instance());
MessageBody alertHubAttributes = HubSoundsCapability.PlayToneRequest.builder().withDurationSec(ALERT_TIMEOUT_SEC).withTone(tone).build();
SubsystemUtils.sendTo(context, isHub, alertHubAttributes);
}
protected void sendKeyPads(SubsystemContext<?> context, MessageBody request) {
SubsystemUtils.sendTo(context, isKeypad, request);
}
protected Date getTimeout(SubsystemContext<?> context) {
return context.getVariable(getClreplaced().getName()).as(Date.clreplaced);
}
protected Date setTimeout(SubsystemContext<?> context, long timeout, TimeUnit unit) {
return SubsystemUtils.setTimeout(unit.toMillis(timeout), context, this.getClreplaced().getName());
}
protected void cancelTimeout(SubsystemContext<?> context) {
SubsystemUtils.clearTimeout(context, getClreplaced().getName());
}
protected void restoreTimeout(SubsystemContext<?> context) {
SubsystemUtils.restoreTimeout(context, getClreplaced().getName());
}
public String toString() {
return "AlarmState: [state=" + getName() + "]";
}
}
19
Source : AlarmSubsystemState.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected void sendArmed(SubsystemContext<?> context, String mode) {
MessageBody keypadArmed = KeyPadCapability.ArmedRequest.builder().withAlarmMode(mode).build();
sendKeyPads(context, keypadArmed);
}
19
Source : AlarmUtil.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public static String extractErrorMessage(MessageBody msg) {
if (msg != null && msg instanceof ErrorEvent) {
return ((ErrorEvent) msg).getMessage();
} else {
return "";
}
}
19
Source : SetAttributesPermissionExtractor.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
protected Collection<String> extractNames(MessageBody command) {
return command.getAttributes() != null ? command.getAttributes().keySet() : Collections.<String>emptySet();
}
19
Source : GetAttributesPermissionExtractor.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
protected Collection<String> extractNames(MessageBody command) {
Map<String, Object> arguments = command.getAttributes();
Collection<String> attributes = (Collection<String>) arguments.get(Capability.GetAttributesRequest.ATTR_NAMES);
// TODO: not sure what to do if no names are specified
return attributes == null ? Collections.<String>emptyList() : attributes;
}
19
Source : DefaultPermissionExtractor.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
protected Collection<String> extractNames(MessageBody command) {
return Collections.<String>singleton(command.getMessageType());
}
19
Source : AbstractPermissionExtractor.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public List<Permission> extractRequiredPermissions(PlatformMessage message) {
String objectId = message.getDestination().getId() == null ? "*" : String.valueOf(message.getDestination().getId());
MessageBody command = message.getValue();
return AuthzUtil.createPermissions(extractNames(command), getRequiredPermission(), objectId);
}
19
Source : TestDefaultDriver.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
protected void sendToDevice(MessageBody request) {
sendToDevice(request, null);
}
19
Source : TaggedEventBuilder.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public PlatformMessage build() {
MessageBody messageBody = TaggedEvent.builder().withName(tagName).withPlaceId(context == null ? null : context.getPlaceId().toString()).withSource(SOURCE_PLATFORM).withVersion(getApplicationVersion()).withServiceLevel(context == null ? null : context.getServiceLevel()).withContext(buildTagContext()).build();
return PlatformMessage.builder().from(source).withPlaceId(context == null ? null : context.getPlaceId()).withPopulation(context.getPopulation()).withPayload(messageBody).create();
}
19
Source : RemoveTagsModelRequestHandler.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public MessageBody handleRequest(Model model, PlatformMessage message) {
MessageBody request = message.getValue();
Set<String> tagsToRemove = Capability.AddTagsRequest.getTags(request);
Set<String> currentTags = (Set<String>) TYPE_STRING_SET.coerce(model.getAttribute(Capability.ATTR_TAGS));
// make it modifiable
Set<String> newTags = new HashSet<>(currentTags);
newTags.removeAll(tagsToRemove);
model.setAttribute(Capability.ATTR_TAGS, newTags);
return Capability.AddTagsResponse.instance();
}
19
Source : AddTagsModelRequestHandler.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public MessageBody handleRequest(Model model, PlatformMessage message) {
MessageBody request = message.getValue();
Set<String> tagsToAdd = Capability.AddTagsRequest.getTags(request);
Set<String> currentTags = (Set<String>) TYPE_STRING_SET.coerce(model.getAttribute(Capability.ATTR_TAGS));
if (currentTags == null) {
currentTags = ImmutableSet.of();
}
// make it modifiable
Set<String> newTags = new HashSet<>(currentTags);
newTags.addAll(tagsToAdd);
model.setAttribute(Capability.ATTR_TAGS, newTags);
return Capability.AddTagsResponse.instance();
}
19
Source : ContextualPlatformMessageDispatcher.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
protected PlatformMessage getResponse(PlatformMessage message, MessageBody response) {
return PlatformMessage.buildResponse(message, response).create();
}
19
Source : AbstractMessageListener.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
/**
* Handle the message and create a response. If the message is a type that can't be handled
* then return an unsupported message type error.
* @param body body of the message
* @return the result of handling the request
*/
protected MessageBody handleRequest(MessageBody body) throws Exception {
logger.trace("[{}] returning an error for an unexpected request: {}", this, body);
return Errors.unsupportedMessageType(body.getMessageType());
}
19
Source : ReflectiveCommandHandler.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public Object[] toArgs(DeviceDriverContext context, MessageBody command) {
Object[] args = new Object[matchers.size()];
for (int i = 0; i < matchers.size(); i++) {
args[i] = matchers.get(i).getArgument(context, command);
}
return args;
}
19
Source : TestDirectiveTransformerUnlock.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public clreplaced TestDirectiveTransformerUnlock {
private Model lockModel;
private AlexaConfig config;
private MessageBody request;
@Before
public void setup() {
lockModel = new SimpleModel();
lockModel.setAttribute(Capability.ATTR_CAPS, ImmutableSet.of(DoorLockCapability.NAMESPACE, DeviceAdvancedCapability.NAMESPACE));
config = new AlexaConfig();
request = AlexaService.ExecuteRequest.builder().withDirective(AlexaInterfaces.LockController.REQUEST_UNLOCK).build();
}
@Test
public void testUnlockBusyLocking() {
lockModel.setAttribute(DoorLockCapability.ATTR_LOCKSTATE, DoorLockCapability.LOCKSTATE_LOCKING);
try {
DirectiveTransformer.transformerFor(request).txfmRequest(request, lockModel, config);
} catch (AlexaException ae) {
replacedertEquals(AlexaErrors.TYPE_ENDPOINT_BUSY, ae.getErrorMessage().getAttributes().get("type"));
}
}
@Test
public void testUnlockBusyUnlocking() {
lockModel.setAttribute(DoorLockCapability.ATTR_LOCKSTATE, DoorLockCapability.LOCKSTATE_UNLOCKING);
try {
DirectiveTransformer.transformerFor(request).txfmRequest(request, lockModel, config);
} catch (AlexaException ae) {
replacedertEquals(AlexaErrors.TYPE_ENDPOINT_BUSY, ae.getErrorMessage().getAttributes().get("type"));
}
}
@Test
public void testUnlockJammed() {
lockModel.setAttribute(DeviceAdvancedCapability.ATTR_ERRORS, ImmutableMap.of("WARN_JAM", "jammed"));
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(request).txfmRequest(request, lockModel, config);
replacedertFalse(optBody.isPresent());
}
@Test
public void testUnlockAlreadyUnlocked() {
lockModel.setAttribute(DoorLockCapability.ATTR_LOCKSTATE, DoorLockCapability.LOCKSTATE_UNLOCKED);
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(request).txfmRequest(request, lockModel, config);
replacedertFalse(optBody.isPresent());
}
@Test
public void testUnlockLocked() {
lockModel.setAttribute(DoorLockCapability.ATTR_LOCKSTATE, DoorLockCapability.LOCKSTATE_LOCKED);
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(request).txfmRequest(request, lockModel, config);
replacedertTrue(optBody.isPresent());
MessageBody body = optBody.get();
replacedertEquals(Capability.CMD_SET_ATTRIBUTES, body.getMessageType());
replacedertEquals(1, body.getAttributes().size());
replacedertEquals(DoorLockCapability.LOCKSTATE_UNLOCKED, DoorLockCapability.getLockstate(body));
}
}
19
Source : TestDirectiveTransformerTurnOn.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public clreplaced TestDirectiveTransformerTurnOn {
private Model switchModel;
private Model dimmerModel;
private Model lightModel;
private AlexaConfig config;
private MessageBody request;
@Before
public void setup() {
switchModel = new SimpleModel();
switchModel.setAttribute(Capability.ATTR_CAPS, ImmutableSet.of(SwitchCapability.NAMESPACE));
dimmerModel = new SimpleModel();
dimmerModel.setAttribute(Capability.ATTR_CAPS, ImmutableSet.of(SwitchCapability.NAMESPACE, DimmerCapability.NAMESPACE));
lightModel = new SimpleModel();
lightModel.setAttribute(Capability.ATTR_CAPS, ImmutableSet.of(SwitchCapability.NAMESPACE, DimmerCapability.NAMESPACE, LightCapability.NAMESPACE));
config = new AlexaConfig();
request = AlexaService.ExecuteRequest.builder().withDirective(AlexaInterfaces.PowerController.REQUEST_TURNON).build();
}
@Test
public void testTurnOnSwitchOff() {
switchModel.setAttribute(SwitchCapability.ATTR_STATE, SwitchCapability.STATE_OFF);
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(request).txfmRequest(request, switchModel, config);
replacedertTrue(optBody.isPresent());
MessageBody body = optBody.get();
replacedertEquals(Capability.CMD_SET_ATTRIBUTES, body.getMessageType());
replacedertEquals(SwitchCapability.STATE_ON, body.getAttributes().get(SwitchCapability.ATTR_STATE));
}
@Test
public void testTurnOnSwitchOn() {
switchModel.setAttribute(SwitchCapability.ATTR_STATE, SwitchCapability.STATE_ON);
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(request).txfmRequest(request, switchModel, config);
replacedertFalse(optBody.isPresent());
}
@Test
public void testTurnOnDimmerAt100() {
dimmerModel.setAttribute(SwitchCapability.ATTR_STATE, SwitchCapability.STATE_OFF);
dimmerModel.setAttribute(DimmerCapability.ATTR_BRIGHTNESS, 100);
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(request).txfmRequest(request, dimmerModel, config);
replacedertTrue(optBody.isPresent());
MessageBody body = optBody.get();
replacedertEquals(Capability.CMD_SET_ATTRIBUTES, body.getMessageType());
replacedertEquals(SwitchCapability.STATE_ON, body.getAttributes().get(SwitchCapability.ATTR_STATE));
replacedertNull(body.getAttributes().get(DimmerCapability.ATTR_BRIGHTNESS));
}
@Test
public void testTurnOnDimmerNot100() {
dimmerModel.setAttribute(SwitchCapability.ATTR_STATE, SwitchCapability.STATE_OFF);
dimmerModel.setAttribute(DimmerCapability.ATTR_BRIGHTNESS, 50);
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(request).txfmRequest(request, dimmerModel, config);
replacedertTrue(optBody.isPresent());
MessageBody body = optBody.get();
replacedertEquals(Capability.CMD_SET_ATTRIBUTES, body.getMessageType());
replacedertEquals(SwitchCapability.STATE_ON, body.getAttributes().get(SwitchCapability.ATTR_STATE));
replacedertEquals(100, body.getAttributes().get(DimmerCapability.ATTR_BRIGHTNESS));
}
@Test
public void testTurnOnLightNot100Stays() {
lightModel.setAttribute(SwitchCapability.ATTR_STATE, SwitchCapability.STATE_OFF);
lightModel.setAttribute(DimmerCapability.ATTR_BRIGHTNESS, 50);
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(request).txfmRequest(request, lightModel, config);
replacedertTrue(optBody.isPresent());
MessageBody body = optBody.get();
replacedertEquals(Capability.CMD_SET_ATTRIBUTES, body.getMessageType());
replacedertEquals(SwitchCapability.STATE_ON, body.getAttributes().get(SwitchCapability.ATTR_STATE));
replacedertNull(body.getAttributes().get(DimmerCapability.ATTR_BRIGHTNESS));
}
}
19
Source : TestDirectiveTransformerTurnOff.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public clreplaced TestDirectiveTransformerTurnOff {
private Model switchModel;
private AlexaConfig config;
private MessageBody request;
@Before
public void setup() {
switchModel = new SimpleModel();
switchModel.setAttribute(Capability.ATTR_CAPS, ImmutableSet.of(SwitchCapability.NAMESPACE));
config = new AlexaConfig();
request = AlexaService.ExecuteRequest.builder().withDirective(AlexaInterfaces.PowerController.REQUEST_TURNOFF).build();
}
@Test
public void testTurnOffSwitchOn() {
switchModel.setAttribute(SwitchCapability.ATTR_STATE, SwitchCapability.STATE_ON);
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(request).txfmRequest(request, switchModel, config);
replacedertTrue(optBody.isPresent());
MessageBody body = optBody.get();
replacedertEquals(Capability.CMD_SET_ATTRIBUTES, body.getMessageType());
replacedertEquals(SwitchCapability.STATE_OFF, body.getAttributes().get(SwitchCapability.ATTR_STATE));
}
@Test
public void testTurnOffSwitchOff() {
switchModel.setAttribute(SwitchCapability.ATTR_STATE, SwitchCapability.STATE_OFF);
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(request).txfmRequest(request, switchModel, config);
replacedertFalse(optBody.isPresent());
}
}
19
Source : TestDirectiveTransformerReportState.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public clreplaced TestDirectiveTransformerReportState {
private Model model;
private AlexaConfig config;
private MessageBody reportState;
@Before
public void setup() {
model = new SimpleModel();
model.setAttribute(Capability.ATTR_CAPS, ImmutableSet.of(DeviceCapability.NAMESPACE));
config = new AlexaConfig();
reportState = AlexaService.ExecuteRequest.builder().withDirective(AlexaInterfaces.REQUEST_REPORTSTATE).build();
}
@Test
public void testReportState() {
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(reportState).txfmRequest(reportState, model, config);
replacedertFalse(optBody.isPresent());
}
}
19
Source : TestDirectiveTransformerLock.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public clreplaced TestDirectiveTransformerLock {
private Model lockModel;
private AlexaConfig config;
private MessageBody request;
@Before
public void setup() {
lockModel = new SimpleModel();
lockModel.setAttribute(Capability.ATTR_CAPS, ImmutableSet.of(DoorLockCapability.NAMESPACE, DeviceAdvancedCapability.NAMESPACE));
config = new AlexaConfig();
request = AlexaService.ExecuteRequest.builder().withDirective(AlexaInterfaces.LockController.REQUEST_LOCK).build();
}
@Test
public void testLockBusyLocking() {
lockModel.setAttribute(DoorLockCapability.ATTR_LOCKSTATE, DoorLockCapability.LOCKSTATE_LOCKING);
try {
DirectiveTransformer.transformerFor(request).txfmRequest(request, lockModel, config);
} catch (AlexaException ae) {
replacedertEquals(AlexaErrors.TYPE_ENDPOINT_BUSY, ae.getErrorMessage().getAttributes().get("type"));
}
}
@Test
public void testLockBusyUnlocking() {
lockModel.setAttribute(DoorLockCapability.ATTR_LOCKSTATE, DoorLockCapability.LOCKSTATE_UNLOCKING);
try {
DirectiveTransformer.transformerFor(request).txfmRequest(request, lockModel, config);
} catch (AlexaException ae) {
replacedertEquals(AlexaErrors.TYPE_ENDPOINT_BUSY, ae.getErrorMessage().getAttributes().get("type"));
}
}
@Test
public void testLockJammed() {
lockModel.setAttribute(DeviceAdvancedCapability.ATTR_ERRORS, ImmutableMap.of("WARN_JAM", "jammed"));
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(request).txfmRequest(request, lockModel, config);
replacedertFalse(optBody.isPresent());
}
@Test
public void testLockAlreadyLocked() {
lockModel.setAttribute(DoorLockCapability.ATTR_LOCKSTATE, DoorLockCapability.LOCKSTATE_LOCKED);
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(request).txfmRequest(request, lockModel, config);
replacedertFalse(optBody.isPresent());
}
@Test
public void testLockUnlocked() {
lockModel.setAttribute(DoorLockCapability.ATTR_LOCKSTATE, DoorLockCapability.LOCKSTATE_UNLOCKED);
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(request).txfmRequest(request, lockModel, config);
replacedertTrue(optBody.isPresent());
MessageBody body = optBody.get();
replacedertEquals(Capability.CMD_SET_ATTRIBUTES, body.getMessageType());
replacedertEquals(1, body.getAttributes().size());
replacedertEquals(DoorLockCapability.LOCKSTATE_LOCKED, DoorLockCapability.getLockstate(body));
}
}
19
Source : TestDirectiveTransformerActivate.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public clreplaced TestDirectiveTransformerActivate {
private Model sceneModel;
private AlexaConfig config;
private MessageBody activate;
@Before
public void setup() {
Action a = new Action();
a.setTemplate("switches");
a.setContext(ImmutableMap.of(Address.platformDriverAddress(UUID.randomUUID()).getRepresentation(), ImmutableMap.of("switch", "ON")));
sceneModel = new SimpleModel();
sceneModel.setAttribute(SceneCapability.ATTR_NAME, "test");
sceneModel.setAttribute(SceneCapability.ATTR_ENABLED, true);
sceneModel.setAttribute(Capability.ATTR_CAPS, ImmutableSet.of(SceneCapability.NAMESPACE));
sceneModel.setAttribute(SceneCapability.ATTR_ACTIONS, ImmutableList.of(a.toMap()));
config = new AlexaConfig();
activate = AlexaService.ExecuteRequest.builder().withDirective(AlexaInterfaces.SceneController.REQUEST_ACTIVATE).build();
}
@Test
public void testActivate() {
Optional<MessageBody> optBody = DirectiveTransformer.transformerFor(activate).txfmRequest(activate, sceneModel, config);
replacedertTrue(optBody.isPresent());
MessageBody body = optBody.get();
replacedertEquals(SceneCapability.FireRequest.NAME, body.getMessageType());
}
@Test
public void testActivateForbidden() {
Action a = new Action();
a.setTemplate("doorlocks");
a.setContext(ImmutableMap.of(Address.platformDriverAddress(UUID.randomUUID()).getRepresentation(), ImmutableMap.of("lockstate", "UNLOCKED")));
sceneModel.setAttribute(SceneCapability.ATTR_ACTIONS, ImmutableList.of(a.toMap()));
try {
DirectiveTransformer.transformerFor(activate).txfmRequest(activate, sceneModel, config);
} catch (AlexaException ae) {
replacedertEquals(AlexaErrors.TYPE_INVALID_VALUE, ae.getErrorMessage().getAttributes().get("type"));
}
}
@Test
public void testResponse() {
Map<String, Object> resp = DirectiveTransformer.transformerFor(activate).txfmResponse(sceneModel, null, config);
replacedertNotNull(resp.get("cause"));
replacedertNotNull(resp.get("timestamp"));
Map<String, Object> cause = (Map<String, Object>) resp.get("cause");
AlexaCause c = new AlexaCause(cause);
replacedertEquals("VOICE_INTERACTION", c.getType());
}
}
19
Source : ProactiveReporter.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public void onMessage(VoiceContext context, Model m, MessageBody body) {
if (!context.hasreplacedistants()) {
return;
}
context.getreplacedistants().forEach(replacedistant -> {
ProactiveReportHandler handler = handlers.get(replacedistant);
if (handler != null) {
executor.execute(() -> {
if (handler.isInterestedIn(context, m, body)) {
handler.report(context, m, body);
}
});
}
});
}
19
Source : ReportStateHandler.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
/**
* Only send the Report State if an attribute Google is tracking has changed. See {@link Transformers#modelToStateMap(Model, boolean, boolean, ProductCatalogEntry)} for reference.
*/
private boolean hasInterestingReportStateAttribute(MessageBody body) {
Map<String, Object> attributes = body.getAttributes();
if (attributes.keySet().stream().noneMatch(interestingAttributes::contains)) {
return false;
}
return true;
}
19
Source : ReportStateHandler.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public void report(VoiceContext context, Model m, MessageBody body) {
homegraph.sendReportState(context);
}
19
Source : ReportStateHandler.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public boolean isInterestedIn(VoiceContext context, Model m, MessageBody body) {
boolean whitelisted = whitelist.isWhitelisted(context.getPlaceId());
ProductCatalogEntry entry = VoiceUtil.getProduct(prodCat, m);
switch(body.getMessageType()) {
// case Capability.EVENT_ADDED: // When adding and deleting devices, the ReportState needs to come after the SYNC response. (Note, this is different than the SYNC request)
// case Capability.EVENT_DELETED: // Report State is triggered in RequestHandler#handleSync
case Capability.EVENT_VALUE_CHANGE:
return hasInterestingReportStateAttribute(body) && Predicates.isSupportedModel(m, whitelisted, entry);
default:
return false;
}
}
19
Source : GoogleProactiveReportHandler.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public boolean isInterestedIn(VoiceContext context, Model m, MessageBody body) {
return this.handlers.stream().anyMatch(handler -> handler.isInterestedIn(context, m, body));
}
19
Source : GoogleProactiveReportHandler.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Override
public void report(VoiceContext context, Model m, MessageBody body) {
this.handlers.stream().forEach(handler -> {
if (handler.isInterestedIn(context, m, body)) {
handler.report(context, m, body);
}
});
}
19
Source : DeferredCorrelator.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public synchronized boolean complete(MessageBody body) {
expectedAttributes.removeAll(body.getAttributes().keySet());
if (expectedAttributes.isEmpty()) {
return true;
}
Map<String, String> errors = DeviceAdvancedCapability.getErrors(body);
if (errors == null) {
return false;
}
if (errors.isEmpty()) {
return false;
}
if (!Sets.intersection(completableDevAdvErrors, errors.keySet()).isEmpty()) {
expectedAttributes.clear();
return true;
}
return false;
}
19
Source : VideoServiceUtil.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public static UUID getAccountId(PlatformMessage message, MessageBody body) {
String accountId = null;
String attrId = null;
switch(message.getMessageType()) {
case StartRecordingRequest.NAME:
accountId = StartRecordingRequest.getAccountId(body);
attrId = StartRecordingRequest.ATTR_ACCOUNTID;
break;
}
Errors.replacedertRequiredParam(accountId, attrId);
return UUID.fromString(accountId);
}
19
Source : VideoServiceUtil.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public static UUID getPlaceId(PlatformMessage message, MessageBody body) {
String placeId;
String attrId;
switch(message.getMessageType()) {
case ListRecordingsRequest.NAME:
placeId = ListRecordingsRequest.getPlaceId(body);
attrId = ListRecordingsRequest.ATTR_PLACEID;
break;
case PageRecordingsRequest.NAME:
placeId = PageRecordingsRequest.getPlaceId(body);
attrId = PageRecordingsRequest.ATTR_PLACEID;
break;
case StartRecordingRequest.NAME:
placeId = StartRecordingRequest.getPlaceId(body);
attrId = StartRecordingRequest.ATTR_PLACEID;
break;
case StopRecordingRequest.NAME:
placeId = StopRecordingRequest.getPlaceId(body);
attrId = StopRecordingRequest.ATTR_PLACEID;
break;
case GetQuotaRequest.NAME:
placeId = GetQuotaRequest.getPlaceId(body);
attrId = GetQuotaRequest.ATTR_PLACEID;
break;
case GetFavoriteQuotaRequest.NAME:
placeId = GetFavoriteQuotaRequest.getPlaceId(body);
attrId = GetFavoriteQuotaRequest.ATTR_PLACEID;
break;
case DeleteAllRequest.NAME:
placeId = DeleteAllRequest.getPlaceId(body);
attrId = DeleteAllRequest.ATTR_PLACEID;
break;
case RefreshQuotaRequest.NAME:
placeId = RefreshQuotaRequest.getPlaceId(body);
attrId = RefreshQuotaRequest.ATTR_PLACEID;
break;
default:
return UUID.fromString(message.getPlaceId());
}
Errors.replacedertRequiredParam(placeId, attrId);
Errors.replacedertPlaceMatches(message, placeId);
return UUID.fromString(placeId);
}
19
Source : VideoServiceUtil.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
public static UUID getRecordingId(PlatformMessage message, MessageBody body) {
Object id = message.getDestination().getId();
if (id == null || !(id instanceof UUID)) {
throw new NotFoundException(message.getDestination());
}
return (UUID) id;
}
19
Source : TestSearching_HubZWave.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Test
public void testFactoryResetHubOffline() {
// send the request
{
Optional<MessageBody> response = factoryReset();
// no response until the hub responds
replacedertEquals(Optional.empty(), response);
replacedertSearchingHubNotFound(productAddress);
replacedertStopPairingRequestSent(hub.getAddress());
}
// complete the action
{
SendAndExpect request = popRequest();
replacedertStartUnpairingRequestSent(hub.getAddress(), request);
request.getAction().onTimeout(context);
MessageBody response = responses.getValues().get(responses.getValues().size() - 1);
replacedertError(FactoryResetResponse.CODE_HUB_OFFLINE, response);
replacedertSearchingHubNotFound(productAddress);
}
}
19
Source : TestIdleState_OtherRequests.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Test
public void testDismissAll() {
MessageBody response = dismissAll().get();
replacedertEquals(DismissAllResponse.NAME, response.getMessageType());
replacedertEquals(ImmutableList.of(), response.getAttributes().get(DismissAllResponse.ATTR_ACTIONS));
replacedertIdle();
}
19
Source : TestIdleState_OtherRequests.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Test
public void testFactoryReset() {
MessageBody response = factoryReset().get();
replacedertError(FactoryResetResponse.CODE_REQUEST_STATE_INVALID, response);
replacedertIdle();
}
19
Source : TestIdleState_OtherRequests.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Test
public void testListHelpSteps() {
MessageBody response = listHelpSteps().get();
replacedertError(ListHelpStepsResponse.CODE_REQUEST_STATE_INVALID, response);
replacedertIdle();
}
19
Source : TestIdleState_OtherRequests.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
@Test
public void testStopSearching() {
MessageBody response = stopSearching().get();
replacedertEquals(StopSearchingResponse.instance(), response);
replacedertIdle();
}
19
Source : OfflineNotificationsHandler.java
with Apache License 2.0
from arcus-smart-home
with Apache License 2.0
from arcus-smart-home
private void broadcastDeviceOfflineEvent(ConnectionCapableDevice device, SubsystemContext<PlaceMonitorSubsystemModel> context) {
MessageBody body = PlaceMonitorSubsystemCapability.DeviceOfflineEvent.builder().withDeviceAddress(device.getAddress().getRepresentation()).withLastOnlineTime(device.getLastChange()).build();
context.broadcast(body);
}
See More Examples