### Question:
RestfulClientProvisioner implements ClientProvisioner { RSAPublicKey getACAPublicKey() { ResponseEntity<byte[]> response = restTemplate.getForEntity(acaPublicKeyURL, byte[].class); try { X509EncodedKeySpec keySpec = new X509EncodedKeySpec(response.getBody()); return (RSAPublicKey) KeyFactory.getInstance("RSA").generatePublic(keySpec); } catch (InvalidKeySpecException | NoSuchAlgorithmException e) { throw new ProvisioningException("Encountered error while create Public Key from " + "ACA response: " + e.getMessage(), e); } }  @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 testGetACAPublicKey() throws Exception { KeyPairGenerator keyPairGenerator = KeyPairGenerator.getInstance("RSA"); keyPairGenerator.initialize(512); KeyPair keyPair = keyPairGenerator.generateKeyPair(); RSAPublicKey publicKey = (RSAPublicKey) keyPair.getPublic(); ReflectionTestUtils.setField(provisioner, "acaPublicKeyURL", ACA_KEY_URL); ResponseEntity responseEntity = mock(ResponseEntity.class); when(mockRestTemplate.getForEntity(ACA_KEY_URL, byte[].class)).thenReturn(responseEntity); when(responseEntity.getBody()).thenReturn(publicKey.getEncoded()); RSAPublicKey result = provisioner.getACAPublicKey(); assertEquals(result.getPublicExponent(), publicKey.getPublicExponent()); assertEquals(result.getModulus(), publicKey.getModulus()); verify(mockRestTemplate).getForEntity(ACA_KEY_URL, byte[].class); verify(responseEntity).getBody(); }