### Question:
PrivGetPrivateTransaction implements JsonRpcMethod { @Override public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { LOG.trace("Executing {}", RpcMethod.PRIV_GET_PRIVATE_TRANSACTION.getMethodName()); final Hash hash = requestContext.getRequiredParameter(0, Hash.class); final String enclaveKey = enclavePublicKeyProvider.getEnclaveKey(requestContext.getUser()); final Optional<PrivateTransaction> maybePrivateTx; try { maybePrivateTx = privacyController .findPrivateTransactionByPmtHash(hash, enclaveKey) .map(PrivateTransaction.class::cast); } catch (EnclaveClientException e) { return new JsonRpcErrorResponse( requestContext.getRequest().getId(), JsonRpcEnclaveErrorConverter.convertEnclaveInvalidReason(e.getMessage())); } return maybePrivateTx .map(this::mapTransactionResult) .map(result -> new JsonRpcSuccessResponse(requestContext.getRequest().getId(), result)) .orElse(new JsonRpcSuccessResponse(requestContext.getRequest().getId(), null)); } PrivGetPrivateTransaction(
      final PrivacyController privacyController,
      final EnclavePublicKeyProvider enclavePublicKeyProvider); @Override String getName(); @Override JsonRpcResponse response(final JsonRpcRequestContext requestContext);  }### Answer:
@Test public void returnNullWhenPrivateMarkerTransactionDoesNotExist() { when(privacyController.findPrivateTransactionByPmtHash(any(), any())) .thenReturn(Optional.empty()); final JsonRpcRequestContext request = createRequestContext(); final JsonRpcSuccessResponse response = (JsonRpcSuccessResponse) privGetPrivateTransaction.response(request); assertThat(response.getResult()).isNull(); }
@Test public void failsWithEnclaveErrorOnEnclaveError() { final JsonRpcRequestContext request = createRequestContext(); final JsonRpcResponse expectedResponse = new JsonRpcErrorResponse(request.getRequest().getId(), JsonRpcError.ENCLAVE_ERROR); when(privacyController.findPrivateTransactionByPmtHash(any(), any())) .thenThrow(new EnclaveClientException(500, "enclave failure")); final JsonRpcResponse response = privGetPrivateTransaction.response(request); assertThat(response).isEqualTo(expectedResponse); }