Search in sources :

Example 6 with IdentifiableValueImpl

use of com.google.appengine.api.memcache.AsyncMemcacheServiceImpl.IdentifiableValueImpl in project appengine-java-standard by GoogleCloudPlatform.

the class MemcacheServiceImplTest method multiGetIdentifiableTest.

private void multiGetIdentifiableTest(MemcacheService memcache, String namespace) {
    MemcacheGetRequest request = MemcacheGetRequest.newBuilder().setNameSpace(namespace).setForCas(true).addKey(ByteString.copyFrom(makePbKey(ONE))).addKey(ByteString.copyFrom(makePbKey(null))).addKey(ByteString.copyFrom(makePbKey("Missing"))).build();
    MemcacheGetResponse response = MemcacheGetResponse.newBuilder().addItem(MemcacheGetResponse.Item.newBuilder().setKey(ByteString.copyFrom(makePbKey(ONE))).setCasId(10).setFlags(Flag.OBJECT.ordinal()).setValue(ByteString.copyFrom(serialize(null).value))).addItem(MemcacheGetResponse.Item.newBuilder().setKey(ByteString.copyFrom(makePbKey(null))).setCasId(20).setFlags(Flag.INTEGER.ordinal()).setValue(ByteString.copyFrom(serialize(456).value))).build();
    expectAsyncCall("Get", request, response);
    ArrayList<String> collection = new ArrayList<>();
    collection.add(ONE);
    collection.add(null);
    collection.add("Missing");
    Map<String, IdentifiableValue> result = memcache.getIdentifiables(collection);
    assertThat(result).hasSize(2);
    assertThat(result.get(ONE).getValue()).isEqualTo(null);
    assertThat(((IdentifiableValueImpl) result.get(ONE)).getCasId()).isEqualTo(10);
    assertThat(result.get(null).getValue()).isEqualTo(456);
    assertThat(((IdentifiableValueImpl) result.get(null)).getCasId()).isEqualTo(20);
    verifyAsyncCall("Get", request);
}
Also used : IdentifiableValue(com.google.appengine.api.memcache.MemcacheService.IdentifiableValue) MemcacheGetResponse(com.google.appengine.api.memcache.MemcacheServicePb.MemcacheGetResponse) MemcacheGetRequest(com.google.appengine.api.memcache.MemcacheServicePb.MemcacheGetRequest) ArrayList(java.util.ArrayList) IdentifiableValueImpl(com.google.appengine.api.memcache.AsyncMemcacheServiceImpl.IdentifiableValueImpl) ByteString(com.google.protobuf.ByteString)

Aggregations

IdentifiableValueImpl (com.google.appengine.api.memcache.AsyncMemcacheServiceImpl.IdentifiableValueImpl)6 ByteString (com.google.protobuf.ByteString)4 Test (org.junit.Test)4 IdentifiableValue (com.google.appengine.api.memcache.MemcacheService.IdentifiableValue)3 MemcacheGetRequest (com.google.appengine.api.memcache.MemcacheServicePb.MemcacheGetRequest)3 MemcacheGetResponse (com.google.appengine.api.memcache.MemcacheServicePb.MemcacheGetResponse)3 ValueAndFlags (com.google.appengine.api.memcache.MemcacheSerialization.ValueAndFlags)2 CasValues (com.google.appengine.api.memcache.MemcacheService.CasValues)2 MemcacheSetRequest (com.google.appengine.api.memcache.MemcacheServicePb.MemcacheSetRequest)2 MemcacheSetResponse (com.google.appengine.api.memcache.MemcacheServicePb.MemcacheSetResponse)2 EqualsTester (com.google.common.testing.EqualsTester)2 ArrayList (java.util.ArrayList)1 Date (java.util.Date)1 LinkedHashMap (java.util.LinkedHashMap)1