-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Expand file tree
/
Copy pathInstrumentationProxyHelperTest.java
More file actions
38 lines (29 loc) · 1.07 KB
/
InstrumentationProxyHelperTest.java
File metadata and controls
38 lines (29 loc) · 1.07 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
/*
* Copyright The OpenTelemetry Authors
* SPDX-License-Identifier: Apache-2.0
*/
package io.opentelemetry.javaagent.bootstrap;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import org.junit.jupiter.api.Test;
class InstrumentationProxyHelperTest {
@Test
void wrongType() {
assertThatThrownBy(() -> InstrumentationProxyHelper.unwrapIfNeeded("", Integer.class))
.isInstanceOf(IllegalArgumentException.class);
assertThatThrownBy(() -> InstrumentationProxyHelper.unwrapIfNeeded(proxy(""), Integer.class))
.isInstanceOf(IllegalArgumentException.class);
}
@Test
void unwrap() {
// no wrapping
Number number = InstrumentationProxyHelper.unwrapIfNeeded(42, Number.class);
assertThat(number).isEqualTo(42);
// unwrap needed
String string = InstrumentationProxyHelper.unwrapIfNeeded(proxy("hello"), String.class);
assertThat(string).isEqualTo("hello");
}
private static InstrumentationProxy proxy(Object delegate) {
return () -> delegate;
}
}