UserManager implements NemoIntentService { @Override public Future<RpcResult<LanguageStyleNemoRequestOutput>> languageStyleNemoRequest(LanguageStyleNemoRequestInput input) { final LanguageStyleNemoRequestOutputBuilder outputBuilder = new LanguageStyleNemoRequestOutputBuilder(); try { String errorInfo = languageIntent.LanIntentHandler(aaa,input); if (errorInfo != null){ if (errorInfo.contains(NEMOConstants.Results)){ outputBuilder.setResultCode(Ok).setMessage(errorInfo); } else{ outputBuilder.setResultCode(Error).setMessage(errorInfo); } } else{ outputBuilder.setResultCode(Ok).setMessage("The intent has been stored in this transaction."); informresolver = true; } } catch (ParseException e) { LOG.error("Exception:",e); outputBuilder.setResultCode(Error).setMessage(e.getMessage()); } catch (NumberFormatException e) { LOG.error("Exception:",e); outputBuilder.setResultCode(Error).setMessage(e.getMessage()); } return RpcResultBuilder.success(outputBuilder).buildFuture(); } UserManager(DataBroker dataBroker0, IntentResolver intentResolver0); @Override Future<RpcResult<AdvancedNemoQueryOutput>> advancedNemoQuery(AdvancedNemoQueryInput input); @Override Future<RpcResult<BeginTransactionOutput>> beginTransaction(BeginTransactionInput input); @Override Future<RpcResult<EndTransactionOutput>> endTransaction(EndTransactionInput input); @Override Future<RpcResult<LanguageStyleNemoRequestOutput>> languageStyleNemoRequest(LanguageStyleNemoRequestInput input); @Override Future<RpcResult<RegisterUserOutput>> registerUser(RegisterUserInput input); @Override Future<RpcResult<StructureStyleNemoDeleteOutput>> structureStyleNemoDelete(StructureStyleNemoDeleteInput input); @Override Future<RpcResult<StructureStyleNemoUpdateOutput>> structureStyleNemoUpdate(StructureStyleNemoUpdateInput input);  }
@Test public void languageStyleNemoRequestTest() throws Exception{ LanguageStyleNemoRequestInput input=mock(LanguageStyleNemoRequestInput.class); Map<UserId, User> result; Users users = mock(Users.class); User user = mock(User.class); UserId userId = mock(UserId.class); UserId userId1 = mock(UserId.class); ReadOnlyTransaction readOnlyTransaction = mock(ReadOnlyTransaction.class); CheckedFuture checkedFuture = mock(CheckedFuture.class); Optional<Users> usersOpt = Optional.of(users); List<User> userList = new ArrayList<User>(); userList.add(user); when(input.getUserId()).thenReturn(userId1); when(dataBroker.newReadOnlyTransaction()).thenReturn(readOnlyTransaction); when(readOnlyTransaction.read(any(LogicalDatastoreType.class), any(InstanceIdentifier.class))).thenReturn(checkedFuture); when(checkedFuture.get()).thenReturn(usersOpt); when(users.getUser()).thenReturn(userList); when(user.getUserId()).thenReturn(userId); Assert.assertNotNull(usermanager1.languageStyleNemoRequest(input)); }