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

LearnLib / learnlib / 6605620268

22 Oct 2023 06:53PM UTC coverage: 93.218% (+0.9%) from 92.296%
6605620268

push

github

mtf90
cleanup passive integration tests

11546 of 12386 relevant lines covered (93.22%)

1.68 hits per line

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

85.71
/drivers/basic/src/main/java/de/learnlib/driver/reflect/MethodInput.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.InvocationTargetException;
19
import java.lang.reflect.Method;
20

21
import de.learnlib.api.ContextExecutableInput;
22
import de.learnlib.api.exception.SULException;
23
import org.checkerframework.checker.nullness.qual.Nullable;
24

25
/**
26
 * An input symbol that represents a call to a method with a specific set of parameters.
27
 */
28
public class MethodInput implements ContextExecutableInput<MethodOutput, Object> {
29

30
    private final String displayName;
31
    private final Method method;
32
    private final Object[] parameters;
33

34
    public MethodInput(String displayName, Method method, Object[] parameters) {
2✔
35
        this.displayName = displayName;
2✔
36
        this.method = method;
2✔
37
        this.parameters = parameters;
2✔
38
    }
2✔
39

40
    @SuppressWarnings("PMD.PreserveStackTrace")
41
    @Override
42
    public MethodOutput execute(Object context) {
43
        try {
44
            final Object ret = this.method.invoke(context, parameters);
2✔
45
            if (Void.TYPE.equals(this.method.getReturnType())) {
2✔
46
                return VoidOutput.INSTANCE;
2✔
47
            } else {
48
                return new ReturnValue<@Nullable Object>(ret);
2✔
49
            }
50
        } catch (IllegalAccessException | IllegalArgumentException e) {
×
51
            throw new SULException(e);
×
52
        } catch (InvocationTargetException e) {
2✔
53
            throw new SULException(e.getCause());
2✔
54
        }
55
    }
56

57
    @Override
58
    public String toString() {
59
        return this.displayName;
1✔
60
    }
61

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