BTCMarketsDigest extends BaseParamsDigest { @Override public String digestParams(RestInvocation inv) { final String nonce = inv.getParamValue(HeaderParam.class, "timestamp").toString(); return digest(inv.getMethodPath(), nonce, inv.getRequestBody(), inv.getQueryString()); } BTCMarketsDigest(String secretKey, Boolean includeQueryString); @Override String digestParams(RestInvocation inv);  }
@Test public void shouldEncodeRestInvocation() throws Exception { String expected = "wPYiZy9kIfRsexepi81dvv/eHv8fiyWdAoRSlaZrE3D63GbK3VOPRExKe5alTcNoldn2xd+7RS2avbCInTltlA=="; RestInvocation invocation = mock(RestInvocation.class); PowerMockito.when( invocation, "getParamValue", Mockito.eq(HeaderParam.class), Mockito.eq("timestamp")) .thenReturn("nonce"); PowerMockito.when(invocation, "getMethodPath").thenReturn("/path/to/method"); PowerMockito.when(invocation, "getRequestBody").thenReturn("request body"); String encoded = btcMarketsDigest.digestParams(invocation); assertThat(encoded).isEqualTo(expected); }