@Test public void processReturnsCacheRegions() throws Exception { RegionAttributes regionAttributesStub = mock(RegionAttributes.class); when(cacheStub.getRegion(TEST_REGION1)).thenReturn(region1Stub); when(region1Stub.getName()).thenReturn(TEST_REGION1); when(region1Stub.size()).thenReturn(10); when(region1Stub.getAttributes()).thenReturn(regionAttributesStub); when(regionAttributesStub.getDataPolicy()).thenReturn(DataPolicy.PERSISTENT_REPLICATE); when(regionAttributesStub.getKeyConstraint()).thenReturn(String.class); when(regionAttributesStub.getValueConstraint()).thenReturn(Integer.class); when(regionAttributesStub.getScope()).thenReturn(Scope.DISTRIBUTED_ACK); Result result = operationHandler.process(serializationService, MessageUtil.makeGetSizeRequest(TEST_REGION1), getNoAuthCacheExecutionContext(cacheStub)); RegionAPI.GetSizeResponse response = (RegionAPI.GetSizeResponse) result.getMessage(); Assert.assertEquals(10, response.getSize()); }
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.GetSizeResponse getSizeResponse = 17;</code> */ public Builder mergeGetSizeResponse(org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse value) { if (getSizeResponseBuilder_ == null) { if (messageTypeCase_ == 17 && messageType_ != org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse.getDefaultInstance()) { messageType_ = org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse.newBuilder((org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse) messageType_) .mergeFrom(value).buildPartial(); } else { messageType_ = value; } onChanged(); } else { if (messageTypeCase_ == 17) { getSizeResponseBuilder_.mergeFrom(value); } getSizeResponseBuilder_.setMessage(value); } messageTypeCase_ = 17; return this; } /**
@java.lang.Override public int hashCode() { if (memoizedHashCode != 0) { return memoizedHashCode; } int hash = 41; hash = (19 * hash) + getDescriptor().hashCode(); hash = (37 * hash) + SIZE_FIELD_NUMBER; hash = (53 * hash) + getSize(); hash = (29 * hash) + unknownFields.hashCode(); memoizedHashCode = hash; return hash; }
case 17: result = result && getGetSizeResponse() .equals(other.getGetSizeResponse()); break; case 18:
case 17: hash = (37 * hash) + GETSIZERESPONSE_FIELD_NUMBER; hash = (53 * hash) + getGetSizeResponse().hashCode(); break; case 18:
if (!parseUnknownFieldProto3( input, unknownFields, extensionRegistry, tag)) { done = true; } finally { this.unknownFields = unknownFields.build(); makeExtensionsImmutable();
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.GetSizeResponse getSizeResponse = 17;</code> */ private com.google.protobuf.SingleFieldBuilderV3< org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse, org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse.Builder, org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponseOrBuilder> getGetSizeResponseFieldBuilder() { if (getSizeResponseBuilder_ == null) { if (!(messageTypeCase_ == 17)) { messageType_ = org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse.getDefaultInstance(); } getSizeResponseBuilder_ = new com.google.protobuf.SingleFieldBuilderV3< org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse, org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse.Builder, org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponseOrBuilder>( (org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse) messageType_, getParentForChildren(), isClean()); messageType_ = null; } messageTypeCase_ = 17; onChanged();; return getSizeResponseBuilder_; }
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.GetSizeResponse getSizeResponse = 17;</code> */ public org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse getGetSizeResponse() { if (getSizeResponseBuilder_ == null) { if (messageTypeCase_ == 17) { return (org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse) messageType_; } return org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse.getDefaultInstance(); } else { if (messageTypeCase_ == 17) { return getSizeResponseBuilder_.getMessage(); } return org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse.getDefaultInstance(); } } /**
@java.lang.Override public boolean equals(final java.lang.Object obj) { if (obj == this) { return true; } if (!(obj instanceof org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse)) { return super.equals(obj); } org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse other = (org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse) obj; boolean result = true; result = result && (getSize() == other.getSize()); result = result && unknownFields.equals(other.unknownFields); return result; }
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.GetSizeResponse getSizeResponse = 17;</code> */ public org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponseOrBuilder getGetSizeResponseOrBuilder() { if ((messageTypeCase_ == 17) && (getSizeResponseBuilder_ != null)) { return getSizeResponseBuilder_.getMessageOrBuilder(); } else { if (messageTypeCase_ == 17) { return (org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse) messageType_; } return org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse.getDefaultInstance(); } } /**
@java.lang.Override public Builder newBuilderForType() { return newBuilder(); } public static Builder newBuilder() {
@java.lang.Override public org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse getDefaultInstanceForType() { return org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse.getDefaultInstance(); }
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.GetSizeResponse getSizeResponse = 17;</code> */ public org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponseOrBuilder getGetSizeResponseOrBuilder() { if (messageTypeCase_ == 17) { return (org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse) messageType_; } return org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse.getDefaultInstance(); }
/** * <code>.org.apache.geode.internal.protocol.protobuf.v1.GetSizeResponse getSizeResponse = 17;</code> */ public org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse getGetSizeResponse() { if (messageTypeCase_ == 17) { return (org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse) messageType_; } return org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse.getDefaultInstance(); } /**
@Override public Result<RegionAPI.GetSizeResponse> process( ProtobufSerializationService serializationService, RegionAPI.GetSizeRequest request, MessageExecutionContext messageExecutionContext) throws InvalidExecutionContextException { String regionName = request.getRegionName(); int size = messageExecutionContext.getSecureCache().getSize(regionName); return Success.of(RegionAPI.GetSizeResponse.newBuilder().setSize(size).build()); } }
@java.lang.Override public org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse buildPartial() { org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse result = new org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse(this); result.size_ = size_; onBuilt(); return result; }
@java.lang.Override public org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse build() { org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse result = buildPartial(); if (!result.isInitialized()) { throw newUninitializedMessageException(result); } return result; }
public Builder mergeFrom(org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse other) { if (other == org.apache.geode.internal.protocol.protobuf.v1.RegionAPI.GetSizeResponse.getDefaultInstance()) return this; if (other.getSize() != 0) { setSize(other.getSize()); } this.mergeUnknownFields(other.unknownFields); onChanged(); return this; }
@Override public int size() throws IOException { final Message request = Message.newBuilder() .setGetSizeRequest(RegionAPI.GetSizeRequest.newBuilder().setRegionName(name)).build(); return protobufChannel.sendRequest(request, MessageTypeCase.GETSIZERESPONSE) .getGetSizeResponse().getSize(); }