use of org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.request.PrivateUnsubscribeRequest in project besu by hyperledger.
the class PrivUnsubscribe method response.
@Override
public JsonRpcResponse response(final JsonRpcRequestContext requestContext) {
try {
final PrivateUnsubscribeRequest unsubscribeRequest = getMapper().mapPrivateUnsubscribeRequest(requestContext);
if (privacyController instanceof MultiTenancyPrivacyController) {
checkIfPrivacyGroupMatchesAuthenticatedPrivacyUserId(requestContext, unsubscribeRequest.getPrivacyGroupId());
}
final boolean unsubscribed = subscriptionManager().unsubscribe(unsubscribeRequest);
return new JsonRpcSuccessResponse(requestContext.getRequest().getId(), unsubscribed);
} catch (final InvalidSubscriptionRequestException isEx) {
return new JsonRpcErrorResponse(requestContext.getRequest().getId(), JsonRpcError.INVALID_REQUEST);
} catch (final SubscriptionNotFoundException snfEx) {
return new JsonRpcErrorResponse(requestContext.getRequest().getId(), JsonRpcError.SUBSCRIPTION_NOT_FOUND);
}
}
use of org.hyperledger.besu.ethereum.api.jsonrpc.websocket.subscription.request.PrivateUnsubscribeRequest in project besu by hyperledger.
the class PrivUnsubscribeTest method responseContainsUnsubscribeStatus.
@Test
public void responseContainsUnsubscribeStatus() {
final JsonRpcRequestContext request = createPrivUnsubscribeRequest();
final PrivateUnsubscribeRequest unsubscribeRequest = new PrivateUnsubscribeRequest(1L, CONNECTION_ID, PRIVACY_GROUP_ID);
when(mapperMock.mapPrivateUnsubscribeRequest(eq(request))).thenReturn(unsubscribeRequest);
when(subscriptionManagerMock.unsubscribe(eq(unsubscribeRequest))).thenReturn(true);
final JsonRpcSuccessResponse expectedResponse = new JsonRpcSuccessResponse(request.getRequest().getId(), true);
assertThat(privUnsubscribe.response(request)).isEqualTo(expectedResponse);
}
Aggregations