use of com.cloud.legacymodel.communication.command.NetworkUsageCommand in project cosmic by MissionCriticalCloud.
the class XcpServerWrapperTest method testNetworkUsageCommandCreate.
@Test
public void testNetworkUsageCommandCreate() {
final Connection conn = Mockito.mock(Connection.class);
final String privateIP = "192.168.0.10";
final String domRName = "dom";
final String option = "create";
final boolean forVpc = true;
final NetworkUsageCommand usageCommand = new NetworkUsageCommand(privateIP, domRName, option, forVpc);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(XcpServerResource.getConnection()).thenReturn(conn);
when(XcpServerResource.networkUsage(conn, usageCommand.getPrivateIP(), "create", null)).thenReturn("success");
final Answer answer = wrapper.execute(usageCommand, XcpServerResource);
verify(XcpServerResource, times(1)).getConnection();
assertTrue(answer.getResult());
}
use of com.cloud.legacymodel.communication.command.NetworkUsageCommand in project cosmic by MissionCriticalCloud.
the class XcpServerWrapperTest method testNetworkUsageCommandExceptiopn.
@Test
public void testNetworkUsageCommandExceptiopn() {
final Connection conn = Mockito.mock(Connection.class);
final String privateIP = "192.168.0.10";
final String domRName = "dom";
final String option = null;
final boolean forVpc = true;
final NetworkUsageCommand usageCommand = new NetworkUsageCommand(privateIP, domRName, option, forVpc);
final CitrixRequestWrapper wrapper = CitrixRequestWrapper.getInstance();
assertNotNull(wrapper);
when(XcpServerResource.getConnection()).thenReturn(conn);
when(XcpServerResource.networkUsage(conn, usageCommand.getPrivateIP(), "create", null)).thenThrow(new CloudRuntimeException("FAILED"));
final Answer answer = wrapper.execute(usageCommand, XcpServerResource);
verify(XcpServerResource, times(1)).getConnection();
assertFalse(answer.getResult());
}
Aggregations