IntentAddShellCommand extends OsgiCommandSupport { @Override protected Object doExecute() throws Exception { UUID uuid = UUID.randomUUID(); List<Subjects> subjects = null; List<Actions> intentActions = null; List<Constraints> intentConstraints = null; try { subjects = createSubjects(); intentActions = createActions(); intentConstraints = createConstraints(); } catch(InvalidObjectException e) { LOG.error("Error at executing intent attributes creation"); return e.getMessage(); } Intent intent = new IntentBuilder(). setId(new Uuid(uuid.toString())) .setSubjects(subjects) .setActions(intentActions) .setConstraints(intentConstraints) .build(); if (provider.addIntent(intent)) { return String.format("Intent created (id: %s)", uuid.toString()); } else { return "Error creating new intent"; } } IntentAddShellCommand(NicConsoleProvider provider, IntentMappingService mappingService);   }
@Test public final void testDoExecute() throws Exception { Object feedBack = nicAddShellCmd.doExecute(); assertNotNull(feedBack); assertEquals("As we test a mocked object the feedback should be error message","No subject found with value: any in the mapping service. Try adding it using: intent:map' command", feedBack); }