### Question:
PrivDebugGetStateRoot extends AbstractBlockParameterMethod { @Override public JsonRpcResponse response(final JsonRpcRequestContext requestContext) { return (JsonRpcResponse) findResultByParamType(requestContext); } PrivDebugGetStateRoot(
      final BlockchainQueries blockchainQueries,
      final EnclavePublicKeyProvider enclavePublicKeyProvider,
      final PrivacyController privacyController); @Override String getName(); @Override JsonRpcResponse response(final JsonRpcRequestContext requestContext);  }### Answer:
@Test public void shouldThrowInvalidJsonRpcParametersExceptionWhenNoPrivacyGroup() { final JsonRpcRequestContext request = request(null, "latest"); final Throwable thrown = catchThrowable(() -> method.response(request)); assertThat(thrown) .isInstanceOf(InvalidJsonRpcParameters.class) .hasNoCause() .hasMessage("Missing required json rpc parameter at index 0"); }
@Test public void shouldReturnErrorIfPrivacyGroupDoesNotExist() { when(privacyController.findPrivacyGroup(anyList(), anyString())) .thenReturn(new PrivacyGroup[] {}); final JsonRpcResponse response = method.response(request("invalid_group", "latest")); assertThat(response.getType()).isEqualByComparingTo(JsonRpcResponseType.ERROR); assertThat(((JsonRpcErrorResponse) response).getError().getMessage()) .contains(FIND_PRIVACY_GROUP_ERROR.getMessage()); }
@Test public void shouldReturnErrorIfUnableToFindStateRoot() { when(privacyController.findPrivacyGroup(anyList(), anyString())) .thenReturn(new PrivacyGroup[] {PRIVACY_GROUP}); when(privacyController.getStateRootByBlockNumber(anyString(), anyString(), anyLong())) .thenReturn(Optional.empty()); final JsonRpcErrorResponse response = (JsonRpcErrorResponse) method.response(request(ENCLAVE_PUBLIC_KEY, "latest")); assertThat(response.getError().getMessage()).contains(INVALID_PARAMS.getMessage()); }
@Test public void shouldReturnSuccessWhenValidPrivacyGroupAndStateRoot() { final Hash hash = Hash.EMPTY_LIST_HASH; when(privacyController.findPrivacyGroup(anyList(), anyString())) .thenReturn(new PrivacyGroup[] {PRIVACY_GROUP}); when(privacyController.getStateRootByBlockNumber(anyString(), anyString(), anyLong())) .thenReturn(Optional.of(hash)); final JsonRpcSuccessResponse response = (JsonRpcSuccessResponse) method.response(request(ENCLAVE_PUBLIC_KEY, "latest")); final Hash result = (Hash) response.getResult(); assertThat(result).isEqualTo(hash); }