### Question:
SubscriptionRequestMapper { public PrivateSubscribeRequest mapPrivateSubscribeRequest( final JsonRpcRequestContext jsonRpcRequestContext, final String enclavePublicKey) throws InvalidSubscriptionRequestException { try { final WebSocketRpcRequest webSocketRpcRequestBody = validateRequest(jsonRpcRequestContext); final String privacyGroupId = webSocketRpcRequestBody.getRequiredParameter(0, String.class); final SubscriptionType subscriptionType = webSocketRpcRequestBody.getRequiredParameter(1, SubscriptionType.class); switch (subscriptionType) { case LOGS: { final FilterParameter filterParameter = jsonRpcRequestContext.getRequiredParameter(2, FilterParameter.class); return new PrivateSubscribeRequest( SubscriptionType.LOGS, filterParameter, null, webSocketRpcRequestBody.getConnectionId(), privacyGroupId, enclavePublicKey); } default: throw new InvalidSubscriptionRequestException( "Invalid subscribe request. Invalid private subscription type."); } } catch (final InvalidSubscriptionRequestException e) { throw e; } catch (final Exception e) { throw new InvalidSubscriptionRequestException("Error parsing subscribe request", e); } } SubscriptionRequestMapper(); SubscribeRequest mapSubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext); UnsubscribeRequest mapUnsubscribeRequest(final JsonRpcRequestContext jsonRpcRequestContext); PrivateSubscribeRequest mapPrivateSubscribeRequest(
      final JsonRpcRequestContext jsonRpcRequestContext, final String enclavePublicKey); PrivateUnsubscribeRequest mapPrivateUnsubscribeRequest(
      final JsonRpcRequestContext jsonRpcRequestContext);  }### Answer:
@Test public void mapRequestToPrivateLogsSubscription() { final JsonRpcRequest jsonRpcRequest = parseWebSocketRpcRequest( "{\"id\": 1, \"method\": \"priv_subscribe\", \"params\": [\"B1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=\", \"logs\", {\"address\": \"0x8320fe7702b96808f7bbc0d4a888ed1468216cfd\"}]}"); final PrivateSubscribeRequest expectedSubscribeRequest = new PrivateSubscribeRequest( SubscriptionType.LOGS, new FilterParameter( BlockParameter.LATEST, BlockParameter.LATEST, singletonList(Address.fromHexString("0x8320fe7702b96808f7bbc0d4a888ed1468216cfd")), emptyList(), null), null, null, "B1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=", ENCLAVE_PUBLIC_KEY); final PrivateSubscribeRequest subscribeRequest = mapper.mapPrivateSubscribeRequest( new JsonRpcRequestContext(jsonRpcRequest), ENCLAVE_PUBLIC_KEY); assertThat(subscribeRequest) .isEqualToComparingFieldByFieldRecursively(expectedSubscribeRequest); }
@Test public void mapRequestToPrivateSubscriptionWithInvalidType() { final JsonRpcRequest jsonRpcRequest = parseWebSocketRpcRequest( "{\"id\": 1, \"method\": \"priv_subscribe\", \"params\": [\"B1aVtMxLCUHmBVHXoZzzBgPbW/wj5axDpW9X8l91SGo=\", \"syncing\", {\"includeTransactions\": true}]}"); thrown.expect(InvalidSubscriptionRequestException.class); thrown.expectMessage("Invalid subscribe request. Invalid private subscription type."); mapper.mapPrivateSubscribeRequest( new JsonRpcRequestContext(jsonRpcRequest), ENCLAVE_PUBLIC_KEY); }