• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

pgpainless / sop-java / #54

25 Sep 2025 09:07PM UTC coverage: 58.308% (-0.1%) from 58.411%
#54

push

other

vanitasvitae
Remove unused import

2088 of 3581 relevant lines covered (58.31%)

0.58 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

76.92
/sop-java-testfixtures/src/main/java/sop/testsuite/operation/AbstractSOPTest.java
1
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
2
//
3
// SPDX-License-Identifier: Apache-2.0
4

5
package sop.testsuite.operation;
6

7
import kotlin.jvm.functions.Function0;
8
import org.junit.jupiter.api.Named;
9
import org.junit.jupiter.api.extension.ExtendWith;
10
import org.junit.jupiter.params.provider.Arguments;
11
import sop.SOP;
12
import sop.exception.SOPGPException;
13
import sop.testsuite.AbortOnUnsupportedOption;
14
import sop.testsuite.AbortOnUnsupportedOptionExtension;
15
import sop.testsuite.SOPInstanceFactory;
16

17
import java.lang.reflect.InvocationTargetException;
18
import java.util.ArrayList;
19
import java.util.List;
20
import java.util.Map;
21
import java.util.stream.Stream;
22

23
import static org.junit.jupiter.api.Assumptions.assumeTrue;
24

25
@ExtendWith(AbortOnUnsupportedOptionExtension.class)
26
@AbortOnUnsupportedOption
27
public abstract class AbstractSOPTest {
1✔
28

29
    private static final List<Arguments> backends = new ArrayList<>();
1✔
30

31
    static {
32
        initBackends();
1✔
33
    }
1✔
34

35
    // populate instances list via configured test subject factory
36
    private static void initBackends() {
37
        String factoryName = System.getenv("test.implementation");
1✔
38
        if (factoryName == null) {
1✔
39
            return;
×
40
        }
41

42
        SOPInstanceFactory factory;
43
        try {
44
            Class<?> testSubjectFactoryClass = Class.forName(factoryName);
1✔
45
            factory = (SOPInstanceFactory) testSubjectFactoryClass
1✔
46
                    .getDeclaredConstructor().newInstance();
1✔
47
        } catch (ClassNotFoundException | InstantiationException | IllegalAccessException |
×
48
                 InvocationTargetException | NoSuchMethodException e) {
49
            throw new RuntimeException(e);
×
50
        }
1✔
51

52
        Map<String, SOP> testSubjects = factory.provideSOPInstances();
1✔
53
        for (String key : testSubjects.keySet()) {
1✔
54
            backends.add(Arguments.of(Named.of(key, testSubjects.get(key))));
1✔
55
        }
1✔
56
    }
1✔
57

58
    public <T> T assumeSupported(Function0<T> f) {
59
        try {
60
            T t = f.invoke();
1✔
61
            assumeTrue(t != null, "Unsupported operation.");
1✔
62
            return t;
1✔
63
        } catch (SOPGPException.UnsupportedSubcommand e) {
×
64
            assumeTrue(false, e.getMessage());
×
65
            return null;
×
66
        }
67
    }
68

69
    public static Stream<Arguments> provideBackends() {
70
        return backends.stream();
1✔
71
    }
72

73
    public static boolean hasBackends() {
74
        return !backends.isEmpty();
1✔
75
    }
76

77
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc