Skip to content

Commit e0e6e33

Browse files
committed
update reflective tests to account for jacoco
1 parent 3072a61 commit e0e6e33

3 files changed

Lines changed: 22 additions & 15 deletions

File tree

core/src/test/java/dev/morphia/test/OptionsTest.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,9 @@ public void updateOptions() {
9898
private void beanScan(Class<?> driver, Class<?> morphia, List<String> filtered) {
9999
Method[] methods = driver.getDeclaredMethods();
100100
for (Method method : methods) {
101-
if (!filtered.contains(method.getName()) && method.getAnnotation(Deprecated.class) == null) {
101+
if (!method.getName().equals("$jacocoInit")
102+
&& !filtered.contains(method.getName())
103+
&& method.getAnnotation(Deprecated.class) == null) {
102104
try {
103105
morphia.getDeclaredMethod(method.getName(), convert(method.getParameterTypes()));
104106
} catch (ReflectiveOperationException e) {
@@ -174,7 +176,10 @@ private void scan(Class<?> driverType, Class<?> morphiaType, List<Class<?>> loca
174176
Assert.assertEquals(driverType.equals(morphiaType.getSuperclass()), !Modifier.isFinal(driverType.getModifiers()),
175177
"Options class should be a subclass");
176178
for (Method method : methods) {
177-
if (method.getAnnotation(Deprecated.class) == null && !method.getName().equals("builder") && !getter(method)) {
179+
if (method.getAnnotation(Deprecated.class) == null
180+
&& !method.getName().equals("$jacocoInit")
181+
&& !method.getName().equals("builder")
182+
&& !getter(method)) {
178183
checkOverride(driverType, morphiaType, method);
179184
}
180185
}

core/src/test/java/dev/morphia/test/TestUpdateOperations.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import java.time.LocalDateTime;
44
import java.time.LocalTime;
55
import java.util.ArrayList;
6+
import java.util.Arrays;
67
import java.util.Date;
78
import java.util.HashMap;
89
import java.util.HashSet;
@@ -577,7 +578,13 @@ private static Iterator<TranslationParams> paths() {
577578
List<TranslationParams> list = new ArrayList<>();
578579

579580
list.addAll(prepParams("stars", "s"));
580-
assertEquals(list.size(), countUpdateOperators(), "Should have checks for all UpdateOperators methods");
581+
// dec by 1 to exclude set(Entity) since there will be no path translation to check
582+
var expected = Arrays.stream(UpdateOperators.class
583+
.getDeclaredMethods())
584+
.filter(m -> !m.getName().equals("$jacocoInit")
585+
&& !(m.getName().equals("set") && m.getParameterCount() == 1))
586+
.toList();
587+
assertEquals(list.size(), expected.size(), "Should have checks for all UpdateOperators methods");
581588
list.addAll(prepParams("s", "s"));
582589

583590
list.addAll(prepParams("address.street", "addr.address_street"));
@@ -589,11 +596,6 @@ private static Iterator<TranslationParams> paths() {
589596
return list.iterator();
590597
}
591598

592-
private static int countUpdateOperators() {
593-
// dec by 1 to exclude set(Entity) since there will be no path translation to check
594-
return UpdateOperators.class.getDeclaredMethods().length - 1;
595-
}
596-
597599
@NotNull
598600
private static List<TranslationParams> prepParams(String updateName, String mappedName) {
599601
LocalTime now = LocalTime.of(15, 16, 17);

docs/antora.yml

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
---
2-
name: morphia
3-
title: Morphia
4-
version: '3.0'
5-
prerelease: -SNAPSHOT
2+
name: "morphia"
3+
title: "Morphia"
4+
version: "3.0"
5+
prerelease: "-SNAPSHOT"
66
nav:
7-
- modules/ROOT/nav.adoc
7+
- "modules/ROOT/nav.adoc"
88
asciidoc:
99
attributes:
10-
version: 3.0.0-SNAPSHOT
11-
srcRef: https://github.com/MorphiaOrg/morphia/tree/master
10+
version: "3.0.0-SNAPSHOT"
11+
srcRef: "https://github.com/MorphiaOrg/morphia/blob/master"

0 commit comments

Comments
 (0)