Skip to content

Commit cbe8eb4

Browse files
Refactored AssertJ, Hamcrest and Google.Truth to Junit5.Assertions. (#9556)
1 parent 28bb458 commit cbe8eb4

File tree

36 files changed

+367
-368
lines changed

36 files changed

+367
-368
lines changed

buildSrc/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,6 @@ testing {
7676
val integTest by registering(JvmTestSuite::class) {
7777
dependencies {
7878
implementation(gradleTestKit())
79-
implementation("org.assertj:assertj-core:3.25.3")
8079
}
8180
// Makes the gradle plugin publish its declared plugins to this source set
8281
gradlePlugin.testSourceSet(sources)

buildSrc/src/integTest/kotlin/datadog/gradle/plugin/version/TracerVersionIntegrationTest.kt

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
package datadog.gradle.plugin.version
22

3-
import org.assertj.core.api.Assertions.assertThat
43
import org.gradle.testkit.runner.GradleRunner
5-
import org.junit.jupiter.api.Disabled
4+
import org.junit.jupiter.api.Assertions.assertEquals
65
import org.junit.jupiter.api.Test
7-
import org.junit.jupiter.api.io.CleanupMode
86
import org.junit.jupiter.api.io.TempDir
97
import java.io.File
108
import java.io.IOException
@@ -289,7 +287,7 @@ class TracerVersionIntegrationTest {
289287
// .withDebug(true)
290288
.build()
291289

292-
assertThat(buildResult.output).isEqualToIgnoringNewLines(expectedVersion)
290+
assertEquals(expectedVersion, buildResult.output.lines().first())
293291
}
294292

295293
private fun exec(workingDirectory: File, vararg args: String) {

communication/build.gradle.kts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,6 @@ dependencies {
2323

2424
testImplementation(project(":utils:test-utils"))
2525
testImplementation(libs.bundles.junit5)
26-
testImplementation(libs.truth)
2726
testImplementation(libs.bytebuddy)
2827
testImplementation("org.msgpack:msgpack-core:0.8.20")
2928
testImplementation("org.msgpack:jackson-dataformat-msgpack:0.8.20")
Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,31 +1,34 @@
11
package datadog.communication.http
22

3-
import com.google.common.truth.Truth
43
import okhttp3.Request
5-
import org.junit.jupiter.api.Assertions
64
import org.junit.jupiter.api.Test
75

6+
import static org.junit.jupiter.api.Assertions.assertFalse
7+
import static org.junit.jupiter.api.Assertions.assertThrows
8+
import static org.junit.jupiter.api.Assertions.assertTrue
9+
810
class SafeRequestBuilderTest {
911
Request.Builder testBuilder = new Request.Builder()
1012

1113
@Test
1214
void "test adding bad header"() {
1315
def name = 'bad'
1416
def password = 'very-secret-password'
15-
IllegalArgumentException ex = Assertions.assertThrows(IllegalArgumentException, {
17+
IllegalArgumentException ex = assertThrows(IllegalArgumentException, {
1618
testBuilder.url("http:localhost").addHeader(name, "$password\n")
1719
})
18-
Truth.assertThat(ex).hasMessageThat().contains(name)
19-
Truth.assertThat(ex).hasMessageThat().doesNotContain(password)
20+
assertTrue(ex.getMessage().contains(name))
21+
assertFalse(ex.getMessage().contains(password))
2022
}
23+
2124
@Test
2225
void "test adding bad header2"(){
2326
def name = '\u0019'
2427
def password = 'very-secret-password'
25-
IllegalArgumentException ex = Assertions.assertThrows(IllegalArgumentException, {
28+
IllegalArgumentException ex = assertThrows(IllegalArgumentException, {
2629
testBuilder.url("http:localhost").addHeader(name, "\u0080$password")
2730
})
28-
Truth.assertThat(ex).hasMessageThat().contains(name)
29-
Truth.assertThat(ex).hasMessageThat().doesNotContain(password)
31+
assertTrue(ex.getMessage().contains(name))
32+
assertFalse(ex.getMessage().contains(password))
3033
}
3134
}

dd-java-agent/agent-profiling/profiling-controller-openjdk/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ dependencies {
2626

2727
testImplementation libs.bundles.junit5
2828
testImplementation libs.bundles.mockito
29-
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '2.1'
3029
testImplementation files(project(':dd-java-agent:agent-profiling:profiling-controller-jfr').sourceSets.test.output)
3130
testImplementation project(':dd-java-agent:agent-profiling')
3231
}

dd-java-agent/agent-profiling/profiling-controller-openjdk/src/test/java/com/datadog/profiling/controller/openjdk/OpenJdkRecordingDataTest.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
package com.datadog.profiling.controller.openjdk;
22

3-
import static org.hamcrest.CoreMatchers.containsString;
4-
import static org.hamcrest.MatcherAssert.assertThat;
53
import static org.junit.jupiter.api.Assertions.assertEquals;
64
import static org.junit.jupiter.api.Assertions.assertNotNull;
5+
import static org.junit.jupiter.api.Assertions.assertTrue;
76
import static org.junit.jupiter.api.Assumptions.assumeFalse;
87
import static org.mockito.Mockito.verify;
98
import static org.mockito.Mockito.when;
@@ -76,7 +75,7 @@ public void testGetName() {
7675

7776
@Test
7877
public void testToString() {
79-
assertThat(recordingData.toString(), containsString(TEST_NAME));
78+
assertTrue(recordingData.toString().contains(TEST_NAME));
8079
}
8180

8281
@Test

dd-java-agent/agent-profiling/profiling-controller-oracle/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ dependencies {
2424

2525
testImplementation libs.bundles.junit5
2626
testImplementation libs.bundles.mockito
27-
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '2.1'
2827
testImplementation files(project(':dd-java-agent:agent-profiling:profiling-controller-jfr').sourceSets.test.output)
2928
testImplementation project(':dd-java-agent:agent-profiling')
3029
}

dd-java-agent/agent-profiling/profiling-controller-oracle/src/test/java/com/datadog/profiling/controller/oracle/JfrMBeanHelperTest.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,12 @@
11
package com.datadog.profiling.controller.oracle;
22

3-
import static org.junit.jupiter.api.Assertions.*;
3+
import static org.junit.jupiter.api.Assertions.assertDoesNotThrow;
4+
import static org.junit.jupiter.api.Assertions.assertEquals;
5+
import static org.junit.jupiter.api.Assertions.assertFalse;
6+
import static org.junit.jupiter.api.Assertions.assertNotEquals;
7+
import static org.junit.jupiter.api.Assertions.assertNotNull;
8+
import static org.junit.jupiter.api.Assertions.assertThrows;
9+
import static org.junit.jupiter.api.Assertions.assertTrue;
410

511
import com.datadog.profiling.controller.jfr.JfpUtils;
612
import java.io.IOException;

dd-java-agent/appsec/build.gradle

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,6 @@ dependencies {
2020
testImplementation libs.bytebuddy
2121
testImplementation project(':remote-config:remote-config-core')
2222
testImplementation project(':utils:test-utils')
23-
testImplementation group: 'org.hamcrest', name: 'hamcrest', version: '2.2'
2423
testImplementation group: 'com.flipkart.zjsonpatch', name: 'zjsonpatch', version: '0.4.11'
2524
testImplementation libs.logback.classic
2625
testImplementation libs.jackson.databind

dd-java-agent/appsec/src/test/groovy/com/datadog/appsec/ddwaf/WAFModuleSpecification.groovy

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,6 @@ import java.util.concurrent.atomic.AtomicLong
5555

5656
import static datadog.trace.api.config.AppSecConfig.APPSEC_OBFUSCATION_PARAMETER_KEY_REGEXP
5757
import static datadog.trace.api.config.AppSecConfig.APPSEC_OBFUSCATION_PARAMETER_VALUE_REGEXP
58-
import static org.hamcrest.Matchers.hasSize
5958

6059
class WAFModuleSpecification extends DDSpecification {
6160
@Shared
@@ -508,7 +507,7 @@ class WAFModuleSpecification extends DDSpecification {
508507
then:
509508
1 * ctx.getOrCreateWafContext(_, true, false)
510509
2 * tracer.activeSpan()
511-
1 * ctx.reportEvents(hasSize(1))
510+
1 * ctx.reportEvents({ it.size() == 1 })
512511
2 * ctx.getWafMetrics()
513512
1 * ctx.isWafContextClosed() >> false
514513
1 * ctx.closeWafContext()

0 commit comments

Comments
 (0)