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

LearnLib / learnlib / 31619759710

12 Aug 2026 04:27PM UTC coverage: 95.488% (+1.1%) from 94.368%
31619759710

push

github

mtf90
use new version scheme

15533 of 16267 relevant lines covered (95.49%)

1.72 hits per line

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

95.0
/examples/src/main/java/de/learnlib/example/aaar/Protocol.java
1
/* Copyright (C) 2013-2026 TU Dortmund University
2
 * This file is part of LearnLib <https://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.example.aaar;
17

18
import java.util.stream.StreamSupport;
19

20
import de.learnlib.example.aaar.Event.Msg;
21
import de.learnlib.example.aaar.Event.Recv;
22
import de.learnlib.oracle.SingleQueryOracle.SingleQueryOracleMealy;
23
import net.automatalib.word.Word;
24
import org.checkerframework.checker.nullness.qual.Nullable;
25

26
class Protocol implements SingleQueryOracleMealy<Event, String> {
1✔
27

28
    private int seqExp;
29
    private @Nullable Object buffer;
30

31
    @Override
32
    public Word<String> answerQuery(Word<Event> prefix, Word<Event> suffix) {
33
        reset();
1✔
34
        prefix.forEach(this::handleEvent);
1✔
35
        return StreamSupport.stream(suffix.spliterator(), false).map(this::handleEvent).collect(Word.collector());
1✔
36
    }
37

38
    private void reset() {
39
        seqExp = 0;
1✔
40
        buffer = null;
1✔
41
    }
1✔
42

43
    private String handleEvent(Event event) {
44
        if (event instanceof Msg<?> msg) {
1✔
45
            if (buffer == null && msg.seq % 2 == seqExp % 2) {
1✔
46
                buffer = msg.data;
1✔
47
                seqExp++;
1✔
48
                return "ind";
1✔
49
            }
50
            return "-";
1✔
51
        } else if (event instanceof Recv) {
1✔
52
            if (buffer == null) {
1✔
53
                return "-";
1✔
54
            }
55
            int ack = (seqExp - 1) % 2;
1✔
56
            buffer = null;
1✔
57
            return "ack(" + ack + ')';
1✔
58
        } else {
59
            throw new IllegalArgumentException("Unknown event: " + event);
×
60
        }
61
    }
62
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE TRIAL · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc