### Question:
RestfulClientProvisioner implements ClientProvisioner { IdentityResponseEnvelope attestIdentityRequest(final IdentityRequestEnvelope identityRequest) { HttpEntity<byte[]> message = new HttpEntity<>(structConverter.convert(identityRequest)); ResponseEntity<byte[]> response = restTemplate.exchange(acaIdentityURL, HttpMethod.POST, message, byte[].class); byte[] responseBody = response.getBody(); if (ArrayUtils.isEmpty(responseBody)) { return null; } return structConverter.convert(responseBody, IdentityResponseEnvelope.class); }  @EventListener @SuppressFBWarnings(value = "DM_EXIT", justification = "need to exit app from spring managed class here") final void handleContextInitialized(final ContextRefreshedEvent event); @Override boolean provision();  }### Answer:
@Test @SuppressWarnings("unchecked") public void testAttestIdentityRequest() { byte[] requestBytes = new byte[]{1}; byte[] responseBytes = new byte[]{2}; IdentityRequestEnvelope request = mock(IdentityRequestEnvelope.class); IdentityResponseEnvelope response = mock(IdentityResponseEnvelope.class); ResponseEntity responseEntity = mock(ResponseEntity.class); ReflectionTestUtils.setField(provisioner, "acaIdentityURL", ACA_IDENTITY_URL); when(mockStructConverter.convert(request)).thenReturn(requestBytes); when(mockStructConverter.convert(responseBytes, IdentityResponseEnvelope.class)) .thenReturn(response); when(mockRestTemplate.exchange(eq(ACA_IDENTITY_URL), eq(HttpMethod.POST), any(HttpEntity.class), eq(byte[].class))).thenReturn(responseEntity); when(responseEntity.getBody()).thenReturn(responseBytes); provisioner.attestIdentityRequest(request); verify(mockStructConverter).convert(request); verify(mockStructConverter).convert(responseBytes, IdentityResponseEnvelope.class); ArgumentCaptor<HttpEntity> argument = ArgumentCaptor.forClass(HttpEntity.class); verify(mockRestTemplate).exchange(eq(ACA_IDENTITY_URL), eq(HttpMethod.POST), argument.capture(), eq(byte[].class)); verify(responseEntity).getBody(); assertEquals(argument.getValue().getBody(), requestBytes); verifyNoMoreInteractions(request, response, responseEntity); }