Search in sources :

Example 1 with LinkMaxBandwidthDto

use of org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthDto in project open-kilda by telstra.

the class LinkServiceTest method updateMaxBandwidth.

@Test
public void updateMaxBandwidth() {
    final String correlationId = "update-max-bw-corrId";
    Long maxBandwidth = 1000L;
    SwitchId srcSwitch = new SwitchId("ff:fe:00:00:00:00:00:01");
    Integer srcPort = 8;
    SwitchId dstSwitch = new SwitchId("ff:fe:00:00:00:00:00:02");
    Integer dstPort = 9;
    LinkMaxBandwidthRequest inputRequest = new LinkMaxBandwidthRequest();
    inputRequest.setMaxBandwidth(maxBandwidth);
    HashMap<String, String> requestProps = new HashMap<>();
    requestProps.put(LinkProps.MAX_BANDWIDTH_PROP_NAME, String.valueOf(maxBandwidth));
    org.openkilda.messaging.model.LinkPropsDto linkProps = new org.openkilda.messaging.model.LinkPropsDto(new NetworkEndpoint(srcSwitch, srcPort), new NetworkEndpoint(dstSwitch, dstPort), requestProps);
    LinkPropsRequest request = new LinkPropsPut(linkProps);
    LinkPropsResponse payload = new LinkPropsResponse(request, linkProps, null);
    messageExchanger.mockResponse(correlationId, payload);
    RequestCorrelationId.create(correlationId);
    LinkMaxBandwidthDto result = linkService.updateLinkBandwidth(srcSwitch, srcPort, dstSwitch, dstPort, inputRequest).join();
    assertEquals(srcSwitch.toString(), result.getSrcSwitch());
    assertEquals(dstSwitch.toString(), result.getDstSwitch());
    assertEquals(srcPort, result.getSrcPort());
    assertEquals(dstPort, result.getDstPort());
    assertEquals(maxBandwidth, result.getMaxBandwidth());
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) HashMap(java.util.HashMap) LinkPropsDto(org.openkilda.northbound.dto.v1.links.LinkPropsDto) SwitchId(org.openkilda.model.SwitchId) LinkMaxBandwidthRequest(org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthRequest) LinkPropsResponse(org.openkilda.messaging.nbtopology.response.LinkPropsResponse) LinkPropsRequest(org.openkilda.messaging.nbtopology.request.LinkPropsRequest) LinkPropsPut(org.openkilda.messaging.nbtopology.request.LinkPropsPut) LinkMaxBandwidthDto(org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthDto) Test(org.junit.Test)

Example 2 with LinkMaxBandwidthDto

use of org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthDto 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);
}
Also used : NetworkEndpoint(org.openkilda.messaging.model.NetworkEndpoint) LinkMaxBandwidthDto(org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthDto)

Aggregations

NetworkEndpoint (org.openkilda.messaging.model.NetworkEndpoint)2 LinkMaxBandwidthDto (org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthDto)2 HashMap (java.util.HashMap)1 Test (org.junit.Test)1 LinkPropsPut (org.openkilda.messaging.nbtopology.request.LinkPropsPut)1 LinkPropsRequest (org.openkilda.messaging.nbtopology.request.LinkPropsRequest)1 LinkPropsResponse (org.openkilda.messaging.nbtopology.response.LinkPropsResponse)1 SwitchId (org.openkilda.model.SwitchId)1 LinkMaxBandwidthRequest (org.openkilda.northbound.dto.v1.links.LinkMaxBandwidthRequest)1 LinkPropsDto (org.openkilda.northbound.dto.v1.links.LinkPropsDto)1