• 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

62.5
/drivers/mapper/src/main/java/de/learnlib/mapper/SULMapperComposition.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.mapper;
17

18
import java.util.Optional;
19

20
import de.learnlib.api.SULMapper;
21
import de.learnlib.api.exception.MappedException;
22
import de.learnlib.api.exception.SULException;
23

24
final class SULMapperComposition<AI, AO, ACI, CAO, CI, CO>
25
        extends MapperComposition<AI, AO, ACI, CAO, CI, CO, SULMapper<? super AI, ? extends AO, ACI, CAO>, SULMapper<? super ACI, ? extends CAO, ? extends CI, ? super CO>>
26
        implements SULMapper<AI, AO, CI, CO> {
27

28
    SULMapperComposition(SULMapper<? super AI, ? extends AO, ACI, CAO> outerMapper,
29
                         SULMapper<? super ACI, ? extends CAO, ? extends CI, ? super CO> innerMapper) {
30
        super(outerMapper, innerMapper);
2✔
31
    }
2✔
32

33
    @SuppressWarnings("PMD.AvoidCatchingGenericException") //  we want to allow mapping generic RuntimeExceptions
34
    @Override
35
    public MappedException<? extends AO> mapWrappedException(SULException exception) {
36
        MappedException<? extends CAO> mappedEx;
37
        try {
38
            mappedEx = mapper2.mapWrappedException(exception);
×
39
        } catch (SULException ex) {
2✔
40
            return mapper1.mapWrappedException(ex);
2✔
41
        } catch (RuntimeException ex) {
×
42
            return mapper1.mapUnwrappedException(ex);
×
43
        }
×
44

45
        return mapMappedException(mappedEx);
×
46
    }
47

48
    @SuppressWarnings("PMD.AvoidCatchingGenericException") //  we want to allow mapping generic RuntimeExceptions
49
    @Override
50
    public MappedException<? extends AO> mapUnwrappedException(RuntimeException exception) {
51
        MappedException<? extends CAO> mappedEx;
52
        try {
53
            mappedEx = mapper2.mapUnwrappedException(exception);
2✔
54
        } catch (SULException ex) {
×
55
            return mapper1.mapWrappedException(ex);
×
56
        } catch (RuntimeException ex) {
2✔
57
            return mapper1.mapUnwrappedException(ex);
2✔
58
        }
2✔
59

60
        return mapMappedException(mappedEx);
2✔
61
    }
62

63
    @Override
64
    public boolean canFork() {
65
        return mapper1.canFork() && mapper2.canFork();
2✔
66
    }
67

68
    @Override
69
    public SULMapper<AI, AO, CI, CO> fork() {
70
        return new SULMapperComposition<>(mapper1.fork(), mapper2.fork());
×
71
    }
72

73
    private MappedException<? extends AO> mapMappedException(MappedException<? extends CAO> mappedEx) {
74
        AO thisStepOutput = mapper1.mapOutput(mappedEx.getThisStepOutput());
2✔
75
        Optional<? extends CAO> repeatOutput = mappedEx.getSubsequentStepsOutput();
2✔
76
        if (repeatOutput.isPresent()) {
2✔
77
            AO repeatOutputMapped = mapper1.mapOutput(repeatOutput.get());
2✔
78
            return MappedException.repeatOutput(thisStepOutput, repeatOutputMapped);
2✔
79
        }
80
        return MappedException.ignoreAndContinue(thisStepOutput);
×
81
    }
82

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