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

LearnLib / learnlib / 6673301747

27 Oct 2023 11:46PM UTC coverage: 91.986% (-1.3%) from 93.327%
6673301747

push

github

mtf90
merge the release and sign-artifacts profiles

10984 of 11941 relevant lines covered (91.99%)

1.72 hits per line

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

78.57
/drivers/basic/src/main/java/de/learnlib/driver/reflect/SimplePOJOTestDriver.java
1
/* Copyright (C) 2013-2023 TU Dortmund
2
 * This file is part of LearnLib, http://www.learnlib.de/.
3
 *
4
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 * you may not use this file except in compliance with the License.
6
 * You may obtain a copy of the License at
7
 *
8
 *     http://www.apache.org/licenses/LICENSE-2.0
9
 *
10
 * Unless required by applicable law or agreed to in writing, software
11
 * distributed under the License is distributed on an "AS IS" BASIS,
12
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13
 * See the License for the specific language governing permissions and
14
 * limitations under the License.
15
 */
16
package de.learnlib.driver.reflect;
17

18
import java.lang.reflect.Constructor;
19
import java.lang.reflect.Method;
20

21
import de.learnlib.api.SUL;
22
import de.learnlib.driver.ContextExecutableInputSUL;
23
import net.automatalib.alphabet.Alphabet;
24
import net.automatalib.alphabet.GrowingAlphabet;
25
import net.automatalib.alphabet.impl.GrowingMapAlphabet;
26
import net.automatalib.common.util.ReflectUtil;
27

28
/**
29
 * A test driver for plain old java objects. Given a constructor of a Java {@link Class}, this {@link SUL} creates
30
 * objects of the respective class and invokes methods on these objects as specified in the respective
31
 * {@link #addInput(String, Method, Object...) addInput} methods.
32
 */
33
public final class SimplePOJOTestDriver extends ContextExecutableInputSUL<MethodInput, MethodOutput, Object> {
34

35
    private final Class<?> instanceClass;
36
    private final GrowingAlphabet<MethodInput> inputs;
37

38
    public SimplePOJOTestDriver(Class<?> c) throws NoSuchMethodException {
39
        this(c.getConstructor());
×
40
    }
×
41

42
    public SimplePOJOTestDriver(Constructor<?> c, Object... cParams) {
43
        super(new InstanceConstructor(c, cParams));
2✔
44
        this.instanceClass = c.getDeclaringClass();
2✔
45
        this.inputs = new GrowingMapAlphabet<>();
2✔
46
    }
2✔
47

48
    public MethodInput addInput(String name, String methodName, Object... params) {
49
        Method m = ReflectUtil.findMatchingMethod(instanceClass, methodName, params);
2✔
50
        if (m == null) {
2✔
51
            throw new IllegalArgumentException();
×
52
        }
53
        return addInput(name, m, params);
2✔
54
    }
55

56
    public MethodInput addInput(String name, Method m, Object... params) {
57
        MethodInput i = new MethodInput(name, m, params);
2✔
58
        inputs.add(i);
2✔
59
        return i;
2✔
60
    }
61

62
    public Alphabet<MethodInput> getInputs() {
63
        return this.inputs;
1✔
64
    }
65

66
}
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