-
Notifications
You must be signed in to change notification settings - Fork 3.9k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(iotevents): allow setting description, evaluation method and key of DetectorModel #18644
Changes from all commits
49b3387
3dc2d35
3ee41a6
dba6fd4
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -76,10 +76,15 @@ test('can get detector model name', () => { | |
}); | ||
}); | ||
|
||
test('can set physical name', () => { | ||
test.each([ | ||
['physical name', { detectorModelName: 'test-detector-model' }, { DetectorModelName: 'test-detector-model' }], | ||
['description', { description: 'test-detector-model-description' }, { DetectorModelDescription: 'test-detector-model-description' }], | ||
['evaluationMethod', { evaluationMethod: iotevents.EventEvaluation.SERIAL }, { EvaluationMethod: 'SERIAL' }], | ||
['detectorKey', { detectorKey: 'payload.deviceId' }, { Key: 'payload.deviceId' }], | ||
])('can set %s', (_, partialProps, expected) => { | ||
// WHEN | ||
new iotevents.DetectorModel(stack, 'MyDetectorModel', { | ||
detectorModelName: 'test-detector-model', | ||
...partialProps, | ||
initialState: new iotevents.State({ | ||
stateName: 'test-state', | ||
onEnter: [{ | ||
|
@@ -90,9 +95,7 @@ test('can set physical name', () => { | |
}); | ||
|
||
// THEN | ||
Template.fromStack(stack).hasResourceProperties('AWS::IoTEvents::DetectorModel', { | ||
DetectorModelName: 'test-detector-model', | ||
}); | ||
Template.fromStack(stack).hasResourceProperties('AWS::IoTEvents::DetectorModel', expected); | ||
}); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's just do all 3 in one test. Spreading them out like that just makes the tests longer, it doesn't really improve coverage in any way. |
||
|
||
test('can set multiple events to State', () => { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,7 +7,7 @@ class TestStack extends cdk.Stack { | |
|
||
const input = new iotevents.Input(this, 'MyInput', { | ||
inputName: 'test_input', | ||
attributeJsonPaths: ['payload.temperature'], | ||
attributeJsonPaths: ['payload.deviceId', 'payload.temperature'], | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, why are we changing existing things? |
||
}); | ||
|
||
const onlineState = new iotevents.State({ | ||
|
@@ -27,6 +27,9 @@ class TestStack extends cdk.Stack { | |
|
||
new iotevents.DetectorModel(this, 'MyDetectorModel', { | ||
detectorModelName: 'test-detector-model', | ||
description: 'test-detector-model-description', | ||
evaluationMethod: iotevents.EventEvaluation.SERIAL, | ||
detectorKey: 'payload.deviceId', | ||
initialState: onlineState, | ||
}); | ||
} | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why this change - seems unrelated to the rest of this PR...?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I modified this for the sake of reality.
The path passed in
detectorKey
must be declared in thisattributeJsonPaths
. And the value passed indetectorKey
is often the unique value of the device or device group.This is because IoT Events is often used to monitor devices and device groups.
I modified integ test for the same reason.