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

SpiNNakerManchester / JavaSpiNNaker / 6310285782

26 Sep 2023 08:47AM UTC coverage: 36.367% (-0.5%) from 36.866%
6310285782

Pull #658

github

dkfellows
Merge branch 'master' into java-17
Pull Request #658: Update Java version to 17 and JEE to 9

1675 of 1675 new or added lines in 266 files covered. (100.0%)

8368 of 23010 relevant lines covered (36.37%)

0.36 hits per line

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

0.0
/SpiNNaker-allocserv/src/main/java/uk/ac/manchester/spinnaker/alloc/web/MachinesResponse.java
1
/*
2
 * Copyright (c) 2021 The University of Manchester
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
 *     https://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 uk.ac.manchester.spinnaker.alloc.web;
17

18
import static java.util.stream.Collectors.toUnmodifiableList;
19
import static uk.ac.manchester.spinnaker.utils.CollectionUtils.copy;
20

21
import java.net.URI;
22
import java.util.List;
23
import java.util.Map;
24

25
import jakarta.ws.rs.core.UriInfo;
26
import uk.ac.manchester.spinnaker.alloc.allocator.SpallocAPI.Machine;
27
import uk.ac.manchester.spinnaker.alloc.model.BoardCoords;
28
import uk.ac.manchester.spinnaker.alloc.model.DownLink;
29

30
/**
31
 * The description of machines known to the service. A list of
32
 * {@link BriefMachineDescription}s.
33
 *
34
 * @author Donal Fellows
35
 * @param machines
36
 *            The list of machines known to the service.
37
 */
38
public record MachinesResponse(List<BriefMachineDescription> machines) {
×
39
        /**
40
         * A brief, summary description of a machine.
41
         *
42
         * @author Donal Fellows
43
         * @param name
44
         *            The name of the machine.
45
         * @param tags
46
         *            The tags of the machine.
47
         * @param uri
48
         *            The URI to the machine.
49
         * @param width
50
         *            The width of the machine, in triads.
51
         * @param height
52
         *            The height of the machine, in triads.
53
         * @param deadBoards
54
         *            The dead boards on the machine.
55
         * @param deadLinks
56
         *            The dead links on the machine.
57
         */
58
        public record BriefMachineDescription(String name, List<String> tags,
×
59
                        URI uri, int width, int height, List<BoardCoords> deadBoards,
60
                        List<DownLink> deadLinks) {
61
        }
62

63
        MachinesResponse(Map<String, Machine> machines, UriInfo ui) {
64
                this(makeBriefDescriptions(machines, ui));
×
65
        }
×
66

67
        private static List<BriefMachineDescription> makeBriefDescriptions(
68
                        Map<String, Machine> machines, UriInfo ui) {
69
                var ub = ui.getAbsolutePathBuilder().path("{name}");
×
70
                return machines.entrySet().stream()
×
71
                                .map(e -> new BriefMachineDescription(e.getKey(),
×
72
                                                List.copyOf(e.getValue().getTags()),
×
73
                                                ub.build(e.getKey()), e.getValue().getWidth(),
×
74
                                                e.getValue().getHeight(),
×
75
                                                copy(e.getValue().getDeadBoards()),
×
76
                                                copy(e.getValue().getDownLinks())))
×
77
                                .collect(toUnmodifiableList());
×
78
        }
79
}
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

© 2026 Coveralls, Inc