Search in sources :

Example 1 with SwitchSyncResult

use of org.openkilda.northbound.dto.v1.switches.SwitchSyncResult in project open-kilda by telstra.

the class JsonSerializationTest method switchSyncResultTest.

@Test
public void switchSyncResultTest() throws IOException {
    RulesSyncDto rules = new RulesSyncDto(singletonList(0L), singletonList(1L), singletonList(2L), singletonList(3L), singletonList(4L), singletonList(5L));
    MetersSyncDto meters = new MetersSyncDto(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList());
    GroupsSyncDto groups = new GroupsSyncDto(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList());
    LogicalPortsSyncDto logicalPorts = new LogicalPortsSyncDto(emptyList(), emptyList(), emptyList(), emptyList(), emptyList(), emptyList());
    SwitchSyncResult dto = new SwitchSyncResult(rules, meters, groups, logicalPorts);
    assertEquals(dto, pass(dto, SwitchSyncResult.class));
}
Also used : GroupsSyncDto(org.openkilda.northbound.dto.v1.switches.GroupsSyncDto) RulesSyncDto(org.openkilda.northbound.dto.v1.switches.RulesSyncDto) LogicalPortsSyncDto(org.openkilda.northbound.dto.v1.switches.LogicalPortsSyncDto) MetersSyncDto(org.openkilda.northbound.dto.v1.switches.MetersSyncDto) SwitchSyncResult(org.openkilda.northbound.dto.v1.switches.SwitchSyncResult) Test(org.junit.Test)

Example 2 with SwitchSyncResult

use of org.openkilda.northbound.dto.v1.switches.SwitchSyncResult in project open-kilda by telstra.

the class SwitchServiceTest method shouldSynchronizeSwitch.

@Test
public void shouldSynchronizeSwitch() throws ExecutionException, InterruptedException {
    String correlationId = "not-sync-rules";
    RequestCorrelationId.create(correlationId);
    Long missingRule = 100L;
    Long misconfiguredRule = 11L;
    Long excessRule = 101L;
    Long properRule = 10L;
    SwitchId switchId = new SwitchId(1L);
    RulesSyncEntry rulesEntry = new RulesSyncEntry(singletonList(missingRule), singletonList(misconfiguredRule), singletonList(properRule), singletonList(excessRule), singletonList(missingRule), singletonList(excessRule));
    InfoData validationResult = new SwitchSyncResponse(switchId, rulesEntry, MetersSyncEntry.builder().proper(singletonList(getMeterInfo(properRule))).build(), GroupSyncEntry.builder().build(), LogicalPortsSyncEntry.builder().build());
    messageExchanger.mockResponse(correlationId, validationResult);
    SwitchSyncResult result = switchService.syncSwitch(switchId, true).get();
    RulesSyncDto rules = result.getRules();
    assertThat(rules.getMissing(), is(singletonList(missingRule)));
    assertThat(rules.getMisconfigured(), is(singletonList(misconfiguredRule)));
    assertThat(rules.getInstalled(), is(singletonList(missingRule)));
    assertThat(rules.getExcess(), is(singletonList(excessRule)));
    assertThat(rules.getInstalled(), is(singletonList(missingRule)));
    assertThat(rules.getRemoved(), is(singletonList(excessRule)));
}
Also used : RulesSyncEntry(org.openkilda.messaging.info.switches.RulesSyncEntry) InfoData(org.openkilda.messaging.info.InfoData) RulesSyncDto(org.openkilda.northbound.dto.v1.switches.RulesSyncDto) SwitchId(org.openkilda.model.SwitchId) SwitchSyncResponse(org.openkilda.messaging.info.switches.SwitchSyncResponse) SwitchSyncResult(org.openkilda.northbound.dto.v1.switches.SwitchSyncResult) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)2 RulesSyncDto (org.openkilda.northbound.dto.v1.switches.RulesSyncDto)2 SwitchSyncResult (org.openkilda.northbound.dto.v1.switches.SwitchSyncResult)2 InfoData (org.openkilda.messaging.info.InfoData)1 RulesSyncEntry (org.openkilda.messaging.info.switches.RulesSyncEntry)1 SwitchSyncResponse (org.openkilda.messaging.info.switches.SwitchSyncResponse)1 SwitchId (org.openkilda.model.SwitchId)1 GroupsSyncDto (org.openkilda.northbound.dto.v1.switches.GroupsSyncDto)1 LogicalPortsSyncDto (org.openkilda.northbound.dto.v1.switches.LogicalPortsSyncDto)1 MetersSyncDto (org.openkilda.northbound.dto.v1.switches.MetersSyncDto)1