Search in sources :

Example 1 with ListIslsPayload

use of org.openkilda.server42.control.stormstub.api.ListIslsPayload in project open-kilda by telstra.

the class StubApplicationTests method clearIsls.

@BeforeEach
public void clearIsls() throws Exception {
    mockMvc.perform(delete("/kafka/isl/{switchId}", switchId)).andExpect(status().isOk());
    MvcResult result = mockMvc.perform(get("/kafka/isl/{switchId}", switchId)).andReturn();
    ListIslsPayload emptyPayload = new ListIslsPayload();
    mockMvc.perform(asyncDispatch(result)).andExpect(status().isOk()).andExpect(content().json(objectWriter.writeValueAsString(emptyPayload)));
}
Also used : ListIslsPayload(org.openkilda.server42.control.stormstub.api.ListIslsPayload) MvcResult(org.springframework.test.web.servlet.MvcResult) BeforeEach(org.junit.jupiter.api.BeforeEach)

Example 2 with ListIslsPayload

use of org.openkilda.server42.control.stormstub.api.ListIslsPayload in project open-kilda by telstra.

the class StubApplicationTests method deleteIsl.

@Test
public void deleteIsl() throws Exception {
    AddIslPayload testIsl = AddIslPayload.builder().switchId(new SwitchId(switchId)).port(456).build();
    pushIsl(testIsl);
    mockMvc.perform(delete("/kafka/isl/{switchId}/{port}", switchId, testIsl.getPort())).andExpect(status().isOk());
    MvcResult result = mockMvc.perform(get("/kafka/isl/{switchId}", switchId)).andReturn();
    ListIslsPayload listIslsPayload = new ListIslsPayload();
    listIslsPayload.getPorts().add(testIsl.getPort());
    mockMvc.perform(asyncDispatch(result)).andExpect(status().isOk()).andExpect(content().json(objectWriter.writeValueAsString(listIslsPayload)));
}
Also used : SwitchId(org.openkilda.model.SwitchId) ListIslsPayload(org.openkilda.server42.control.stormstub.api.ListIslsPayload) AddIslPayload(org.openkilda.server42.control.stormstub.api.AddIslPayload) MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Example 3 with ListIslsPayload

use of org.openkilda.server42.control.stormstub.api.ListIslsPayload in project open-kilda by telstra.

the class StubApplicationTests method addIsls.

@Test
public void addIsls() throws Exception {
    AddIslPayload testIsl = AddIslPayload.builder().switchId(new SwitchId(switchId)).port(456).build();
    pushIsl(testIsl);
    ListIslsPayload listIslsPayload = new ListIslsPayload();
    listIslsPayload.getPorts().add(testIsl.getPort());
    MvcResult result = mockMvc.perform(get("/kafka/isl/{switchId}", switchId)).andReturn();
    mockMvc.perform(asyncDispatch(result)).andDo(print()).andExpect(status().isOk()).andExpect(content().json(objectWriter.writeValueAsString(listIslsPayload)));
}
Also used : SwitchId(org.openkilda.model.SwitchId) ListIslsPayload(org.openkilda.server42.control.stormstub.api.ListIslsPayload) AddIslPayload(org.openkilda.server42.control.stormstub.api.AddIslPayload) MvcResult(org.springframework.test.web.servlet.MvcResult) Test(org.junit.jupiter.api.Test) SpringBootTest(org.springframework.boot.test.context.SpringBootTest)

Aggregations

ListIslsPayload (org.openkilda.server42.control.stormstub.api.ListIslsPayload)3 MvcResult (org.springframework.test.web.servlet.MvcResult)3 Test (org.junit.jupiter.api.Test)2 SwitchId (org.openkilda.model.SwitchId)2 AddIslPayload (org.openkilda.server42.control.stormstub.api.AddIslPayload)2 SpringBootTest (org.springframework.boot.test.context.SpringBootTest)2 BeforeEach (org.junit.jupiter.api.BeforeEach)1