IndexMaintainerHelper { public static boolean hasIndexedFieldChanged(BSONObject oldObject, Index index, Document entity) { BSONObject newObject = entity.getObject(); for (IndexField indexField : index.getFields()) { String field = indexField.getField(); if (newObject.get(field) == null && oldObject.get(field) == null) { return false; } else if (newObject.get(field) == null || oldObject.get(field) == null) { return true; } if (!newObject.get(field).equals(oldObject.get(field))) { return true; } } return false; } private  IndexMaintainerHelper(); static List<BoundStatement> generateDocumentCreateIndexEntriesStatements(Session session, Document entity, BucketLocator bucketLocator); static BoundStatement generateDocumentCreateIndexEntryStatement(Session session, Index index, Document entity, BucketLocator bucketLocator); static List<BoundStatement> generateDocumentUpdateIndexEntriesStatements(Session session, Document entity, BucketLocator bucketLocator); static List<BoundStatement> generateDocumentDeleteIndexEntriesStatements(Session session, Document entity, BucketLocator bucketLocator); static List<Index> getIndexForDocument(Session session, Document entity); static boolean hasIndexedFieldChanged(BSONObject oldObject, Index index, Document entity); static BSONObject getOldObjectForUpdate(Session session, Document entity); static String getCQLStatementForInsert(Index index); static String generateCQLStatementForInsert(Index index); static String getCQLStatementForWhereClauses(String CQL, Index index); static String generateCQLStatementForWhereClauses(String CQL, Index index); static final String ITABLE_INSERT_CQL; static final String ITABLE_UPDATE_CQL; static final String ITABLE_DELETE_CQL; }
@Test public void testHasIndexedFieldChanged() { System.out.println("hasIndexedFieldChanged"); tableRepo.create(table); Document entity = Fixtures.createTestDocument2(); docRepo.create(entity); entity.setObjectAsString("{'greeting':'hola', 'myindexedfield': 'this is my field', 'myindexedfield1':'my second field', 'myindexedfield2':'my third field'}"); boolean result = IndexMaintainerHelper.hasIndexedFieldChanged(IndexMaintainerHelper.getOldObjectForUpdate(f.getSession(), entity), index1, entity); assertEquals(false, result); entity.setObjectAsString("{'greeting':'hello', 'myindexedfield': 'this is NOT my field', 'myindexedfield1':'my second field', 'myindexedfield2':'my third field'}"); result = IndexMaintainerHelper.hasIndexedFieldChanged(IndexMaintainerHelper.getOldObjectForUpdate(f.getSession(), entity), index1, entity); assertEquals(true, result); }