### Question:
EthSendRawTransaction implements JsonRpcMethod { @Override public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { if (requestContext.getRequest().getParamLength() != 1) { return new JsonRpcErrorResponse( requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS); } final String rawTransaction = requestContext.getRequiredParameter(0, String.class); final Transaction transaction; try { transaction = DomainObjectDecodeUtils.decodeRawTransaction(rawTransaction); } catch (final InvalidJsonRpcRequestException e) { return new JsonRpcErrorResponse( requestContext.getRequest().getId(), JsonRpcError.INVALID_PARAMS); } final ValidationResult<TransactionInvalidReason> validationResult = transactionPool.get().addLocalTransaction(transaction); return validationResult.either( () -> new JsonRpcSuccessResponse( requestContext.getRequest().getId(), transaction.getHash().toString()), errorReason -> sendEmptyHashOnInvalidBlock ? new JsonRpcSuccessResponse( requestContext.getRequest().getId(), Hash.EMPTY.toString()) : new JsonRpcErrorResponse( requestContext.getRequest().getId(), JsonRpcErrorConverter.convertTransactionInvalidReason(errorReason))); } EthSendRawTransaction(final TransactionPool transactionPool);  EthSendRawTransaction(
      final Supplier<TransactionPool> transactionPool, final boolean sendEmptyHashOnInvalidBlock); @Override String getName(); @Override JsonRpcResponse response(final JsonRpcRequestContext requestContext);  }### Answer:
@Test public void requestIsMissingParameter() { final JsonRpcRequestContext request = new JsonRpcRequestContext( new JsonRpcRequest("2.0", "eth_sendRawTransaction", new String[] {})); final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.INVALID_PARAMS); final JsonRpcResponse actualResponse = method.response(request); assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); }
@Test public void requestHasNullObjectParameter() { final JsonRpcRequestContext request = new JsonRpcRequestContext(new JsonRpcRequest("2.0", "eth_sendRawTransaction", null)); final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.INVALID_PARAMS); final JsonRpcResponse actualResponse = method.response(request); assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); }
@Test public void requestHasNullArrayParameter() { final JsonRpcRequestContext request = new JsonRpcRequestContext( new JsonRpcRequest("2.0", "eth_sendRawTransaction", new String[] {null})); final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.INVALID_PARAMS); final JsonRpcResponse actualResponse = method.response(request); assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); }
@Test public void invalidTransactionRlpDecoding() { final String rawTransaction = "0x00"; final JsonRpcRequestContext request = new JsonRpcRequestContext( new JsonRpcRequest("2.0", "eth_sendRawTransaction", new String[] {rawTransaction})); final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.INVALID_PARAMS); final JsonRpcResponse actualResponse = method.response(request); assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); }
@Test public void validTransactionIsSentToTransactionPool() { when(transactionPool.addLocalTransaction(any(Transaction.class))) .thenReturn(ValidationResult.valid()); final JsonRpcRequestContext request = new JsonRpcRequestContext( new JsonRpcRequest("2.0", "eth_sendRawTransaction", new String[] {VALID_TRANSACTION})); final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse( request.getRequest().getId(), "0xbaabcc1bd699e7378451e4ce5969edb9bdcae76cb79bdacae793525c31e423c7"); final JsonRpcResponse actualResponse = method.response(request); assertThat(actualResponse).isEqualToComparingFieldByField(expectedResponse); verify(transactionPool).addLocalTransaction(any(Transaction.class)); }