Skip to content

Commit

Permalink
address commits
Browse files Browse the repository at this point in the history
  • Loading branch information
yamatatsu committed Mar 4, 2022
1 parent 9f7ddf7 commit c0ccdf8
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 60 deletions.
2 changes: 1 addition & 1 deletion packages/@aws-cdk/aws-iotevents/lib/state.ts
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ function toEventsJson(
scope: Construct,
actionBindOptions: ActionBindOptions,
events: Event[],
): CfnDetectorModel.EventProperty[] | undefined {
): CfnDetectorModel.EventProperty[] {
return events.map(event => ({
eventName: event.eventName,
condition: event.condition?.evaluate(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,25 +43,6 @@
"OnEnter": {
"Events": [
{
"Actions": [
{
"SetVariable": {
"Value": {
"Fn::Join": [
"",
[
"$input.",
{
"Ref": "MyInput08947B23"
},
".payload.temperature"
]
]
},
"VariableName": "temperature"
}
}
],
"Condition": {
"Fn::Join": [
"",
Expand All @@ -85,25 +66,6 @@
"OnInput": {
"TransitionEvents": [
{
"Actions": [
{
"SetVariable": {
"Value": {
"Fn::Join": [
"",
[
"$input.",
{
"Ref": "MyInput08947B23"
},
".payload.temperature"
]
]
},
"VariableName": "temperature"
}
}
],
"Condition": {
"Fn::Join": [
"",
Expand Down
23 changes: 2 additions & 21 deletions packages/@aws-cdk/aws-iotevents/test/integ.detector-model.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,3 @@
/**
* Stack verification steps:
* * put a message
* * aws iotevents-data batch-put-message --messages=messageId=(date | md5),inputName=test_input,payload=(echo '{"payload":{"temperature":31.9,"deviceId":"000"}}' | base64)
* * describe the detector
* * aws iotevents-data describe-detector --detector-model-name test-detector-model --key-value=000
* * verify `stateName` and `variables` of the detector
*/
import * as cdk from '@aws-cdk/core';
import * as iotevents from '../lib';

Expand All @@ -18,17 +10,6 @@ class TestStack extends cdk.Stack {
attributeJsonPaths: ['payload.deviceId', 'payload.temperature'],
});

const setTemperatureAction: iotevents.IAction = {
bind: () => ({
configuration: {
setVariable: {
variableName: 'temperature',
value: iotevents.Expression.inputAttribute(input, 'payload.temperature').evaluate(),
},
},
}),
};

const onlineState = new iotevents.State({
stateName: 'online',
onEnter: [{
Expand All @@ -41,20 +22,20 @@ class TestStack extends cdk.Stack {
iotevents.Expression.fromString('31.5'),
),
),
actions: [setTemperatureAction],
}],
});
const offlineState = new iotevents.State({
stateName: 'offline',
});

// 1st => 2nd
onlineState.transitionTo(offlineState, {
when: iotevents.Expression.eq(
iotevents.Expression.inputAttribute(input, 'payload.temperature'),
iotevents.Expression.fromString('12'),
),
executing: [setTemperatureAction],
});
// 2st => 1st
offlineState.transitionTo(onlineState, {
when: iotevents.Expression.eq(
iotevents.Expression.inputAttribute(input, 'payload.temperature'),
Expand Down

0 comments on commit c0ccdf8

Please sign in to comment.