• 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

82.35
/drivers/basic/src/main/java/de/learnlib/drivers/reflect/ConcreteMethodInput.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.InvocationTargetException;
19
import java.util.Arrays;
20
import java.util.Map;
21

22
import de.learnlib.api.exception.SULException;
23
import de.learnlib.mapper.api.ExecutableInput;
24
import org.checkerframework.checker.nullness.qual.Nullable;
25

26
/**
27
 * A concrete inputs contains the information for one specific method call.
28
 */
29
public class ConcreteMethodInput implements ExecutableInput<@Nullable Object> {
30

31
    /**
32
     * corresponding abstract input.
33
     */
34
    private final MethodInput input;
35

36
    /**
37
     * parameter values.
38
     */
39
    private final Map<String, Object> values;
40

41
    /**
42
     * invocation target.
43
     */
44
    private final Object target;
45

46
    public ConcreteMethodInput(MethodInput input, Map<String, Object> values, Object target) {
2✔
47
        this.input = input;
2✔
48
        this.values = values;
2✔
49
        this.target = target;
2✔
50
    }
2✔
51

52
    @Override
53
    public String toString() {
54
        return target + "." + this.input.getMethod().getName() + Arrays.toString(getParameterValues());
×
55
    }
56

57
    private Object[] getParameterValues() {
58
        return this.input.getParameters(values);
2✔
59
    }
60

61
    // RuntimeExceptions are the type of exceptions we allow to handle, therefore we should throw them
62
    @SuppressWarnings({"PMD.AvoidThrowingRawExceptionTypes", "PMD.PreserveStackTrace"})
63
    @Override
64
    public @Nullable Object execute() {
65
        Object out;
66
        try {
67
            Object ret = this.input.getMethod().invoke(this.target, getParameterValues());
2✔
68
            if (this.input.getMethod().getReturnType().equals(Void.TYPE)) {
2✔
69
                out = Void.TYPE;
2✔
70
            } else {
71
                out = ret;
2✔
72
            }
73
        } catch (IllegalAccessException | IllegalArgumentException e) {
×
74
            throw new RuntimeException(e);
×
75
        } catch (InvocationTargetException e) {
2✔
76
            throw new SULException(e.getCause());
2✔
77
        }
2✔
78
        return out;
2✔
79
    }
80

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