@Test public void removePreparedStatement() { final CMapSync map = mapService.getMap(RING_OF_POWER_TABLE); final String quote = newQuote(); final ValueTuple valueToPut = ValueTuple.of(COL_QUOTES, quote).with(COL_TIMESTAMP, DateTime.now(DateTimeZone.UTC)); map.put(new CPutQuery(valueToPut)); final CQuery query = CQueryBuilder.createPreparedRemoveQuery() .addFilters() .eq(COL_QUOTES) .noMoreFilters() .noFiltering(); final CPreparedRemove preparedQuery = mapService.prepareRemove(RING_OF_POWER_TABLE, query); final CPreparedRemove.PreparedRemoveExecutor prepared = preparedQuery.bind().bindTo(COL_QUOTES, quote).stopBinding(); prepared.execute(); assertEquals(0, Lists.newArrayList(map.all()).size()); map.put(new CPutQuery(valueToPut)); prepared.execute(); assertEquals(0, Lists.newArrayList(map.all()).size()); }
@Test public void batchStatementTest() { final CMapSync map = mapService.getMap(RING_OF_POWER_TABLE); final CQuery query = CQueryBuilder.createPreparedRemoveQuery() .addFilters() .eq(COL_QUOTES) .noMoreFilters() .noFiltering(); final CPreparedPut preparedPutQuery = mapService.preparePut(RING_OF_POWER_TABLE); final CPreparedRemove preparedRemoveQuery = mapService.prepareRemove(RING_OF_POWER_TABLE, query); final CPreparedPut.PreparedPutExecutor preparedPutExecutor = preparedPutQuery .bind() .bindTo(COL_QUOTES, newQuote()) .bindTo(COL_TIMESTAMP, DateTime.now(DateTimeZone.UTC)) .stopBinding(); final CPreparedRemove.PreparedRemoveExecutor preparedRemoveExecutor = preparedRemoveQuery.bind().bindTo(COL_QUOTES, newQuote()).stopBinding(); final CBatch batch = mapService.batch(); batch.put(preparedPutExecutor); batch.remove(preparedRemoveExecutor); batch.apply(); assertEquals(1, Lists.newArrayList(map.all()).size()); }
@Test public void putPreparedStatement() { final CMapSync map = mapService.getMap(RING_OF_POWER_TABLE); final CPreparedPut preparedQuery = mapService.preparePut(RING_OF_POWER_TABLE); final CPreparedPut.PreparedPutExecutor preparedExecutor = preparedQuery .bind() .bindTo(COL_QUOTES, newQuote()) .bindTo(COL_TIMESTAMP, DateTime.now(DateTimeZone.UTC)) .stopBinding(); preparedExecutor.execute(); assertEquals(1, Lists.newArrayList(map.all()).size()); preparedQuery .bind() .bindTo(COL_TIMESTAMP, DateTime.now(DateTimeZone.UTC)) .bindTo(COL_QUOTES, newQuote()) .stopBinding() .execute(); assertEquals(2, Lists.newArrayList(map.all()).size()); }