IntentListShellCommand extends OsgiCommandSupport { @Override protected Object doExecute() throws Exception { List<Intent> listIntents = provider.listIntents(isConfigurationData); if (listIntents.size() > 0) { StringBuilder sb = new StringBuilder(); Integer counter = 1; for (Intent intent : listIntents) { sb.append(String.format("#%d - id: %s\n", counter, intent.getId().getValue())); counter++; } return sb.toString(); } else { return String.format("No intents found. Check the logs for more details."); } } IntentListShellCommand(NicConsoleProvider provider);   }
@Test public final void testDoExecute() throws Exception { boolean isConfigurationData = false; final String expectedID = "#1 - id: "+intentID+"\n"; final String failResult = "No intents found. Check the logs for more details."; final String noIntent = "No intent found"; final List<Intent> intentlist = new ArrayList<Intent>(); Object feedBack = intentListShellCommand.doExecute(); assertEquals(noIntent, failResult, feedBack); when(intent.getId()).thenReturn(uuid); when(uuid.getValue()).thenReturn(intentID); intentlist.add(intent); when(provider.listIntents(isConfigurationData)).thenReturn(intentlist); Object result = intentListShellCommand.doExecute(); assertEquals(expectedID, result); }