Search in sources :

Example 1 with Host

use of com.sequenceiq.ambari.shell.completion.Host in project ambari-shell by sequenceiq.

the class ClusterCommandsTest method testAssignForInvalidHostGroup.

@Test
public void testAssignForInvalidHostGroup() {
    Map<String, List<String>> map = singletonMap("group1", asList("host", "host2"));
    ReflectionTestUtils.setField(clusterCommands, "hostGroups", map);
    when(client.getHostNames()).thenReturn(singletonMap("host3", "HEALTHY"));
    String result = clusterCommands.assign(new Host("host3"), "group0");
    assertEquals("group0 is not a valid host group", result);
}
Also used : ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) Host(com.sequenceiq.ambari.shell.completion.Host) Test(org.junit.Test)

Example 2 with Host

use of com.sequenceiq.ambari.shell.completion.Host in project ambari-shell by sequenceiq.

the class ClusterCommandsTest method testAssignForValidHostGroup.

@Test
public void testAssignForValidHostGroup() {
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    map.put("group1", new ArrayList<String>());
    ReflectionTestUtils.setField(clusterCommands, "hostGroups", map);
    when(client.getHostNames()).thenReturn(singletonMap("host3", "HEALTHY"));
    String result = clusterCommands.assign(new Host("host3"), "group1");
    assertEquals("host3 has been added to group1", result);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) Host(com.sequenceiq.ambari.shell.completion.Host) Test(org.junit.Test)

Example 3 with Host

use of com.sequenceiq.ambari.shell.completion.Host in project ambari-shell by sequenceiq.

the class HostCommandsTest method testFocusHostForValidHost.

@Test
public void testFocusHostForValidHost() {
    when(client.getHostNames()).thenReturn(singletonMap("host1", "HEALTHY"));
    String result = hostCommands.focusHost(new Host("host1"));
    verify(context).setFocus("host1", FocusType.HOST);
    assertEquals("Focus set to: host1", result);
}
Also used : Host(com.sequenceiq.ambari.shell.completion.Host) Test(org.junit.Test)

Example 4 with Host

use of com.sequenceiq.ambari.shell.completion.Host in project ambari-shell by sequenceiq.

the class ClusterCommandsTest method testAssignForInvalidHost.

@Test
public void testAssignForInvalidHost() {
    Map<String, List<String>> map = new HashMap<String, List<String>>();
    map.put("group1", new ArrayList<String>());
    ReflectionTestUtils.setField(clusterCommands, "hostGroups", map);
    when(client.getHostNames()).thenReturn(singletonMap("host2", "HEALTHY"));
    String result = clusterCommands.assign(new Host("host3"), "group1");
    assertEquals("host3 is not a valid hostname", result);
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) Arrays.asList(java.util.Arrays.asList) Collections.emptyList(java.util.Collections.emptyList) List(java.util.List) Host(com.sequenceiq.ambari.shell.completion.Host) Test(org.junit.Test)

Example 5 with Host

use of com.sequenceiq.ambari.shell.completion.Host in project ambari-shell by sequenceiq.

the class HostCommandsTest method testFocusHostForInvalidHost.

@Test
public void testFocusHostForInvalidHost() {
    when(client.getHostNames()).thenReturn(singletonMap("host3", "HEALTHY"));
    String result = hostCommands.focusHost(new Host("host1"));
    verify(context, times(0)).setFocus("host1", FocusType.HOST);
    assertEquals("host1 is not a valid host name", result);
}
Also used : Host(com.sequenceiq.ambari.shell.completion.Host) Test(org.junit.Test)

Aggregations

Host (com.sequenceiq.ambari.shell.completion.Host)5 Test (org.junit.Test)5 ArrayList (java.util.ArrayList)3 Arrays.asList (java.util.Arrays.asList)3 Collections.emptyList (java.util.Collections.emptyList)3 List (java.util.List)3 HashMap (java.util.HashMap)2