use of com.cloud.network.bigswitch.BigSwitchBcfApiException in project cloudstack by apache.
the class BigSwitchBcfResourceTest method testPingCommandStatusApiException.
@Test
public void testPingCommandStatusApiException() throws ConfigurationException, BigSwitchBcfApiException {
_resource.configure("BigSwitchBcfResource", _parameters);
ControlClusterStatus ccs = mock(ControlClusterStatus.class);
when(ccs.getStatus()).thenReturn(false);
when(_bigswitchBcfApi.getControlClusterStatus()).thenThrow(new BigSwitchBcfApiException());
PingCommand ping = _resource.getCurrentStatus(42);
assertTrue(ping == null);
}
use of com.cloud.network.bigswitch.BigSwitchBcfApiException in project cloudstack by apache.
the class BigSwitchBcfResourceTest method testCreateAttachmentApiException.
@Test
public void testCreateAttachmentApiException() throws ConfigurationException, BigSwitchBcfApiException {
_resource.configure("BigSwitchBcfResource", _parameters);
AttachmentData attachmentData = mock(AttachmentData.class);
AttachmentData.Attachment attachment = mock(AttachmentData.Attachment.class);
when(attachmentData.getAttachment()).thenReturn(attachment);
when(attachment.getId()).thenReturn("eeee");
doThrow(new BigSwitchBcfApiException()).when(_bigswitchBcfApi).createAttachment((String) any(), (String) any(), (AttachmentData) any());
CreateBcfAttachmentCommand cmd = new CreateBcfAttachmentCommand("tenantid", "tenantname", "networkid", "portid", "nicId", 100, "1.2.3.4", "aa:bb:cc:dd:ee:ff");
BcfAnswer ans = (BcfAnswer) _resource.executeRequest(cmd);
assertFalse(ans.getResult());
verify(_bigswitchBcfApi, times(3)).createAttachment((String) any(), (String) any(), (AttachmentData) any());
}
use of com.cloud.network.bigswitch.BigSwitchBcfApiException in project cloudstack by apache.
the class BigSwitchBcfResourceTest method testCreateRouterRetryOnce.
@Test
public void testCreateRouterRetryOnce() throws ConfigurationException, BigSwitchBcfApiException {
_resource.configure("BigSwitchBcfResource", _parameters);
when(_bigswitchBcfApi.createRouter((String) any(), (RouterData) any())).thenThrow(new BigSwitchBcfApiException()).thenReturn(UUID.randomUUID().toString());
CreateBcfRouterCommand cmd = new CreateBcfRouterCommand("tenantid");
BcfAnswer ans = (BcfAnswer) _resource.executeRequest(cmd);
assertTrue(ans.getResult());
}
use of com.cloud.network.bigswitch.BigSwitchBcfApiException in project cloudstack by apache.
the class BigSwitchBcfResourceTest method testUpdateAttachmentException.
@Test
public void testUpdateAttachmentException() throws ConfigurationException, BigSwitchBcfApiException {
_resource.configure("BigSwitchBcfResource", _parameters);
doThrow(new BigSwitchBcfApiException()).when(_bigswitchBcfApi).modifyAttachment((String) any(), (String) any(), (AttachmentData) any());
BcfAnswer ans = (BcfAnswer) _resource.executeRequest(new UpdateBcfAttachmentCommand("networkId", "portId", "tenantId", "portname"));
assertFalse(ans.getResult());
verify(_bigswitchBcfApi, times(3)).modifyAttachment((String) any(), (String) any(), (AttachmentData) any());
}
use of com.cloud.network.bigswitch.BigSwitchBcfApiException in project cloudstack by apache.
the class BigSwitchBcfResourceTest method testDeleteNetworkRetryOnce.
@Test
public void testDeleteNetworkRetryOnce() throws ConfigurationException, BigSwitchBcfApiException {
_resource.configure("BigSwitchBcfResource", _parameters);
when(_bigswitchBcfApi.deleteNetwork((String) any(), (String) any())).thenThrow(new BigSwitchBcfApiException()).thenReturn(UUID.randomUUID().toString());
DeleteBcfSegmentCommand cmd = new DeleteBcfSegmentCommand("tenantid", "networkid");
BcfAnswer ans = (BcfAnswer) _resource.executeRequest(cmd);
assertTrue(ans.getResult());
}
Aggregations