• 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

92.31
/oracles/equivalence-oracles/src/main/java/de/learnlib/oracle/equivalence/sba/WMethodEQOracle.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.oracle.equivalence.sba;
17

18
import java.util.Collection;
19
import java.util.stream.Stream;
20

21
import com.google.common.collect.Streams;
22
import de.learnlib.api.oracle.MembershipOracle;
23
import de.learnlib.oracle.equivalence.AbstractTestWordEQOracle;
24
import net.automatalib.automata.concepts.FiniteRepresentation;
25
import net.automatalib.automata.procedural.SBA;
26
import net.automatalib.util.automata.conformance.SBAWMethodTestsIterator;
27
import net.automatalib.util.automata.conformance.WMethodTestsIterator;
28
import net.automatalib.words.ProceduralInputAlphabet;
29
import net.automatalib.words.Word;
30

31
/**
32
 * An {@link SBA} version of {@link de.learnlib.oracle.equivalence.WMethodEQOracle} which generates test sequences based
33
 * on the {@link SBAWMethodTestsIterator W-method} for each procedure.
34
 *
35
 * @param <I>
36
 *         input symbol type
37
 */
38
public class WMethodEQOracle<I> extends AbstractTestWordEQOracle<SBA<?, I>, I, Boolean> {
39

40
    private final int lookahead;
41
    private final int expectedSize;
42

43
    /**
44
     * Constructor. Convenience method for {@link #WMethodEQOracle(MembershipOracle, int, int)} that sets
45
     * {@code expectedSize} to 0.
46
     *
47
     * @param sulOracle
48
     *         interface to the system under learning
49
     * @param lookahead
50
     *         the maximum length of the "middle" part of the test cases
51
     */
52
    public WMethodEQOracle(MembershipOracle<I, Boolean> sulOracle, int lookahead) {
53
        this(sulOracle, lookahead, 0);
2✔
54
    }
2✔
55

56
    /**
57
     * Constructor. Convenience method for {@link #WMethodEQOracle(MembershipOracle, int, int, int)} that sets
58
     * {@code batchSize} to 1.
59
     *
60
     * @param sulOracle
61
     *         interface to the system under learning
62
     * @param lookahead
63
     *         the (minimal) maximum length of the "middle" part of the test cases
64
     * @param expectedSize
65
     *         the expected size of the system under learning
66
     */
67
    public WMethodEQOracle(MembershipOracle<I, Boolean> sulOracle, int lookahead, int expectedSize) {
68
        this(sulOracle, lookahead, expectedSize, 1);
2✔
69
    }
2✔
70

71
    /**
72
     * Constructor. Uses
73
     * {@link Math#max(int, int) Math.max}{@code (lookahead, expectedSize - }{@link FiniteRepresentation#size()
74
     * hypothesis.size()}{@code )} to determine the maximum length of sequences, that should be appended to the
75
     * transition-cover part of the test sequence to account for the fact that the system under learning may have more
76
     * states than the current hypothesis.
77
     *
78
     * @param sulOracle
79
     *         interface to the system under learning
80
     * @param lookahead
81
     *         the (minimal) maximum length of the "middle" part of the test cases
82
     * @param expectedSize
83
     *         the expected size of the system under learning
84
     * @param batchSize
85
     *         size of the batches sent to the membership oracle
86
     *
87
     * @see WMethodTestsIterator
88
     */
89
    public WMethodEQOracle(MembershipOracle<I, Boolean> sulOracle, int lookahead, int expectedSize, int batchSize) {
90
        super(sulOracle, batchSize);
2✔
91
        this.lookahead = lookahead;
2✔
92
        this.expectedSize = expectedSize;
2✔
93
    }
2✔
94

95
    @Override
96
    protected Stream<Word<I>> generateTestWords(SBA<?, I> hypothesis, Collection<? extends I> inputs) {
97
        if (!(inputs instanceof ProceduralInputAlphabet)) {
2✔
98
            throw new IllegalArgumentException("Inputs are not a procedural alphabet");
×
99
        }
100

101
        @SuppressWarnings("unchecked")
102
        final ProceduralInputAlphabet<I> alphabet = (ProceduralInputAlphabet<I>) inputs;
2✔
103

104
        return Streams.stream(new SBAWMethodTestsIterator<>(hypothesis,
2✔
105
                                                            alphabet,
106
                                                            Math.max(lookahead, expectedSize - hypothesis.size())));
2✔
107
    }
108
}
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