@Test public void testRemoveMany() { List<TestEntity> entities = new ArrayList<>(); for (int i = 0; i < 10; i++) { TestEntity entity = new TestEntity(); entity.setSimpleInt(2000 + i); entities.add(entity); } box.put(entities); assertEquals(entities.size(), box.count()); box.remove(entities.get(1)); assertEquals(entities.size() - 1, box.count()); box.remove(entities.get(4), entities.get(5)); assertEquals(entities.size() - 3, box.count()); List<TestEntity> entitiesRemove = new ArrayList<>(); entitiesRemove.add(entities.get(2)); entitiesRemove.add(entities.get(8)); entitiesRemove.add(entities.get(7)); box.remove(entitiesRemove); assertEquals(entities.size() - 6, box.count()); List<TestEntity> entitiesRead = box.getAll(); assertEquals(entities.size() - 6, entitiesRead.size()); assertEquals(2000, entitiesRead.get(0).getSimpleInt()); assertEquals(2003, entitiesRead.get(1).getSimpleInt()); assertEquals(2006, entitiesRead.get(2).getSimpleInt()); assertEquals(2009, entitiesRead.get(3).getSimpleInt()); box.removeAll(); assertEquals(0, box.count()); }
@Test public void testRelationToMany_activeRelationshipChanges() { Customer customer = putCustomer(); Order order1 = putOrder(customer, "Bananas"); Order order2 = putOrder(customer, "Oranges"); List<Order> orders = customer.getOrders(); assertEquals(2, orders.size()); orderBox.remove(order1); ((ToMany) orders).reset(); assertEquals(1, orders.size()); order2.setCustomer(null); orderBox.put(order2); ((ToMany) orders).reset(); assertEquals(0, orders.size()); }
orderBox.remove(order1); logOrders(orderBox, customer);
orderBox.remove(order); order = orderBox.query().eager(Order_.customer).build().findUnique(); assertTrue(order.customer__toOne.isResolved());
@Test public void testBasics() { ObfuscatedEntity object = new ObfuscatedEntity(); long id = box.put(object); assertTrue(id > 0); assertEquals(id, (long) object.getId()); ObfuscatedEntity objectRead = box.get(id); assertNotNull(objectRead); assertEquals(id, (long) objectRead.getId()); assertEquals(1, box.count()); box.remove(id); assertEquals(0, box.count()); assertNull(box.get(id)); }
customerBox.remove(customer); customer = customerBox.query().eager(Customer_.orders).build().findUnique(); assertTrue(((ToMany) customer.getOrders()).isResolved());
@Test public void testPutGetUpdateGetRemove() { // create an entity TestEntity entity = new TestEntity(); entity.setSimpleInt(1977); entity.setSimpleLong(54321); String value1 = "lulu321"; entity.setSimpleString(value1); long key = box.put(entity); // get it TestEntity entityRead = box.get(key); assertNotNull(entityRead); assertEquals(1977, entityRead.getSimpleInt()); assertEquals(54321, entityRead.getSimpleLong()); assertEquals(value1, entityRead.getSimpleString()); // put with changed values String value2 = "lala123"; entityRead.setSimpleString(value2); entityRead.setSimpleLong(12345); box.put(entityRead); // get the changed entity entityRead = box.get(key); assertNotNull(entityRead); assertEquals(1977, entityRead.getSimpleInt()); assertEquals(12345, entityRead.getSimpleLong()); assertEquals(value2, entityRead.getSimpleString()); // and remove it box.remove(key); assertNull(box.get(key)); }
@Override public void delete_impl(org.owntracks.android.data.WaypointModel w) { box.remove(w); } }
private long delete(long modelId) { mSentencesBox.remove(modelId); return modelId; }
private long delete(long modelId) { mPremissionBox.remove(modelId); return modelId; }
@Override public void onNoteClick(@Nullable Note note) { if (note == null) { return; } notesBox.remove(note); Log.d(App.TAG, "Deleted note, ID: " + note.getId()); } };
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Note note = notesAdapter.getItem(position); notesBox.remove(note); Log.d(App.TAG, "Deleted note, ID: " + note.getId()); updateNotes(); } };
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Note note = notesAdapter.getItem(position); notesBox.remove(note); Log.d(App.TAG, "Deleted note, ID: " + note.getId()); } };
@Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Note note = notesAdapter.getItem(position); notesBox.remove(note); Log.d(App.TAG, "Deleted note, ID: " + note.getId()); } };
@Override public void evict(String key) { CacheEntity entity = cacheEntityBox.query().equal(CacheEntity_.key, key).build().findUnique(); if (entity!=null) { cacheEntityBox.remove(entity); } }
public void runBatchPerfTest(boolean scalarsOnly) { List<SimpleEntity> list = prepareAndPutEntities(scalarsOnly); for (SimpleEntity entity : list) { if (scalarsOnly) { setRandomScalars(entity); } else { setRandomValues(entity); } } startBenchmark("update"); box.put(list); stopBenchmark(); list = null; startBenchmark("load"); List<SimpleEntity> reloaded = box.getAll(); stopBenchmark(); assertEntityCount(reloaded.size()); startBenchmark("access"); accessAll(reloaded); stopBenchmark(); startBenchmark("delete"); box.remove(reloaded); stopBenchmark(); }
public void runBatchPerfTestIndexed() { List<SimpleEntityIndexed> list = prepareAndPutEntitiesIndexed(); for (SimpleEntityIndexed entity : list) { setRandomValues(entity); } startBenchmark("update"); boxIndexed.put(list); stopBenchmark(); list = null; startBenchmark("load"); List<SimpleEntityIndexed> reloaded = boxIndexed.getAll(); stopBenchmark(); startBenchmark("access"); accessAllIndexed(reloaded); stopBenchmark(); startBenchmark("delete"); boxIndexed.remove(reloaded); stopBenchmark(); }