use of com.cloud.network.schema.showvcs.VcsNodes in project cloudstack by apache.
the class BrocadeVcsResourceTest method testPingCommandStatusOk.
@Test
public void testPingCommandStatusOk() throws ConfigurationException, BrocadeVcsApiException {
resource.configure("BrocadeVcsResource", parameters);
final VcsNodeInfo nodeInfo = mock(VcsNodeInfo.class);
when(nodeInfo.getNodeState()).thenReturn("Online");
List<VcsNodeInfo> nodes = new ArrayList<VcsNodeInfo>();
nodes.add(nodeInfo);
final VcsNodes vcsNodes = mock(VcsNodes.class);
final Output output = mock(Output.class);
when(output.getVcsNodes()).thenReturn(vcsNodes);
when(vcsNodes.getVcsNodeInfo()).thenReturn(nodes);
when(api.getSwitchStatus()).thenReturn(output);
final PingCommand ping = resource.getCurrentStatus(42);
assertTrue(ping != null);
assertTrue(ping.getHostId() == 42);
assertTrue(ping.getHostType() == Host.Type.L2Networking);
}
use of com.cloud.network.schema.showvcs.VcsNodes in project cloudstack by apache.
the class BrocadeVcsResourceTest method testPingCommandStatusFail.
@Test
public void testPingCommandStatusFail() throws ConfigurationException, BrocadeVcsApiException {
resource.configure("BrocadeVcsResource", parameters);
final VcsNodeInfo nodeInfo = mock(VcsNodeInfo.class);
when(nodeInfo.getNodeState()).thenReturn("Offline");
List<VcsNodeInfo> nodes = new ArrayList<VcsNodeInfo>();
nodes.add(nodeInfo);
final VcsNodes vcsNodes = mock(VcsNodes.class);
final Output output = mock(Output.class);
when(output.getVcsNodes()).thenReturn(vcsNodes);
when(vcsNodes.getVcsNodeInfo()).thenReturn(nodes);
when(api.getSwitchStatus()).thenReturn(output);
final PingCommand ping = resource.getCurrentStatus(42);
assertTrue(ping == null);
}
Aggregations