Skip to content

Commit 640c2f3

Browse files
committed
improve
1 parent 8669bcc commit 640c2f3

File tree

1 file changed

+30
-55
lines changed

1 file changed

+30
-55
lines changed

muzzle/src/test/java/io/opentelemetry/javaagent/tooling/muzzle/HelperReferenceWrapperTest.java

Lines changed: 30 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
package io.opentelemetry.javaagent.tooling.muzzle;
77

88
import static org.assertj.core.api.Assertions.assertThat;
9-
import static org.assertj.core.api.Assertions.atIndex;
109

1110
import io.opentelemetry.javaagent.tooling.muzzle.references.ClassRef;
1211
import io.opentelemetry.javaagent.tooling.muzzle.references.Flag;
@@ -74,105 +73,81 @@ void shouldWrapHelperTypes() {
7473
assertThat(helperWrapper.isAbstract()).isFalse();
7574

7675
assertThat(helperWrapper.getMethods())
77-
.hasSize(1)
78-
.satisfies(
76+
.satisfiesExactly(
7977
method -> {
8078
assertThat(method.isAbstract()).isFalse();
8179
assertThat(method.getName()).isEqualTo("bar");
8280
assertThat(method.getDescriptor()).isEqualTo("()V");
83-
},
84-
atIndex(0));
81+
});
8582

8683
assertThat(helperWrapper.getFields())
87-
.hasSize(1)
88-
.satisfies(
84+
.satisfiesExactly(
8985
field -> {
9086
assertThat(field.getName()).isEqualTo("declaredField");
9187
assertThat(field.getDescriptor()).isEqualTo("Ljava/lang/Object;");
92-
},
93-
atIndex(0));
88+
});
9489

9590
assertThat(helperWrapper.hasSuperTypes()).isTrue();
9691
assertThat(helperWrapper.getSuperTypes())
97-
.hasSize(2)
98-
.satisfies(
92+
.satisfiesExactly(
9993
baseHelper -> {
10094
assertThat(baseHelper.isAbstract()).isTrue();
10195
assertThat(baseHelper.getMethods())
102-
.hasSize(2)
103-
.satisfies(
96+
.satisfiesExactly(
10497
method -> {
10598
assertThat(method.isAbstract()).isFalse();
10699
assertThat(method.getName()).isEqualTo("foo");
107100
assertThat(method.getDescriptor()).isEqualTo("()V");
108101
},
109-
atIndex(0))
110-
.satisfies(
111102
method -> {
112103
assertThat(method.isAbstract()).isTrue();
113104
assertThat(method.getName()).isEqualTo("abstract");
114105
assertThat(method.getDescriptor()).isEqualTo("()I");
115-
},
116-
atIndex(1));
106+
});
117107

118108
assertThat(baseHelper.hasSuperTypes()).isTrue();
119109
assertThat(baseHelper.getSuperTypes())
120-
.hasSize(1)
121-
.satisfies(
122-
abstractClasspathType -> {
123-
assertThat(abstractClasspathType.isAbstract()).isTrue();
124-
assertThat(abstractClasspathType.getMethods()).isEmpty();
125-
126-
assertThat(abstractClasspathType.getFields())
127-
.hasSize(1)
128-
.satisfies(
110+
.satisfiesExactly(
111+
helperReferenceWrapper -> {
112+
assertThat(helperReferenceWrapper.isAbstract()).isTrue();
113+
assertThat(helperReferenceWrapper.getMethods()).isEmpty();
114+
115+
assertThat(helperReferenceWrapper.getFields())
116+
.satisfiesExactly(
129117
field -> {
130118
assertThat(field.getName()).isEqualTo("field");
131119
assertThat(field.getDescriptor()).isEqualTo("Ljava/lang/Object;");
132-
},
133-
atIndex(0));
120+
});
134121

135-
assertThat(abstractClasspathType.hasSuperTypes()).isTrue();
136-
assertThat(abstractClasspathType.getSuperTypes())
137-
.hasSize(2)
138-
.satisfies(
122+
assertThat(helperReferenceWrapper.hasSuperTypes()).isTrue();
123+
assertThat(helperReferenceWrapper.getSuperTypes())
124+
.satisfiesExactly(
139125
wrapper -> assertThat(wrapper.hasSuperTypes()).isFalse(),
140-
atIndex(0))
141-
.satisfies(
142126
wrapper -> {
143127
assertThat(wrapper.isAbstract()).isTrue();
144128
assertThat(wrapper.getMethods())
145-
.hasSize(1)
146-
.satisfies(
129+
.satisfiesExactly(
147130
method -> {
148131
assertThat(method.isAbstract()).isTrue();
149132
assertThat(method.getName()).isEqualTo("foo");
150133
assertThat(method.getDescriptor()).isEqualTo("()V");
151-
},
152-
atIndex(0));
134+
});
153135
assertThat(wrapper.hasSuperTypes()).isFalse();
154136
assertThat(wrapper.getSuperTypes()).isEmpty();
155-
},
156-
atIndex(1));
157-
},
158-
atIndex(0));
137+
});
138+
});
159139
},
160-
atIndex(0))
161-
.satisfies(
162-
interface2 -> {
163-
assertThat(interface2.isAbstract()).isTrue();
164-
assertThat(interface2.getMethods())
165-
.hasSize(1)
166-
.satisfies(
140+
wrapper -> {
141+
assertThat(wrapper.isAbstract()).isTrue();
142+
assertThat(wrapper.getMethods())
143+
.satisfiesExactly(
167144
method -> {
168145
assertThat(method.isAbstract()).isTrue();
169146
assertThat(method.getName()).isEqualTo("bar");
170147
assertThat(method.getDescriptor()).isEqualTo("()V");
171-
},
172-
atIndex(0));
173-
assertThat(interface2.hasSuperTypes()).isFalse();
174-
assertThat(interface2.getSuperTypes()).isEmpty();
175-
},
176-
atIndex(1));
148+
});
149+
assertThat(wrapper.hasSuperTypes()).isFalse();
150+
assertThat(wrapper.getSuperTypes()).isEmpty();
151+
});
177152
}
178153
}

0 commit comments

Comments
 (0)