@Test public void beginTransactionTest()throws Exception{ IntentResolver intentResolver1=mock(IntentResolver.class); BeginTransactionInput input=mock(BeginTransactionInput.class); BeginTransactionOutputBuilder outputBuilder = new BeginTransactionOutputBuilder(); 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.beginTransaction(input)); }
@Override public Future<RpcResult<BeginTransactionOutput>> beginTransaction(BeginTransactionInput input) { final BeginTransactionOutputBuilder outputBuilder = new BeginTransactionOutputBuilder(); if (transaction){ outputBuilder.setResultCode(Error).setMessage("The previous transaction has not been finished."); } else{ String errorInfo = transactionBegin.transactionbegin(aaa,input); if (errorInfo != null){ outputBuilder.setResultCode(Error).setMessage(errorInfo); } else{ transaction = true; outputBuilder.setResultCode(Ok).setMessage("Transaction Begin."); } } return RpcResultBuilder.success(outputBuilder).buildFuture(); }
UserManager implements NemoIntentService { @Override public Future<RpcResult<BeginTransactionOutput>> beginTransaction(BeginTransactionInput input) { final BeginTransactionOutputBuilder outputBuilder = new BeginTransactionOutputBuilder(); if (transaction){ outputBuilder.setResultCode(Error).setMessage("The previous transaction has not been finished."); } else{ String errorInfo = transactionBegin.transactionbegin(aaa,input); if (errorInfo != null){ outputBuilder.setResultCode(Error).setMessage(errorInfo); } else{ transaction = true; outputBuilder.setResultCode(Ok).setMessage("Transaction Begin."); } } return RpcResultBuilder.success(outputBuilder).buildFuture(); } }
UserManager implements NemoIntentService { @Override public Future<RpcResult<BeginTransactionOutput>> beginTransaction(BeginTransactionInput input) { final BeginTransactionOutputBuilder outputBuilder = new BeginTransactionOutputBuilder(); if (transaction){ outputBuilder.setResultCode(Error).setMessage("The previous transaction has not been finished."); } else{ String errorInfo = transactionBegin.transactionbegin(aaa,input); if (errorInfo != null){ outputBuilder.setResultCode(Error).setMessage(errorInfo); } else{ transaction = true; outputBuilder.setResultCode(Ok).setMessage("Transaction Begin."); } } return RpcResultBuilder.success(outputBuilder).buildFuture(); } UserManager(DataBroker dataBroker0, IntentResolver intentResolver0); }
UserManager implements NemoIntentService { @Override public Future<RpcResult<BeginTransactionOutput>> beginTransaction(BeginTransactionInput input) { final BeginTransactionOutputBuilder outputBuilder = new BeginTransactionOutputBuilder(); if (transaction){ outputBuilder.setResultCode(Error).setMessage("The previous transaction has not been finished."); } else{ String errorInfo = transactionBegin.transactionbegin(aaa,input); if (errorInfo != null){ outputBuilder.setResultCode(Error).setMessage(errorInfo); } else{ transaction = true; outputBuilder.setResultCode(Ok).setMessage("Transaction Begin."); } } 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); }
UserManager implements NemoIntentService { @Override public Future<RpcResult<BeginTransactionOutput>> beginTransaction(BeginTransactionInput input) { final BeginTransactionOutputBuilder outputBuilder = new BeginTransactionOutputBuilder(); if (transaction){ outputBuilder.setResultCode(Error).setMessage("The previous transaction has not been finished."); } else{ String errorInfo = transactionBegin.transactionbegin(aaa,input); if (errorInfo != null){ outputBuilder.setResultCode(Error).setMessage(errorInfo); } else{ transaction = true; outputBuilder.setResultCode(Ok).setMessage("Transaction Begin."); } } 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);  }