builder.setStringResult((String) unencodedValue); } else if (JSONWrapper.class.isAssignableFrom(unencodedValue.getClass())) { builder.setJsonObjectResult(((JSONWrapper) unencodedValue).getJSON()); } else { ByteString customBytes = customSerialize(unencodedValue);
@Test(expected = DecodingException.class) public void processThrowsExceptionWhenUnableToDecodeRequest() throws Exception { Exception exception = new DecodingException("error finding codec for type"); ProtobufSerializationService serializationServiceStub = mock(ProtobufSerializationService.class); when(serializationServiceStub.decode(any())).thenThrow(exception); BasicTypes.EncodedValue encodedKey = BasicTypes.EncodedValue.newBuilder() .setJsonObjectResult("{\"someKey\":\"someValue\"}").build(); RegionAPI.RemoveRequest removeRequest = ProtobufRequestUtilities.createRemoveRequest(TEST_REGION, encodedKey).getRemoveRequest();; operationHandler.process(serializationServiceStub, removeRequest, TestExecutionContext.getNoAuthCacheExecutionContext(cacheStub)); }
@Test(expected = DecodingException.class) public void processThrowsExceptionWhenUnableToDecodeRequest() throws Exception { Exception exception = new DecodingException("error finding codec for type"); ProtobufSerializationService serializationServiceStub = mock(ProtobufSerializationService.class); when(serializationServiceStub.decode(any())).thenThrow(exception); BasicTypes.EncodedValue encodedKey = BasicTypes.EncodedValue.newBuilder() .setJsonObjectResult("{\"someKey\":\"someValue\"}").build(); RegionAPI.GetRequest getRequest = ProtobufRequestUtilities.createGetRequest(TEST_REGION, encodedKey).getGetRequest(); operationHandler.process(serializationServiceStub, getRequest, TestExecutionContext.getNoAuthCacheExecutionContext(cacheStub)); }
builder.setCustomObjectResult(customResult); } else if (value instanceof PdxInstance) { builder.setJsonObjectResult(jsonPdxConverter.encode((PdxInstance) value)); } else { throw new EncodingException("No handler for object type " + value.getClass());
@Test(expected = DecodingException.class) public void processThrowsExceptionWhenUnableToDecode() throws Exception { String exceptionText = "unsupported type!"; Exception exception = new DecodingException(exceptionText); ProtobufSerializationService serializationServiceStub = mock(ProtobufSerializationService.class); when(serializationServiceStub.decode(any())).thenThrow(exception); BasicTypes.EncodedValue encodedKey = BasicTypes.EncodedValue.newBuilder() .setJsonObjectResult("{\"someKey\":\"someValue\"}").build(); PutRequestOperationHandler operationHandler = new PutRequestOperationHandler(); BasicTypes.EncodedValue testValue = serializationService.encode(TEST_VALUE); BasicTypes.Entry testEntry = ProtobufUtilities.createEntry(encodedKey, testValue); RegionAPI.PutRequest putRequest = ProtobufRequestUtilities.createPutRequest(TEST_REGION, testEntry).getPutRequest(); operationHandler.process(serializationServiceStub, putRequest, TestExecutionContext.getNoAuthCacheExecutionContext(cacheStub)); }