AmbariContext { public String getPrompt() { return focus.isType(FocusType.ROOT) ? isConnectedToCluster() ? formatPrompt(focus.getPrefix(), cluster) : "ambari-shell>" : formatPrompt(focus.getPrefix(), focus.getValue()); } AmbariContext(); void setCluster(String cluster); void resetFocus(); void setFocus(String id, FocusType type); String getFocusValue(); boolean areBlueprintsAvailable(); void setHint(Hints hint); String getPrompt(); boolean isConnectedToCluster(); boolean isFocusOnHost(); boolean isFocusOnClusterBuild(); String getHint(); String getCluster(); void setBlueprintsAvailable(boolean blueprintsAvailable);  }
@Test public void testGetPromptForRoot() { ReflectionTestUtils.setField(ambariContext, "cluster", "single-node"); String result = ambariContext.getPrompt(); assertEquals(FocusType.ROOT.prefix() + ":single-node>", result); }
@Test public void testGetPromptForRootButNotConnected() { ReflectionTestUtils.setField(ambariContext, "cluster", null); String result = ambariContext.getPrompt(); assertEquals("ambari-shell>", result); }
@Test public void testGetPromptForFocus() { ReflectionTestUtils.setField(ambariContext, "cluster", "single-node"); ReflectionTestUtils.setField(ambariContext, "focus", new Focus("target", FocusType.HOST)); String result = ambariContext.getPrompt(); assertEquals(String.format("%s:%s>", FocusType.HOST.prefix(), "target"), result); }