Package com.basho.riak.client.core.query

Examples of com.basho.riak.client.core.query.RiakObject


            FetchValue fv = new FetchValue.Builder(loc).build();
            FetchValue.Response fResp = client.execute(fv);
           
            assertEquals(pojo.value, fResp.getValue(Pojo.class).value);
           
            RiakObject ro = fResp.getValue(RiakObject.class);
            assertNotNull(ro.getValue());
            assertEquals("{\"value\":\"test value\"}", ro.getValue().toString());
        }
        catch (ExecutionException ex)
        {
            System.out.println(ex.getCause().getCause());
        }
View Full Code Here


        FetchValue.Response fResp = client.execute(fv);
       
        assertFalse(fResp.hasValues());
        assertTrue(fResp.isNotFound());
        assertNull(fResp.getValue(Pojo.class));
        RiakObject ro = fResp.getValue(RiakObject.class);
    }
View Full Code Here

        Namespace ns = new Namespace(bucketType, bucketName.toString());
        Location loc = new Location(ns, "test_fetch_key5");
       
        String jsonValue = "{\"value\":\"my value\"}";
       
        RiakObject ro = new RiakObject()
                        .setValue(BinaryValue.create(jsonValue))
                        .setContentType("application/json");
       
        StoreValue sv = new StoreValue.Builder(ro).withLocation(loc).build();
        client.execute(sv);
       
        FetchValue fv = new FetchValue.Builder(loc).build();
        FetchValue.Response resp = client.execute(fv);
       
        RiakAnnotatedPojo rap = resp.getValue(RiakAnnotatedPojo.class);
       
        assertNotNull(rap.bucketName);
        assertEquals(ns.getBucketNameAsString(), rap.bucketName);
        assertNotNull(rap.key);
        assertEquals(loc.getKeyAsString(), rap.key);
        assertNotNull(rap.bucketType);
        assertEquals(ns.getBucketTypeAsString(), rap.bucketType);
        assertNotNull(rap.contentType);
        assertEquals(ro.getContentType(), rap.contentType);
        assertNotNull(rap.vclock);
        assertNotNull(rap.vtag);
        assertNotNull(rap.lastModified);
        assertNotNull(rap.value);
        assertFalse(rap.deleted);
View Full Code Here

        Namespace ns = new Namespace(Namespace.DEFAULT_BUCKET_TYPE, bucketName.toString());
        Location loc = new Location(ns,"test_fetch_key6");
       
        String jsonValue = "{\"value\":\"my value\"}";
       
        RiakObject ro = new RiakObject()
                        .setValue(BinaryValue.create(jsonValue))
                        .setContentType("application/json");
       
        ro.getIndexes().getIndex(StringBinIndex.named("email")).add("roach@basho.com");
        ro.getIndexes().getIndex(LongIntIndex.named("user_id")).add(1L);
       
        StoreValue sv = new StoreValue.Builder(ro).withLocation(loc).build();
        client.execute(sv);
       
        FetchValue fv = new FetchValue.Builder(loc).build();
View Full Code Here

       
        String keyPrefix = "mr_test_";
        for (int i = 0; i < 200; i++)
        {
            Location loc = new Location(ns, keyPrefix + i);
            RiakObject ro = new RiakObject().setContentType("text/plain")
                .setValue(BinaryValue.create(Integer.toString(i)));
            StoreValue sv = new StoreValue.Builder(ro).withLocation(loc).build();
            RiakFuture<StoreValue.Response, Location> future = client.executeAsync(sv);
            future.await();
            assertTrue(future.isSuccess());
View Full Code Here

    }
   
    private void testSimpleStore(String bucketType) throws InterruptedException, ExecutionException
    {
       
        RiakObject obj = new RiakObject().setValue(BinaryValue.create(value));
        Namespace ns = new Namespace(bucketType, bucketName.toString());
        Location location = new Location(ns, key);
        StoreOperation storeOp =
            new StoreOperation.Builder(location)
                .withContent(obj)
                .build();
       
        cluster.execute(storeOp);
        storeOp.get();
       
        FetchOperation fetchOp =
                new FetchOperation.Builder(location).build();
               
        cluster.execute(fetchOp);
        RiakObject obj2 = fetchOp.get().getObjectList().get(0);
       
        assertEquals(obj.getValue(), obj2.getValue());
              
    }
View Full Code Here

    when(mockFuture.get(anyLong(), any(TimeUnit.class))).thenReturn(mockResponse);
    when(mockFuture.isCancelled()).thenReturn(false);
    when(mockFuture.isDone()).thenReturn(true);
    when(mockCluster.execute(any(FutureOperation.class))).thenReturn(mockFuture);
    client = new RiakClient(mockCluster);
    riakObject = new RiakObject();
        riakObject.setVClock(vClock);
    riakObject.setValue(BinaryValue.create(new byte[]{'O', '_', 'o'}));
  }
View Full Code Here

                .withAllowMulti(true)
                .build();
        cluster.execute(op);
        op.get();
       
        RiakObject obj = new RiakObject().setValue(BinaryValue.create(value));
        Location location = new Location(ns, key);
      
        StoreOperation storeOp =
            new StoreOperation.Builder(location)
                .withContent(obj)
                .withReturnBody(true)
                .build();
       
        cluster.execute(storeOp);
        StoreOperation.Response response = storeOp.get();
        obj = response.getObjectList().get(0);
       
        assertNotNull(obj.getVClock());
       
        obj.setValue(BinaryValue.create("changed"));

        storeOp = new StoreOperation.Builder(location)
                .withContent(obj)
                .withReturnBody(true)
                .build();
       
        cluster.execute(storeOp);
        response = storeOp.get();
        obj = response.getObjectList().get(0);
       
        assertEquals(obj.getValue().toString(), "changed");
       
        resetAndEmptyBucket(ns);
    }
View Full Code Here

  @SuppressWarnings("unchecked")
  public void init() throws Exception
  {
    MockitoAnnotations.initMocks(this);

    riakObject = new RiakObject();
    riakObject.setValue(BinaryValue.create(new byte[]{'O', '_', 'o'}));

    ArrayList<RiakObject> objects = new ArrayList<RiakObject>();
    objects.add(riakObject);
View Full Code Here

    {
        // Empty buckets do not show up
        final BinaryValue key = BinaryValue.unsafeCreate("my_key".getBytes());
        final String value = "{\"value\":\"value\"}";
       
        RiakObject rObj = new RiakObject().setValue(BinaryValue.create(value));
        Location location = new Location(new Namespace(bucketType, bucketName.toString()), key);
        StoreOperation storeOp =
            new StoreOperation.Builder(location)
                .withContent(rObj)
                .build();
View Full Code Here

TOP

Related Classes of com.basho.riak.client.core.query.RiakObject

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.