Skip to content

Commit 386ae9b

Browse files
fix: with usage in tests
1 parent c650b84 commit 386ae9b

File tree

4 files changed

+24
-24
lines changed

4 files changed

+24
-24
lines changed

dd-java-agent/agent-iast/src/test/groovy/com/datadog/iast/propagation/CodecModuleTest.groovy

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,10 @@ class CodecModuleTest extends IastModuleImplTestBase {
290290
then:
291291
final helloTainted = to.get(hello)
292292
helloTainted.ranges.length == 1
293-
helloTainted.ranges.first().with {
294-
assert it.source.origin == (byte) 0
295-
assert it.source.name == 'name1'
296-
assert it.source.value == 'Hello'
293+
with(helloTainted.ranges.first()) {
294+
it.source.origin == (byte) 0
295+
it.source.name == 'name1'
296+
it.source.value == 'Hello'
297297
}
298298

299299
when:
@@ -303,10 +303,10 @@ class CodecModuleTest extends IastModuleImplTestBase {
303303
then:
304304
final worldTainted = to.get(world)
305305
worldTainted.ranges.length == 1
306-
worldTainted.ranges.first().with {
307-
assert it.source.origin == (byte) 1
308-
assert it.source.name == 'name2'
309-
assert it.source.value == 'World!'
306+
with(worldTainted.ranges.first()) {
307+
it.source.origin == (byte) 1
308+
it.source.name == 'name2'
309+
it.source.value == 'World!'
310310
}
311311
}
312312

dd-java-agent/agent-tooling/src/test/groovy/datadog/trace/agent/tooling/iast/IastPostProcessorFactoryTest.groovy

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -76,10 +76,10 @@ class IastPostProcessorFactoryTest extends DDSpecification {
7676
final metrics = collector.drain()
7777
assert metrics.size() == 1
7878
// one method has ben instrumented
79-
metrics.first().with {
80-
assert it.metric == IastMetric.INSTRUMENTED_SINK
81-
assert it.tags == ['vulnerability_type:SQL_INJECTION']
82-
assert it.value == 1L
79+
with(metrics.first()) {
80+
it.metric == IastMetric.INSTRUMENTED_SINK
81+
it.tags == ['vulnerability_type:SQL_INJECTION']
82+
it.value == 1L
8383
}
8484

8585
when: 'the advice is used'

dd-java-agent/appsec/src/test/groovy/com/datadog/appsec/event/data/UnionDataBundleSpecification.groovy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,15 +26,15 @@ class UnionDataBundleSpecification extends Specification {
2626
expect:
2727
assert it.hasNext() == true
2828

29-
it.next().with { e ->
30-
assert e.key == KnownAddresses.REQUEST_URI_RAW
31-
assert e.value == '/'
29+
with(it.next()) { e ->
30+
e.key == KnownAddresses.REQUEST_URI_RAW
31+
e.value == '/'
3232
}
3333

3434
assert it.hasNext() == true
35-
it.next().with { e ->
36-
assert e.key == KnownAddresses.REQUEST_SCHEME
37-
assert e.value == 'http'
35+
with(it.next()) { e ->
36+
e.key == KnownAddresses.REQUEST_SCHEME
37+
e.value == 'http'
3838
}
3939

4040
assert it.hasNext() == false

dd-smoke-tests/appsec/springboot/src/test/groovy/datadog/smoketest/appsec/AIGuardSmokeTest.groovy

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,13 @@ class AIGuardSmokeTest extends AbstractAppSecServerSmokeTest {
7474
assert span.meta.get('ai_guard.target') == 'prompt'
7575
final messages = span.metaStruct.get('ai_guard').messages as List<Map<String, Object>>
7676
assert messages.size() == 2
77-
messages[0].with {
78-
assert role == 'system'
79-
assert content == 'You are a beautiful AI'
77+
with(messages[0]) {
78+
role == 'system'
79+
content == 'You are a beautiful AI'
8080
}
81-
messages[1].with {
82-
assert role == 'user'
83-
assert content != null
81+
with(messages[1]) {
82+
role == 'user'
83+
content != null
8484
}
8585

8686
where:

0 commit comments

Comments
 (0)