Skip to content

Commit 3c532ba

Browse files
committed
improve
1 parent 834c051 commit 3c532ba

File tree

1 file changed

+38
-27
lines changed

1 file changed

+38
-27
lines changed

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

Lines changed: 38 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,12 @@ void shouldWrapHelperTypes() {
8686

8787
List<HelperReferenceWrapper.Field> helperFields =
8888
helperWrapper.getFields().collect(Collectors.toList());
89-
assertThat(helperFields).hasSize(1);
90-
HelperReferenceWrapper.Field declaredField = helperFields.get(0);
91-
assertThat(declaredField.getName()).isEqualTo("declaredField");
92-
assertThat(declaredField.getDescriptor()).isEqualTo("Ljava/lang/Object;");
89+
assertThat(helperFields)
90+
.hasSize(1)
91+
.satisfies(field -> {
92+
assertThat(field.getName()).isEqualTo("declaredField");
93+
assertThat(field.getDescriptor()).isEqualTo("Ljava/lang/Object;");
94+
}, atIndex(0));
9395

9496
assertThat(helperWrapper.hasSuperTypes()).isTrue();
9597
List<HelperReferenceWrapper> superTypes =
@@ -101,15 +103,18 @@ void shouldWrapHelperTypes() {
101103
assertThat(baseHelper.isAbstract()).isTrue();
102104
List<HelperReferenceWrapper.Method> baseHelperMethods =
103105
baseHelper.getMethods().collect(Collectors.toList());
104-
assertThat(baseHelperMethods).hasSize(2);
105-
HelperReferenceWrapper.Method fooMethod = baseHelperMethods.get(0);
106-
assertThat(fooMethod.isAbstract()).isFalse();
107-
assertThat(fooMethod.getName()).isEqualTo("foo");
108-
assertThat(fooMethod.getDescriptor()).isEqualTo("()V");
109-
HelperReferenceWrapper.Method abstractMethod = baseHelperMethods.get(1);
110-
assertThat(abstractMethod.isAbstract()).isTrue();
111-
assertThat(abstractMethod.getName()).isEqualTo("abstract");
112-
assertThat(abstractMethod.getDescriptor()).isEqualTo("()I");
106+
assertThat(baseHelperMethods)
107+
.hasSize(2)
108+
.satisfies(method -> {
109+
assertThat(method.isAbstract()).isFalse();
110+
assertThat(method.getName()).isEqualTo("foo");
111+
assertThat(method.getDescriptor()).isEqualTo("()V");
112+
}, atIndex(0))
113+
.satisfies(method -> {
114+
assertThat(method.isAbstract()).isTrue();
115+
assertThat(method.getName()).isEqualTo("abstract");
116+
assertThat(method.getDescriptor()).isEqualTo("()I");
117+
}, atIndex(1));
113118

114119
assertThat(baseHelper.hasSuperTypes()).isTrue();
115120
List<HelperReferenceWrapper> baseSuperTypes =
@@ -120,10 +125,12 @@ void shouldWrapHelperTypes() {
120125
assertThat(abstractClasspathType.getMethods().collect(Collectors.toList())).isEmpty();
121126
List<HelperReferenceWrapper.Field> abstractFields =
122127
abstractClasspathType.getFields().collect(Collectors.toList());
123-
assertThat(abstractFields).hasSize(1);
124-
HelperReferenceWrapper.Field field = abstractFields.get(0);
125-
assertThat(field.getName()).isEqualTo("field");
126-
assertThat(field.getDescriptor()).isEqualTo("Ljava/lang/Object;");
128+
assertThat(abstractFields)
129+
.hasSize(1)
130+
.satisfies(field -> {
131+
assertThat(field.getName()).isEqualTo("field");
132+
assertThat(field.getDescriptor()).isEqualTo("Ljava/lang/Object;");
133+
}, atIndex(0));
127134

128135
assertThat(abstractClasspathType.hasSuperTypes()).isTrue();
129136
List<HelperReferenceWrapper> abstractSuperTypes =
@@ -135,11 +142,13 @@ void shouldWrapHelperTypes() {
135142
assertThat(interface1.isAbstract()).isTrue();
136143
List<HelperReferenceWrapper.Method> interface1Methods =
137144
interface1.getMethods().collect(Collectors.toList());
138-
assertThat(interface1Methods).hasSize(1);
139-
HelperReferenceWrapper.Method interface1Method = interface1Methods.get(0);
140-
assertThat(interface1Method.isAbstract()).isTrue();
141-
assertThat(interface1Method.getName()).isEqualTo("foo");
142-
assertThat(interface1Method.getDescriptor()).isEqualTo("()V");
145+
assertThat(interface1Methods)
146+
.hasSize(1)
147+
.satisfies(method -> {
148+
assertThat(method.isAbstract()).isTrue();
149+
assertThat(method.getName()).isEqualTo("foo");
150+
assertThat(method.getDescriptor()).isEqualTo("()V");
151+
}, atIndex(0));
143152
assertThat(interface1.hasSuperTypes()).isFalse();
144153
assertThat(interface1.getSuperTypes().collect(Collectors.toList())).isEmpty();
145154

@@ -148,11 +157,13 @@ void shouldWrapHelperTypes() {
148157
assertThat(interface2.isAbstract()).isTrue();
149158
List<HelperReferenceWrapper.Method> interface2Methods =
150159
interface2.getMethods().collect(Collectors.toList());
151-
assertThat(interface2Methods).hasSize(1);
152-
HelperReferenceWrapper.Method interface2Method = interface2Methods.get(0);
153-
assertThat(interface2Method.isAbstract()).isTrue();
154-
assertThat(interface2Method.getName()).isEqualTo("bar");
155-
assertThat(interface2Method.getDescriptor()).isEqualTo("()V");
160+
assertThat(interface2Methods)
161+
.hasSize(1)
162+
.satisfies(method -> {
163+
assertThat(method.isAbstract()).isTrue();
164+
assertThat(method.getName()).isEqualTo("bar");
165+
assertThat(method.getDescriptor()).isEqualTo("()V");
166+
}, atIndex(0));
156167
assertThat(interface2.hasSuperTypes()).isFalse();
157168
assertThat(interface2.getSuperTypes().collect(Collectors.toList())).isEmpty();
158169
}

0 commit comments

Comments
 (0)