### Question:
KeyResource { @GET @ApiOperation(value = "Fetch local public keys managed by the enclave") @ApiResponses({@ApiResponse(code = 200, message = "Managed public keys")}) public Response getPublicKeys() { RuntimeContext runtimeContext = RuntimeContext.getInstance(); Set<PublicKey> publicKeys = runtimeContext.getPublicKeys(); final JsonArrayBuilder keyBuilder = Json.createArrayBuilder(); publicKeys.stream() .map(key -> Json.createObjectBuilder().add("key", key.encodeToBase64()).build()) .forEach(keyBuilder::add); final String output = Json.createObjectBuilder().add("keys", keyBuilder.build()).build().toString(); return Response.status(Response.Status.OK).entity(output).build(); }  @GET @ApiOperation(value = "Fetch local keys managed by the enclave") @ApiResponses({@ApiResponse(code = 200, message = "Managed keys")}) Response getPublicKeys();  }### Answer:
@Test public void testGetPublicKeys() { Base64.Decoder base64Decoder = Base64.getDecoder(); final String keyJsonString = "{\"keys\": [{\"key\": \"QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc=\"}]}"; String key = "QfeDAys9MPDs2XHExtc84jKGHxZg/aj52DTh0vtA3Xc="; Set<PublicKey> publicKeys = new HashSet<>(); publicKeys.add(PublicKey.from(base64Decoder.decode(key))); when(runtimeContext.getPublicKeys()).thenReturn(publicKeys); Response response = keyResource.getPublicKeys(); assertThat(response).isNotNull(); assertThat(response.getStatus()).isEqualTo(200); final String output = response.getEntity().toString(); final JsonReader expected = Json.createReader(new StringReader(keyJsonString)); final JsonReader actual = Json.createReader(new StringReader(output)); assertThat(expected.readObject()).isEqualTo(actual.readObject()); verify(runtimeContext).getPublicKeys(); }