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

LearnLib / learnlib / 6433387082

06 Oct 2023 03:10PM UTC coverage: 92.296% (-0.007%) from 92.303%
6433387082

push

github

mtf90
update Falk's developer id

11573 of 12539 relevant lines covered (92.3%)

1.67 hits per line

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

57.14
/drivers/basic/src/main/java/de/learnlib/drivers/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.drivers.reflect;
17

18
import java.lang.reflect.Constructor;
19
import java.lang.reflect.Method;
20
import java.util.HashMap;
21

22
import de.learnlib.drivers.api.TestDriver;
23
import net.automatalib.commons.util.ReflectUtil;
24
import net.automatalib.words.Alphabet;
25
import net.automatalib.words.GrowingAlphabet;
26
import net.automatalib.words.impl.GrowingMapAlphabet;
27
import org.checkerframework.checker.nullness.qual.Nullable;
28

29
/**
30
 * Simple test driver for plain java objects. Uses a very simple data mapper without state or storage. Inputs cannot
31
 * have abstract parameters.
32
 */
33
public final class SimplePOJOTestDriver
34
        extends TestDriver<MethodInput, MethodOutput, ConcreteMethodInput, @Nullable Object> {
35

36
    private final GrowingAlphabet<MethodInput> inputs = new GrowingMapAlphabet<>();
2✔
37

38
    private final Class<?> instanceClass;
39

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

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

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

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

63
    /**
64
     * @return the inputs
65
     */
66
    public Alphabet<MethodInput> getInputs() {
67
        return this.inputs;
2✔
68
    }
69

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