Search in sources :

Example 1 with PathDto

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

the class JsonSerializationTest method linksDtoTest.

@Test
public void linksDtoTest() throws IOException {
    LinkDto dto = new LinkDto(-1, 1, 0, 0, 0, LinkStatus.DISCOVERED, LinkStatus.DISCOVERED, LinkStatus.FAILED, 0, false, false, "bfd-session-status", singletonList(new PathDto(SWITCH_ID, 1, 0, 10L)));
    assertEquals(dto, pass(dto, LinkDto.class));
}
Also used : PathDto(org.openkilda.northbound.dto.v1.links.PathDto) LinkDto(org.openkilda.northbound.dto.v1.links.LinkDto) Test(org.junit.Test)

Example 2 with PathDto

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

the class JsonSerializationTest method pathDtoTest.

@Test
public void pathDtoTest() throws IOException {
    PathDto dto = new PathDto(SWITCH_ID, 1, 0, 10L);
    assertEquals(dto, pass(dto, PathDto.class));
}
Also used : PathDto(org.openkilda.northbound.dto.v1.links.PathDto) Test(org.junit.Test)

Example 3 with PathDto

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

the class LinkServiceTest method shouldGetLinksList.

@Test
public void shouldGetLinksList() {
    String correlationId = "links-list";
    SwitchId switchId = new SwitchId(1L);
    IslInfoData islInfoData = new IslInfoData(new PathNode(switchId, 1, 0), new PathNode(switchId, 2, 1), IslChangeType.DISCOVERED, false);
    messageExchanger.mockChunkedResponse(correlationId, Collections.singletonList(islInfoData));
    RequestCorrelationId.create(correlationId);
    List<LinkDto> result = linkService.getLinks(islInfoData.getSource().getSwitchId(), islInfoData.getSource().getPortNo(), islInfoData.getDestination().getSwitchId(), islInfoData.getDestination().getPortNo()).join();
    assertFalse("List of link shouldn't be empty", result.isEmpty());
    LinkDto link = result.get(0);
    assertThat(link.getSpeed(), is(0L));
    assertThat(link.getMaxBandwidth(), is(0L));
    assertThat(link.getAvailableBandwidth(), is(0L));
    assertThat(link.getCost(), is(0));
    assertThat(link.isUnderMaintenance(), is(false));
    assertThat(link.getState(), is(LinkStatus.DISCOVERED));
    assertFalse(link.getPath().isEmpty());
    PathDto path = link.getPath().get(0);
    assertThat(path.getSwitchId(), is(switchId.toString()));
    assertThat(path.getPortNo(), is(1));
    path = link.getPath().get(1);
    assertThat(path.getSwitchId(), is(switchId.toString()));
    assertThat(path.getPortNo(), is(2));
}
Also used : PathDto(org.openkilda.northbound.dto.v1.links.PathDto) LinkDto(org.openkilda.northbound.dto.v1.links.LinkDto) SwitchId(org.openkilda.model.SwitchId) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) Test(org.junit.Test)

Example 4 with PathDto

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

the class LinkServiceTest method testLinkUnderMaintenance.

@Test
public void testLinkUnderMaintenance() {
    String correlationId = "links-list";
    SwitchId switchId = new SwitchId(1L);
    boolean underMaintenance = true;
    boolean evacuate = false;
    IslInfoData islInfoData = new IslInfoData(new PathNode(switchId, 1, 0), new PathNode(switchId, 2, 1), IslChangeType.DISCOVERED, true);
    messageExchanger.mockChunkedResponse(correlationId, Collections.singletonList(islInfoData));
    RequestCorrelationId.create(correlationId);
    LinkUnderMaintenanceDto linkUnderMaintenanceDto = new LinkUnderMaintenanceDto(islInfoData.getSource().getSwitchId().toString(), islInfoData.getSource().getPortNo(), islInfoData.getDestination().getSwitchId().toString(), islInfoData.getDestination().getPortNo(), underMaintenance, evacuate);
    List<LinkDto> result = linkService.updateLinkUnderMaintenance(linkUnderMaintenanceDto).join();
    assertFalse("List of link shouldn't be empty", result.isEmpty());
    LinkDto link = result.get(0);
    assertThat(link.isUnderMaintenance(), is(true));
    assertThat(link.getState(), is(LinkStatus.DISCOVERED));
    assertFalse(link.getPath().isEmpty());
    PathDto path = link.getPath().get(0);
    assertThat(path.getSwitchId(), is(switchId.toString()));
    assertThat(path.getPortNo(), is(1));
}
Also used : PathDto(org.openkilda.northbound.dto.v1.links.PathDto) LinkDto(org.openkilda.northbound.dto.v1.links.LinkDto) SwitchId(org.openkilda.model.SwitchId) IslInfoData(org.openkilda.messaging.info.event.IslInfoData) PathNode(org.openkilda.messaging.info.event.PathNode) LinkUnderMaintenanceDto(org.openkilda.northbound.dto.v1.links.LinkUnderMaintenanceDto) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)4 PathDto (org.openkilda.northbound.dto.v1.links.PathDto)4 LinkDto (org.openkilda.northbound.dto.v1.links.LinkDto)3 IslInfoData (org.openkilda.messaging.info.event.IslInfoData)2 PathNode (org.openkilda.messaging.info.event.PathNode)2 SwitchId (org.openkilda.model.SwitchId)2 LinkUnderMaintenanceDto (org.openkilda.northbound.dto.v1.links.LinkUnderMaintenanceDto)1