use of org.openkilda.northbound.dto.v1.links.LinkPropsDto in project open-kilda by telstra.
the class LinkServiceTest method shouldGetPropsList.
@Test
public void shouldGetPropsList() {
final String correlationId = "non-empty-link-props";
org.openkilda.messaging.model.LinkPropsDto linkProps = new org.openkilda.messaging.model.LinkPropsDto(new NetworkEndpoint(new SwitchId("00:00:00:00:00:00:00:01"), 1), new NetworkEndpoint(new SwitchId("00:00:00:00:00:00:00:02"), 2), Collections.singletonMap("cost", "2"));
LinkPropsData linkPropsData = new LinkPropsData(linkProps);
messageExchanger.mockChunkedResponse(correlationId, Collections.singletonList(linkPropsData));
RequestCorrelationId.create(correlationId);
List<LinkPropsDto> result = linkService.getLinkProps(null, 0, null, 0).join();
assertFalse("List of link props shouldn't be empty", result.isEmpty());
LinkPropsDto dto = result.get(0);
assertThat(dto.getSrcSwitch(), is(linkPropsData.getLinkProps().getSource().getDatapath().toString()));
assertThat(dto.getSrcPort(), is(linkPropsData.getLinkProps().getSource().getPortNumber()));
assertThat(dto.getDstSwitch(), is(linkPropsData.getLinkProps().getDest().getDatapath().toString()));
assertThat(dto.getDstPort(), is(linkPropsData.getLinkProps().getDest().getPortNumber()));
}
use of org.openkilda.northbound.dto.v1.links.LinkPropsDto in project open-kilda by telstra.
the class LinkPropertiesSteps method createLinkPropertiesRequest.
@When("^create link properties request for ISL '(.*)'$")
public void createLinkPropertiesRequest(String islAlias) {
linkPropsRequest = new LinkPropsDto();
Isl theIsl = topologyUnderTest.getAliasedObject(islAlias);
linkPropsRequest.setSrcSwitch(theIsl.getSrcSwitch().getDpId().toString());
linkPropsRequest.setSrcPort(theIsl.getSrcPort());
linkPropsRequest.setDstSwitch(theIsl.getDstSwitch().getDpId().toString());
linkPropsRequest.setDstPort(theIsl.getDstPort());
}
use of org.openkilda.northbound.dto.v1.links.LinkPropsDto in project open-kilda by telstra.
the class LinkPropertiesSteps method verifyResponseLinkProperties.
@Then("^response link properties from request has property '(.*)' with value '(.*)'$")
public void verifyResponseLinkProperties(String key, String value) {
LinkPropsDto props = getLinkPropsResponse.stream().filter(p -> p.equals(linkPropsRequest)).findFirst().orElseThrow(() -> new IllegalStateException(format("Link properties %s not found.", linkPropsRequest)));
assertThat(value, equalTo(String.valueOf(props.getProperty(key))));
}
use of org.openkilda.northbound.dto.v1.links.LinkPropsDto in project open-kilda by telstra.
the class LinkServiceImpl method delLinkProps.
@Override
public CompletableFuture<BatchResults> delLinkProps(List<LinkPropsDto> linkPropsList) {
List<CompletableFuture<List<InfoData>>> pendingRequest = new ArrayList<>(linkPropsList.size());
for (LinkPropsDto requestItem : linkPropsList) {
LinkPropsDrop request = new LinkPropsDrop(linkPropsMapper.toLinkPropsMask(requestItem));
String requestId = idFactory.produceChained(RequestCorrelationId.getId());
CommandMessage message = new CommandMessage(request, System.currentTimeMillis(), requestId);
pendingRequest.add(messagingChannel.sendAndGetChunked(nbworkerTopic, message));
}
return collectChunkedResponses(pendingRequest, LinkPropsResponse.class).thenApply(responses -> getLinkPropsResult(responses, new ArrayList<>()));
}
use of org.openkilda.northbound.dto.v1.links.LinkPropsDto in project open-kilda by telstra.
the class LinkPropsMapper method toLinkMaxBandwidth.
/**
* Converts {@link LinkPropsDto} to {@link LinkMaxBandwidthDto}.
*/
default LinkMaxBandwidthDto toLinkMaxBandwidth(LinkPropsDto input) {
NetworkEndpoint source = input.getSource();
NetworkEndpoint dest = input.getDest();
Long maxBandwidth = Long.valueOf(input.getProps().get(LinkProps.MAX_BANDWIDTH_PROP_NAME));
return new LinkMaxBandwidthDto(source.getDatapath().toString(), source.getPortNumber(), dest.getDatapath().toString(), dest.getPortNumber(), maxBandwidth);
}
Aggregations