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

pgpainless / sop-java / #17

15 Nov 2023 01:23PM UTC coverage: 65.932% (-3.9%) from 69.789%
#17

push

other

vanitasvitae
Fix gradle version

1167 of 1770 relevant lines covered (65.93%)

0.66 hits per line

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

41.18
/external-sop/src/main/java/sop/external/operation/ListProfilesExternal.java
1
// SPDX-FileCopyrightText: 2023 Paul Schaub <vanitasvitae@fsfe.org>
2
//
3
// SPDX-License-Identifier: Apache-2.0
4

5
package sop.external.operation;
6

7
import sop.Profile;
8
import sop.external.ExternalSOP;
9
import sop.operation.ListProfiles;
10

11
import javax.annotation.Nonnull;
12
import java.io.IOException;
13
import java.util.ArrayList;
14
import java.util.List;
15
import java.util.Properties;
16

17
public class ListProfilesExternal implements ListProfiles {
18

19
    private final List<String> commandList = new ArrayList<>();
1✔
20
    private final List<String> envList;
21

22
    public ListProfilesExternal(String binary, Properties properties) {
1✔
23
        this.commandList.add(binary);
1✔
24
        this.commandList.add("list-profiles");
1✔
25
        this.envList = ExternalSOP.propertiesToEnv(properties);
1✔
26
    }
1✔
27

28
    @Override
29
    @Nonnull
30
    public List<Profile> subcommand(@Nonnull String command) {
31
        commandList.add(command);
1✔
32
        try {
33
            String output = new String(ExternalSOP.executeProducingOperation(Runtime.getRuntime(), commandList, envList).getBytes());
×
34
            return toProfiles(output);
×
35
        } catch (IOException e) {
×
36
            throw new RuntimeException(e);
×
37
        }
38
    }
39

40
    private static List<Profile> toProfiles(String output) {
41
        List<Profile> profiles = new ArrayList<>();
×
42
        for (String line : output.split("\n")) {
×
43
            if (line.trim().isEmpty()) {
×
44
                continue;
×
45
            }
46
            profiles.add(Profile.parse(line));
×
47
        }
48
        return profiles;
×
49
    }
50
}
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