Search in sources :

Example 1 with SwitchPatch

use of org.openkilda.messaging.model.SwitchPatch in project open-kilda by telstra.

the class SwitchOperationsServiceTest method shouldSetNullPopWhenPopIsEmptyString.

@Test
public void shouldSetNullPopWhenPopIsEmptyString() throws SwitchNotFoundException {
    Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
    switchRepository.add(sw);
    SwitchPatch switchPatch = new SwitchPatch("", null);
    switchOperationsService.patchSwitch(TEST_SWITCH_ID, switchPatch);
    Switch updatedSwitch = switchRepository.findById(TEST_SWITCH_ID).get();
    assertNull(updatedSwitch.getPop());
}
Also used : Switch(org.openkilda.model.Switch) SwitchPatch(org.openkilda.messaging.model.SwitchPatch) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 2 with SwitchPatch

use of org.openkilda.messaging.model.SwitchPatch in project open-kilda by telstra.

the class SwitchOperationsServiceTest method shouldPatchSwitch.

@Test
public void shouldPatchSwitch() throws SwitchNotFoundException {
    Switch sw = Switch.builder().switchId(TEST_SWITCH_ID).status(SwitchStatus.ACTIVE).build();
    switchRepository.add(sw);
    SwitchPatch switchPatch = new SwitchPatch("pop", new SwitchLocation(48.860611, 2.337633, "street", "city", "country"));
    switchOperationsService.patchSwitch(TEST_SWITCH_ID, switchPatch);
    Switch updatedSwitch = switchRepository.findById(TEST_SWITCH_ID).get();
    assertEquals(switchPatch.getPop(), updatedSwitch.getPop());
    assertEquals(switchPatch.getLocation().getLatitude(), updatedSwitch.getLatitude());
    assertEquals(switchPatch.getLocation().getLongitude(), updatedSwitch.getLongitude());
    assertEquals(switchPatch.getLocation().getStreet(), updatedSwitch.getStreet());
    assertEquals(switchPatch.getLocation().getCity(), updatedSwitch.getCity());
    assertEquals(switchPatch.getLocation().getCountry(), updatedSwitch.getCountry());
}
Also used : Switch(org.openkilda.model.Switch) SwitchLocation(org.openkilda.messaging.model.SwitchLocation) SwitchPatch(org.openkilda.messaging.model.SwitchPatch) InMemoryGraphBasedTest(org.openkilda.persistence.inmemory.InMemoryGraphBasedTest) Test(org.junit.Test)

Example 3 with SwitchPatch

use of org.openkilda.messaging.model.SwitchPatch in project open-kilda by telstra.

the class SwitchMapperTest method testSwitchPatchDtoToSwitchPatch.

@Test
public void testSwitchPatchDtoToSwitchPatch() {
    SwitchPatchDto switchPatchDto = new SwitchPatchDto("pop", new SwitchLocationDtoV2(48.860611, 2.337633, "street", "city", "country"));
    SwitchPatch switchPatch = switchMapper.map(switchPatchDto);
    assertEquals(switchPatchDto.getPop(), switchPatch.getPop());
    assertEquals(switchPatchDto.getLocation().getLatitude(), switchPatch.getLocation().getLatitude());
    assertEquals(switchPatchDto.getLocation().getLongitude(), switchPatch.getLocation().getLongitude());
    assertEquals(switchPatchDto.getLocation().getStreet(), switchPatch.getLocation().getStreet());
    assertEquals(switchPatchDto.getLocation().getCity(), switchPatch.getLocation().getCity());
    assertEquals(switchPatchDto.getLocation().getCountry(), switchPatch.getLocation().getCountry());
}
Also used : SwitchLocationDtoV2(org.openkilda.northbound.dto.v2.switches.SwitchLocationDtoV2) SwitchPatchDto(org.openkilda.northbound.dto.v2.switches.SwitchPatchDto) SwitchPatch(org.openkilda.messaging.model.SwitchPatch) Test(org.junit.Test)

Aggregations

Test (org.junit.Test)3 SwitchPatch (org.openkilda.messaging.model.SwitchPatch)3 Switch (org.openkilda.model.Switch)2 InMemoryGraphBasedTest (org.openkilda.persistence.inmemory.InMemoryGraphBasedTest)2 SwitchLocation (org.openkilda.messaging.model.SwitchLocation)1 SwitchLocationDtoV2 (org.openkilda.northbound.dto.v2.switches.SwitchLocationDtoV2)1 SwitchPatchDto (org.openkilda.northbound.dto.v2.switches.SwitchPatchDto)1